Skip to content

Commit 061ee7d

Browse files
author
Ian Seyler
committed
Working interrupts for virtio-net
1 parent 8bdc835 commit 061ee7d

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src/drivers/bus/xhci.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ xhci_init:
2828
call os_bus_write ; Write updated Status/Command
2929

3030
; Configure MSI-X (if available)
31+
; TODO - Keep track of used vectors and increment as needed
3132
mov al, 0xA0
3233
call msix_init
3334
jnc xhci_init_msix_msi_done

src/drivers/net/virtio-net.asm

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ net_virtio_init:
1717
push rbx
1818
push rax
1919

20-
; push rdx ; Save packed bus address
21-
2220
mov rdi, net_table
2321
xor eax, eax
2422
mov al, [os_net_icount]
@@ -47,27 +45,23 @@ net_virtio_init:
4745
call os_bus_write
4846

4947
; Configure MSI-X (if available)
48+
; TODO - Keep track of used vectors and increment as needed
5049
mov al, 0xB0
5150
call msix_init
5251
jc net_virtio_init_skip_int
5352

5453
; Create gate(s) in the IDT
5554
push rdi
56-
sub rdi, 0x1C
57-
mov ax, 0x0001 ; Set flag for nt_interrupt
58-
stosw
5955
mov edi, 0xB0
6056
mov rax, net_virtio_int
6157
call create_gate
62-
mov edi, 0xB1
63-
mov rax, net_virtio_int
64-
call create_gate
65-
; mov edi, 0xB2
66-
; mov rax, net_virtio_int
67-
; call create_gate
68-
; mov edi, 0xB3
69-
; mov rax, net_virtio_int
70-
; call create_gate
58+
pop rdi
59+
60+
; Set flag for interrupts enabled in net_table
61+
push rdi
62+
sub rdi, 0x1C
63+
mov ax, 0x0001 ; Set flag for nt_interrupt
64+
stosw
7165
pop rdi
7266

7367
net_virtio_init_skip_int:
@@ -269,7 +263,7 @@ virtio_net_init_reset_wait:
269263
; reading and possibly writing the device’s virtio configuration space
270264
; population of virtqueues
271265

272-
mov ax, 0xFFFF
266+
mov ax, 0xFFFF ; Disable config interrupts
273267
mov [rsi+VIRTIO_CONFIG_MSIX_VECTOR], ax
274268

275269
; Set up Queue 0 (Receive)
@@ -293,7 +287,7 @@ virtio_net_init_reset_wait:
293287
rol rax, 32
294288
mov [rsi+VIRTIO_QUEUE_DEVICE+8], eax
295289
rol rax, 32
296-
mov ax, 0x0000
290+
mov ax, 0x0000 ; MSI-X index 0
297291
mov [rsi+VIRTIO_QUEUE_MSIX_VECTOR], ax
298292
mov ax, 1
299293
mov [rsi+VIRTIO_QUEUE_ENABLE], ax
@@ -559,10 +553,6 @@ net_virtio_int:
559553
push rcx
560554
push rax
561555

562-
; Clear pending interrupt (if set)
563-
mov al, 0xab
564-
call os_debug_dump_al
565-
566556
; Acknowledge the interrupt
567557
mov ecx, APIC_EOI
568558
xor eax, eax
@@ -574,7 +564,6 @@ net_virtio_int:
574564
; -----------------------------------------------------------------------------
575565

576566

577-
578567
; Variables
579568
virtio_net_notify_offset: dq 0
580569
virtio_net_notify_offset_multiplier: dq 0

0 commit comments

Comments
 (0)