Skip to content

Commit

Permalink
Kernel: Modernize the E1000(E) driver using the new IORegister API
Browse files Browse the repository at this point in the history
This also adds some quirk handling, and 64 bit DMA support, which where
previously missing.
  • Loading branch information
Hendiadyoin1 committed Dec 1, 2024
1 parent 04095ca commit af99d75
Show file tree
Hide file tree
Showing 5 changed files with 518 additions and 252 deletions.
17 changes: 3 additions & 14 deletions Kernel/Net/Intel/E1000ENetworkAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ UNMAP_AFTER_INIT ErrorOr<void> E1000ENetworkAdapter::initialize(Badge<Networking
dmesgln("E1000e: Found @ {}", device_identifier().address());
enable_bus_mastering(device_identifier());

dmesgln("E1000e: IO base: {}", m_registers_io_window);
dmesgln("E1000e: IO base: {}", m_registers.window());
dmesgln("E1000e: Interrupt line: {}", interrupt_number());
check_quirks();
detect_eeprom();
dmesgln("E1000e: Has EEPROM? {}", m_has_eeprom.was_set());
read_mac_address();
Expand Down Expand Up @@ -253,20 +254,8 @@ UNMAP_AFTER_INIT E1000ENetworkAdapter::~E1000ENetworkAdapter() = default;
UNMAP_AFTER_INIT void E1000ENetworkAdapter::detect_eeprom()
{
// Section 13.4.3 of https://www.intel.com/content/dam/doc/manual/pci-pci-x-family-gbe-controllers-software-dev-manual.pdf
if (in32(REG_EECD) & EECD_PRES)
if (m_registers.read<Register::EEPROMControl>().eeprom_present)
m_has_eeprom.set();
}

UNMAP_AFTER_INIT u32 E1000ENetworkAdapter::read_eeprom(u8 address)
{
VERIFY(m_has_eeprom.was_set());
u16 data = 0;
u32 tmp = 0;
out32(REG_EEPROM, ((u32)address << 2) | 1);
while (!((tmp = in32(REG_EEPROM)) & (1 << 1)))
Processor::wait_check();
data = (tmp >> 16) & 0xffff;
return data;
}

}
1 change: 0 additions & 1 deletion Kernel/Net/Intel/E1000ENetworkAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ class E1000ENetworkAdapter final
virtual StringView class_name() const override { return "E1000ENetworkAdapter"sv; }

virtual void detect_eeprom() override;
virtual u32 read_eeprom(u8 address) override;
};
}
Loading

0 comments on commit af99d75

Please sign in to comment.