1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:58:11 +00:00

Kernel/PCI: Cache interrupt line and interrupt pin of a device

This allows us to remove the PCI::get_interrupt_line API function. As a
result, this removes a bunch of not so great patterns that we used to
cache PCI interrupt line in many IRQHandler derived classes instead of
just using interrupt_number method of IRQHandler class.
This commit is contained in:
Liav A 2021-09-23 10:50:45 +03:00 committed by Andreas Kling
parent 057f5a12c2
commit a411a44fda
17 changed files with 43 additions and 39 deletions

View file

@ -186,7 +186,7 @@ UNMAP_AFTER_INIT RefPtr<E1000ENetworkAdapter> E1000ENetworkAdapter::try_to_initi
return {};
if (!is_valid_device_id(pci_device_identifier.hardware_id().device_id))
return {};
u8 irq = PCI::get_interrupt_line(pci_device_identifier.address());
u8 irq = pci_device_identifier.interrupt_line().value();
auto adapter = adopt_ref_if_nonnull(new (nothrow) E1000ENetworkAdapter(pci_device_identifier.address(), irq));
if (!adapter)
return {};
@ -210,11 +210,10 @@ UNMAP_AFTER_INIT bool E1000ENetworkAdapter::initialize()
m_mmio_region = region_or_error.release_value();
m_mmio_base = m_mmio_region->vaddr();
m_use_mmio = true;
m_interrupt_line = PCI::get_interrupt_line(pci_address());
dmesgln("E1000e: port base: {}", m_io_base);
dmesgln("E1000e: MMIO base: {}", PhysicalAddress(PCI::get_BAR0(pci_address()) & 0xfffffffc));
dmesgln("E1000e: MMIO base size: {} bytes", mmio_base_size);
dmesgln("E1000e: Interrupt line: {}", m_interrupt_line);
dmesgln("E1000e: Interrupt line: {}", interrupt_number());
detect_eeprom();
dmesgln("E1000e: Has EEPROM? {}", m_has_eeprom);
read_mac_address();

View file

@ -164,7 +164,7 @@ UNMAP_AFTER_INIT RefPtr<E1000NetworkAdapter> E1000NetworkAdapter::try_to_initial
return {};
if (!is_valid_device_id(pci_device_identifier.hardware_id().device_id))
return {};
u8 irq = PCI::get_interrupt_line(pci_device_identifier.address());
u8 irq = pci_device_identifier.interrupt_line().value();
auto adapter = adopt_ref_if_nonnull(new (nothrow) E1000NetworkAdapter(pci_device_identifier.address(), irq));
if (!adapter)
return {};
@ -201,11 +201,10 @@ UNMAP_AFTER_INIT bool E1000NetworkAdapter::initialize()
m_mmio_region = region_or_error.release_value();
m_mmio_base = m_mmio_region->vaddr();
m_use_mmio = true;
m_interrupt_line = PCI::get_interrupt_line(pci_address());
dmesgln("E1000: port base: {}", m_io_base);
dmesgln("E1000: MMIO base: {}", PhysicalAddress(PCI::get_BAR0(pci_address()) & 0xfffffffc));
dmesgln("E1000: MMIO base size: {} bytes", mmio_base_size);
dmesgln("E1000: Interrupt line: {}", m_interrupt_line);
dmesgln("E1000: Interrupt line: {}", interrupt_number());
detect_eeprom();
dmesgln("E1000: Has EEPROM? {}", m_has_eeprom);
read_mac_address();

View file

@ -91,7 +91,6 @@ protected:
Array<void*, number_of_rx_descriptors> m_rx_buffers;
Array<void*, number_of_tx_descriptors> m_tx_buffers;
OwnPtr<Memory::Region> m_mmio_region;
u8 m_interrupt_line { 0 };
bool m_has_eeprom { false };
bool m_use_mmio { false };
EntropySource m_entropy_source;

View file

@ -156,7 +156,7 @@ UNMAP_AFTER_INIT RefPtr<NE2000NetworkAdapter> NE2000NetworkAdapter::try_to_initi
};
if (!ne2k_ids.span().contains_slow(pci_device_identifier.hardware_id()))
return {};
u8 irq = PCI::get_interrupt_line(pci_device_identifier.address());
u8 irq = pci_device_identifier.interrupt_line().value();
return adopt_ref_if_nonnull(new (nothrow) NE2000NetworkAdapter(pci_device_identifier.address(), irq));
}
@ -169,9 +169,8 @@ UNMAP_AFTER_INIT NE2000NetworkAdapter::NE2000NetworkAdapter(PCI::Address address
dmesgln("NE2000: Found @ {}", pci_address());
m_interrupt_line = PCI::get_interrupt_line(pci_address());
dmesgln("NE2000: Port base: {}", m_io_base);
dmesgln("NE2000: Interrupt line: {}", m_interrupt_line);
dmesgln("NE2000: Interrupt line: {}", interrupt_number());
int ram_errors = ram_test();
dmesgln("NE2000: RAM test {}, got {} byte errors", (ram_errors == 0 ? "OK" : "KO"), ram_errors);

View file

@ -117,7 +117,7 @@ UNMAP_AFTER_INIT RefPtr<RTL8139NetworkAdapter> RTL8139NetworkAdapter::try_to_ini
constexpr PCI::HardwareID rtl8139_id = { 0x10EC, 0x8139 };
if (pci_device_identifier.hardware_id() != rtl8139_id)
return {};
u8 irq = PCI::get_interrupt_line(pci_device_identifier.address());
u8 irq = pci_device_identifier.interrupt_line().value();
return adopt_ref_if_nonnull(new (nothrow) RTL8139NetworkAdapter(pci_device_identifier.address(), irq));
}
@ -135,9 +135,8 @@ UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address addre
enable_bus_mastering(pci_address());
m_interrupt_line = PCI::get_interrupt_line(pci_address());
dmesgln("RTL8139: I/O port base: {}", m_io_base);
dmesgln("RTL8139: Interrupt line: {}", m_interrupt_line);
dmesgln("RTL8139: Interrupt line: {}", interrupt_number());
// we add space to account for overhang from the last packet - the rtl8139
// can optionally guarantee that packets will be contiguous by

View file

@ -187,7 +187,7 @@ UNMAP_AFTER_INIT RefPtr<RTL8168NetworkAdapter> RTL8168NetworkAdapter::try_to_ini
return {};
if (pci_device_identifier.hardware_id().device_id != 0x8168)
return {};
u8 irq = PCI::get_interrupt_line(pci_device_identifier.address());
u8 irq = pci_device_identifier.interrupt_line().value();
return adopt_ref_if_nonnull(new (nothrow) RTL8168NetworkAdapter(pci_device_identifier.address(), irq));
}