]>
Commit | Line | Data |
---|---|---|
a0818cc1 | 1 | /** @file\r |
4cda7726 | 2 | Implementation of shuting down a network adapter.\r |
3 | \r | |
e5eed7d3 HT |
4 | Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials are licensed \r | |
4cda7726 | 6 | and made available under the terms and conditions of the BSD License which \r |
7 | accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
a0818cc1 | 9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
a0818cc1 | 13 | **/\r |
14 | \r | |
15 | #include "Snp.h"\r | |
16 | \r | |
17 | \r | |
18 | /**\r | |
f3816027 | 19 | Call UNDI to shut down the interface.\r |
a0818cc1 | 20 | \r |
f3816027 | 21 | @param Snp Pointer to snp driver structure.\r |
a0818cc1 | 22 | \r |
f3816027 | 23 | @retval EFI_SUCCESS UNDI is shut down successfully.\r |
24 | @retval EFI_DEVICE_ERROR UNDI could not be shut down.\r | |
a0818cc1 | 25 | \r |
26 | **/\r | |
27 | EFI_STATUS\r | |
4cda7726 | 28 | PxeShutdown (\r |
29 | IN SNP_DRIVER *Snp\r | |
a0818cc1 | 30 | )\r |
31 | {\r | |
4cda7726 | 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 | |
a0818cc1 | 42 | \r |
43 | //\r | |
44 | // Issue UNDI command and check result.\r | |
45 | //\r | |
9cff2f8d | 46 | DEBUG ((EFI_D_NET, "\nsnp->undi.shutdown() "));\r |
a0818cc1 | 47 | \r |
4cda7726 | 48 | (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r |
a0818cc1 | 49 | \r |
4cda7726 | 50 | if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r |
a0818cc1 | 51 | //\r |
52 | // UNDI could not be shutdown. Return UNDI error.\r | |
53 | //\r | |
9cff2f8d | 54 | DEBUG ((EFI_D_WARN, "\nsnp->undi.shutdown() %xh:%xh\n", Snp->Cdb.StatFlags, Snp->Cdb.StatCode));\r |
a0818cc1 | 55 | \r |
56 | return EFI_DEVICE_ERROR;\r | |
57 | }\r | |
58 | //\r | |
59 | // Free allocated memory.\r | |
60 | //\r | |
4cda7726 | 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 | |
a0818cc1 | 66 | );\r |
67 | }\r | |
68 | \r | |
4cda7726 | 69 | Snp->TxRxBuffer = NULL;\r |
70 | Snp->TxRxBufferSize = 0;\r | |
a0818cc1 | 71 | \r |
72 | return EFI_SUCCESS;\r | |
73 | }\r | |
74 | \r | |
75 | \r | |
76 | /**\r | |
4cda7726 | 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 | |
a0818cc1 | 93 | \r |
94 | **/\r | |
95 | EFI_STATUS\r | |
96 | EFIAPI\r | |
4cda7726 | 97 | SnpUndi32Shutdown (\r |
98 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r | |
a0818cc1 | 99 | )\r |
100 | {\r | |
4cda7726 | 101 | SNP_DRIVER *Snp;\r |
a0818cc1 | 102 | EFI_STATUS Status;\r |
103 | EFI_TPL OldTpl;\r | |
104 | \r | |
105 | //\r | |
4cda7726 | 106 | // Get pointer to SNP driver instance for *This.\r |
a0818cc1 | 107 | //\r |
4cda7726 | 108 | if (This == NULL) {\r |
a0818cc1 | 109 | return EFI_INVALID_PARAMETER;\r |
110 | }\r | |
111 | \r | |
4cda7726 | 112 | Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r |
a0818cc1 | 113 | \r |
114 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
115 | \r | |
116 | //\r | |
4cda7726 | 117 | // Return error if the SNP is not initialized.\r |
a0818cc1 | 118 | //\r |
4cda7726 | 119 | switch (Snp->Mode.State) {\r |
a0818cc1 | 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 | |
4cda7726 | 131 | \r |
132 | Status = PxeShutdown (Snp);\r | |
a0818cc1 | 133 | \r |
4cda7726 | 134 | Snp->Mode.State = EfiSimpleNetworkStarted;\r |
135 | Snp->Mode.ReceiveFilterSetting = 0;\r | |
a0818cc1 | 136 | \r |
4cda7726 | 137 | Snp->Mode.MCastFilterCount = 0;\r |
138 | Snp->Mode.ReceiveFilterSetting = 0;\r | |
139 | ZeroMem (Snp->Mode.MCastFilter, sizeof Snp->Mode.MCastFilter);\r | |
a0818cc1 | 140 | CopyMem (\r |
4cda7726 | 141 | &Snp->Mode.CurrentAddress,\r |
142 | &Snp->Mode.PermanentAddress,\r | |
a0818cc1 | 143 | sizeof (EFI_MAC_ADDRESS)\r |
144 | );\r | |
145 | \r | |
4cda7726 | 146 | gBS->CloseEvent (Snp->Snp.WaitForPacket);\r |
a0818cc1 | 147 | \r |
148 | ON_EXIT:\r | |
149 | gBS->RestoreTPL (OldTpl);\r | |
150 | \r | |
151 | return Status;\r | |
152 | }\r |