]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/VirtioNetDxe/SnpStart.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / SnpStart.c
1 /** @file
2
3 Implementation of the SNP.Start() function and its private helpers if any.
4
5 Copyright (C) 2013, Red Hat, Inc.
6 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12 #include <Library/UefiBootServicesTableLib.h>
13
14 #include "VirtioNet.h"
15
16 /**
17 Changes the state of a network interface from "stopped" to "started".
18
19 @param This Protocol instance pointer.
20
21 @retval EFI_SUCCESS The network interface was started.
22 @retval EFI_ALREADY_STARTED The network interface is already in the started
23 state.
24 @retval EFI_INVALID_PARAMETER One or more of the parameters has an
25 unsupported value.
26 @retval EFI_DEVICE_ERROR The command could not be sent to the network
27 interface.
28 @retval EFI_UNSUPPORTED This function is not supported by the network
29 interface.
30 **/
31 EFI_STATUS
32 EFIAPI
33 VirtioNetStart (
34 IN EFI_SIMPLE_NETWORK_PROTOCOL *This
35 )
36 {
37 VNET_DEV *Dev;
38 EFI_TPL OldTpl;
39 EFI_STATUS Status;
40
41 if (This == NULL) {
42 return EFI_INVALID_PARAMETER;
43 }
44
45 Dev = VIRTIO_NET_FROM_SNP (This);
46 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
47 if (Dev->Snm.State != EfiSimpleNetworkStopped) {
48 Status = EFI_ALREADY_STARTED;
49 } else {
50 Dev->Snm.State = EfiSimpleNetworkStarted;
51 Status = EFI_SUCCESS;
52 }
53
54 gBS->RestoreTPL (OldTpl);
55 return Status;
56 }