Skip to content

Commit a84c0a2

Browse files
author
Ian Seyler
committed
Update i8257x and i8259x drivers for zerocopy
1 parent c0bef38 commit a84c0a2

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/drivers/net/i8257x.asm

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ net_i8257x_transmit:
285285
; Bits 47:40 - Errors
286286
; Bits 63:48 - VLAN
287287
net_i8257x_poll:
288-
push rdi
289288
push rsi ; Used for the base MMIO of the NIC
289+
push rbx
290290
push rax
291291

292292
mov rdi, [rdx+nt_rx_desc]
@@ -295,8 +295,9 @@ net_i8257x_poll:
295295
; Calculate the descriptor to read from
296296
mov eax, [rdx+nt_rx_head] ; Get rx_lasthead
297297
shl eax, 4 ; Quick multiply by 16
298-
add eax, 8 ; Offset to bytes received
299298
add rdi, rax ; Add offset to RDI
299+
mov rbx, [rdi]
300+
add rdi, 8 ; Offset to bytes received
300301
; Todo: read all 64 bits. check status bit for DD
301302
xor ecx, ecx ; Clear RCX
302303
mov cx, [rdi] ; Get the packet length
@@ -305,6 +306,7 @@ net_i8257x_poll:
305306

306307
xor eax, eax
307308
stosq ; Clear the descriptor length and status
309+
mov rdi, rbx
308310

309311
; Increment i8257x_rx_lasthead and the Receive Descriptor Tail
310312
mov eax, [rdx+nt_rx_head] ; Get rx_lasthead
@@ -317,16 +319,10 @@ net_i8257x_poll:
317319
and eax, i8257x_MAX_DESC - 1
318320
mov [rsi+i8257x_RDT], eax ; Write the updated Receive Descriptor Tail
319321

320-
pop rax
321-
pop rsi
322-
pop rdi
323-
ret
324-
325322
net_i8257x_poll_end:
326-
xor ecx, ecx
327323
pop rax
324+
pop rbx
328325
pop rsi
329-
pop rdi
330326
ret
331327
; -----------------------------------------------------------------------------
332328

src/drivers/net/i8259x.asm

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ net_i8259x_transmit:
434434
; Bits 95:64 - Fragment Checksum (Bits 31:16) / Length (Bits 15:0)
435435
; Bits 127:96 - VLAN (Bits 63:48) / Errors (Bits 47:40) / STA (Bits 39:32)
436436
net_i8259x_poll:
437-
push rdi
438437
push rsi ; Used for the base MMIO of the NIC
438+
push rbx
439439
push rax
440440

441441
mov rdi, [rdx+nt_rx_desc]
@@ -444,8 +444,9 @@ net_i8259x_poll:
444444
; Calculate the descriptor to read from
445445
mov eax, [rdx+nt_rx_head] ; Get rx_lasthead
446446
shl eax, 4 ; Quick multiply by 16
447-
add eax, 8 ; Offset to bytes received
448447
add rdi, rax ; Add offset to RDI
448+
mov rbx, [rdi]
449+
add rdi, 8 ; Offset to bytes received
449450
; Todo: read all 64 bits. check status bit for DD
450451
xor ecx, ecx ; Clear RCX
451452
mov cx, [rdi] ; Get the packet length
@@ -454,6 +455,7 @@ net_i8259x_poll:
454455

455456
xor eax, eax
456457
stosq ; Clear the descriptor length and status
458+
mov rdi, rbx
457459

458460
; Increment i8259x_rx_lasthead and the Receive Descriptor Tail
459461
mov eax, [rdx+nt_rx_head] ; Get rx_lasthead
@@ -466,16 +468,10 @@ net_i8259x_poll:
466468
and eax, i8259x_MAX_DESC - 1
467469
mov [rsi+i8259x_RDT], eax ; Write the updated Receive Descriptor Tail
468470

469-
pop rax
470-
pop rsi
471-
pop rdi
472-
ret
473-
474471
net_i8259x_poll_end:
475-
xor ecx, ecx
476472
pop rax
473+
pop rbx
477474
pop rsi
478-
pop rdi
479475
ret
480476
; -----------------------------------------------------------------------------
481477

0 commit comments

Comments
 (0)