Skip to content

Commit

Permalink
Kernel/NE2000: Correct receive ring buffer wrap-around
Browse files Browse the repository at this point in the history
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 SerenityOS#8327.
  • Loading branch information
twvd authored and awesomekling committed Jul 24, 2021
1 parent a1d0ad6 commit de2d5d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Kernel/Net/NE2000NetworkAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit de2d5d6

Please sign in to comment.