mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 11:45:06 +00:00
Kernel: Convert network adapter names to Kernel::KString
Another step of incremental progress of removing `AK::String` from the kernel, to harden against OOM.
This commit is contained in:
parent
33a9f908a6
commit
2770433d30
16 changed files with 64 additions and 68 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <Kernel/Arch/x86/IO.h>
|
||||
#include <Kernel/Bus/PCI/API.h>
|
||||
#include <Kernel/CommandLine.h>
|
||||
#include <Kernel/KString.h>
|
||||
#include <Kernel/Memory/AnonymousVMObject.h>
|
||||
#include <Kernel/Multiboot.h>
|
||||
#include <Kernel/Net/E1000ENetworkAdapter.h>
|
||||
|
@ -75,15 +76,24 @@ RefPtr<NetworkAdapter> NetworkingManagement::lookup_by_name(const StringView& na
|
|||
|
||||
UNMAP_AFTER_INIT RefPtr<NetworkAdapter> NetworkingManagement::determine_network_device(PCI::DeviceIdentifier const& device_identifier) const
|
||||
{
|
||||
if (auto candidate = E1000NetworkAdapter::try_to_initialize(device_identifier); !candidate.is_null())
|
||||
// Note: This stands for e - "Ethernet", p - "Port" as for PCI bus, "s" for slot as for PCI slot
|
||||
auto name = String::formatted("ep{}s{}", device_identifier.address().bus(), device_identifier.address().device());
|
||||
VERIFY(!NetworkingManagement::the().lookup_by_name(name));
|
||||
|
||||
// TODO: We need some way to to format data into a `KString`.
|
||||
auto interface_name_or_error = KString::try_create(name.view());
|
||||
if (interface_name_or_error.is_error())
|
||||
return {};
|
||||
auto interface_name = interface_name_or_error.release_value();
|
||||
if (auto candidate = E1000NetworkAdapter::try_to_initialize(device_identifier, move(interface_name)); !candidate.is_null())
|
||||
return candidate;
|
||||
if (auto candidate = E1000ENetworkAdapter::try_to_initialize(device_identifier); !candidate.is_null())
|
||||
if (auto candidate = E1000ENetworkAdapter::try_to_initialize(device_identifier, move(interface_name)); !candidate.is_null())
|
||||
return candidate;
|
||||
if (auto candidate = RTL8139NetworkAdapter::try_to_initialize(device_identifier); !candidate.is_null())
|
||||
if (auto candidate = RTL8139NetworkAdapter::try_to_initialize(device_identifier, move(interface_name)); !candidate.is_null())
|
||||
return candidate;
|
||||
if (auto candidate = RTL8168NetworkAdapter::try_to_initialize(device_identifier); !candidate.is_null())
|
||||
if (auto candidate = RTL8168NetworkAdapter::try_to_initialize(device_identifier, move(interface_name)); !candidate.is_null())
|
||||
return candidate;
|
||||
if (auto candidate = NE2000NetworkAdapter::try_to_initialize(device_identifier); !candidate.is_null())
|
||||
if (auto candidate = NE2000NetworkAdapter::try_to_initialize(device_identifier, move(interface_name)); !candidate.is_null())
|
||||
return candidate;
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue