mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +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:
parent
65f939b55c
commit
ea58563970
6 changed files with 27 additions and 22 deletions
|
@ -125,16 +125,17 @@ namespace Kernel {
|
|||
#define RX_BUFFER_SIZE 32768
|
||||
#define TX_BUFFER_SIZE PACKET_SIZE_MAX
|
||||
|
||||
void RTL8139NetworkAdapter::detect(const PCI::Address& address)
|
||||
void RTL8139NetworkAdapter::detect()
|
||||
{
|
||||
if (address.is_null())
|
||||
return;
|
||||
static const PCI::ID rtl8139_id = { 0x10EC, 0x8139 };
|
||||
PCI::ID id = PCI::get_id(address);
|
||||
if (id != rtl8139_id)
|
||||
return;
|
||||
u8 irq = PCI::get_interrupt_line(address);
|
||||
(void)adopt(*new RTL8139NetworkAdapter(address, irq)).leak_ref();
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::ID id) {
|
||||
if (address.is_null())
|
||||
return;
|
||||
if (id != rtl8139_id)
|
||||
return;
|
||||
u8 irq = PCI::get_interrupt_line(address);
|
||||
(void)adopt(*new RTL8139NetworkAdapter(address, irq)).leak_ref();
|
||||
});
|
||||
}
|
||||
|
||||
RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address address, u8 irq)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue