Skip to content

Commit c199aed

Browse files
author
Ian Seyler
committed
save rdx in msix_init
1 parent 25e17f1 commit c199aed

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

src/drivers/msi.asm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
; 00000801 <- Pending Bit BIR (2:0) is 0x1 so BAR1 and Pending Bit Offset (31:3) is 0x800
2626
msix_init:
2727
push r8
28+
push rdi
2829
push rdx
2930
push rcx
3031
push rbx
@@ -55,13 +56,21 @@ msix_init_enable:
5556
mov ebx, eax ; EBX for the Table Offset
5657
and ebx, 0xFFFFFFF8 ; Clear bits 2:0
5758
and eax, 0x00000007 ; Keep bits 2:0 for the BIR
59+
5860
add al, 0x04 ; Add offset to start of BARs
5961
mov dl, al
6062
call os_bus_read ; Read the BAR address
63+
64+
; TODO - Read BAR properly
65+
; push rcx ; Save RCX as os_bus_read_bar returns a value in it
66+
; call os_bus_read_bar ; Read the BAR address
67+
; pop rcx
68+
6169
add rax, rbx ; Add offset to base
62-
sub rax, 0x04
70+
and eax, 0xFFFFFFF8 ; Clear bits 2:0 of a 32-bit BAR
6371
mov rdi, rax
6472
pop rdx
73+
6574
; Configure MSI-X Table
6675
add cx, 1 ; Table Size is 0-indexed
6776
mov ebx, 0x00004000 ; Trigger Mode (15), Level (14), Delivery Mode (10:8), Vector (7:0)
@@ -90,6 +99,7 @@ msix_init_create_entry:
9099
pop rbx
91100
pop rcx
92101
pop rdx
102+
pop rdi
93103
pop r8
94104
clc ; Clear the carry flag
95105
ret
@@ -99,6 +109,7 @@ msix_init_error:
99109
pop rbx
100110
pop rcx
101111
pop rdx
112+
pop rdi
102113
pop r8
103114
stc ; Set the carry flag
104115
ret

src/drivers/net/virtio-net.asm

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,25 @@ virtio_net_init_cap_end:
150150

151151
; Enable interrupts
152152
pop rdx ; Restore packed bus address
153-
; mov al, 0x40
154-
; call msix_init
155-
; jc virtio_net_init_no_int
156-
; Create a gate in the IDT
157-
; mov edi, 0x40
158-
; mov rax, net_virtio_int
159-
; call create_gate
160-
; mov edi, 0x41
161-
; mov rax, net_virtio_int
162-
; call create_gate
163-
; mov edi, 0x42
153+
mov al, 0xB0
154+
call msix_init
155+
jc virtio_net_init_no_int
156+
157+
; Create gate(s) in the IDT
158+
push rdi
159+
mov edi, 0xB0
160+
mov rax, net_virtio_int
161+
call create_gate
162+
mov edi, 0xB1
163+
mov rax, net_virtio_int
164+
call create_gate
165+
; mov edi, 0xB2
164166
; mov rax, net_virtio_int
165167
; call create_gate
166-
; mov edi, 0x43
168+
; mov edi, 0xB3
167169
; mov rax, net_virtio_int
168170
; call create_gate
171+
pop rdi
169172

170173
virtio_net_init_no_int:
171174

@@ -553,7 +556,7 @@ align 8
553556
net_virtio_int:
554557
push rcx
555558
push rax
556-
559+
jmp $
557560
; Clear pending interrupt (if set)
558561
mov al, 0xab
559562
call os_debug_dump_al

0 commit comments

Comments
 (0)