Skip to content

Commit d81ada9

Browse files
authored
Merge pull request #113 from ReturnInfinity/dev
Check DD Status Bit on Transmit for Intel NICs
2 parents 9b14da2 + 72c2c00 commit d81ada9

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

src/drivers/net/i8254x.asm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ net_i8254x_config_next_record:
262262
; Bits 63:48 - Special
263263
net_i8254x_transmit:
264264
push rdi
265+
push rbx
265266
push rax
266267

267268
mov rdi, [rdx+nt_tx_desc] ; Transmit Descriptor Base Address
@@ -279,6 +280,7 @@ net_i8254x_transmit:
279280
bts rax, 24 ; TDESC.CMD.EOP (0) - End Of Packet
280281
bts rax, 25 ; TDESC.CMD.IFCS (1) - Insert FCS (CRC)
281282
bts rax, 27 ; TDESC.CMD.RS (3) - Report Status
283+
mov rbx, rdi ; Save location of Second Qword to RBX
282284
stosq
283285

284286
; Increment i8254x_tx_lasttail and the Transmit Descriptor Tail
@@ -289,7 +291,14 @@ net_i8254x_transmit:
289291
mov rdi, [rdx+nt_base] ; Load the base MMIO of the NIC
290292
mov [rdi+i8254x_TDT], eax ; TDL - Transmit Descriptor Tail
291293

294+
; Check for TDESC.STA.DD (32) - Descriptor Done
295+
net_i8254x_transmit_wait:
296+
mov rax, [rbx]
297+
bt rax, 32
298+
jnc net_i8254x_transmit_wait
299+
292300
pop rax
301+
pop rbx
293302
pop rdi
294303
ret
295304
; -----------------------------------------------------------------------------

src/drivers/net/i8257x.asm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ net_i8257x_config_next_record:
264264
; Bits 63:48 - VLAN
265265
net_i8257x_transmit:
266266
push rdi
267+
push rbx
267268
push rax
268269

269270
mov rdi, [rdx+nt_tx_desc] ; Transmit Descriptor Base Address
@@ -281,6 +282,7 @@ net_i8257x_transmit:
281282
bts rax, 24 ; TDESC.CMD.EOP (0) - End Of Packet
282283
bts rax, 25 ; TDESC.CMD.IFCS (1) - Insert FCS (CRC)
283284
bts rax, 27 ; TDESC.CMD.RS (3) - Report Status
285+
mov rbx, rdi ; Save location of Second Qword to RBX
284286
stosq
285287

286288
; Increment i8257x_tx_lasttail and the Transmit Descriptor Tail
@@ -291,7 +293,14 @@ net_i8257x_transmit:
291293
mov rdi, [rdx+nt_base] ; Load the base MMIO of the NIC
292294
mov [rdi+i8257x_TDT], eax ; TDL - Transmit Descriptor Tail
293295

296+
; Check for TDESC.STA.DD (32) - Descriptor Done
297+
net_i8257x_transmit_wait:
298+
mov rax, [rbx]
299+
bt rax, 32
300+
jnc net_i8257x_transmit_wait
301+
294302
pop rax
303+
pop rbx
295304
pop rdi
296305
ret
297306
; -----------------------------------------------------------------------------

src/drivers/net/i8259x.asm

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,21 @@ net_i8259x_config_next_record:
427427
; RDX = Interface ID
428428
; RCX = Length of packet
429429
; OUT: Nothing
430-
; Note: Transmit Descriptor (TDESC) Layout - Legacy Mode (7.2.3.2.2):
430+
; Note: This driver uses the "legacy format" so TDESC.CMD.DEXT (5) is cleared to 0 - (7.2.3.2.2):
431+
; TDESC Descriptor Format:
432+
; First Qword:
431433
; Bits 63:0 - Buffer Address
432-
; Bits 95:64 - CMD (Bits 31:24) / CSO (Bits 23:16) / Length (Bits 15:0)
433-
; Bits 127:96 - VLAN (Bits 63:48) / CSS (Bits 47:40) / Reserved (Bits 39:36) / STA (Bits 35:32)
434+
; Second Qword:
435+
; Bits 15:0 - Length
436+
; Bits 23:16 - CSO - Checksum Offset
437+
; Bits 31:24 - CMD - Command Byte
438+
; Bits 35:32 - STA - Status
439+
; Bits 39:36 - Reserved
440+
; Bits 47:40 - CSS - Checksum Start
441+
; Bits 63:48 - VLAN
434442
net_i8259x_transmit:
435443
push rdi
444+
push rbx
436445
push rax
437446

438447
mov rdi, [rdx+nt_tx_desc] ; Transmit Descriptor Base Address
@@ -450,6 +459,7 @@ net_i8259x_transmit:
450459
bts rax, 24 ; TDESC.CMD.EOP (0) - End Of Packet
451460
bts rax, 25 ; TDESC.CMD.IFCS (1) - Insert FCS (CRC)
452461
bts rax, 27 ; TDESC.CMD.RS (3) - Report Status
462+
mov rbx, rdi ; Save location of Second Qword to RBX
453463
stosq
454464

455465
; Increment i8259x_tx_lasttail and the Transmit Descriptor Tail
@@ -460,9 +470,14 @@ net_i8259x_transmit:
460470
mov rdi, [rdx+nt_base] ; Load the base MMIO of the NIC
461471
mov [rdi+i8259x_TDT], eax ; TDL - Transmit Descriptor Tail
462472

463-
; TDESC.STA.DD (bit 32) should be 1 once the hardware has sent the packet
473+
; Check for TDESC.STA.DD (32) - Descriptor Done
474+
net_i8259x_transmit_wait:
475+
mov rax, [rbx]
476+
bt rax, 32
477+
jnc net_i8259x_transmit_wait
464478

465479
pop rax
480+
pop rbx
466481
pop rdi
467482
ret
468483
; -----------------------------------------------------------------------------

src/drivers/ps2.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ mouse_getbyte:
200200
add ebx, os_ps2_mouse_packet ; Add the address of the mouse packet
201201
mov [ebx], cl ; Store the byte in CL to the correct index into the mouse packet
202202
inc byte [os_ps2_mouse_count] ; Increment the byte counter
203-
mov bl, [os_ps2_mouse_count] ; Copy the byte counter value to BL
203+
mov bl, [os_ps2_mouse_count] ; Copy the byte counter value to BL
204204
cmp bl, [packetsize] ; Compare byte counter to excepted packet size
205205
jb mouse_end ; If below then bail out, wait for rest of packet
206206
mov word [os_ps2_mouse_count], 0 ; At this point we have a full packet. Clear the byte counter

0 commit comments

Comments
 (0)