]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioNetDxe/SnpStop.c
ShellPkg/for: Fix potential null pointer deference
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / SnpStop.c
CommitLineData
395e912e
LE
1/** @file\r
2\r
3 Implementation of the SNP.Stop() function and its private helpers if any.\r
4\r
5 Copyright (C) 2013, Red Hat, Inc.\r
6 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
7\r
8 This program and the accompanying materials are licensed and made available\r
9 under the terms and conditions of the BSD License which accompanies this\r
10 distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#include <Library/UefiBootServicesTableLib.h>\r
19\r
20#include "VirtioNet.h"\r
21\r
22/**\r
23 Changes the state of a network interface from "started" to "stopped".\r
24\r
25 @param This Protocol instance pointer.\r
26\r
27 @retval EFI_SUCCESS The network interface was stopped.\r
28 @retval EFI_ALREADY_STARTED The network interface is already in the stopped\r
29 state.\r
30 @retval EFI_INVALID_PARAMETER One or more of the parameters has an\r
31 unsupported value.\r
32 @retval EFI_DEVICE_ERROR The command could not be sent to the network\r
33 interface.\r
34 @retval EFI_UNSUPPORTED This function is not supported by the network\r
35 interface.\r
36\r
37**/\r
38\r
39EFI_STATUS\r
40EFIAPI\r
41VirtioNetStop (\r
42 IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
43 )\r
44{\r
45 VNET_DEV *Dev;\r
46 EFI_TPL OldTpl;\r
47 EFI_STATUS Status;\r
48\r
49 if (This == NULL) {\r
50 return EFI_INVALID_PARAMETER;\r
51 }\r
52\r
53 Dev = VIRTIO_NET_FROM_SNP (This);\r
54 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
55 if (Dev->Snm.State != EfiSimpleNetworkStarted) {\r
56 Status = EFI_NOT_STARTED;\r
57 }\r
58 else {\r
59 Dev->Snm.State = EfiSimpleNetworkStopped;\r
60 Status = EFI_SUCCESS;\r
61 }\r
62\r
63 gBS->RestoreTPL (OldTpl);\r
64 return Status;\r
65}\r