diff options
author | Liav A <liavalb@gmail.com> | 2020-02-02 01:52:51 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-02 00:57:13 +0100 |
commit | 583e9ad372388a88a82474dff0fcb1f30a153d21 (patch) | |
tree | 2a322e26330d4ec37029560d3cf88ca732047a9b /Kernel/Net/E1000NetworkAdapter.cpp | |
parent | 60715695b285f8d74711e925300d22346ca838d2 (diff) | |
download | serenity-583e9ad372388a88a82474dff0fcb1f30a153d21.zip |
Kernel: Detect devices when enumerating the PCI bus
Instead of making each driver to enumerate the PCI bus itself,
PCI::Initializer will call detect_devices() to do one enumeration
of the bus.
Diffstat (limited to 'Kernel/Net/E1000NetworkAdapter.cpp')
-rw-r--r-- | Kernel/Net/E1000NetworkAdapter.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp index 128009d220..a62fe622c3 100644 --- a/Kernel/Net/E1000NetworkAdapter.cpp +++ b/Kernel/Net/E1000NetworkAdapter.cpp @@ -119,20 +119,16 @@ #define STATUS_SPEED_1000MB1 0x80 #define STATUS_SPEED_1000MB2 0xC0 -OwnPtr<E1000NetworkAdapter> E1000NetworkAdapter::autodetect() +void E1000NetworkAdapter::detect(const PCI::Address& address) { + if (address.is_null()) + return; static const PCI::ID qemu_bochs_vbox_id = { 0x8086, 0x100e }; - PCI::Address found_address; - PCI::enumerate_all([&](const PCI::Address& address, PCI::ID id) { - if (id == qemu_bochs_vbox_id) { - found_address = address; - return; - } - }); - if (found_address.is_null()) - return nullptr; - u8 irq = PCI::get_interrupt_line(found_address); - return make<E1000NetworkAdapter>(found_address, irq); + const PCI::ID id = PCI::get_id(address); + if (id != qemu_bochs_vbox_id) + return; + u8 irq = PCI::get_interrupt_line(address); + new E1000NetworkAdapter(address, irq); } E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address pci_address, u8 irq) |