From de2d5d6a7ecda2ea89b1b68c18e4a2d9b577b892 Mon Sep 17 00:00:00 2001 From: Thomas Wagenveld Date: Sat, 24 Jul 2021 14:38:59 +0200 Subject: [PATCH] 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. --- Kernel/Net/NE2000NetworkAdapter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel/Net/NE2000NetworkAdapter.cpp b/Kernel/Net/NE2000NetworkAdapter.cpp index 7695a3a88c..84d71364e4 100644 --- a/Kernel/Net/NE2000NetworkAdapter.cpp +++ b/Kernel/Net/NE2000NetworkAdapter.cpp @@ -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);