]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Network/Snp32_64/Dxe/reset.c
Partially make EdkModulePkg pass intel IPF compiler with /W4 /WX switched on.
[mirror_edk2.git] / EdkModulePkg / Universal / Network / Snp32_64 / Dxe / reset.c
1 /*++
2 Copyright (c) 2006, 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 STATIC
24 EFI_STATUS
25 pxe_reset (
26 SNP_DRIVER *snp
27 )
28 /*++
29
30 Routine Description:
31 This routine calls undi to reset the nic.
32
33 Arguments:
34 snp - pointer to the snp driver structure
35
36 Returns:
37 EFI_SUCCESSFUL for a successful completion
38 other for failed calls
39
40 --*/
41 {
42 snp->cdb.OpCode = PXE_OPCODE_RESET;
43 snp->cdb.OpFlags = PXE_OPFLAGS_NOT_USED;
44 snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
45 snp->cdb.DBsize = PXE_DBSIZE_NOT_USED;
46 snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
47 snp->cdb.DBaddr = PXE_DBADDR_NOT_USED;
48 snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
49 snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
50 snp->cdb.IFnum = snp->if_num;
51 snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
52
53 //
54 // Issue UNDI command and check result.
55 //
56 DEBUG ((EFI_D_NET, "\nsnp->undi.reset() "));
57
58 (*snp->issue_undi32_command) ((UINT64) (UINTN) &snp->cdb);
59
60 if (snp->cdb.StatCode != PXE_STATCODE_SUCCESS) {
61 DEBUG (
62 (EFI_D_WARN,
63 "\nsnp->undi32.reset() %xh:%xh\n",
64 snp->cdb.StatFlags,
65 snp->cdb.StatCode)
66 );
67
68 //
69 // UNDI could not be reset. Return UNDI error.
70 //
71 return EFI_DEVICE_ERROR;
72 }
73
74 return EFI_SUCCESS;
75 }
76
77 EFI_STATUS
78 EFIAPI
79 snp_undi32_reset (
80 IN EFI_SIMPLE_NETWORK_PROTOCOL *this,
81 IN BOOLEAN ExtendedVerification
82 )
83 /*++
84
85 Routine Description:
86 This is the SNP interface routine for resetting the NIC
87 This routine basically retrieves snp structure, checks the SNP state and
88 calls the pxe_reset routine to actually do the reset!
89
90 Arguments:
91 this - context pointer
92 ExtendedVerification - not implemented
93
94 Returns:
95
96 --*/
97 {
98 SNP_DRIVER *snp;
99
100 if (this == NULL) {
101 return EFI_INVALID_PARAMETER;
102 }
103
104 snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
105
106 if (snp == NULL) {
107 return EFI_DEVICE_ERROR;
108 }
109
110 switch (snp->mode.State) {
111 case EfiSimpleNetworkInitialized:
112 break;
113
114 case EfiSimpleNetworkStopped:
115 return EFI_NOT_STARTED;
116
117 case EfiSimpleNetworkStarted:
118 return EFI_DEVICE_ERROR;
119
120 default:
121 return EFI_DEVICE_ERROR;
122 }
123
124 return pxe_reset (snp);
125 }