]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioNetDxe/Events.c
OvmfPkg/VirtioNetDxe: list "VirtioNet.h" in the INF file
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / Events.c
CommitLineData
38f52db9
LE
1/** @file\r
2\r
3 Implements\r
4 - the SNM.WaitForPacket EVT_NOTIFY_WAIT event,\r
5 - the EVT_SIGNAL_EXIT_BOOT_SERVICES event\r
6 for the virtio-net driver.\r
7\r
8 Copyright (C) 2013, Red Hat, Inc.\r
9 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
10\r
11 This program and the accompanying materials are licensed and made available\r
12 under the terms and conditions of the BSD License which accompanies this\r
13 distribution. The full text of the license may be found at\r
14 http://opensource.org/licenses/bsd-license.php\r
15\r
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
17 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
18\r
19**/\r
20\r
21#include <Library/BaseLib.h>\r
22#include <Library/UefiBootServicesTableLib.h>\r
23\r
24#include "VirtioNet.h"\r
25\r
26/**\r
27 Invoke a notification event\r
28\r
29 @param Event Event whose notification function is being\r
30 invoked.\r
31 @param Context The pointer to the notification function's\r
32 context, which is implementation-dependent.\r
33\r
34**/\r
35\r
36VOID\r
37EFIAPI\r
38VirtioNetIsPacketAvailable (\r
39 IN EFI_EVENT Event,\r
40 IN VOID *Context\r
41 )\r
42{\r
43 //\r
44 // This callback has been enqueued by an external application and is\r
45 // running at TPL_CALLBACK already.\r
46 //\r
47 // The WaitForPacket logic is similar to that of WaitForKey. The former has\r
48 // almost no documentation in either the UEFI-2.3.1+errC spec or the\r
49 // DWG-2.3.1, but WaitForKey does have some.\r
50 //\r
51 VNET_DEV *Dev;\r
52 UINT16 RxCurUsed;\r
53\r
54 Dev = Context;\r
55 if (Dev->Snm.State != EfiSimpleNetworkInitialized) {\r
56 return;\r
57 }\r
58\r
59 //\r
60 // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device\r
61 //\r
62 MemoryFence ();\r
63 RxCurUsed = *Dev->RxRing.Used.Idx;\r
dc9447bd 64 MemoryFence ();\r
38f52db9
LE
65\r
66 if (Dev->RxLastUsed != RxCurUsed) {\r
67 gBS->SignalEvent (&Dev->Snp.WaitForPacket);\r
68 }\r
69}\r
70\r
71VOID\r
72EFIAPI\r
73VirtioNetExitBoot (\r
74 IN EFI_EVENT Event,\r
75 IN VOID *Context\r
76 )\r
77{\r
78 //\r
79 // This callback has been enqueued by ExitBootServices() and is running at\r
80 // TPL_CALLBACK already.\r
81 //\r
82 // Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot\r
83 // Services Event".\r
84 //\r
85 VNET_DEV *Dev;\r
86\r
d83defe0 87 DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));\r
38f52db9
LE
88 Dev = Context;\r
89 if (Dev->Snm.State == EfiSimpleNetworkInitialized) {\r
56f65ed8 90 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);\r
38f52db9
LE
91 }\r
92}\r