]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/SnpDxe/Reset.c
Fix build break for missing PeCoffLib mapping
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Reset.c
CommitLineData
a7e0614a 1/** @file\r
f3816027 2 Implementation of resetting a network adapter.\r
3 \r
4Copyright (c) 2004 - 2007, Intel Corporation.<BR> All rights reserved. This \r
5program and the accompanying materials are licensed and made available under the \r
6terms and conditions of the BSD License which accompanies this distribution. The \r
7full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
a7e0614a 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
a7e0614a 13**/\r
14\r
15#include "Snp.h"\r
16\r
17\r
18/**\r
f3816027 19 Call UNDI to reset the NIC.\r
a7e0614a 20\r
f3816027 21 @param Snp Pointer to the snp driver structure.\r
a7e0614a 22\r
f3816027 23 @return EFI_SUCCESSFUL The NIC was reset.\r
24 @retval EFI_DEVICE_ERROR The NIC cannot be reset.\r
a7e0614a 25\r
26**/\r
a7e0614a 27EFI_STATUS\r
4cda7726 28PxeReset (\r
29 SNP_DRIVER *Snp\r
a7e0614a 30 )\r
31{\r
4cda7726 32 Snp->Cdb.OpCode = PXE_OPCODE_RESET;\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
a7e0614a 42\r
43 //\r
44 // Issue UNDI command and check result.\r
45 //\r
f3816027 46 DEBUG ((EFI_D_INFO | EFI_D_NET, "\nsnp->undi.reset() "));\r
a7e0614a 47\r
4cda7726 48 (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r
a7e0614a 49\r
4cda7726 50 if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
a7e0614a 51 DEBUG (\r
f3816027 52 (EFI_D_ERROR | EFI_D_NET,\r
a7e0614a 53 "\nsnp->undi32.reset() %xh:%xh\n",\r
4cda7726 54 Snp->Cdb.StatFlags,\r
55 Snp->Cdb.StatCode)\r
a7e0614a 56 );\r
57\r
58 //\r
59 // UNDI could not be reset. Return UNDI error.\r
60 //\r
61 return EFI_DEVICE_ERROR;\r
62 }\r
63\r
64 return EFI_SUCCESS;\r
65}\r
66\r
67\r
68/**\r
4cda7726 69 Resets a network adapter and reinitializes it with the parameters that were\r
70 provided in the previous call to Initialize().\r
71\r
72 This function resets a network adapter and reinitializes it with the parameters\r
73 that were provided in the previous call to Initialize(). The transmit and \r
74 receive queues are emptied and all pending interrupts are cleared.\r
75 Receive filters, the station address, the statistics, and the multicast-IP-to-HW \r
76 MAC addresses are not reset by this call. If the network interface was \r
77 successfully reset, then EFI_SUCCESS will be returned. If the driver has not \r
78 been initialized, EFI_DEVICE_ERROR will be returned.\r
79\r
80 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r
81 @param ExtendedVerification Indicates that the driver may perform a more \r
82 exhaustive verification operation of the device \r
83 during reset.\r
84\r
85 @retval EFI_SUCCESS The network interface was reset.\r
86 @retval EFI_NOT_STARTED The network interface has not been started.\r
87 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
88 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
89 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
a7e0614a 90\r
91**/\r
92EFI_STATUS\r
93EFIAPI\r
4cda7726 94SnpUndi32Reset (\r
95 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
a7e0614a 96 IN BOOLEAN ExtendedVerification\r
97 )\r
98{\r
4cda7726 99 SNP_DRIVER *Snp;\r
a7e0614a 100 EFI_TPL OldTpl;\r
101 EFI_STATUS Status;\r
102\r
103 //\r
104 // Resolve Warning 4 unreferenced parameter problem\r
105 //\r
106 ExtendedVerification = 0;\r
107 DEBUG ((EFI_D_WARN, "ExtendedVerification = %d is not implemented!\n", ExtendedVerification));\r
108\r
4cda7726 109 if (This == NULL) {\r
a7e0614a 110 return EFI_INVALID_PARAMETER;\r
111 }\r
112\r
4cda7726 113 Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r
a7e0614a 114\r
115 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
116\r
4cda7726 117 switch (Snp->Mode.State) {\r
a7e0614a 118 case EfiSimpleNetworkInitialized:\r
119 break;\r
120\r
121 case EfiSimpleNetworkStopped:\r
122 Status = EFI_NOT_STARTED;\r
123 goto ON_EXIT;\r
124\r
125 default:\r
126 Status = EFI_DEVICE_ERROR;\r
127 goto ON_EXIT;\r
128 }\r
129\r
4cda7726 130 Status = PxeReset (Snp);\r
a7e0614a 131\r
132ON_EXIT:\r
133 gBS->RestoreTPL (OldTpl);\r
134\r
135 return Status;\r
136}\r