]>
Commit | Line | Data |
---|---|---|
75d0f44d | 1 | /** @file\r |
4cda7726 | 2 | Implementation of reading the current interrupt status and recycled transmit\r |
3 | buffer status from a network interface.\r | |
4 | \r | |
5 | Copyright (c) 2004 - 2007, Intel Corporation. <BR> \r | |
6 | All rights reserved. This program and the accompanying materials are licensed \r | |
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 |
f3816027 | 19 | Call undi to get the status of the interrupts, get the list of transmit \r |
20 | buffers that completed transmitting. \r | |
21 | \r | |
22 | @param Snp Pointer to snp driver structure.\r | |
23 | @param InterruptStatusPtr A non null pointer to contain the interrupt \r | |
24 | status.\r | |
25 | @param TransmitBufferListPtrs A non null pointer to contain the list of \r | |
26 | pointers of previous transmitted buffers whose\r | |
27 | transmission was completed asynchrnously.\r | |
28 | \r | |
29 | @retval EFI_SUCCESS The status of the network interface was retrieved.\r | |
30 | @retval EFI_DEVICE_ERROR The command could not be sent to the network \r | |
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 | |
4cda7726 | 57 | Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r |
58 | Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r | |
75d0f44d | 59 | \r |
60 | //\r | |
61 | // size DB for return of one buffer\r | |
62 | //\r | |
4cda7726 | 63 | Snp->Cdb.DBsize = (UINT16) ((sizeof (PXE_DB_GET_STATUS) - sizeof (Db->TxBuffer)) + sizeof (Db->TxBuffer[0]));\r |
75d0f44d | 64 | \r |
4cda7726 | 65 | Snp->Cdb.DBaddr = (UINT64)(UINTN) Db;\r |
75d0f44d | 66 | \r |
4cda7726 | 67 | Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;\r |
68 | Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r | |
69 | Snp->Cdb.IFnum = Snp->IfNum;\r | |
70 | Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r | |
75d0f44d | 71 | \r |
72 | //\r | |
73 | // Issue UNDI command and check result.\r | |
74 | //\r | |
f3816027 | 75 | DEBUG ((EFI_D_INFO | EFI_D_NET, "\nSnp->undi.get_status() "));\r |
75d0f44d | 76 | \r |
4cda7726 | 77 | (*Snp->IssueUndi32Command) ((UINT64)(UINTN) &Snp->Cdb);\r |
75d0f44d | 78 | \r |
4cda7726 | 79 | if (Snp->Cdb.StatCode != EFI_SUCCESS) {\r |
75d0f44d | 80 | DEBUG (\r |
f3816027 | 81 | (EFI_D_ERROR | EFI_D_NET,\r |
4cda7726 | 82 | "\nSnp->undi.get_status() %xh:%xh\n",\r |
83 | Snp->Cdb.StatFlags,\r | |
84 | Snp->Cdb.StatFlags)\r | |
75d0f44d | 85 | );\r |
86 | \r | |
87 | return EFI_DEVICE_ERROR;\r | |
88 | }\r | |
89 | //\r | |
90 | // report the values back..\r | |
91 | //\r | |
92 | if (InterruptStatusPtr != NULL) {\r | |
4cda7726 | 93 | InterruptFlags = (UINT16) (Snp->Cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK);\r |
75d0f44d | 94 | \r |
95 | *InterruptStatusPtr = 0;\r | |
96 | \r | |
4cda7726 | 97 | if ((InterruptFlags & PXE_STATFLAGS_GET_STATUS_RECEIVE) == PXE_STATFLAGS_GET_STATUS_RECEIVE) {\r |
75d0f44d | 98 | *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;\r |
99 | }\r | |
100 | \r | |
4cda7726 | 101 | if ((InterruptFlags & PXE_STATFLAGS_GET_STATUS_TRANSMIT) == PXE_STATFLAGS_GET_STATUS_TRANSMIT) {\r |
75d0f44d | 102 | *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;\r |
103 | }\r | |
104 | \r | |
4cda7726 | 105 | if ((InterruptFlags & PXE_STATFLAGS_GET_STATUS_COMMAND) == PXE_STATFLAGS_GET_STATUS_COMMAND) {\r |
75d0f44d | 106 | *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT;\r |
107 | }\r | |
108 | \r | |
4cda7726 | 109 | if ((InterruptFlags & PXE_STATFLAGS_GET_STATUS_SOFTWARE) == PXE_STATFLAGS_GET_STATUS_SOFTWARE) {\r |
75d0f44d | 110 | *InterruptStatusPtr |= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT;\r |
111 | }\r | |
112 | \r | |
113 | }\r | |
114 | \r | |
115 | if (TransmitBufferListPtr != NULL) {\r | |
116 | *TransmitBufferListPtr =\r | |
117 | (\r | |
4cda7726 | 118 | (Snp->Cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN) ||\r |
119 | (Snp->Cdb.StatFlags & PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY)\r | |
120 | ) ? 0 : (VOID *) (UINTN) Db->TxBuffer[0];\r | |
75d0f44d | 121 | \r |
122 | }\r | |
123 | \r | |
124 | return EFI_SUCCESS;\r | |
125 | }\r | |
126 | \r | |
75d0f44d | 127 | /**\r |
4cda7726 | 128 | Reads the current interrupt status and recycled transmit buffer status from a\r |
129 | network interface.\r | |
130 | \r | |
131 | This function gets the current interrupt and recycled transmit buffer status \r | |
132 | from the network interface. The interrupt status is returned as a bit mask in\r | |
133 | InterruptStatus. If InterruptStatus is NULL, the interrupt status will not be\r | |
134 | read. If TxBuf is not NULL, a recycled transmit buffer address will be retrieved.\r | |
135 | If a recycled transmit buffer address is returned in TxBuf, then the buffer has\r | |
136 | been successfully transmitted, and the status for that buffer is cleared. If\r | |
137 | the status of the network interface is successfully collected, EFI_SUCCESS \r | |
138 | will be returned. If the driver has not been initialized, EFI_DEVICE_ERROR will\r | |
139 | be returned.\r | |
140 | \r | |
141 | @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r | |
142 | @param InterruptStatus A pointer to the bit mask of the currently active \r | |
143 | interrupts (see "Related Definitions"). If this is NULL,\r | |
144 | the interrupt status will not be read from the device.\r | |
145 | If this is not NULL, the interrupt status will be read\r | |
146 | from the device. When the interrupt status is read, it \r | |
147 | will also be cleared. Clearing the transmit interrupt does \r | |
148 | not empty the recycled transmit buffer array.\r | |
149 | @param TxBuf Recycled transmit buffer address. The network interface\r | |
150 | will not transmit if its internal recycled transmit \r | |
151 | buffer array is full. Reading the transmit buffer does\r | |
152 | not clear the transmit interrupt. If this is NULL, then\r | |
153 | the transmit buffer status will not be read. If there \r | |
154 | are no transmit buffers to recycle and TxBuf is not NULL, \r | |
155 | TxBuf will be set to NULL.\r | |
156 | \r | |
157 | @retval EFI_SUCCESS The status of the network interface was retrieved.\r | |
158 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
159 | @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid \r | |
160 | EFI_SIMPLE_NETWORK_PROTOCOL structure.\r | |
161 | @retval EFI_DEVICE_ERROR The command could not be sent to the network \r | |
162 | interface.\r | |
75d0f44d | 163 | \r |
164 | **/\r | |
165 | EFI_STATUS\r | |
166 | EFIAPI\r | |
4cda7726 | 167 | SnpUndi32GetStatus (\r |
168 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r | |
169 | OUT UINT32 *InterruptStatus, OPTIONAL\r | |
170 | OUT VOID **TxBuf OPTIONAL\r | |
75d0f44d | 171 | )\r |
172 | {\r | |
4cda7726 | 173 | SNP_DRIVER *Snp;\r |
75d0f44d | 174 | EFI_TPL OldTpl;\r |
175 | EFI_STATUS Status;\r | |
176 | \r | |
4cda7726 | 177 | if (This == NULL) {\r |
75d0f44d | 178 | return EFI_INVALID_PARAMETER;\r |
179 | }\r | |
180 | \r | |
4cda7726 | 181 | if (InterruptStatus == NULL && TxBuf == NULL) {\r |
75d0f44d | 182 | return EFI_INVALID_PARAMETER;\r |
183 | }\r | |
184 | \r | |
4cda7726 | 185 | Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r |
75d0f44d | 186 | \r |
187 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
188 | \r | |
4cda7726 | 189 | if (Snp == NULL) {\r |
75d0f44d | 190 | return EFI_DEVICE_ERROR;\r |
191 | }\r | |
192 | \r | |
4cda7726 | 193 | switch (Snp->Mode.State) {\r |
75d0f44d | 194 | case EfiSimpleNetworkInitialized:\r |
195 | break;\r | |
196 | \r | |
197 | case EfiSimpleNetworkStopped:\r | |
198 | Status = EFI_NOT_STARTED;\r | |
199 | goto ON_EXIT;\r | |
200 | \r | |
201 | default:\r | |
202 | Status = EFI_DEVICE_ERROR;\r | |
203 | goto ON_EXIT;\r | |
204 | }\r | |
205 | \r | |
4cda7726 | 206 | Status = PxeGetStatus (Snp, InterruptStatus, TxBuf);\r |
75d0f44d | 207 | \r |
208 | ON_EXIT:\r | |
209 | gBS->RestoreTPL (OldTpl);\r | |
210 | \r | |
211 | return Status;\r | |
212 | }\r |