]>
Commit | Line | Data |
---|---|---|
75d0f44d | 1 | /** @file\r |
4140a663 | 2 | Implementation of reading the current interrupt status and recycled transmit\r |
3 | buffer status from a network interface.\r | |
4cda7726 | 4 | \r |
e5eed7d3 HT |
5 | Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r |
6 | This program and the accompanying materials are licensed\r | |
c777c357 | 7 | and made available under the terms and conditions of the BSD License which\r |
8 | accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
75d0f44d | 10 | \r |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
75d0f44d | 14 | **/\r |
15 | \r | |
16 | #include "Snp.h"\r | |
17 | \r | |
75d0f44d | 18 | /**\r |
c777c357 | 19 | Call undi to get the status of the interrupts, get the list of transmit\r |
20 | buffers that completed transmitting.\r | |
f3816027 | 21 | \r |
22 | @param Snp Pointer to snp driver structure.\r | |
c777c357 | 23 | @param InterruptStatusPtr A non null pointer to contain the interrupt\r |
f3816027 | 24 | status.\r |
c777c357 | 25 | @param TransmitBufferListPtrs A non null pointer to contain the list of\r |
f3816027 | 26 | pointers of previous transmitted buffers whose\r |
27 | transmission was completed asynchrnously.\r | |
c777c357 | 28 | \r |
f3816027 | 29 | @retval EFI_SUCCESS The status of the network interface was retrieved.\r |
c777c357 | 30 | @retval EFI_DEVICE_ERROR The command could not be sent to the network\r |
f3816027 | 31 | interface.\r |
75d0f44d | 32 | \r |
33 | **/\r | |
34 | EFI_STATUS\r | |
4cda7726 | 35 | PxeGetStatus (\r |
36 | SNP_DRIVER *Snp,\r | |
75d0f44d | 37 | UINT32 *InterruptStatusPtr,\r |
38 | VOID **TransmitBufferListPtr\r | |
39 | )\r | |
40 | {\r | |
4cda7726 | 41 | PXE_DB_GET_STATUS *Db;\r |
75d0f44d | 42 | UINT16 InterruptFlags;\r |
43 | \r | |
4cda7726 | 44 | Db = Snp->Db;\r |
45 | Snp->Cdb.OpCode = PXE_OPCODE_GET_STATUS;\r | |
75d0f44d | 46 | \r |
4cda7726 | 47 | Snp->Cdb.OpFlags = 0;\r |
75d0f44d | 48 | \r |
49 | if (TransmitBufferListPtr != NULL) {\r | |
4cda7726 | 50 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS;\r |
75d0f44d | 51 | }\r |
52 | \r | |
53 | if (InterruptStatusPtr != NULL) {\r | |
4cda7726 | 54 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_GET_INTERRUPT_STATUS;\r |
75d0f44d | 55 | }\r |
56 | \r | |
c777c357 | 57 | if (Snp->MediaStatusSupported) {\r |
58 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_GET_MEDIA_STATUS;\r | |
59 | }\r | |
60 | \r | |
4cda7726 | 61 | Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r |
62 | Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r | |
75d0f44d | 63 | \r |
64 | //\r | |
65 | // size DB for return of one buffer\r | |
66 | //\r | |
4cda7726 | 67 | Snp->Cdb.DBsize = (UINT16) ((sizeof (PXE_DB_GET_STATUS) - sizeof (Db->TxBuffer)) + sizeof (Db->TxBuffer[0]));\r |
75d0f44d | 68 | \r |
4cda7726 | 69 | Snp->Cdb.DBaddr = (UINT64)(UINTN) Db;\r |
75d0f44d | 70 | \r |
4cda7726 | 71 | Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;\r |
72 | Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r | |
73 | Snp->Cdb.IFnum = Snp->IfNum;\r | |
74 | Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r | |
75d0f44d | 75 | \r |
76 | //\r | |
77 | // Issue UNDI command and check result.\r | |
78 | //\r | |
9cff2f8d | 79 | DEBUG ((EFI_D_NET, "\nSnp->undi.get_status() "));\r |
75d0f44d | 80 | \r |
4cda7726 | 81 | (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r |
75d0f44d | 82 | \r |
4cda7726 | 83 | if (Snp->Cdb.StatCode != EFI_SUCCESS) {\r |
75d0f44d | 84 | DEBUG (\r |
9cff2f8d | 85 | (EFI_D_NET,\r |
4cda7726 | 86 | "\nSnp->undi.get_status() %xh:%xh\n",\r |
87 | Snp->Cdb.StatFlags,\r | |
88 | Snp->Cdb.StatFlags)\r | |
75d0f44d | 89 | );\r |
90 | \r | |
91 | return EFI_DEVICE_ERROR;\r | |
92 | }\r | |
93 | //\r | |
94 | // report the values back..\r | |
95 | //\r | |
96 | if (InterruptStatusPtr != NULL) {\r | |
4cda7726 | 97 | InterruptFlags = (UINT16) (Snp->Cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK);\r |
75d0f44d | 98 | \r |
99 | *InterruptStatusPtr = 0;\r | |
100 | \r | |
4cda7726 | 101 | if ((InterruptFlags & PXE_STATFLAGS_GET_STATUS_RECEIVE) == PXE_STATFLAGS_GET_STATUS_RECEIVE) {\r |
75d0f44d | 102 | *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;\r |
103 | }\r | |
104 | \r | |
4cda7726 | 105 | if ((InterruptFlags & PXE_STATFLAGS_GET_STATUS_TRANSMIT) == PXE_STATFLAGS_GET_STATUS_TRANSMIT) {\r |
75d0f44d | 106 | *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;\r |
107 | }\r | |
108 | \r | |
4cda7726 | 109 | if ((InterruptFlags & PXE_STATFLAGS_GET_STATUS_COMMAND) == PXE_STATFLAGS_GET_STATUS_COMMAND) {\r |
75d0f44d | 110 | *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT;\r |
111 | }\r | |
112 | \r | |
4cda7726 | 113 | if ((InterruptFlags & PXE_STATFLAGS_GET_STATUS_SOFTWARE) == PXE_STATFLAGS_GET_STATUS_SOFTWARE) {\r |
75d0f44d | 114 | *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT;\r |
115 | }\r | |
116 | \r | |
117 | }\r | |
118 | \r | |
119 | if (TransmitBufferListPtr != NULL) {\r | |
120 | *TransmitBufferListPtr =\r | |
121 | (\r | |
4140a663 | 122 | ((Snp->Cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN) != 0) ||\r |
123 | ((Snp->Cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY) != 0)\r | |
4cda7726 | 124 | ) ? 0 : (VOID *) (UINTN) Db->TxBuffer[0];\r |
75d0f44d | 125 | \r |
126 | }\r | |
127 | \r | |
c777c357 | 128 | //\r |
129 | // Update MediaPresent field of EFI_SIMPLE_NETWORK_MODE if the UNDI support\r | |
130 | // returning media status from GET_STATUS command\r | |
131 | //\r | |
132 | if (Snp->MediaStatusSupported) {\r | |
133 | Snp->Snp.Mode->MediaPresent =\r | |
134 | (BOOLEAN) (((Snp->Cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_NO_MEDIA) != 0) ? FALSE : TRUE);\r | |
135 | }\r | |
136 | \r | |
75d0f44d | 137 | return EFI_SUCCESS;\r |
138 | }\r | |
139 | \r | |
75d0f44d | 140 | /**\r |
4cda7726 | 141 | Reads the current interrupt status and recycled transmit buffer status from a\r |
142 | network interface.\r | |
c777c357 | 143 | \r |
144 | This function gets the current interrupt and recycled transmit buffer status\r | |
4cda7726 | 145 | from the network interface. The interrupt status is returned as a bit mask in\r |
146 | InterruptStatus. If InterruptStatus is NULL, the interrupt status will not be\r | |
147 | read. If TxBuf is not NULL, a recycled transmit buffer address will be retrieved.\r | |
148 | If a recycled transmit buffer address is returned in TxBuf, then the buffer has\r | |
149 | been successfully transmitted, and the status for that buffer is cleared. If\r | |
c777c357 | 150 | the status of the network interface is successfully collected, EFI_SUCCESS\r |
4cda7726 | 151 | will be returned. If the driver has not been initialized, EFI_DEVICE_ERROR will\r |
152 | be returned.\r | |
153 | \r | |
154 | @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r | |
c777c357 | 155 | @param InterruptStatus A pointer to the bit mask of the currently active\r |
4cda7726 | 156 | interrupts (see "Related Definitions"). If this is NULL,\r |
157 | the interrupt status will not be read from the device.\r | |
158 | If this is not NULL, the interrupt status will be read\r | |
c777c357 | 159 | from the device. When the interrupt status is read, it\r |
160 | will also be cleared. Clearing the transmit interrupt does\r | |
4cda7726 | 161 | not empty the recycled transmit buffer array.\r |
162 | @param TxBuf Recycled transmit buffer address. The network interface\r | |
c777c357 | 163 | will not transmit if its internal recycled transmit\r |
4cda7726 | 164 | buffer array is full. Reading the transmit buffer does\r |
165 | not clear the transmit interrupt. If this is NULL, then\r | |
c777c357 | 166 | the transmit buffer status will not be read. If there\r |
167 | are no transmit buffers to recycle and TxBuf is not NULL,\r | |
4cda7726 | 168 | TxBuf will be set to NULL.\r |
169 | \r | |
170 | @retval EFI_SUCCESS The status of the network interface was retrieved.\r | |
171 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
c777c357 | 172 | @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid\r |
4cda7726 | 173 | EFI_SIMPLE_NETWORK_PROTOCOL structure.\r |
c777c357 | 174 | @retval EFI_DEVICE_ERROR The command could not be sent to the network\r |
4cda7726 | 175 | interface.\r |
75d0f44d | 176 | \r |
177 | **/\r | |
178 | EFI_STATUS\r | |
179 | EFIAPI\r | |
4cda7726 | 180 | SnpUndi32GetStatus (\r |
181 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
182 | OUT UINT32 *InterruptStatus, OPTIONAL\r | |
183 | OUT VOID **TxBuf OPTIONAL\r | |
75d0f44d | 184 | )\r |
185 | {\r | |
4cda7726 | 186 | SNP_DRIVER *Snp;\r |
75d0f44d | 187 | EFI_TPL OldTpl;\r |
188 | EFI_STATUS Status;\r | |
189 | \r | |
4cda7726 | 190 | if (This == NULL) {\r |
75d0f44d | 191 | return EFI_INVALID_PARAMETER;\r |
192 | }\r | |
193 | \r | |
4cda7726 | 194 | if (InterruptStatus == NULL && TxBuf == NULL) {\r |
75d0f44d | 195 | return EFI_INVALID_PARAMETER;\r |
196 | }\r | |
197 | \r | |
4cda7726 | 198 | Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r |
75d0f44d | 199 | \r |
200 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
201 | \r | |
4cda7726 | 202 | if (Snp == NULL) {\r |
75d0f44d | 203 | return EFI_DEVICE_ERROR;\r |
204 | }\r | |
205 | \r | |
4cda7726 | 206 | switch (Snp->Mode.State) {\r |
75d0f44d | 207 | case EfiSimpleNetworkInitialized:\r |
208 | break;\r | |
209 | \r | |
210 | case EfiSimpleNetworkStopped:\r | |
211 | Status = EFI_NOT_STARTED;\r | |
212 | goto ON_EXIT;\r | |
213 | \r | |
214 | default:\r | |
215 | Status = EFI_DEVICE_ERROR;\r | |
216 | goto ON_EXIT;\r | |
217 | }\r | |
218 | \r | |
4cda7726 | 219 | Status = PxeGetStatus (Snp, InterruptStatus, TxBuf);\r |
75d0f44d | 220 | \r |
221 | ON_EXIT:\r | |
222 | gBS->RestoreTPL (OldTpl);\r | |
223 | \r | |
224 | return Status;\r | |
225 | }\r |