4 - the SNM.WaitForPacket EVT_NOTIFY_WAIT event,
5 - the EVT_SIGNAL_EXIT_BOOT_SERVICES event
6 for the virtio-net driver.
8 Copyright (C) 2013, Red Hat, Inc.
9 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
11 SPDX-License-Identifier: BSD-2-Clause-Patent
15 #include <Library/BaseLib.h>
16 #include <Library/UefiBootServicesTableLib.h>
18 #include "VirtioNet.h"
21 Invoke a notification event
23 @param Event Event whose notification function is being
25 @param Context The pointer to the notification function's
26 context, which is implementation-dependent.
32 VirtioNetIsPacketAvailable (
38 // This callback has been enqueued by an external application and is
39 // running at TPL_CALLBACK already.
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.
49 if (Dev
->Snm
.State
!= EfiSimpleNetworkInitialized
) {
54 // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device
57 RxCurUsed
= *Dev
->RxRing
.Used
.Idx
;
60 if (Dev
->RxLastUsed
!= RxCurUsed
) {
61 gBS
->SignalEvent (&Dev
->Snp
.WaitForPacket
);
73 // This callback has been enqueued by ExitBootServices() and is running at
74 // TPL_CALLBACK already.
76 // Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot
81 DEBUG ((DEBUG_VERBOSE
, "%a: Context=0x%p\n", __FUNCTION__
, Context
));
83 if (Dev
->Snm
.State
== EfiSimpleNetworkInitialized
) {
84 Dev
->VirtIo
->SetDeviceStatus (Dev
->VirtIo
, 0);