Skip to content

Commit 8910c7a

Browse files
authored
Merge pull request #1283 from fwsGonzo/dev
virtionet: Add back legacy IRQ support
2 parents cfc0070 + 130eb1a commit 8910c7a

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

src/arch/x86/start.asm

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extern kernel_start
2020
global _start
2121
global __xsave_enabled
2222
global __avx_enabled
23+
global __ecx_was
2324

2425
%define MB_MAGIC 0x1BADB002
2526
%define MB_FLAGS 0x3 ;; ALIGN + MEMINFO
@@ -77,8 +78,10 @@ rock_bottom:
7778

7879
;; enable SSE before we enter C/C++ land
7980
call enable_sse
81+
;; try to enable XSAVE before checking AVX
82+
call enable_xsave
8083
;; enable AVX if xsave and avx supported on CPU
81-
;call enable_avx
84+
call enable_avx
8285

8386
;; Place multiboot parameters on stack
8487
push ebx
@@ -99,11 +102,24 @@ enable_sse:
99102
ret
100103

101104
enable_xsave:
105+
push eax
106+
push ebx
107+
; check for XSAVE support
108+
mov eax, 1
109+
xor ecx, ecx
110+
cpuid
111+
; bit 26 ecx
112+
and ecx, 0x04000000
113+
cmp ecx, 0x04000000
114+
jne xsave_not_supported
102115
; enable XSAVE
103116
mov eax, cr4
104117
or eax, 0x40000
105118
mov cr4, eax
106119
mov WORD [__xsave_enabled], 0x1
120+
xsave_not_supported:
121+
pop ebx
122+
pop eax
107123
ret
108124

109125
enable_avx:
@@ -117,8 +133,6 @@ enable_avx:
117133
and ecx, 0x18000000
118134
cmp ecx, 0x18000000
119135
jne avx_not_supported
120-
;; enable XSAVE
121-
call enable_xsave
122136
;; enable AVX support
123137
xor ecx, ecx
124138
xgetbv

src/drivers/virtionet.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ VirtioNet::VirtioNet(hw::PCI_Device& d)
156156
}
157157
else
158158
{
159-
assert(0 && "Legacy IRQs not supported");
159+
auto irq = Virtio::get_legacy_irq();
160+
IRQ_manager::get().subscribe(irq, {this, &VirtioNet::legacy_handler});
160161
}
161162

162163
#ifndef NO_DEFERRED_KICK
@@ -243,6 +244,12 @@ void VirtioNet::msix_xmit_handler()
243244
}
244245
}
245246

247+
void VirtioNet::legacy_handler()
248+
{
249+
msix_recv_handler();
250+
msix_xmit_handler();
251+
}
252+
246253
void VirtioNet::add_receive_buffer(uint8_t* pkt)
247254
{
248255
// offset pointer to virtionet header

src/drivers/virtionet.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ class VirtioNet : Virtio, public net::Link_layer<net::Ethernet> {
220220
void msix_xmit_handler();
221221
void msix_conf_handler();
222222

223+
void legacy_handler();
224+
223225
/** Allocate and queue buffer from bufstore_ in RX queue. */
224226
void add_receive_buffer(uint8_t*);
225227

0 commit comments

Comments
 (0)