]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/SnpDxe/Reset.c
Code Scrub:
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / Reset.c
CommitLineData
a7e0614a 1/** @file\r
2Copyright (c) 2004 - 2007, Intel Corporation\r
3All rights reserved. This program and the accompanying materials\r
4are licensed and made available under the terms and conditions of the BSD License\r
5which accompanies this distribution. The full text of the license may be found at\r
6http://opensource.org/licenses/bsd-license.php\r
7\r
8THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
9WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
10\r
11Module name:\r
12 reset.c\r
13\r
14Abstract:\r
15\r
16Revision history:\r
17 2000-Feb-09 M(f)J Genesis.\r
18\r
19**/\r
20\r
21#include "Snp.h"\r
22\r
23\r
24/**\r
25 This routine calls undi to reset the nic.\r
26\r
27 @param snp pointer to the snp driver structure\r
28\r
29 @return EFI_SUCCESSFUL for a successful completion\r
30 @return other for failed calls\r
31\r
32**/\r
a7e0614a 33EFI_STATUS\r
34pxe_reset (\r
35 SNP_DRIVER *snp\r
36 )\r
37{\r
38 snp->cdb.OpCode = PXE_OPCODE_RESET;\r
39 snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;\r
40 snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r
41 snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;\r
42 snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r
43 snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;\r
44 snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;\r
45 snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r
46 snp->cdb.IFnum = snp->if_num;\r
47 snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r
48\r
49 //\r
50 // Issue UNDI command and check result.\r
51 //\r
52 DEBUG ((EFI_D_NET, "\nsnp->undi.reset() "));\r
53\r
54 (*snp->issue_undi32_command) ((UINT64)(UINTN) &snp->cdb);\r
55\r
56 if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {\r
57 DEBUG (\r
58 (EFI_D_WARN,\r
59 "\nsnp->undi32.reset() %xh:%xh\n",\r
60 snp->cdb.StatFlags,\r
61 snp->cdb.StatCode)\r
62 );\r
63\r
64 //\r
65 // UNDI could not be reset. Return UNDI error.\r
66 //\r
67 return EFI_DEVICE_ERROR;\r
68 }\r
69\r
70 return EFI_SUCCESS;\r
71}\r
72\r
73\r
74/**\r
75 This is the SNP interface routine for resetting the NIC\r
76 This routine basically retrieves snp structure, checks the SNP state and\r
77 calls the pxe_reset routine to actually do the reset!\r
78\r
79 @param this context pointer\r
80 @param ExtendedVerification not implemented\r
81\r
82\r
83**/\r
84EFI_STATUS\r
85EFIAPI\r
86snp_undi32_reset (\r
87 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,\r
88 IN BOOLEAN ExtendedVerification\r
89 )\r
90{\r
91 SNP_DRIVER *snp;\r
92 EFI_TPL OldTpl;\r
93 EFI_STATUS Status;\r
94\r
95 //\r
96 // Resolve Warning 4 unreferenced parameter problem\r
97 //\r
98 ExtendedVerification = 0;\r
99 DEBUG ((EFI_D_WARN, "ExtendedVerification = %d is not implemented!\n", ExtendedVerification));\r
100\r
101 if (this == NULL) {\r
102 return EFI_INVALID_PARAMETER;\r
103 }\r
104\r
105 snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);\r
106\r
107 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
108\r
109 switch (snp->mode.State) {\r
110 case EfiSimpleNetworkInitialized:\r
111 break;\r
112\r
113 case EfiSimpleNetworkStopped:\r
114 Status = EFI_NOT_STARTED;\r
115 goto ON_EXIT;\r
116\r
117 default:\r
118 Status = EFI_DEVICE_ERROR;\r
119 goto ON_EXIT;\r
120 }\r
121\r
122 Status = pxe_reset (snp);\r
123\r
124ON_EXIT:\r
125 gBS->RestoreTPL (OldTpl);\r
126\r
127 return Status;\r
128}\r