mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 14:37:45 +00:00
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.
This commit is contained in:
parent
60715695b2
commit
583e9ad372
10 changed files with 64 additions and 50 deletions
|
@ -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)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
class E1000NetworkAdapter final : public NetworkAdapter
|
||||
, public IRQHandler {
|
||||
public:
|
||||
static OwnPtr<E1000NetworkAdapter> autodetect();
|
||||
static void detect(const PCI::Address&);
|
||||
|
||||
E1000NetworkAdapter(PCI::Address, u8 irq);
|
||||
virtual ~E1000NetworkAdapter() override;
|
||||
|
|
|
@ -123,20 +123,16 @@
|
|||
#define RX_BUFFER_SIZE 32768
|
||||
#define TX_BUFFER_SIZE PACKET_SIZE_MAX
|
||||
|
||||
OwnPtr<RTL8139NetworkAdapter> RTL8139NetworkAdapter::autodetect()
|
||||
void RTL8139NetworkAdapter::detect(const PCI::Address& address)
|
||||
{
|
||||
if (address.is_null())
|
||||
return;
|
||||
static const PCI::ID rtl8139_id = { 0x10EC, 0x8139 };
|
||||
PCI::Address found_address;
|
||||
PCI::enumerate_all([&](const PCI::Address& address, PCI::ID id) {
|
||||
if (id == rtl8139_id) {
|
||||
found_address = address;
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (found_address.is_null())
|
||||
return nullptr;
|
||||
u8 irq = PCI::get_interrupt_line(found_address);
|
||||
return make<RTL8139NetworkAdapter>(found_address, irq);
|
||||
PCI::ID id = PCI::get_id(address);
|
||||
if (id != rtl8139_id)
|
||||
return;
|
||||
u8 irq = PCI::get_interrupt_line(address);
|
||||
new RTL8139NetworkAdapter(address, irq);
|
||||
}
|
||||
|
||||
RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address pci_address, u8 irq)
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
class RTL8139NetworkAdapter final : public NetworkAdapter
|
||||
, public IRQHandler {
|
||||
public:
|
||||
static OwnPtr<RTL8139NetworkAdapter> autodetect();
|
||||
static void detect(const PCI::Address&);
|
||||
|
||||
RTL8139NetworkAdapter(PCI::Address, u8 irq);
|
||||
virtual ~RTL8139NetworkAdapter() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue