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