mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 20:17:42 +00:00
RTL8139: Unbreak RealTek Ethernet driver after paging changes
This commit is contained in:
parent
94ca55cefd
commit
22d4920cef
1 changed files with 5 additions and 6 deletions
|
@ -157,17 +157,16 @@ RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address pci_address, u8 irq)
|
||||||
// we add space to account for overhang from the last packet - the rtl8139
|
// we add space to account for overhang from the last packet - the rtl8139
|
||||||
// can optionally guarantee that packets will be contiguous by
|
// can optionally guarantee that packets will be contiguous by
|
||||||
// purposefully overrunning the rx buffer
|
// purposefully overrunning the rx buffer
|
||||||
m_rx_buffer_addr = (u32)kmalloc_aligned(RX_BUFFER_SIZE + PACKET_SIZE_MAX, 16);
|
m_rx_buffer_addr = (u32)virtual_to_low_physical(kmalloc_aligned(RX_BUFFER_SIZE + PACKET_SIZE_MAX, 16));
|
||||||
kprintf("RTL8139: RX buffer: P%p\n", m_rx_buffer_addr);
|
kprintf("RTL8139: RX buffer: P%p\n", m_rx_buffer_addr);
|
||||||
|
|
||||||
auto tx_buffer_addr = (u32)kmalloc_aligned(TX_BUFFER_SIZE * 4, 16);
|
auto tx_buffer_addr = (u32)virtual_to_low_physical(kmalloc_aligned(TX_BUFFER_SIZE * 4, 16));
|
||||||
for (int i = 0; i < RTL8139_TX_BUFFER_COUNT; i++) {
|
for (int i = 0; i < RTL8139_TX_BUFFER_COUNT; i++) {
|
||||||
m_tx_buffer_addr[i] = tx_buffer_addr + TX_BUFFER_SIZE * i;
|
m_tx_buffer_addr[i] = tx_buffer_addr + TX_BUFFER_SIZE * i;
|
||||||
kprintf("RTL8139: TX buffer %d: P%p\n", i, m_tx_buffer_addr[i]);
|
kprintf("RTL8139: TX buffer %d: P%p\n", i, m_tx_buffer_addr[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_packet_buffer = (u32)kmalloc(PACKET_SIZE_MAX);
|
m_packet_buffer = (u32)kmalloc(PACKET_SIZE_MAX);
|
||||||
kprintf("RTL8139: Packet buffer: P%p\n", m_packet_buffer);
|
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
@ -324,8 +323,8 @@ void RTL8139NetworkAdapter::send_raw(const u8* data, int length)
|
||||||
m_tx_next_buffer = (hw_buffer + 1) % 4;
|
m_tx_next_buffer = (hw_buffer + 1) % 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy((void*)(m_tx_buffer_addr[hw_buffer]), data, length);
|
memcpy((void*)low_physical_to_virtual(m_tx_buffer_addr[hw_buffer]), data, length);
|
||||||
memset((void*)(m_tx_buffer_addr[hw_buffer] + length), 0, TX_BUFFER_SIZE - length);
|
memset((void*)(low_physical_to_virtual(m_tx_buffer_addr[hw_buffer]) + length), 0, TX_BUFFER_SIZE - length);
|
||||||
|
|
||||||
// the rtl8139 will not actually emit packets onto the network if they're
|
// the rtl8139 will not actually emit packets onto the network if they're
|
||||||
// smaller than 64 bytes. the rtl8139 adds a checksum to the end of each
|
// smaller than 64 bytes. the rtl8139 adds a checksum to the end of each
|
||||||
|
@ -343,7 +342,7 @@ void RTL8139NetworkAdapter::send_raw(const u8* data, int length)
|
||||||
|
|
||||||
void RTL8139NetworkAdapter::receive()
|
void RTL8139NetworkAdapter::receive()
|
||||||
{
|
{
|
||||||
auto* start_of_packet = (const u8*)(m_rx_buffer_addr + m_rx_buffer_offset);
|
auto* start_of_packet = (const u8*)(low_physical_to_virtual(m_rx_buffer_addr) + m_rx_buffer_offset);
|
||||||
|
|
||||||
u16 status = *(const u16*)(start_of_packet + 0);
|
u16 status = *(const u16*)(start_of_packet + 0);
|
||||||
u16 length = *(const u16*)(start_of_packet + 2);
|
u16 length = *(const u16*)(start_of_packet + 2);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue