mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:17:35 +00:00
Kernel/Net: Allocate regions before invoking Intel driver constructors
Instead of allocating after the construction point ensure that all Intel drivers are allocating necessary buffer regions and then pass them to the constructors. This could let us fail early in case of OOM, so we don't touch a network adapter before we ensure we have all the appropriate mappings in place.
This commit is contained in:
parent
301f9de915
commit
102186b0f5
4 changed files with 62 additions and 19 deletions
|
@ -35,10 +35,17 @@ public:
|
|||
virtual StringView device_name() const override { return "E1000"sv; }
|
||||
|
||||
protected:
|
||||
static constexpr size_t rx_buffer_size = 8192;
|
||||
static constexpr size_t tx_buffer_size = 8192;
|
||||
|
||||
void setup_interrupts();
|
||||
void setup_link();
|
||||
|
||||
E1000NetworkAdapter(PCI::Address, u8 irq, NonnullOwnPtr<IOWindow> registers_io_window, NonnullOwnPtr<KString>);
|
||||
E1000NetworkAdapter(PCI::Address, u8 irq,
|
||||
NonnullOwnPtr<IOWindow> registers_io_window, NonnullOwnPtr<Memory::Region> rx_buffer_region,
|
||||
NonnullOwnPtr<Memory::Region> tx_buffer_region, NonnullOwnPtr<Memory::Region> rx_descriptors_region,
|
||||
NonnullOwnPtr<Memory::Region> tx_descriptors_region, NonnullOwnPtr<KString>);
|
||||
|
||||
virtual bool handle_irq(RegisterState const&) override;
|
||||
virtual StringView class_name() const override { return "E1000NetworkAdapter"sv; }
|
||||
|
||||
|
@ -85,10 +92,10 @@ protected:
|
|||
|
||||
NonnullOwnPtr<IOWindow> m_registers_io_window;
|
||||
|
||||
OwnPtr<Memory::Region> m_rx_descriptors_region;
|
||||
OwnPtr<Memory::Region> m_tx_descriptors_region;
|
||||
OwnPtr<Memory::Region> m_rx_buffer_region;
|
||||
OwnPtr<Memory::Region> m_tx_buffer_region;
|
||||
NonnullOwnPtr<Memory::Region> m_rx_descriptors_region;
|
||||
NonnullOwnPtr<Memory::Region> m_tx_descriptors_region;
|
||||
NonnullOwnPtr<Memory::Region> m_rx_buffer_region;
|
||||
NonnullOwnPtr<Memory::Region> m_tx_buffer_region;
|
||||
Array<void*, number_of_rx_descriptors> m_rx_buffers;
|
||||
Array<void*, number_of_tx_descriptors> m_tx_buffers;
|
||||
bool m_has_eeprom { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue