mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:37:42 +00:00
Kernel/Net: Introduce a new mechanism to initialize a PCI device
Instead of using a clunky if-statement paradigm, we now have all drivers being declaring two methods for their adapter class - create and probe. These methods are linked in each PCINetworkDriverInitializer structure, in a new s_initializers static list of them. Then, when we probe for a PCI device, we use each probe method and if there's a match, then the corresponding create method is called. After the adapter instance is created, we call the virtual initialize method on it, because many drivers actually require a sort of post-construction initialization sequence to ensure the network adapter can properly function. As a result of this change, it's much more easy to add more drivers and the initialization code is more readable and it's easier to understand when and where things could fail in the whole initialization sequence.
This commit is contained in:
parent
90ac9d7253
commit
0cede94c39
13 changed files with 131 additions and 86 deletions
|
@ -18,6 +18,8 @@ public:
|
|||
static LockRefPtr<LoopbackAdapter> try_create();
|
||||
virtual ~LoopbackAdapter() override;
|
||||
|
||||
virtual ErrorOr<void> initialize(Badge<NetworkingManagement>) override { VERIFY_NOT_REACHED(); }
|
||||
|
||||
virtual void send_raw(ReadonlyBytes) override;
|
||||
virtual StringView class_name() const override { return "LoopbackAdapter"sv; }
|
||||
virtual bool link_up() override { return true; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue