TianoCore EDK2 master
Loading...
Searching...
No Matches
Events.c
Go to the documentation of this file.
1
15#include <Library/BaseLib.h>
17
18#include "VirtioNet.h"
19
29VOID
30EFIAPI
32 IN EFI_EVENT Event,
33 IN VOID *Context
34 )
35{
36 //
37 // This callback has been enqueued by an external application and is
38 // running at TPL_CALLBACK already.
39 //
40 // The WaitForPacket logic is similar to that of WaitForKey. The former has
41 // almost no documentation in either the UEFI-2.3.1+errC spec or the
42 // DWG-2.3.1, but WaitForKey does have some.
43 //
44 VNET_DEV *Dev;
45 UINT16 RxCurUsed;
46
47 Dev = Context;
48 if (Dev->Snm.State != EfiSimpleNetworkInitialized) {
49 return;
50 }
51
52 //
53 // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device
54 //
55 MemoryFence ();
56 RxCurUsed = *Dev->RxRing.Used.Idx;
57 MemoryFence ();
58
59 if (Dev->RxLastUsed != RxCurUsed) {
60 gBS->SignalEvent (Dev->Snp.WaitForPacket);
61 }
62}
63
64VOID
65EFIAPI
66VirtioNetExitBoot (
67 IN EFI_EVENT Event,
68 IN VOID *Context
69 )
70{
71 //
72 // This callback has been enqueued by ExitBootServices() and is running at
73 // TPL_CALLBACK already.
74 //
75 // Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot
76 // Services Event".
77 //
78 VNET_DEV *Dev;
79
80 DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __func__, Context));
81 Dev = Context;
82 if (Dev->Snm.State == EfiSimpleNetworkInitialized) {
83 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
84 }
85}
VOID EFIAPI MemoryFence(VOID)
Definition: CpuBreakpoint.c:42
VOID EFIAPI VirtioNetIsPacketAvailable(IN EFI_EVENT Event, IN VOID *Context)
Definition: Events.c:31
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
EFI_BOOT_SERVICES * gBS