ladybird/Kernel/Net/E1000ENetworkAdapter.h
Liav A 64aaf263a2 Kernel/Net: Generate interface name near construction point
This change allows the Kernel to actually construct other interfaces
besides the E1000 type.
This solves a breakage that was introduced recently because of move
semantics.

A couple of points on this patch:
1. In current situation, we can waste time to create a KString and throw
it for nothing. This patch ensures we only create it near construction
point so we know we actually need it.
2. It's very likely to assume that non-x86 machines will expose network
device with a device tree (or with ACPI). The raspberry pi machine is a
good example of that. Therefore, each driver should explicitly ask the
correct interface name generation method, and this patch simplifies this
pattern greatly, especially in a case where the same network device can
appear as a PCI device or as device in another bus type on the same
platform target. For example, the (in)famous ne2000 device can be used
either as a PCI device or as an ISA device, depending on the model.
3. In my opinion, it seems much more readable to construct the name near
calling point of the object constructor than to just pass it with move
semantics.
2021-10-18 12:25:56 -07:00

41 lines
1 KiB
C++

/*
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullOwnPtrVector.h>
#include <AK/OwnPtr.h>
#include <Kernel/Arch/x86/IO.h>
#include <Kernel/Bus/PCI/Access.h>
#include <Kernel/Bus/PCI/Device.h>
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Net/E1000NetworkAdapter.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/Random.h>
namespace Kernel {
class E1000ENetworkAdapter final
: public E1000NetworkAdapter {
public:
static RefPtr<E1000ENetworkAdapter> try_to_initialize(PCI::DeviceIdentifier const&);
virtual bool initialize() override;
virtual ~E1000ENetworkAdapter() override;
virtual StringView purpose() const override { return class_name(); }
private:
E1000ENetworkAdapter(PCI::Address, u8 irq, NonnullOwnPtr<KString>);
virtual StringView class_name() const override { return "E1000ENetworkAdapter"sv; }
virtual void detect_eeprom() override;
virtual u32 read_eeprom(u8 address) override;
};
}