mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 04:15:23 +03:00
ac7ce12123
This was a premature optimization from the early days of SerenityOS. The eternal heap was a simple bump pointer allocator over a static byte array. My original idea was to avoid heap fragmentation and improve data locality, but both ideas were rooted in cargo culting, not data. We would reserve 4 MiB at boot and only ended up using ~256 KiB, wasting the rest. This patch replaces all kmalloc_eternal() usage by regular kmalloc().
49 lines
1.2 KiB
C++
49 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Function.h>
|
|
#include <AK/NonnullOwnPtr.h>
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <AK/NonnullRefPtrVector.h>
|
|
#include <AK/Types.h>
|
|
#include <Kernel/Bus/PCI/Definitions.h>
|
|
#include <Kernel/Locking/Mutex.h>
|
|
#include <Kernel/Memory/Region.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class NetworkAdapter;
|
|
class NetworkingManagement {
|
|
friend class NetworkAdapter;
|
|
|
|
public:
|
|
static NetworkingManagement& the();
|
|
static bool is_initialized();
|
|
bool initialize();
|
|
|
|
static ErrorOr<NonnullOwnPtr<KString>> generate_interface_name_from_pci_address(PCI::DeviceIdentifier const&);
|
|
|
|
NetworkingManagement();
|
|
|
|
void for_each(Function<void(NetworkAdapter&)>);
|
|
|
|
RefPtr<NetworkAdapter> from_ipv4_address(const IPv4Address&) const;
|
|
RefPtr<NetworkAdapter> lookup_by_name(StringView) const;
|
|
|
|
NonnullRefPtr<NetworkAdapter> loopback_adapter() const;
|
|
|
|
private:
|
|
RefPtr<NetworkAdapter> determine_network_device(PCI::DeviceIdentifier const&) const;
|
|
|
|
NonnullRefPtrVector<NetworkAdapter> m_adapters;
|
|
RefPtr<NetworkAdapter> m_loopback_adapter;
|
|
mutable Mutex m_lock { "Networking" };
|
|
};
|
|
|
|
}
|