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