]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/SnpDxe/Reset.c
Patch to remove STATIC modifier. This is on longer recommended by EFI Framework codin...
[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 pxe_reset (
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->if_num;
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->issue_undi32_command) ((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 This is the SNP interface routine for resetting the NIC
76 This routine basically retrieves snp structure, checks the SNP state and
77 calls the pxe_reset routine to actually do the reset!
78
79 @param this context pointer
80 @param ExtendedVerification not implemented
81
82
83 **/
84 EFI_STATUS
85 EFIAPI
86 snp_undi32_reset (
87 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
88 IN BOOLEAN ExtendedVerification
89 )
90 {
91 SNP_DRIVER *snp;
92 EFI_TPL OldTpl;
93 EFI_STATUS Status;
94
95 //
96 // Resolve Warning 4 unreferenced parameter problem
97 //
98 ExtendedVerification = 0;
99 DEBUG ((EFI_D_WARN, "ExtendedVerification = %d is not implemented!\n", ExtendedVerification));
100
101 if (this == NULL) {
102 return EFI_INVALID_PARAMETER;
103 }
104
105 snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
106
107 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
108
109 switch (snp->mode.State) {
110 case EfiSimpleNetworkInitialized:
111 break;
112
113 case EfiSimpleNetworkStopped:
114 Status = EFI_NOT_STARTED;
115 goto ON_EXIT;
116
117 default:
118 Status = EFI_DEVICE_ERROR;
119 goto ON_EXIT;
120 }
121
122 Status = pxe_reset (snp);
123
124 ON_EXIT:
125 gBS->RestoreTPL (OldTpl);
126
127 return Status;
128 }