@@ -58,6 +58,19 @@ net_i8254x_init:
5858 shr eax , 8
5959 stosb
6060
61+ ; Set base addresses for TX and RX descriptors
62+ xor ecx , ecx
63+ mov cl , byte [ os_net_icount ]
64+ shl ecx , 15
65+
66+ add rdi , 0x22
67+ mov rax , os_tx_desc
68+ add rax , rcx
69+ stosq
70+ mov rax , os_rx_desc
71+ add rax , rcx
72+ stosq
73+
6174 ; Reset the device
6275 xor edx , edx
6376 mov dl , [ os_net_icount ]
@@ -141,8 +154,11 @@ net_i8254x_reset:
141154 ; Create RX descriptors
142155 push rdi
143156 mov ecx , i8254x_MAX_DESC
144- ; TODO - Adjust value based on iid
157+ xor eax , eax
158+ mov al , byte [ os_net_icount ]
159+ shl eax , 15
145160 mov rdi , os_rx_desc
161+ add rdi , rax
146162net_i8254x_reset_nextdesc:
147163 mov rax , os_PacketBuffers ; Default packet will go here
148164 stosq
@@ -153,8 +169,10 @@ net_i8254x_reset_nextdesc:
153169 pop rdi
154170
155171 ; Initialize receive
156- ; TODO - Adjust value based on iid
157- mov rax , os_rx_desc
172+ xor eax , eax
173+ mov al , byte [ os_net_icount ]
174+ shl eax , 15
175+ add rax , os_rx_desc
158176 mov [ rsi + i8254x_RDBAL ], eax ; Receive Descriptor Base Address Low
159177 shr rax , 32
160178 mov [ rsi + i8254x_RDBAH ], eax ; Receive Descriptor Base Address High
@@ -168,8 +186,10 @@ net_i8254x_reset_nextdesc:
168186 mov [ rsi + i8254x_RCTL ], eax ; Receive Control Register
169187
170188 ; Initialize transmit
171- ; TODO - Adjust value based on iid
172- mov rax , os_tx_desc
189+ xor eax , eax
190+ mov al , byte [ os_net_icount ]
191+ shl eax , 15
192+ add rax , os_tx_desc
173193 mov [ rsi + i8254x_TDBAL ], eax ; Transmit Descriptor Base Address Low
174194 shr rax , 32
175195 mov [ rsi + i8254x_TDBAH ], eax ; Transmit Descriptor Base Address High
@@ -217,7 +237,7 @@ net_i8254x_transmit:
217237 push rdi
218238 push rax
219239
220- mov rdi , os_tx_desc ; Transmit Descriptor Base Address
240+ mov rdi , [ rdx + nt_tx_desc ] ; Transmit Descriptor Base Address
221241
222242 ; Calculate the descriptor to write to
223243 mov eax , [ rdx + nt_tx_head ] ; Get tx_lasttail
@@ -267,7 +287,7 @@ net_i8254x_poll:
267287 push rsi ; Used for the base MMIO of the NIC
268288 push rax
269289
270- mov rdi , os_rx_desc
290+ mov rdi , [ rdx + nt_rx_desc ]
271291 mov rsi , [ rdx + nt_base ] ; Load the base MMIO of the NIC
272292
273293 ; Calculate the descriptor to read from
0 commit comments