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