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