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.
31 VirtioNetIsPacketAvailable (
37 // This callback has been enqueued by an external application and is
38 // running at TPL_CALLBACK already.
40 // The WaitForPacket logic is similar to that of WaitForKey. The former has
41 // almost no documentation in either the UEFI-2.3.1+errC spec or the
42 // DWG-2.3.1, but WaitForKey does have some.
48 if (Dev
->Snm
.State
!= EfiSimpleNetworkInitialized
) {
53 // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device
56 RxCurUsed
= *Dev
->RxRing
.Used
.Idx
;
59 if (Dev
->RxLastUsed
!= RxCurUsed
) {
60 gBS
->SignalEvent (Dev
->Snp
.WaitForPacket
);
72 // This callback has been enqueued by ExitBootServices() and is running at
73 // TPL_CALLBACK already.
75 // Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot
80 DEBUG ((DEBUG_VERBOSE
, "%a: Context=0x%p\n", __FUNCTION__
, Context
));
82 if (Dev
->Snm
.State
== EfiSimpleNetworkInitialized
) {
83 Dev
->VirtIo
->SetDeviceStatus (Dev
->VirtIo
, 0);