]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: VirtioNetDxe: SNP.Shutdown
authorLaszlo Ersek <lersek@redhat.com>
Fri, 14 Jun 2013 07:40:11 +0000 (07:40 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 14 Jun 2013 07:40:11 +0000 (07:40 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14411 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/VirtioNetDxe/SnpShutdown.c [new file with mode: 0644]

diff --git a/OvmfPkg/VirtioNetDxe/SnpShutdown.c b/OvmfPkg/VirtioNetDxe/SnpShutdown.c
new file mode 100644 (file)
index 0000000..42aeca1
--- /dev/null
@@ -0,0 +1,78 @@
+/** @file\r
+\r
+  Implementation of the SNP.Shutdown() function and its private helpers if any.\r
+\r
+  Copyright (C) 2013, Red Hat, Inc.\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution. The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+#include "VirtioNet.h"\r
+\r
+/**\r
+  Resets a network adapter and leaves it in a state that is safe for  another\r
+  driver to initialize.\r
+\r
+  @param  This Protocol instance pointer.\r
+\r
+  @retval EFI_SUCCESS           The network interface was shutdown.\r
+  @retval EFI_NOT_STARTED       The network interface has not been started.\r
+  @retval EFI_INVALID_PARAMETER One or more of the parameters has an\r
+                                unsupported value.\r
+  @retval EFI_DEVICE_ERROR      The command could not be sent to the network\r
+                                interface.\r
+  @retval EFI_UNSUPPORTED       This function is not supported by the network\r
+                                interface.\r
+\r
+**/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+VirtioNetShutdown (\r
+  IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
+  )\r
+{\r
+  VNET_DEV   *Dev;\r
+  EFI_TPL    OldTpl;\r
+  EFI_STATUS Status;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Dev = VIRTIO_NET_FROM_SNP (This);\r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+  switch (Dev->Snm.State) {\r
+  case EfiSimpleNetworkStopped:\r
+    Status = EFI_NOT_STARTED;\r
+    goto Exit;\r
+  case EfiSimpleNetworkStarted:\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto Exit;\r
+  default:\r
+    break;\r
+  }\r
+\r
+  VIRTIO_CFG_WRITE (Dev, Generic.VhdrDeviceStatus, 0);\r
+  VirtioNetShutdownRx (Dev);\r
+  VirtioNetShutdownTx (Dev);\r
+  VirtioRingUninit (&Dev->TxRing);\r
+  VirtioRingUninit (&Dev->RxRing);\r
+\r
+  Dev->Snm.State = EfiSimpleNetworkStarted;\r
+  Status = EFI_SUCCESS;\r
+\r
+Exit:\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r