[edk2] [PATCH 14/15] OvmfPkg: VirtioNetDxe: WaitForPacket and EXIT_BOOT_SERVICES event callbacks

Subject: [edk2] [PATCH 14/15] OvmfPkg: VirtioNetDxe: WaitForPacket and EXIT_BOOT_SERVICES event callbacks

From: Laszlo Ersek <lersek@redhat.com>

To: edk2-devel@lists.sourceforge.net

Date: 2013-05-03 16:09:42

  • 2013-05-03 16:09:42  Laszlo Ersek   [edk2] [PATCH 14/15] OvmfPkg: VirtioNetDxe: WaitForPacket and EXIT_BOOT_SERVICES event callbacks
Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek 
---
 OvmfPkg/VirtioNetDxe/Events.c |   92 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 92 insertions(+), 0 deletions(-)
 create mode 100644 OvmfPkg/VirtioNetDxe/Events.c

diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c
new file mode 100644
index 0000000..bd30c91
--- /dev/null
+++ b/OvmfPkg/VirtioNetDxe/Events.c
@@ -0,0 +1,92 @@
+/** @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.
+
+  UEFI API documentation:
+  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include + +#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; + + if (Dev->RxLastUsed != RxCurUsed) { + gBS->SignalEvent (&Dev->Snp.WaitForPacket); + } +} + +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; + + Dev = Context; + if (Dev->Snm.State == EfiSimpleNetworkInitialized) { + VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0); + } +} -- 1.7.1 ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite It's a free troubleshooting tool designed for production Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://p.sf.net/sfu/appdyn_d2d_ap2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel