summaryrefslogtreecommitdiff
path: root/Kernel/Net
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2020-01-17 19:59:20 +0100
committerAndreas Kling <awesomekling@gmail.com>2020-01-17 22:34:26 +0100
commite362b56b4fd73db86eb8bf62baa8963eec0a967b (patch)
tree38ff10b38b7a8f843c436b629cc8184b2e5f0287 /Kernel/Net
parentcee597a728c89c0d7217a646aea84b14b534e200 (diff)
downloadserenity-e362b56b4fd73db86eb8bf62baa8963eec0a967b.zip
Kernel: Move kernel above the 3GB virtual address mark
The kernel and its static data structures are no longer identity-mapped in the bottom 8MB of the address space, but instead move above 3GB. The first 8MB above 3GB are pseudo-identity-mapped to the bottom 8MB of the physical address space. But things don't have to stay this way! Thanks to Jesse who made an earlier attempt at this, it was really easy to get device drivers working once the page tables were in place! :^) Fixes #734.
Diffstat (limited to 'Kernel/Net')
-rw-r--r--Kernel/Net/E1000NetworkAdapter.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp
index dd9b268893..1450fbd84b 100644
--- a/Kernel/Net/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/E1000NetworkAdapter.cpp
@@ -234,11 +234,14 @@ void E1000NetworkAdapter::initialize_rx_descriptors()
m_rx_descriptors = (e1000_rx_desc*)ptr;
for (int i = 0; i < number_of_rx_descriptors; ++i) {
auto& descriptor = m_rx_descriptors[i];
- descriptor.addr = (u64)kmalloc_eternal(8192 + 16);
+ auto addr = (u32)kmalloc_eternal(8192 + 16);
+ if (addr % 16)
+ addr = (addr + 16) - (addr % 16);
+ descriptor.addr = addr - 0xc0000000;
descriptor.status = 0;
}
- out32(REG_RXDESCLO, ptr);
+ out32(REG_RXDESCLO, (u32)ptr - 0xc0000000);
out32(REG_RXDESCHI, 0);
out32(REG_RXDESCLEN, number_of_rx_descriptors * sizeof(e1000_rx_desc));
out32(REG_RXDESCHEAD, 0);
@@ -256,11 +259,14 @@ void E1000NetworkAdapter::initialize_tx_descriptors()
m_tx_descriptors = (e1000_tx_desc*)ptr;
for (int i = 0; i < number_of_tx_descriptors; ++i) {
auto& descriptor = m_tx_descriptors[i];
- descriptor.addr = (u64)kmalloc_eternal(8192 + 16);
+ auto addr = (u32)kmalloc_eternal(8192 + 16);
+ if (addr % 16)
+ addr = (addr + 16) - (addr % 16);
+ descriptor.addr = addr - 0xc0000000;
descriptor.cmd = 0;
}
- out32(REG_TXDESCLO, ptr);
+ out32(REG_TXDESCLO, (u32)ptr - 0xc0000000);
out32(REG_TXDESCHI, 0);
out32(REG_TXDESCLEN, number_of_tx_descriptors * sizeof(e1000_tx_desc));
out32(REG_TXDESCHEAD, 0);
@@ -348,7 +354,8 @@ void E1000NetworkAdapter::send_raw(const u8* data, int length)
#endif
auto& descriptor = m_tx_descriptors[tx_current];
ASSERT(length <= 8192);
- memcpy((void*)descriptor.addr, data, length);
+ auto *vptr = (void*)(descriptor.addr + 0xc0000000);
+ memcpy(vptr, data, length);
descriptor.length = length;
descriptor.status = 0;
descriptor.cmd = CMD_EOP | CMD_IFCS | CMD_RS;
@@ -381,7 +388,7 @@ void E1000NetworkAdapter::receive()
rx_current = (rx_current + 1) % number_of_rx_descriptors;
if (!(m_rx_descriptors[rx_current].status & 1))
break;
- auto* buffer = (u8*)m_rx_descriptors[rx_current].addr;
+ auto* buffer = (u8*)(m_rx_descriptors[rx_current].addr + 0xc0000000);
u16 length = m_rx_descriptors[rx_current].length;
#ifdef E1000_DEBUG
kprintf("E1000: Received 1 packet @ %p (%u) bytes!\n", buffer, length);