--- /dev/null
+/** @file\r
+Copyright (c) 2004, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module name:\r
+ WaitForPacket.c\r
+\r
+Abstract:\r
+ Event handler to check for available packet.\r
+\r
+\r
+**/\r
+\r
+#include "Snp.h"\r
+\r
+\r
+/**\r
+\r
+\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SnpWaitForPacketNotify (\r
+ EFI_EVENT Event,\r
+ VOID *SnpPtr\r
+ )\r
+{\r
+ PXE_DB_GET_STATUS PxeDbGetStatus;\r
+\r
+ //\r
+ // Do nothing if either parameter is a NULL pointer.\r
+ //\r
+ if (Event == NULL || SnpPtr == NULL) {\r
+ return ;\r
+ }\r
+ //\r
+ // Do nothing if the SNP interface is not initialized.\r
+ //\r
+ switch (((SNP_DRIVER *) SnpPtr)->mode.State) {\r
+ case EfiSimpleNetworkInitialized:\r
+ break;\r
+\r
+ case EfiSimpleNetworkStopped:\r
+ case EfiSimpleNetworkStarted:\r
+ default:\r
+ return ;\r
+ }\r
+ //\r
+ // Fill in CDB for UNDI GetStatus().\r
+ //\r
+ ((SNP_DRIVER *) SnpPtr)->cdb.OpCode = PXE_OPCODE_GET_STATUS;\r
+ ((SNP_DRIVER *) SnpPtr)->cdb.OpFlags = 0;\r
+ ((SNP_DRIVER *) SnpPtr)->cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r
+ ((SNP_DRIVER *) SnpPtr)->cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r
+ ((SNP_DRIVER *) SnpPtr)->cdb.DBsize = sizeof (UINT32) * 2;\r
+ ((SNP_DRIVER *) SnpPtr)->cdb.DBaddr = (UINT64)(UINTN) (((SNP_DRIVER *) SnpPtr)->db);\r
+ ((SNP_DRIVER *) SnpPtr)->cdb.StatCode = PXE_STATCODE_INITIALIZE;\r
+ ((SNP_DRIVER *) SnpPtr)->cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r
+ ((SNP_DRIVER *) SnpPtr)->cdb.IFnum = ((SNP_DRIVER *) SnpPtr)->if_num;\r
+ ((SNP_DRIVER *) SnpPtr)->cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r
+\r
+ //\r
+ // Clear contents of DB buffer.\r
+ //\r
+ ZeroMem (((SNP_DRIVER *) SnpPtr)->db, sizeof (UINT32) * 2);\r
+\r
+ //\r
+ // Issue UNDI command and check result.\r
+ //\r
+ (*((SNP_DRIVER *) SnpPtr)->issue_undi32_command) ((UINT64)(UINTN) &((SNP_DRIVER *) SnpPtr)->cdb);\r
+\r
+ if (((SNP_DRIVER *) SnpPtr)->cdb.StatCode != EFI_SUCCESS) {\r
+ return ;\r
+ }\r
+ //\r
+ // We might have a packet. Check the receive length and signal\r
+ // the event if the length is not zero.\r
+ //\r
+ CopyMem (\r
+ &PxeDbGetStatus,\r
+ ((SNP_DRIVER *) SnpPtr)->db,\r
+ sizeof (UINT32) * 2\r
+ );\r
+\r
+ if (PxeDbGetStatus.RxFrameLen != 0) {\r
+ gBS->SignalEvent (Event);\r
+ }\r
+}\r
+\r
+/* eof - WaitForPacket.c */\r