Skip to content

Commit f63e48f

Browse files
author
Ian Seyler
committed
Cleanup
1 parent a1504a2 commit f63e48f

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

src/drivers/net/i8259x.asm

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ 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
84+
mov eax, i8259x_MAX_DESC - 1
8585
mov [rdi+nt_rx_tail], eax
8686

8787
net_i8259x_init_error:
@@ -140,16 +140,17 @@ net_i8259x_reset_wait:
140140
mov eax, [rsi+i8259x_EICR]
141141

142142
; Preform general configuration (4.6.3.2)
143-
;FCTTV
144-
;FCRTL - Flow Control Low Threshold
145-
;FCRTH - Flow Control High Threshold
146-
;FCRTV
147-
;FCCFG
143+
; On Initialization these registers will be cleared
144+
; FCTTV - Flow Control Transmit Timer Value
145+
; FCRTL - Flow Control Low Threshold
146+
; FCRTH - Flow Control High Threshold
147+
; FCRTV - Flow Control Refresh Threshold Value
148+
; FCCFG - Flow Control Configuration
148149
; Section 3.7.7.3.2 through Section 3.7.7.3.5
149-
;FDIRCTRL - Clear PBALLOC
150-
;SRRCTL[n].BSIZEPACKET field defines the data buffer size. Section 7.1.2
151-
;Aggregation - Section 7.1.7
152-
;Receive Coalescing (RSC) - Section 7.11.5.1
150+
; FDIRCTRL - Flow Director Filters Control Register - Clear PBALLOC
151+
; SRRCTL[n].BSIZEPACKET field defines the data buffer size. Section 7.1.2
152+
; Aggregation - Section 7.1.7
153+
; Receive Coalescing (RSC) - Section 7.11.5.1
153154

154155
; Wait for EEPROM auto read completion (4.6.3)
155156
mov eax, [rsi+i8259x_EEC] ; Read current value
@@ -178,7 +179,7 @@ net_i8259x_reset_dma_wait:
178179
; and eax, 0x00000180 ; Set 10G_PMA_PMD_PARALLEL (bits 8:7)
179180
; mov [rsi+i8259x_AUTOC], eax
180181

181-
; mov rax, 20000 ; Wait 20ms (20000µs)
182+
; mov rax, 20000 ; Wait 20ms (20000µs)
182183
; call b_delay ; Delay for 20ms
183184

184185
mov eax, [rsi+i8259x_AUTOC]
@@ -241,9 +242,10 @@ net_i8259x_reset_nextdesc:
241242
mov eax, [rsi+i8259x_SRRCTL]
242243
and eax, 0xF1FFFFFF ; Clear bits 27:25 for DESCTYPE
243244
; or eax, 0x02000000 ; Bits 27:25 = 001 for Advanced desc one buffer
244-
bts eax, 28 ; i8259x_SRRCTL_DROP_EN
245+
bts eax, 28 ; Enable i8259x_SRRCTL_DROP_EN
245246
mov [rsi+i8259x_SRRCTL], eax
246-
; Set up RX descriptor ring 0
247+
248+
; Set up RX Descriptor Ring 0
247249
xor eax, eax
248250
mov al, byte [os_net_icount]
249251
shl eax, 15 ; Quick multiply by 32768
@@ -253,7 +255,7 @@ net_i8259x_reset_nextdesc:
253255
mov [rsi+i8259x_RDBAH], eax
254256
mov eax, i8259x_MAX_DESC * 16
255257
mov [rsi+i8259x_RDLEN], eax
256-
xor eax, eax
258+
xor eax, eax ; Head and Tail set to same value means buffer is full
257259
mov [rsi+i8259x_RDH], eax
258260
mov [rsi+i8259x_RDT], eax
259261
; Set bit 16 of CTRL_EXT (Last line in 4.6.7)
@@ -268,23 +270,24 @@ net_i8259x_reset_nextdesc:
268270
mov eax, 1 ; RXEN = 1
269271
mov [rsi+i8259x_RXCTRL], eax ; Enable receive
270272

271-
; Enable Multicast
272-
mov eax, 0xFFFFFFFF
273-
mov [rsi+i8259x_MTA], eax
274-
275273
; Enable the RX queue
276274
mov eax, [rsi+i8259x_RXDCTL]
277-
or eax, 0x02000000
275+
or eax, 0x02000000 ; Set ENABLE (bit 25)
278276
mov [rsi+i8259x_RXDCTL], eax
279277
net_i8259x_init_rx_enable_wait:
280278
mov eax, [rsi+i8259x_RXDCTL]
281-
bt eax, 25
279+
bt eax, 25 ; Check ENABLE
282280
jnc net_i8259x_init_rx_enable_wait
281+
; Set the Receive Descriptor Head and Tail
283282
xor eax, eax
284283
mov [rsi+i8259x_RDH], eax
285-
mov eax, i8259x_MAX_DESC / 2
284+
mov eax, i8259x_MAX_DESC - 1
286285
mov [rsi+i8259x_RDT], eax
287286

287+
; Enable Multicast
288+
mov eax, 0xFFFFFFFF
289+
mov [rsi+i8259x_MTA], eax
290+
288291
; ; Set SECRXCTRL_RX_DIS
289292
; mov eax, [rsi+i8259x_SECRXCTRL]
290293
; bts eax, i8259x_SECRXCTRL_RX_DIS
@@ -493,8 +496,6 @@ net_i8259x_poll:
493496
bt rcx, 32 ; DD set?
494497
jnc net_i8259x_poll_end_nodata
495498
and ecx, 0x0000FFFF ; Keep bits 15:0 for the packet length
496-
; cmp cx, 0
497-
; je net_i8259x_poll_end_nodata ; No data? Bail out
498499

499500
; Load the buffer address and clear the status
500501
xor eax, eax

0 commit comments

Comments
 (0)