]>
Commit | Line | Data |
---|---|---|
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 | |
29 | \r | |
30 | VOID\r | |
31 | EFIAPI\r | |
32 | VirtioNetIsPacketAvailable (\r | |
33 | IN EFI_EVENT Event,\r | |
34 | IN VOID *Context\r | |
35 | )\r | |
36 | {\r | |
37 | //\r | |
38 | // This callback has been enqueued by an external application and is\r | |
39 | // running at TPL_CALLBACK already.\r | |
40 | //\r | |
41 | // The WaitForPacket logic is similar to that of WaitForKey. The former has\r | |
42 | // almost no documentation in either the UEFI-2.3.1+errC spec or the\r | |
43 | // DWG-2.3.1, but WaitForKey does have some.\r | |
44 | //\r | |
45 | VNET_DEV *Dev;\r | |
46 | UINT16 RxCurUsed;\r | |
47 | \r | |
48 | Dev = Context;\r | |
49 | if (Dev->Snm.State != EfiSimpleNetworkInitialized) {\r | |
50 | return;\r | |
51 | }\r | |
52 | \r | |
53 | //\r | |
54 | // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device\r | |
55 | //\r | |
56 | MemoryFence ();\r | |
57 | RxCurUsed = *Dev->RxRing.Used.Idx;\r | |
dc9447bd | 58 | MemoryFence ();\r |
38f52db9 LE |
59 | \r |
60 | if (Dev->RxLastUsed != RxCurUsed) {\r | |
61 | gBS->SignalEvent (&Dev->Snp.WaitForPacket);\r | |
62 | }\r | |
63 | }\r | |
64 | \r | |
65 | VOID\r | |
66 | EFIAPI\r | |
67 | VirtioNetExitBoot (\r | |
68 | IN EFI_EVENT Event,\r | |
69 | IN VOID *Context\r | |
70 | )\r | |
71 | {\r | |
72 | //\r | |
73 | // This callback has been enqueued by ExitBootServices() and is running at\r | |
74 | // TPL_CALLBACK already.\r | |
75 | //\r | |
76 | // Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot\r | |
77 | // Services Event".\r | |
78 | //\r | |
79 | VNET_DEV *Dev;\r | |
80 | \r | |
d83defe0 | 81 | DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));\r |
38f52db9 LE |
82 | Dev = Context;\r |
83 | if (Dev->Snm.State == EfiSimpleNetworkInitialized) {\r | |
56f65ed8 | 84 | Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);\r |
38f52db9 LE |
85 | }\r |
86 | }\r |