2 Implementation of reading the current interrupt status and recycled transmit
3 buffer status from a network interface.
5 Copyright (c) 2004 - 2007, Intel Corporation. <BR>
6 All rights reserved. This program and the accompanying materials are licensed
7 and made available under the terms and conditions of the BSD License which
8 accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 this routine calls undi to get the status of the interrupts, get the list of
20 transmit buffers that completed transmitting!
22 @param Snp pointer to snp driver structure
23 @param InterruptStatusPtr a non null pointer gets the interrupt status
24 @param TransmitBufferListPtrs a non null ointer gets the list of pointers of
25 previously transmitted buffers whose
26 transmission was completed asynchrnously.
33 UINT32
*InterruptStatusPtr
,
34 VOID
**TransmitBufferListPtr
37 PXE_DB_GET_STATUS
*Db
;
38 UINT16 InterruptFlags
;
41 Snp
->Cdb
.OpCode
= PXE_OPCODE_GET_STATUS
;
45 if (TransmitBufferListPtr
!= NULL
) {
46 Snp
->Cdb
.OpFlags
|= PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS
;
49 if (InterruptStatusPtr
!= NULL
) {
50 Snp
->Cdb
.OpFlags
|= PXE_OPFLAGS_GET_INTERRUPT_STATUS
;
53 Snp
->Cdb
.CPBsize
= PXE_CPBSIZE_NOT_USED
;
54 Snp
->Cdb
.CPBaddr
= PXE_CPBADDR_NOT_USED
;
57 // size DB for return of one buffer
59 Snp
->Cdb
.DBsize
= (UINT16
) ((sizeof (PXE_DB_GET_STATUS
) - sizeof (Db
->TxBuffer
)) + sizeof (Db
->TxBuffer
[0]));
61 Snp
->Cdb
.DBaddr
= (UINT64
)(UINTN
) Db
;
63 Snp
->Cdb
.StatCode
= PXE_STATCODE_INITIALIZE
;
64 Snp
->Cdb
.StatFlags
= PXE_STATFLAGS_INITIALIZE
;
65 Snp
->Cdb
.IFnum
= Snp
->IfNum
;
66 Snp
->Cdb
.Control
= PXE_CONTROL_LAST_CDB_IN_LIST
;
69 // Issue UNDI command and check result.
71 DEBUG ((EFI_D_NET
, "\nSnp->undi.get_status() "));
73 (*Snp
->IssueUndi32Command
) ((UINT64
)(UINTN
) &Snp
->Cdb
);
75 if (Snp
->Cdb
.StatCode
!= EFI_SUCCESS
) {
78 "\nSnp->undi.get_status() %xh:%xh\n",
83 return EFI_DEVICE_ERROR
;
86 // report the values back..
88 if (InterruptStatusPtr
!= NULL
) {
89 InterruptFlags
= (UINT16
) (Snp
->Cdb
.StatFlags
& PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK
);
91 *InterruptStatusPtr
= 0;
93 if ((InterruptFlags
& PXE_STATFLAGS_GET_STATUS_RECEIVE
) == PXE_STATFLAGS_GET_STATUS_RECEIVE
) {
94 *InterruptStatusPtr
|= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT
;
97 if ((InterruptFlags
& PXE_STATFLAGS_GET_STATUS_TRANSMIT
) == PXE_STATFLAGS_GET_STATUS_TRANSMIT
) {
98 *InterruptStatusPtr
|= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT
;
101 if ((InterruptFlags
& PXE_STATFLAGS_GET_STATUS_COMMAND
) == PXE_STATFLAGS_GET_STATUS_COMMAND
) {
102 *InterruptStatusPtr
|= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT
;
105 if ((InterruptFlags
& PXE_STATFLAGS_GET_STATUS_SOFTWARE
) == PXE_STATFLAGS_GET_STATUS_SOFTWARE
) {
106 *InterruptStatusPtr
|= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT
;
111 if (TransmitBufferListPtr
!= NULL
) {
112 *TransmitBufferListPtr
=
114 (Snp
->Cdb
.StatFlags
& PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN
) ||
115 (Snp
->Cdb
.StatFlags
& PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY
)
116 ) ? 0 : (VOID
*) (UINTN
) Db
->TxBuffer
[0];
124 Reads the current interrupt status and recycled transmit buffer status from a
127 This function gets the current interrupt and recycled transmit buffer status
128 from the network interface. The interrupt status is returned as a bit mask in
129 InterruptStatus. If InterruptStatus is NULL, the interrupt status will not be
130 read. If TxBuf is not NULL, a recycled transmit buffer address will be retrieved.
131 If a recycled transmit buffer address is returned in TxBuf, then the buffer has
132 been successfully transmitted, and the status for that buffer is cleared. If
133 the status of the network interface is successfully collected, EFI_SUCCESS
134 will be returned. If the driver has not been initialized, EFI_DEVICE_ERROR will
137 @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.
138 @param InterruptStatus A pointer to the bit mask of the currently active
139 interrupts (see "Related Definitions"). If this is NULL,
140 the interrupt status will not be read from the device.
141 If this is not NULL, the interrupt status will be read
142 from the device. When the interrupt status is read, it
143 will also be cleared. Clearing the transmit interrupt does
144 not empty the recycled transmit buffer array.
145 @param TxBuf Recycled transmit buffer address. The network interface
146 will not transmit if its internal recycled transmit
147 buffer array is full. Reading the transmit buffer does
148 not clear the transmit interrupt. If this is NULL, then
149 the transmit buffer status will not be read. If there
150 are no transmit buffers to recycle and TxBuf is not NULL,
151 TxBuf will be set to NULL.
153 @retval EFI_SUCCESS The status of the network interface was retrieved.
154 @retval EFI_NOT_STARTED The network interface has not been started.
155 @retval EFI_INVALID_PARAMETER This parameter was NULL or did not point to a valid
156 EFI_SIMPLE_NETWORK_PROTOCOL structure.
157 @retval EFI_DEVICE_ERROR The command could not be sent to the network
164 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
165 OUT UINT32
*InterruptStatus
, OPTIONAL
166 OUT VOID
**TxBuf OPTIONAL
174 return EFI_INVALID_PARAMETER
;
177 if (InterruptStatus
== NULL
&& TxBuf
== NULL
) {
178 return EFI_INVALID_PARAMETER
;
181 Snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This
);
183 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
186 return EFI_DEVICE_ERROR
;
189 switch (Snp
->Mode
.State
) {
190 case EfiSimpleNetworkInitialized
:
193 case EfiSimpleNetworkStopped
:
194 Status
= EFI_NOT_STARTED
;
198 Status
= EFI_DEVICE_ERROR
;
202 Status
= PxeGetStatus (Snp
, InterruptStatus
, TxBuf
);
205 gBS
->RestoreTPL (OldTpl
);