Skip to content

Commit e0f4473

Browse files
author
Ian Seyler
committed
Use aliases in net_table
1 parent da41ce0 commit e0f4473

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

src/drivers/net/i8254x.asm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ net_i8254x_transmit:
220220
mov rdi, os_tx_desc ; Transmit Descriptor Base Address
221221

222222
; Calculate the descriptor to write to
223-
mov eax, [rdx+0x30] ; Get tx_lasttail
223+
mov eax, [rdx+nt_tx_head] ; Get tx_lasttail
224224
push rax ; Save lasttail
225225
shl eax, 4 ; Quick multiply by 16
226226
add rdi, rax ; Add offset to RDI
@@ -238,8 +238,8 @@ net_i8254x_transmit:
238238
pop rax ; Restore lasttail
239239
add eax, 1
240240
and eax, i8254x_MAX_DESC - 1
241-
mov [rdx+0x30], eax ; Set tx_lasttail
242-
mov rdi, [rdx+0x10] ; Load the base MMIO of the NIC
241+
mov [rdx+nt_tx_head], eax ; Set tx_lasttail
242+
mov rdi, [rdx+nt_base] ; Load the base MMIO of the NIC
243243
mov [rdi+i8254x_TDT], eax ; TDL - Transmit Descriptor Tail
244244

245245
pop rax
@@ -268,10 +268,10 @@ net_i8254x_poll:
268268
push rax
269269

270270
mov rdi, os_rx_desc
271-
mov rsi, [rdx+0x10] ; Load the base MMIO of the NIC
271+
mov rsi, [rdx+nt_base] ; Load the base MMIO of the NIC
272272

273273
; Calculate the descriptor to read from
274-
mov eax, [rdx+0x34] ; Get rx_lasthead
274+
mov eax, [rdx+nt_rx_head] ; Get rx_lasthead
275275
shl eax, 4 ; Quick multiply by 16
276276
add eax, 8 ; Offset to bytes received
277277
add rdi, rax ; Add offset to RDI
@@ -285,10 +285,10 @@ net_i8254x_poll:
285285
stosq ; Clear the descriptor length and status
286286

287287
; Increment i8254x_rx_lasthead and the Receive Descriptor Tail
288-
mov eax, [rdx+0x34] ; Get rx_lasthead
288+
mov eax, [rdx+nt_rx_head] ; Get rx_lasthead
289289
add eax, 1
290290
and eax, i8254x_MAX_DESC - 1
291-
mov [rdx+0x34], eax ; Set rx_lasthead
291+
mov [rdx+nt_rx_head], eax ; Set rx_lasthead
292292

293293
mov eax, [rsi+i8254x_RDT] ; Read the current Receive Descriptor Tail
294294
add eax, 1 ; Add 1 to the Receive Descriptor Tail

src/sysvar.asm

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -168,28 +168,19 @@ os_net_entry_rx_tail: equ os_SystemVariables + 0x202C
168168
bus_table: equ os_SystemVariables + 0x8000
169169
net_table: equ os_SystemVariables + 0xA000
170170

171-
; net_table layout - each entry is 128 bytes
172-
; 0x00
173-
; 16-bit driver ID
174-
; 6 bytes of padding
175-
; 48-bit MAC address
176-
; 2 bytes of padding
177-
; 0x10
178-
; 64-bit device base
179-
; 64-bit device length
180-
; 0x20
181-
; 64-bit transmit
182-
; 64-bit poll
183-
; 0x30
184-
; 32-bit tx_last_head
185-
; 32-bit rx_last_head
186-
; 8 bytes of padding
187-
; 0x40
188-
; 64-bit TXPackets
189-
; 64-bit TXBytes
190-
; 0x50
191-
; 64-bit RXPackets
192-
; 64-bit RXBytes
171+
; net_table values (per device - 128 bytes)
172+
nt_ID: equ 0x00 ; 16-bit
173+
nt_MAC: equ 0x08 ; 48-bit
174+
nt_base: equ 0x10 ; 64-bit
175+
nt_len: equ 0x18 ; 64-bit
176+
nt_transmit: equ 0x20 ; 64-bit
177+
nt_poll: equ 0x28 ; 64-bit
178+
nt_tx_head: equ 0x30 ; 64-bit
179+
nt_rx_head: equ 0x34 ; 64-bit
180+
nt_tx_packets: equ 0x40 ; 64-bit
181+
nt_tx_bytes: equ 0x48 ; 64-bit
182+
nt_rx_packets: equ 0x50 ; 64-bit
183+
nt_rx_bytes: equ 0x58 ; 64-bit
193184

194185

195186
; Misc

0 commit comments

Comments
 (0)