mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +00:00
Kernel: Introduce the NetworkingManagement singleton
Instead of initializing network adapters in init.cpp, let's move that logic into a separate class to handle this. Also, it seems like a good idea to shift responsiblity on enumeration of network adapters after the boot process, so this singleton will take care of finding the appropriate network adapter when asked to with an IPv4 address or interface name. With this change being merged, we simplify the creation logic of NetworkAdapter derived classes, so we enumerate the PCI bus only once, searching for driver candidates when doing so, and we let each driver to test if it is resposible for the specified PCI device.
This commit is contained in:
parent
8b1d4d1b8e
commit
1c94b5e8eb
20 changed files with 212 additions and 117 deletions
|
@ -135,7 +135,7 @@ struct [[gnu::packed]] received_packet_header {
|
|||
u16 length;
|
||||
};
|
||||
|
||||
UNMAP_AFTER_INIT void NE2000NetworkAdapter::detect()
|
||||
UNMAP_AFTER_INIT RefPtr<NE2000NetworkAdapter> NE2000NetworkAdapter::try_to_initialize(PCI::Address address)
|
||||
{
|
||||
constexpr auto ne2k_ids = Array {
|
||||
PCI::ID { 0x10EC, 0x8029 }, // RealTek RTL-8029(AS)
|
||||
|
@ -152,14 +152,11 @@ UNMAP_AFTER_INIT void NE2000NetworkAdapter::detect()
|
|||
PCI::ID { 0x12c3, 0x5598 }, // Holtek HT80229
|
||||
PCI::ID { 0x8c4a, 0x1980 }, // Winbond W89C940 (misprogrammed)
|
||||
};
|
||||
PCI::enumerate([&](const PCI::Address& address, PCI::ID id) {
|
||||
if (address.is_null())
|
||||
return;
|
||||
if (!ne2k_ids.span().contains_slow(id))
|
||||
return;
|
||||
u8 irq = PCI::get_interrupt_line(address);
|
||||
[[maybe_unused]] auto& unused = adopt_ref(*new NE2000NetworkAdapter(address, irq)).leak_ref();
|
||||
});
|
||||
auto id = PCI::get_id(address);
|
||||
if (!ne2k_ids.span().contains_slow(id))
|
||||
return {};
|
||||
u8 irq = PCI::get_interrupt_line(address);
|
||||
return adopt_ref_if_nonnull(new NE2000NetworkAdapter(address, irq));
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT NE2000NetworkAdapter::NE2000NetworkAdapter(PCI::Address address, u8 irq)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue