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