]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/VirtioNetDxe/Events.c
ArmPkg/ArmSoftFloatLib: remove source files that are no longer used
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / Events.c
1 /** @file
2
3 Implements
4 - the SNM.WaitForPacket EVT_NOTIFY_WAIT event,
5 - the EVT_SIGNAL_EXIT_BOOT_SERVICES event
6 for the virtio-net driver.
7
8 Copyright (C) 2013, Red Hat, Inc.
9 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
10
11 SPDX-License-Identifier: BSD-2-Clause-Patent
12
13 **/
14
15 #include <Library/BaseLib.h>
16 #include <Library/UefiBootServicesTableLib.h>
17
18 #include "VirtioNet.h"
19
20 /**
21 Invoke a notification event
22
23 @param Event Event whose notification function is being
24 invoked.
25 @param Context The pointer to the notification function's
26 context, which is implementation-dependent.
27
28 **/
29
30 VOID
31 EFIAPI
32 VirtioNetIsPacketAvailable (
33 IN EFI_EVENT Event,
34 IN VOID *Context
35 )
36 {
37 //
38 // This callback has been enqueued by an external application and is
39 // running at TPL_CALLBACK already.
40 //
41 // The WaitForPacket logic is similar to that of WaitForKey. The former has
42 // almost no documentation in either the UEFI-2.3.1+errC spec or the
43 // DWG-2.3.1, but WaitForKey does have some.
44 //
45 VNET_DEV *Dev;
46 UINT16 RxCurUsed;
47
48 Dev = Context;
49 if (Dev->Snm.State != EfiSimpleNetworkInitialized) {
50 return;
51 }
52
53 //
54 // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device
55 //
56 MemoryFence ();
57 RxCurUsed = *Dev->RxRing.Used.Idx;
58 MemoryFence ();
59
60 if (Dev->RxLastUsed != RxCurUsed) {
61 gBS->SignalEvent (&Dev->Snp.WaitForPacket);
62 }
63 }
64
65 VOID
66 EFIAPI
67 VirtioNetExitBoot (
68 IN EFI_EVENT Event,
69 IN VOID *Context
70 )
71 {
72 //
73 // This callback has been enqueued by ExitBootServices() and is running at
74 // TPL_CALLBACK already.
75 //
76 // Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot
77 // Services Event".
78 //
79 VNET_DEV *Dev;
80
81 DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));
82 Dev = Context;
83 if (Dev->Snm.State == EfiSimpleNetworkInitialized) {
84 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
85 }
86 }