2013-06-14 09:40:47 +02:00
|
|
|
/** @file
|
|
|
|
|
|
|
|
Implements
|
|
|
|
- the SNM.WaitForPacket EVT_NOTIFY_WAIT event,
|
|
|
|
- the EVT_SIGNAL_EXIT_BOOT_SERVICES event
|
|
|
|
for the virtio-net driver.
|
|
|
|
|
|
|
|
Copyright (C) 2013, Red Hat, Inc.
|
|
|
|
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
|
|
|
|
|
2019-04-04 01:06:33 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2013-06-14 09:40:47 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
|
|
|
|
#include "VirtioNet.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
Invoke a notification event
|
|
|
|
|
|
|
|
@param Event Event whose notification function is being
|
|
|
|
invoked.
|
|
|
|
@param Context The pointer to the notification function's
|
|
|
|
context, which is implementation-dependent.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
VirtioNetIsPacketAvailable (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This callback has been enqueued by an external application and is
|
|
|
|
// running at TPL_CALLBACK already.
|
|
|
|
//
|
|
|
|
// The WaitForPacket logic is similar to that of WaitForKey. The former has
|
|
|
|
// almost no documentation in either the UEFI-2.3.1+errC spec or the
|
|
|
|
// DWG-2.3.1, but WaitForKey does have some.
|
|
|
|
//
|
|
|
|
VNET_DEV *Dev;
|
|
|
|
UINT16 RxCurUsed;
|
|
|
|
|
|
|
|
Dev = Context;
|
|
|
|
if (Dev->Snm.State != EfiSimpleNetworkInitialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device
|
|
|
|
//
|
|
|
|
MemoryFence ();
|
|
|
|
RxCurUsed = *Dev->RxRing.Used.Idx;
|
2013-08-23 20:46:03 +02:00
|
|
|
MemoryFence ();
|
2013-06-14 09:40:47 +02:00
|
|
|
|
|
|
|
if (Dev->RxLastUsed != RxCurUsed) {
|
2019-09-12 23:27:56 +02:00
|
|
|
gBS->SignalEvent (Dev->Snp.WaitForPacket);
|
2013-06-14 09:40:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
VirtioNetExitBoot (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This callback has been enqueued by ExitBootServices() and is running at
|
|
|
|
// TPL_CALLBACK already.
|
|
|
|
//
|
|
|
|
// Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot
|
|
|
|
// Services Event".
|
|
|
|
//
|
|
|
|
VNET_DEV *Dev;
|
|
|
|
|
2017-09-15 09:56:00 +02:00
|
|
|
DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));
|
2013-06-14 09:40:47 +02:00
|
|
|
Dev = Context;
|
|
|
|
if (Dev->Snm.State == EfiSimpleNetworkInitialized) {
|
2013-12-11 17:58:22 +01:00
|
|
|
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
2013-06-14 09:40:47 +02:00
|
|
|
}
|
|
|
|
}
|