Skip to content

Commit

Permalink
Merge pull request #1283 from fwsGonzo/dev
Browse files Browse the repository at this point in the history
virtionet: Add back legacy IRQ support
  • Loading branch information
fwsGonzo authored Mar 31, 2017
2 parents cfc0070 + 130eb1a commit 8910c7a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/arch/x86/start.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern kernel_start
global _start
global __xsave_enabled
global __avx_enabled
global __ecx_was

%define MB_MAGIC 0x1BADB002
%define MB_FLAGS 0x3 ;; ALIGN + MEMINFO
Expand Down Expand Up @@ -77,8 +78,10 @@ rock_bottom:

;; enable SSE before we enter C/C++ land
call enable_sse
;; try to enable XSAVE before checking AVX
call enable_xsave
;; enable AVX if xsave and avx supported on CPU
;call enable_avx
call enable_avx

;; Place multiboot parameters on stack
push ebx
Expand All @@ -99,11 +102,24 @@ enable_sse:
ret

enable_xsave:
push eax
push ebx
; check for XSAVE support
mov eax, 1
xor ecx, ecx
cpuid
; bit 26 ecx
and ecx, 0x04000000
cmp ecx, 0x04000000
jne xsave_not_supported
; enable XSAVE
mov eax, cr4
or eax, 0x40000
mov cr4, eax
mov WORD [__xsave_enabled], 0x1
xsave_not_supported:
pop ebx
pop eax
ret

enable_avx:
Expand All @@ -117,8 +133,6 @@ enable_avx:
and ecx, 0x18000000
cmp ecx, 0x18000000
jne avx_not_supported
;; enable XSAVE
call enable_xsave
;; enable AVX support
xor ecx, ecx
xgetbv
Expand Down
9 changes: 8 additions & 1 deletion src/drivers/virtionet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ VirtioNet::VirtioNet(hw::PCI_Device& d)
}
else
{
assert(0 && "Legacy IRQs not supported");
auto irq = Virtio::get_legacy_irq();
IRQ_manager::get().subscribe(irq, {this, &VirtioNet::legacy_handler});
}

#ifndef NO_DEFERRED_KICK
Expand Down Expand Up @@ -243,6 +244,12 @@ void VirtioNet::msix_xmit_handler()
}
}

void VirtioNet::legacy_handler()
{
msix_recv_handler();
msix_xmit_handler();
}

void VirtioNet::add_receive_buffer(uint8_t* pkt)
{
// offset pointer to virtionet header
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/virtionet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ class VirtioNet : Virtio, public net::Link_layer<net::Ethernet> {
void msix_xmit_handler();
void msix_conf_handler();

void legacy_handler();

/** Allocate and queue buffer from bufstore_ in RX queue. */
void add_receive_buffer(uint8_t*);

Expand Down

0 comments on commit 8910c7a

Please sign in to comment.