Skip to content

Commit f1fd9af

Browse files
authored
Merge pull request #114 from ReturnInfinity/dev
Virtio-net updates
2 parents d81ada9 + e6f3417 commit f1fd9af

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/drivers/net/virtio-net.asm

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ virtio_net_init_cap_end:
198198
call net_virtio_reset
199199

200200
; Store call addresses
201-
sub rdi, 0x20
201+
sub rdi, 0x28
202+
mov rax, net_virtio_config
203+
stosq
202204
mov rax, net_virtio_transmit
203205
stosq
204206
mov rax, net_virtio_poll
@@ -238,7 +240,7 @@ net_virtio_reset:
238240
mov rdi, rsi
239241

240242
; 3.1.1 - Step 1 - Reset the device (section 2.4)
241-
mov al, 0x00
243+
mov al, 0x00
242244
mov [rsi+VIRTIO_DEVICE_STATUS], al
243245
virtio_net_init_reset_wait:
244246
mov al, [rsi+VIRTIO_DEVICE_STATUS]
@@ -394,6 +396,16 @@ virtio_net_init_pop:
394396
; -----------------------------------------------------------------------------
395397

396398

399+
; -----------------------------------------------------------------------------
400+
; net_virtio_config -
401+
; IN: RAX = Base address to store packets
402+
; RDX = Interface ID
403+
; OUT: Nothing
404+
net_virtio_config:
405+
ret
406+
; -----------------------------------------------------------------------------
407+
408+
397409
; -----------------------------------------------------------------------------
398410
; net_virtio_transmit - Transmit a packet via a Virtio NIC
399411
; IN: RSI = Location of packet
@@ -459,11 +471,10 @@ net_virtio_transmit_wait:
459471

460472
; -----------------------------------------------------------------------------
461473
; net_virtio_poll - Polls the Virtio NIC for a received packet
462-
; IN: RDI = Location to store packet
463-
; RDX = Interface ID
464-
; OUT: RCX = Length of packet
474+
; IN: RDX = Interface ID
475+
; OUT: RDI = Location of stored packet
476+
; RCX = Length of packet
465477
net_virtio_poll:
466-
push rdi
467478
push rsi
468479
push rax
469480

@@ -511,13 +522,13 @@ net_virtio_poll:
511522
mov ax, 0
512523
stosw ; 16-bit ring
513524

525+
mov rdi, os_PacketBuffers
514526
add word [netrxdescindex], 1
515527
add word [netrxavailindex], 1
516528

517529
net_virtio_poll_nodata:
518530
pop rax
519531
pop rsi
520-
pop rdi
521532
ret
522533
; -----------------------------------------------------------------------------
523534

0 commit comments

Comments
 (0)