]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Network/SnpDxe/Shutdown.c
Remove some useless EDK_RELEASE_VERSION, EFI_SPECIFICATION_VERSION ,and review VALID_...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Shutdown.c
... / ...
CommitLineData
1/** @file\r
2 Implementation of shuting down a network adapter.\r
3 \r
4Copyright (c) 2004 - 2007, Intel Corporation. <BR> \r
5All rights reserved. This 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 this routine calls undi to shut down the interface.\r
20\r
21 @param Snp pointer to snp driver structure\r
22\r
23 @retval EFI_SUCCESS UNDI is shut down successfully\r
24 @retval EFI_DEVICE_ERROR UNDI could not be shut down\r
25\r
26**/\r
27EFI_STATUS\r
28PxeShutdown (\r
29 IN SNP_DRIVER *Snp\r
30 )\r
31{\r
32 Snp->Cdb.OpCode = PXE_OPCODE_SHUTDOWN;\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 and check result.\r
45 //\r
46 DEBUG ((EFI_D_NET, "\nsnp->undi.shutdown() "));\r
47\r
48 (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
49\r
50 if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
51 //\r
52 // UNDI could not be shutdown. Return UNDI error.\r
53 //\r
54 DEBUG ((EFI_D_WARN, "\nsnp->undi.shutdown() %xh:%xh\n", Snp->Cdb.StatFlags, Snp->Cdb.StatCode));\r
55\r
56 return EFI_DEVICE_ERROR;\r
57 }\r
58 //\r
59 // Free allocated memory.\r
60 //\r
61 if (Snp->TxRxBuffer != NULL) {\r
62 Snp->PciIo->FreeBuffer (\r
63 Snp->PciIo,\r
64 SNP_MEM_PAGES (Snp->TxRxBufferSize),\r
65 (VOID *) Snp->TxRxBuffer\r
66 );\r
67 }\r
68\r
69 Snp->TxRxBuffer = NULL;\r
70 Snp->TxRxBufferSize = 0;\r
71\r
72 return EFI_SUCCESS;\r
73}\r
74\r
75\r
76/**\r
77 Resets a network adapter and leaves it in a state that is safe for another \r
78 driver to initialize. \r
79 \r
80 This function releases the memory buffers assigned in the Initialize() call.\r
81 Pending transmits and receives are lost, and interrupts are cleared and disabled.\r
82 After this call, only the Initialize() and Stop() calls may be used. If the \r
83 network interface was successfully shutdown, then EFI_SUCCESS will be returned.\r
84 If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r
85\r
86 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
87\r
88 @retval EFI_SUCCESS The network interface was shutdown.\r
89 @retval EFI_NOT_STARTED The network interface has not been started.\r
90 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid \r
91 EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
92 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
93\r
94**/\r
95EFI_STATUS\r
96EFIAPI\r
97SnpUndi32Shutdown (\r
98 IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
99 )\r
100{\r
101 SNP_DRIVER *Snp;\r
102 EFI_STATUS Status;\r
103 EFI_TPL OldTpl;\r
104\r
105 //\r
106 // Get pointer to SNP driver instance for *This.\r
107 //\r
108 if (This == NULL) {\r
109 return EFI_INVALID_PARAMETER;\r
110 }\r
111\r
112 Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
113\r
114 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
115\r
116 //\r
117 // Return error if the SNP is not initialized.\r
118 //\r
119 switch (Snp->Mode.State) {\r
120 case EfiSimpleNetworkInitialized:\r
121 break;\r
122\r
123 case EfiSimpleNetworkStopped:\r
124 Status = EFI_NOT_STARTED;\r
125 goto ON_EXIT;\r
126\r
127 default:\r
128 Status = EFI_DEVICE_ERROR;\r
129 goto ON_EXIT;\r
130 }\r
131 \r
132 Status = PxeShutdown (Snp);\r
133\r
134 Snp->Mode.State = EfiSimpleNetworkStarted;\r
135 Snp->Mode.ReceiveFilterSetting = 0;\r
136\r
137 Snp->Mode.MCastFilterCount = 0;\r
138 Snp->Mode.ReceiveFilterSetting = 0;\r
139 ZeroMem (Snp->Mode.MCastFilter, sizeof Snp->Mode.MCastFilter);\r
140 CopyMem (\r
141 &Snp->Mode.CurrentAddress,\r
142 &Snp->Mode.PermanentAddress,\r
143 sizeof (EFI_MAC_ADDRESS)\r
144 );\r
145\r
146 gBS->CloseEvent (Snp->Snp.WaitForPacket);\r
147\r
148ON_EXIT:\r
149 gBS->RestoreTPL (OldTpl);\r
150\r
151 return Status;\r
152}\r