1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

Kernel/NE2000: Correct receive ring buffer wrap-around

next_packet_page points to a page, but was being compared to a byte
offset rather than a page offset when adjusting the BOUNDARY register
when the ring buffer wraps around.

Fixes #8327.
This commit is contained in:
Thomas Wagenveld 2021-07-24 14:38:59 +02:00 committed by Andreas Kling
parent a1d0ad61a6
commit de2d5d6a7e

View file

@ -116,7 +116,7 @@ static constexpr int NE2K_RAM_END = 32768;
static constexpr int NE2K_RAM_SIZE = NE2K_RAM_END - NE2K_RAM_BEGIN;
static constexpr int NE2K_RAM_SEND_BEGIN = 16384;
static constexpr int NE2K_RAM_SEND_END = 16384 + 6 * 256;
static constexpr int NE2K_RAM_SEND_END = 16384 + 6 * NE2K_PAGE_SIZE;
static constexpr int NE2K_RAM_SEND_SIZE = NE2K_RAM_SEND_END - NE2K_RAM_SEND_BEGIN;
static constexpr int NE2K_RAM_RECV_BEGIN = NE2K_RAM_SEND_END;
@ -426,7 +426,7 @@ void NE2000NetworkAdapter::receive()
did_receive(packet.span().slice(sizeof(received_packet_header)));
}
if (header.next_packet_page == NE2K_RAM_RECV_BEGIN)
if (header.next_packet_page == (NE2K_RAM_RECV_BEGIN >> 8))
out8(REG_RW_BOUNDARY, (NE2K_RAM_RECV_END >> 8) - 1);
else
out8(REG_RW_BOUNDARY, header.next_packet_page - 1);