1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

Kernel: Instantiate network adapters in their own detect() methods

This commit is one step forward for pluggable driver modules.
Instead of creating instances of network adapter classes, we let
their detect() methods to figure out if there are existing devices
to initialize.
This commit is contained in:
Liav A 2020-04-10 20:33:30 +03:00 committed by Andreas Kling
parent 65f939b55c
commit ea58563970
6 changed files with 27 additions and 22 deletions

View file

@ -139,16 +139,18 @@ namespace Kernel {
#define INTERRUPT_TXD_LOW (1 << 15)
#define INTERRUPT_SRPD (1 << 16)
void E1000NetworkAdapter::detect(const PCI::Address& address)
void E1000NetworkAdapter::detect()
{
if (address.is_null())
return;
static const PCI::ID qemu_bochs_vbox_id = { 0x8086, 0x100e };
const PCI::ID id = PCI::get_id(address);
if (id != qemu_bochs_vbox_id)
return;
u8 irq = PCI::get_interrupt_line(address);
(void)adopt(*new E1000NetworkAdapter(address, irq)).leak_ref();
PCI::enumerate([&](const PCI::Address& address, PCI::ID id) {
if (address.is_null())
return;
if (id != qemu_bochs_vbox_id)
return;
u8 irq = PCI::get_interrupt_line(address);
(void)adopt(*new E1000NetworkAdapter(address, irq)).leak_ref();
});
}
E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address address, u8 irq)