2007-07-24 10:06:37 +02:00
|
|
|
/** @file
|
2008-11-13 04:42:21 +01:00
|
|
|
Event handler to check for available packet.
|
|
|
|
|
2018-06-27 15:08:52 +02:00
|
|
|
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:05:13 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2007-07-24 10:06:37 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "Snp.h"
|
|
|
|
|
|
|
|
/**
|
2020-02-07 02:07:59 +01:00
|
|
|
Notification call back function for WaitForPacket event.
|
2007-07-24 10:06:37 +02:00
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
@param Event EFI Event.
|
|
|
|
@param SnpPtr Pointer to SNP_DRIVER structure.
|
2007-07-24 10:06:37 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
SnpWaitForPacketNotify (
|
2008-12-29 02:16:13 +01:00
|
|
|
EFI_EVENT Event,
|
|
|
|
VOID *SnpPtr
|
2007-07-24 10:06:37 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
PXE_DB_GET_STATUS PxeDbGetStatus;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Do nothing if either parameter is a NULL pointer.
|
|
|
|
//
|
|
|
|
if ((Event == NULL) || (SnpPtr == NULL)) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 23:54:07 +01:00
|
|
|
|
2007-07-24 10:06:37 +02:00
|
|
|
//
|
|
|
|
// Do nothing if the SNP interface is not initialized.
|
|
|
|
//
|
2008-11-13 04:42:21 +01:00
|
|
|
switch (((SNP_DRIVER *)SnpPtr)->Mode.State) {
|
2007-07-24 10:06:37 +02:00
|
|
|
case EfiSimpleNetworkInitialized:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiSimpleNetworkStopped:
|
|
|
|
case EfiSimpleNetworkStarted:
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 23:54:07 +01:00
|
|
|
|
2007-07-24 10:06:37 +02:00
|
|
|
//
|
|
|
|
// Fill in CDB for UNDI GetStatus().
|
|
|
|
//
|
2008-11-13 04:42:21 +01:00
|
|
|
((SNP_DRIVER *)SnpPtr)->Cdb.OpCode = PXE_OPCODE_GET_STATUS;
|
|
|
|
((SNP_DRIVER *)SnpPtr)->Cdb.OpFlags = 0;
|
|
|
|
((SNP_DRIVER *)SnpPtr)->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
|
|
|
|
((SNP_DRIVER *)SnpPtr)->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
|
2010-09-15 09:48:11 +02:00
|
|
|
((SNP_DRIVER *)SnpPtr)->Cdb.DBsize = (UINT16)(sizeof (UINT32) * 2);
|
2008-11-13 04:42:21 +01:00
|
|
|
((SNP_DRIVER *)SnpPtr)->Cdb.DBaddr = (UINT64)(UINTN)(((SNP_DRIVER *)SnpPtr)->Db);
|
|
|
|
((SNP_DRIVER *)SnpPtr)->Cdb.StatCode = PXE_STATCODE_INITIALIZE;
|
|
|
|
((SNP_DRIVER *)SnpPtr)->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
|
|
|
|
((SNP_DRIVER *)SnpPtr)->Cdb.IFnum = ((SNP_DRIVER *)SnpPtr)->IfNum;
|
|
|
|
((SNP_DRIVER *)SnpPtr)->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
|
2007-07-24 10:06:37 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Clear contents of DB buffer.
|
|
|
|
//
|
2008-11-13 04:42:21 +01:00
|
|
|
ZeroMem (((SNP_DRIVER *)SnpPtr)->Db, sizeof (UINT32) * 2);
|
2007-07-24 10:06:37 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Issue UNDI command and check result.
|
|
|
|
//
|
2008-11-13 04:42:21 +01:00
|
|
|
(*((SNP_DRIVER *)SnpPtr)->IssueUndi32Command)((UINT64)(UINTN)&((SNP_DRIVER *)SnpPtr)->Cdb);
|
2007-07-24 10:06:37 +02:00
|
|
|
|
2008-11-13 04:42:21 +01:00
|
|
|
if (((SNP_DRIVER *)SnpPtr)->Cdb.StatCode != EFI_SUCCESS) {
|
2007-07-24 10:06:37 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-12-05 23:54:07 +01:00
|
|
|
|
2007-07-24 10:06:37 +02:00
|
|
|
//
|
|
|
|
// We might have a packet. Check the receive length and signal
|
|
|
|
// the event if the length is not zero.
|
|
|
|
//
|
|
|
|
CopyMem (
|
|
|
|
&PxeDbGetStatus,
|
2008-11-13 04:42:21 +01:00
|
|
|
((SNP_DRIVER *)SnpPtr)->Db,
|
2007-07-24 10:06:37 +02:00
|
|
|
sizeof (UINT32) * 2
|
|
|
|
);
|
|
|
|
|
|
|
|
if (PxeDbGetStatus.RxFrameLen != 0) {
|
|
|
|
gBS->SignalEvent (Event);
|
|
|
|
}
|
|
|
|
}
|