Kernel: More work on bringing up E1000 support.

This commit is contained in:
Andreas Kling 2019-03-11 11:11:29 +01:00
parent a36eaeb18c
commit 47b096feb4
Notes: sideshowbarker 2024-07-19 15:05:12 +09:00
4 changed files with 15 additions and 0 deletions

View file

@ -108,6 +108,9 @@ E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address pci_address, byte irq)
{
s_the = this;
kprintf("E1000: Found at PCI address %b:%b:%b\n", pci_address.bus(), pci_address.slot(), pci_address.function());
enable_bus_mastering(m_pci_address);
m_mmio_base = PhysicalAddress(PCI::get_BAR0(m_pci_address));
MM.map_for_kernel(LinearAddress(m_mmio_base.get()), m_mmio_base);
MM.map_for_kernel(LinearAddress(m_mmio_base.offset(4096).get()), m_mmio_base.offset(4096));

View file

@ -56,6 +56,9 @@ void MemoryManager::populate_page_directory(PageDirectory& page_directory)
{
page_directory.m_directory_page = allocate_supervisor_physical_page();
page_directory.entries()[0] = kernel_page_directory().entries()[0];
// Defer to the kernel page tables for 0xC0000000-0xFFFFFFFF
for (int i = 768; i < 1024; ++i)
page_directory.entries()[i] = kernel_page_directory().entries()[i];
}
void MemoryManager::initialize_paging()

View file

@ -103,6 +103,14 @@ dword get_BAR3(Address address) { return read_field<dword>(address, PCI_BAR3); }
dword get_BAR4(Address address) { return read_field<dword>(address, PCI_BAR4); }
dword get_BAR5(Address address) { return read_field<dword>(address, PCI_BAR5); }
void enable_bus_mastering(Address address)
{
auto value = read_field<word>(address, PCI_COMMAND);
value |= (1 << 2);
value |= (1 << 0);
write_field<word>(address, PCI_COMMAND, value);
}
void enumerate_all(Function<void(Address, ID)> callback)
{
// Single PCI host controller.

View file

@ -47,5 +47,6 @@ dword get_BAR2(Address);
dword get_BAR3(Address);
dword get_BAR4(Address);
dword get_BAR5(Address);
void enable_bus_mastering(Address);
}