]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/SnpDxe/Reset.c
sync comments, fix function header, rename variable name to follow coding style.
[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 EFI_STATUS
34 PxeReset (
35 SNP_DRIVER *Snp
36 )
37 {
38 Snp->Cdb.OpCode = PXE_OPCODE_RESET;
39 Snp->Cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
40 Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
41 Snp->Cdb.DBsize = PXE_DBSIZE_NOT_USED;
42 Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
43 Snp->Cdb.DBaddr = PXE_DBADDR_NOT_USED;
44 Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;
45 Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
46 Snp->Cdb.IFnum = Snp->IfNum;
47 Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
48
49 //
50 // Issue UNDI command and check result.
51 //
52 DEBUG ((EFI_D_NET, "\nsnp->undi.reset() "));
53
54 (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);
55
56 if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {
57 DEBUG (
58 (EFI_D_WARN,
59 "\nsnp->undi32.reset() %xh:%xh\n",
60 Snp->Cdb.StatFlags,
61 Snp->Cdb.StatCode)
62 );
63
64 //
65 // UNDI could not be reset. Return UNDI error.
66 //
67 return EFI_DEVICE_ERROR;
68 }
69
70 return EFI_SUCCESS;
71 }
72
73
74 /**
75 Resets a network adapter and reinitializes it with the parameters that were
76 provided in the previous call to Initialize().
77
78 This function resets a network adapter and reinitializes it with the parameters
79 that were provided in the previous call to Initialize(). The transmit and
80 receive queues are emptied and all pending interrupts are cleared.
81 Receive filters, the station address, the statistics, and the multicast-IP-to-HW
82 MAC addresses are not reset by this call. If the network interface was
83 successfully reset, then EFI_SUCCESS will be returned. If the driver has not
84 been initialized, EFI_DEVICE_ERROR will be returned.
85
86 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
87 @param ExtendedVerification Indicates that the driver may perform a more
88 exhaustive verification operation of the device
89 during reset.
90
91 @retval EFI_SUCCESS The network interface was reset.
92 @retval EFI_NOT_STARTED The network interface has not been started.
93 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
94 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
95 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
96
97 **/
98 EFI_STATUS
99 EFIAPI
100 SnpUndi32Reset (
101 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
102 IN BOOLEAN ExtendedVerification
103 )
104 {
105 SNP_DRIVER *Snp;
106 EFI_TPL OldTpl;
107 EFI_STATUS Status;
108
109 //
110 // Resolve Warning 4 unreferenced parameter problem
111 //
112 ExtendedVerification = 0;
113 DEBUG ((EFI_D_WARN, "ExtendedVerification = %d is not implemented!\n", ExtendedVerification));
114
115 if (This == NULL) {
116 return EFI_INVALID_PARAMETER;
117 }
118
119 Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);
120
121 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
122
123 switch (Snp->Mode.State) {
124 case EfiSimpleNetworkInitialized:
125 break;
126
127 case EfiSimpleNetworkStopped:
128 Status = EFI_NOT_STARTED;
129 goto ON_EXIT;
130
131 default:
132 Status = EFI_DEVICE_ERROR;
133 goto ON_EXIT;
134 }
135
136 Status = PxeReset (Snp);
137
138 ON_EXIT:
139 gBS->RestoreTPL (OldTpl);
140
141 return Status;
142 }