2 Copyright (c) 2004 - 2007, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 2000-Feb-03 M(f)J Genesis.
25 this routine calls undi to get the status of the interrupts, get the list of
26 transmit buffers that completed transmitting!
28 @param snp pointer to snp driver structure
29 @param InterruptStatusPtr a non null pointer gets the interrupt status
30 @param TransmitBufferListPtrs a non null ointer gets the list of pointers of
31 previously transmitted buffers whose
32 transmission was completed asynchrnously.
39 UINT32
*InterruptStatusPtr
,
40 VOID
**TransmitBufferListPtr
43 PXE_DB_GET_STATUS
*db
;
44 UINT16 InterruptFlags
;
47 snp
->cdb
.OpCode
= PXE_OPCODE_GET_STATUS
;
51 if (TransmitBufferListPtr
!= NULL
) {
52 snp
->cdb
.OpFlags
|= PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS
;
55 if (InterruptStatusPtr
!= NULL
) {
56 snp
->cdb
.OpFlags
|= PXE_OPFLAGS_GET_INTERRUPT_STATUS
;
59 snp
->cdb
.CPBsize
= PXE_CPBSIZE_NOT_USED
;
60 snp
->cdb
.CPBaddr
= PXE_CPBADDR_NOT_USED
;
63 // size DB for return of one buffer
65 snp
->cdb
.DBsize
= (UINT16
) (((UINT16
) (sizeof (PXE_DB_GET_STATUS
)) - (UINT16
) (sizeof db
->TxBuffer
)) + (UINT16
) (sizeof db
->TxBuffer
[0]));
67 snp
->cdb
.DBaddr
= (UINT64
)(UINTN
) db
;
69 snp
->cdb
.StatCode
= PXE_STATCODE_INITIALIZE
;
70 snp
->cdb
.StatFlags
= PXE_STATFLAGS_INITIALIZE
;
71 snp
->cdb
.IFnum
= snp
->if_num
;
72 snp
->cdb
.Control
= PXE_CONTROL_LAST_CDB_IN_LIST
;
75 // Issue UNDI command and check result.
77 DEBUG ((EFI_D_NET
, "\nsnp->undi.get_status() "));
79 (*snp
->issue_undi32_command
) ((UINT64
)(UINTN
) &snp
->cdb
);
81 if (snp
->cdb
.StatCode
!= EFI_SUCCESS
) {
84 "\nsnp->undi.get_status() %xh:%xh\n",
89 return EFI_DEVICE_ERROR
;
92 // report the values back..
94 if (InterruptStatusPtr
!= NULL
) {
95 InterruptFlags
= (UINT16
) (snp
->cdb
.StatFlags
& PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK
);
97 *InterruptStatusPtr
= 0;
99 if (InterruptFlags
& PXE_STATFLAGS_GET_STATUS_RECEIVE
) {
100 *InterruptStatusPtr
|= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT
;
103 if (InterruptFlags
& PXE_STATFLAGS_GET_STATUS_TRANSMIT
) {
104 *InterruptStatusPtr
|= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT
;
107 if (InterruptFlags
& PXE_STATFLAGS_GET_STATUS_COMMAND
) {
108 *InterruptStatusPtr
|= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT
;
111 if (InterruptFlags
& PXE_STATFLAGS_GET_STATUS_SOFTWARE
) {
112 *InterruptStatusPtr
|= EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT
;
117 if (TransmitBufferListPtr
!= NULL
) {
118 *TransmitBufferListPtr
=
120 (snp
->cdb
.StatFlags
& PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN
) ||
121 (snp
->cdb
.StatFlags
& PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY
)
122 ) ? 0 : (VOID
*) (UINTN
) db
->TxBuffer
[0];
131 This is the SNP interface routine for getting the status
132 This routine basically retrieves snp structure, checks the SNP state and
133 calls the pxe_getstatus routine to actually get the undi status
135 @param this context pointer
136 @param InterruptStatusPtr a non null pointer gets the interrupt status
137 @param TransmitBufferListPtrs a non null ointer gets the list of pointers of
138 previously transmitted buffers whose
139 transmission was completed asynchrnously.
145 snp_undi32_get_status (
146 IN EFI_SIMPLE_NETWORK_PROTOCOL
* this,
147 OUT UINT32
*InterruptStatusPtr OPTIONAL
,
148 OUT VOID
**TransmitBufferListPtr OPTIONAL
156 return EFI_INVALID_PARAMETER
;
159 if (InterruptStatusPtr
== NULL
&& TransmitBufferListPtr
== NULL
) {
160 return EFI_INVALID_PARAMETER
;
163 snp
= EFI_SIMPLE_NETWORK_DEV_FROM_THIS (this);
165 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
168 return EFI_DEVICE_ERROR
;
171 switch (snp
->mode
.State
) {
172 case EfiSimpleNetworkInitialized
:
175 case EfiSimpleNetworkStopped
:
176 Status
= EFI_NOT_STARTED
;
180 Status
= EFI_DEVICE_ERROR
;
184 Status
= pxe_getstatus (snp
, InterruptStatusPtr
, TransmitBufferListPtr
);
187 gBS
->RestoreTPL (OldTpl
);