TianoCore EDK2 master
Loading...
Searching...
No Matches
WaitForPacket.c
Go to the documentation of this file.
1
9#include "Snp.h"
10
18VOID
19EFIAPI
21 EFI_EVENT Event,
22 VOID *SnpPtr
23 )
24{
25 PXE_DB_GET_STATUS PxeDbGetStatus;
26
27 //
28 // Do nothing if either parameter is a NULL pointer.
29 //
30 if ((Event == NULL) || (SnpPtr == NULL)) {
31 return;
32 }
33
34 //
35 // Do nothing if the SNP interface is not initialized.
36 //
37 switch (((SNP_DRIVER *)SnpPtr)->Mode.State) {
38 case EfiSimpleNetworkInitialized:
39 break;
40
41 case EfiSimpleNetworkStopped:
42 case EfiSimpleNetworkStarted:
43 default:
44 return;
45 }
46
47 //
48 // Fill in CDB for UNDI GetStatus().
49 //
50 ((SNP_DRIVER *)SnpPtr)->Cdb.OpCode = PXE_OPCODE_GET_STATUS;
51 ((SNP_DRIVER *)SnpPtr)->Cdb.OpFlags = 0;
52 ((SNP_DRIVER *)SnpPtr)->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;
53 ((SNP_DRIVER *)SnpPtr)->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;
54 ((SNP_DRIVER *)SnpPtr)->Cdb.DBsize = (UINT16)(sizeof (UINT32) * 2);
55 ((SNP_DRIVER *)SnpPtr)->Cdb.DBaddr = (UINT64)(UINTN)(((SNP_DRIVER *)SnpPtr)->Db);
56 ((SNP_DRIVER *)SnpPtr)->Cdb.StatCode = PXE_STATCODE_INITIALIZE;
57 ((SNP_DRIVER *)SnpPtr)->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;
58 ((SNP_DRIVER *)SnpPtr)->Cdb.IFnum = ((SNP_DRIVER *)SnpPtr)->IfNum;
59 ((SNP_DRIVER *)SnpPtr)->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;
60
61 //
62 // Clear contents of DB buffer.
63 //
64 ZeroMem (((SNP_DRIVER *)SnpPtr)->Db, sizeof (UINT32) * 2);
65
66 //
67 // Issue UNDI command and check result.
68 //
69 (*((SNP_DRIVER *)SnpPtr)->IssueUndi32Command)((UINT64)(UINTN)&((SNP_DRIVER *)SnpPtr)->Cdb);
70
71 if (((SNP_DRIVER *)SnpPtr)->Cdb.StatCode != EFI_SUCCESS) {
72 return;
73 }
74
75 //
76 // We might have a packet. Check the receive length and signal
77 // the event if the length is not zero.
78 //
79 CopyMem (
80 &PxeDbGetStatus,
81 ((SNP_DRIVER *)SnpPtr)->Db,
82 sizeof (UINT32) * 2
83 );
84
85 if (PxeDbGetStatus.RxFrameLen != 0) {
86 gBS->SignalEvent (Event);
87 }
88}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define NULL
Definition: Base.h:319
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
#define PXE_CPBSIZE_NOT_USED
zero
Definition: UefiPxe.h:57
#define PXE_OPCODE_GET_STATUS
Definition: UefiPxe.h:155
#define PXE_CPBADDR_NOT_USED
zero
Definition: UefiPxe.h:59
VOID EFIAPI SnpWaitForPacketNotify(EFI_EVENT Event, VOID *SnpPtr)
Definition: WaitForPacket.c:20
Definition: Snp.h:55
PXE_UINT32 RxFrameLen
Definition: UefiPxe.h:1555