mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 18:35:07 +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
|
@ -181,14 +181,14 @@ namespace Kernel {
|
|||
#define TX_BUFFER_SIZE 0x1FF8
|
||||
#define RX_BUFFER_SIZE 0x1FF8 // FIXME: this should be increased (0x3FFF)
|
||||
|
||||
UNMAP_AFTER_INIT RefPtr<RTL8168NetworkAdapter> RTL8168NetworkAdapter::try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier)
|
||||
UNMAP_AFTER_INIT RefPtr<RTL8168NetworkAdapter> RTL8168NetworkAdapter::try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier, NonnullOwnPtr<KString> interface_name)
|
||||
{
|
||||
if (pci_device_identifier.hardware_id().vendor_id != PCI::VendorID::Realtek)
|
||||
return {};
|
||||
if (pci_device_identifier.hardware_id().device_id != 0x8168)
|
||||
return {};
|
||||
u8 irq = pci_device_identifier.interrupt_line().value();
|
||||
return adopt_ref_if_nonnull(new (nothrow) RTL8168NetworkAdapter(pci_device_identifier.address(), irq));
|
||||
return adopt_ref_if_nonnull(new (nothrow) RTL8168NetworkAdapter(pci_device_identifier.address(), irq, move(interface_name)));
|
||||
}
|
||||
|
||||
bool RTL8168NetworkAdapter::determine_supported_version() const
|
||||
|
@ -236,15 +236,14 @@ bool RTL8168NetworkAdapter::determine_supported_version() const
|
|||
}
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT RTL8168NetworkAdapter::RTL8168NetworkAdapter(PCI::Address address, u8 irq)
|
||||
: PCI::Device(address)
|
||||
UNMAP_AFTER_INIT RTL8168NetworkAdapter::RTL8168NetworkAdapter(PCI::Address address, u8 irq, NonnullOwnPtr<KString> interface_name)
|
||||
: NetworkAdapter(move(interface_name))
|
||||
, PCI::Device(address)
|
||||
, IRQHandler(irq)
|
||||
, m_io_base(PCI::get_BAR0(pci_address()) & ~1)
|
||||
, m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(TXDescriptor) * (number_of_rx_descriptors + 1)), "RTL8168 RX", Memory::Region::Access::ReadWrite).release_value())
|
||||
, m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(RXDescriptor) * (number_of_tx_descriptors + 1)), "RTL8168 TX", Memory::Region::Access::ReadWrite).release_value())
|
||||
{
|
||||
set_interface_name(address);
|
||||
|
||||
dmesgln("RTL8168: Found @ {}", pci_address());
|
||||
dmesgln("RTL8168: I/O port base: {}", m_io_base);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue