]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioNetDxe/Events.c
OvmfPkg: Apply uncrustify changes
[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
b26f0cf9 11 SPDX-License-Identifier: BSD-2-Clause-Patent\r
38f52db9
LE
12\r
13**/\r
14\r
15#include <Library/BaseLib.h>\r
16#include <Library/UefiBootServicesTableLib.h>\r
17\r
18#include "VirtioNet.h"\r
19\r
20/**\r
21 Invoke a notification event\r
22\r
23 @param Event Event whose notification function is being\r
24 invoked.\r
25 @param Context The pointer to the notification function's\r
26 context, which is implementation-dependent.\r
27\r
28**/\r
38f52db9
LE
29VOID\r
30EFIAPI\r
31VirtioNetIsPacketAvailable (\r
ac0a286f
MK
32 IN EFI_EVENT Event,\r
33 IN VOID *Context\r
38f52db9
LE
34 )\r
35{\r
36 //\r
37 // This callback has been enqueued by an external application and is\r
38 // running at TPL_CALLBACK already.\r
39 //\r
40 // The WaitForPacket logic is similar to that of WaitForKey. The former has\r
41 // almost no documentation in either the UEFI-2.3.1+errC spec or the\r
42 // DWG-2.3.1, but WaitForKey does have some.\r
43 //\r
ac0a286f
MK
44 VNET_DEV *Dev;\r
45 UINT16 RxCurUsed;\r
38f52db9
LE
46\r
47 Dev = Context;\r
48 if (Dev->Snm.State != EfiSimpleNetworkInitialized) {\r
49 return;\r
50 }\r
51\r
52 //\r
53 // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device\r
54 //\r
55 MemoryFence ();\r
56 RxCurUsed = *Dev->RxRing.Used.Idx;\r
dc9447bd 57 MemoryFence ();\r
38f52db9
LE
58\r
59 if (Dev->RxLastUsed != RxCurUsed) {\r
19c2a928 60 gBS->SignalEvent (Dev->Snp.WaitForPacket);\r
38f52db9
LE
61 }\r
62}\r
63\r
64VOID\r
65EFIAPI\r
66VirtioNetExitBoot (\r
ac0a286f
MK
67 IN EFI_EVENT Event,\r
68 IN VOID *Context\r
38f52db9
LE
69 )\r
70{\r
71 //\r
72 // This callback has been enqueued by ExitBootServices() and is running at\r
73 // TPL_CALLBACK already.\r
74 //\r
75 // Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot\r
76 // Services Event".\r
77 //\r
ac0a286f 78 VNET_DEV *Dev;\r
38f52db9 79\r
d83defe0 80 DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));\r
38f52db9
LE
81 Dev = Context;\r
82 if (Dev->Snm.State == EfiSimpleNetworkInitialized) {\r
56f65ed8 83 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);\r
38f52db9
LE
84 }\r
85}\r