Skip to content

Commit c022287

Browse files
author
Ian Seyler
committed
i8259x cleanup
1 parent 9a4619e commit c022287

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/drivers/net/i8259x.asm

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ net_i8259x_init:
8181
mov [rdi+nt_transmit], rax
8282
mov rax, net_i8259x_poll
8383
mov [rdi+nt_poll], rax
84+
mov eax, i8259x_MAX_DESC / 2
85+
mov [rdi+nt_rx_tail], eax
8486

8587
net_i8259x_init_error:
8688

@@ -486,15 +488,16 @@ net_i8259x_poll:
486488
add rdi, rax ; Add offset to RX descriptor base
487489
mov rbx, [rdi] ; Load the buffer address (where the packet is)
488490
add rdi, 8 ; Offset to bytes received
489-
; Todo: read all 64 bits. check status bit DD(0)
490-
; Errors (Bits 47:40) should be clear
491-
xor ecx, ecx ; Clear RCX
492-
mov cx, [rdi] ; Get the packet length
491+
; Todo: Check Errors (Bits 47:40) should be clear
492+
mov rcx, [rdi] ; Get the packet length
493+
bt rcx, 32 ; Check DD
494+
jnc net_i8259x_poll_end_no_data
495+
and ecx, 0x0000FFFF ; Keep Length (Bits 15:0)
493496
cmp cx, 0
494-
je net_i8259x_poll_end ; No data? Bail out
497+
je net_i8259x_poll_end_no_data ; No data? Bail out
495498

496499
xor eax, eax
497-
stosq ; Clear the descriptor length and status
500+
mov [rdi], rax ; Clear the descriptor length and status
498501
mov rdi, rbx ; Copy the buffer address to RDI
499502

500503
; Increment rx_head
@@ -510,6 +513,11 @@ net_i8259x_poll:
510513
mov [rdx+nt_rx_tail], eax ; Update driver info
511514
mov [rsi+i8259x_RDT], eax ; Write the updated Receive Descriptor Tail
512515

516+
jmp net_i8259x_poll_end
517+
518+
net_i8259x_poll_end_no_data:
519+
xor ecx, ecx
520+
513521
net_i8259x_poll_end:
514522
pop rax
515523
pop rbx

0 commit comments

Comments
 (0)