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