]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Network/Snp32_64/Dxe/get_status.c
Partially make EdkModulePkg pass intel IPF compiler with /W4 /WX switched on.
[mirror_edk2.git] / EdkModulePkg / Universal / Network / Snp32_64 / Dxe / get_status.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 get_status.c
13
14 Abstract:
15
16 Revision history:
17 2000-Feb-03 M(f)J Genesis.
18 --*/
19
20
21 #include "Snp.h"
22
23 STATIC
24 EFI_STATUS
25 pxe_getstatus (
26 SNP_DRIVER *snp,
27 UINT32 *InterruptStatusPtr,
28 VOID **TransmitBufferListPtr
29 )
30 /*++
31
32 Routine Description:
33 this routine calls undi to get the status of the interrupts, get the list of
34 transmit buffers that completed transmitting!
35
36 Arguments:
37 snp - pointer to snp driver structure
38 InterruptStatusPtr - a non null pointer gets the interrupt status
39 TransmitBufferListPtrs - a non null ointer gets the list of pointers of previously
40 transmitted buffers whose transmission was completed
41 asynchrnously.
42
43 Returns:
44
45 --*/
46 {
47 PXE_DB_GET_STATUS *db;
48 UINT16 InterruptFlags;
49 UINT64 TempData;
50
51 db = snp->db;
52 snp->cdb.OpCode = PXE_OPCODE_GET_STATUS;
53
54 snp->cdb.OpFlags = 0;
55
56 if (TransmitBufferListPtr != NULL) {
57 snp->cdb.OpFlags |= PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS;
58 }
59
60 if (InterruptStatusPtr != NULL) {
61 snp->cdb.OpFlags |= PXE_OPFLAGS_GET_INTERRUPT_STATUS;
62 }
63
64 snp->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
65 snp->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
66
67 //
68 // size DB for return of one buffer
69 //
70 snp->cdb.DBsize = (UINT16) (((UINT16) (sizeof (PXE_DB_GET_STATUS)) - (UINT16) (sizeof db->TxBuffer)) + (UINT16) (sizeof db->TxBuffer[0]));
71
72 snp->cdb.DBaddr = (UINT64) (UINTN) db;
73
74 snp->cdb.StatCode = PXE_STATCODE_INITIALIZE;
75 snp->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
76 snp->cdb.IFnum = snp->if_num;
77 snp->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
78
79 //
80 // Issue UNDI command and check result.
81 //
82 DEBUG ((EFI_D_NET, "\nsnp->undi.get_status() "));
83
84 (*snp->issue_undi32_command) ((UINT64) (UINTN) &snp->cdb);
85
86 if (snp->cdb.StatCode != EFI_SUCCESS) {
87 DEBUG (
88 (EFI_D_NET,
89 "\nsnp->undi.get_status() %xh:%xh\n",
90 snp->cdb.StatFlags,
91 snp->cdb.StatFlags)
92 );
93
94 return EFI_DEVICE_ERROR;
95 }
96 //
97 // report the values back..
98 //
99 if (InterruptStatusPtr != NULL) {
100 InterruptFlags = (UINT16) (snp->cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK);
101
102 *InterruptStatusPtr = 0;
103
104 if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_RECEIVE) {
105 *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;
106 }
107
108 if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_TRANSMIT) {
109 *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
110 }
111
112 if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_COMMAND) {
113 *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT;
114 }
115
116 if (InterruptFlags & PXE_STATFLAGS_GET_STATUS_SOFTWARE) {
117 *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT;
118 }
119
120 }
121
122 if (TransmitBufferListPtr != NULL) {
123 *TransmitBufferListPtr =
124 (
125 (snp->cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN) ||
126 (snp->cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY)
127 ) ? 0 : (VOID *) (UINTN) db->TxBuffer[0];
128
129 TempData = (UINT64) (UINTN) (*TransmitBufferListPtr);
130 if (snp->IsOldUndi && (TempData >= FOUR_GIGABYTES)) {
131 del_v2p ((VOID *) (UINTN) (db->TxBuffer[0]));
132 }
133 }
134
135 return EFI_SUCCESS;
136 }
137
138 EFI_STATUS
139 EFIAPI
140 snp_undi32_get_status (
141 IN EFI_SIMPLE_NETWORK_PROTOCOL * this,
142 OUT UINT32 *InterruptStatusPtr OPTIONAL,
143 OUT VOID **TransmitBufferListPtr OPTIONAL
144 )
145 /*++
146
147 Routine Description:
148 This is the SNP interface routine for getting the status
149 This routine basically retrieves snp structure, checks the SNP state and
150 calls the pxe_getstatus routine to actually get the undi status
151
152 Arguments:
153 this - context pointer
154 InterruptStatusPtr - a non null pointer gets the interrupt status
155 TransmitBufferListPtrs - a non null ointer gets the list of pointers of previously
156 transmitted buffers whose transmission was completed
157 asynchrnously.
158
159 Returns:
160
161 --*/
162 {
163 SNP_DRIVER *snp;
164
165 if (this == NULL) {
166 return EFI_INVALID_PARAMETER;
167 }
168
169 snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
170
171 if (snp == NULL) {
172 return EFI_DEVICE_ERROR;
173 }
174
175 switch (snp->mode.State) {
176 case EfiSimpleNetworkInitialized:
177 break;
178
179 case EfiSimpleNetworkStopped:
180 return EFI_NOT_STARTED;
181
182 case EfiSimpleNetworkStarted:
183 return EFI_DEVICE_ERROR;
184
185 default:
186 return EFI_DEVICE_ERROR;
187 }
188
189 if (InterruptStatusPtr == NULL && TransmitBufferListPtr == NULL) {
190 return EFI_INVALID_PARAMETER;
191 }
192
193 return pxe_getstatus (snp, InterruptStatusPtr, TransmitBufferListPtr);
194 }