]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/SnpDxe/WaitForPacket.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / SnpDxe / WaitForPacket.c
CommitLineData
8a67d61d 1/** @file\r
4cda7726 2 Event handler to check for available packet.\r
3\r
4Copyright (c) 2004 - 2008, Intel Corporation. <BR> \r
5All rights reserved. This program and the accompanying materials are licensed \r
6and made available under the terms and conditions of the BSD License which \r
7accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
8a67d61d 9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
8a67d61d 13**/\r
14\r
15#include "Snp.h"\r
16\r
17\r
18/**\r
4cda7726 19 Nofication call back function for WaitForPacket event.\r
8a67d61d 20\r
4cda7726 21 @param Event EFI Event.\r
22 @param SnpPtr Pointer to SNP_DRIVER structure.\r
8a67d61d 23\r
24**/\r
25VOID\r
26EFIAPI\r
27SnpWaitForPacketNotify (\r
28 EFI_EVENT Event,\r
29 VOID *SnpPtr\r
30 )\r
31{\r
32 PXE_DB_GET_STATUS PxeDbGetStatus;\r
33\r
34 //\r
35 // Do nothing if either parameter is a NULL pointer.\r
36 //\r
37 if (Event == NULL || SnpPtr == NULL) {\r
38 return ;\r
39 }\r
40 //\r
41 // Do nothing if the SNP interface is not initialized.\r
42 //\r
4cda7726 43 switch (((SNP_DRIVER *) SnpPtr)->Mode.State) {\r
8a67d61d 44 case EfiSimpleNetworkInitialized:\r
45 break;\r
46\r
47 case EfiSimpleNetworkStopped:\r
48 case EfiSimpleNetworkStarted:\r
49 default:\r
50 return ;\r
51 }\r
52 //\r
53 // Fill in CDB for UNDI GetStatus().\r
54 //\r
4cda7726 55 ((SNP_DRIVER *) SnpPtr)->Cdb.OpCode = PXE_OPCODE_GET_STATUS;\r
56 ((SNP_DRIVER *) SnpPtr)->Cdb.OpFlags = 0;\r
57 ((SNP_DRIVER *) SnpPtr)->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r
58 ((SNP_DRIVER *) SnpPtr)->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r
59 ((SNP_DRIVER *) SnpPtr)->Cdb.DBsize = sizeof (UINT32) * 2;\r
60 ((SNP_DRIVER *) SnpPtr)->Cdb.DBaddr = (UINT64)(UINTN) (((SNP_DRIVER *) SnpPtr)->Db);\r
61 ((SNP_DRIVER *) SnpPtr)->Cdb.StatCode = PXE_STATCODE_INITIALIZE;\r
62 ((SNP_DRIVER *) SnpPtr)->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r
63 ((SNP_DRIVER *) SnpPtr)->Cdb.IFnum = ((SNP_DRIVER *) SnpPtr)->IfNum;\r
64 ((SNP_DRIVER *) SnpPtr)->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r
8a67d61d 65\r
66 //\r
67 // Clear contents of DB buffer.\r
68 //\r
4cda7726 69 ZeroMem (((SNP_DRIVER *) SnpPtr)->Db, sizeof (UINT32) * 2);\r
8a67d61d 70\r
71 //\r
72 // Issue UNDI command and check result.\r
73 //\r
4cda7726 74 (*((SNP_DRIVER *) SnpPtr)->IssueUndi32Command) ((UINT64)(UINTN) &((SNP_DRIVER *) SnpPtr)->Cdb);\r
8a67d61d 75\r
4cda7726 76 if (((SNP_DRIVER *) SnpPtr)->Cdb.StatCode != EFI_SUCCESS) {\r
8a67d61d 77 return ;\r
78 }\r
79 //\r
80 // We might have a packet. Check the receive length and signal\r
81 // the event if the length is not zero.\r
82 //\r
83 CopyMem (\r
84 &PxeDbGetStatus,\r
4cda7726 85 ((SNP_DRIVER *) SnpPtr)->Db,\r
8a67d61d 86 sizeof (UINT32) * 2\r
87 );\r
88\r
89 if (PxeDbGetStatus.RxFrameLen != 0) {\r
90 gBS->SignalEvent (Event);\r
91 }\r
92}\r
93\r
94/* eof - WaitForPacket.c */\r