]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/SnpDxe/Stop.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Stop.c
1 /** @file
2 Implementation of stopping a network interface.
3
4 Copyright (c) 2004 - 2007, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials are licensed
6 and made available under the terms and conditions of the BSD License which
7 accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "Snp.h"
16
17
18 /**
19 this routine calls undi to stop the interface and changes the snp state.
20
21 @param Snp pointer to snp driver structure
22
23 @retval EFI_INVALID_PARAMETER invalid parameter
24 @retval EFI_NOT_STARTED SNP is not started
25 @retval EFI_DEVICE_ERROR SNP is not initialized
26 @retval EFI_UNSUPPORTED operation unsupported
27
28 **/
29 EFI_STATUS
30 PxeStop (
31 SNP_DRIVER *Snp
32 )
33 {
34 Snp->Cdb.OpCode = PXE_OPCODE_STOP;
35 Snp->Cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
36 Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
37 Snp->Cdb.DBsize = PXE_DBSIZE_NOT_USED;
38 Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
39 Snp->Cdb.DBaddr = PXE_DBADDR_NOT_USED;
40 Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;
41 Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
42 Snp->Cdb.IFnum = Snp->IfNum;
43 Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
44
45 //
46 // Issue UNDI command
47 //
48 DEBUG ((EFI_D_NET, "\nsnp->undi.stop() "));
49
50 (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);
51
52 if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {
53 DEBUG (
54 (EFI_D_WARN,
55 "\nsnp->undi.stop() %xh:%xh\n",
56 Snp->Cdb.StatCode,
57 Snp->Cdb.StatFlags)
58 );
59
60 return EFI_DEVICE_ERROR;
61 }
62 //
63 // Set simple network state to Started and return success.
64 //
65 Snp->Mode.State = EfiSimpleNetworkStopped;
66 return EFI_SUCCESS;
67 }
68
69
70 /**
71 Changes the state of a network interface from "started" to "stopped."
72
73 This function stops a network interface. This call is only valid if the network
74 interface is in the started state. If the network interface was successfully
75 stopped, then EFI_SUCCESS will be returned.
76
77 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
78
79
80 @retval EFI_SUCCESS The network interface was stopped.
81 @retval EFI_NOT_STARTED The network interface has not been started.
82 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid
83 EFI_SIMPLE_NETWORK_PROTOCOL structure.
84 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
85 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
86
87 **/
88 EFI_STATUS
89 EFIAPI
90 SnpUndi32Stop (
91 IN EFI_SIMPLE_NETWORK_PROTOCOL *This
92 )
93 {
94 SNP_DRIVER *Snp;
95 EFI_TPL OldTpl;
96 EFI_STATUS Status;
97
98 if (This == NULL) {
99 return EFI_INVALID_PARAMETER;
100 }
101
102 Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);
103
104 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
105
106 switch (Snp->Mode.State) {
107 case EfiSimpleNetworkStarted:
108 break;
109
110 case EfiSimpleNetworkStopped:
111 Status = EFI_NOT_STARTED;
112 goto ON_EXIT;
113
114 default:
115 Status = EFI_DEVICE_ERROR;
116 goto ON_EXIT;
117 }
118
119 Status = PxeStop (Snp);
120
121 ON_EXIT:
122 gBS->RestoreTPL (OldTpl);
123
124 return Status;
125 }