summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library/DxeNetLib
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-11-20 05:42:23 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-11-20 05:42:23 +0000
commit36ee91ca3661d3d020a7841aacbf858d885c4728 (patch)
tree418e7a4d4a84d86a78d4b260acab20877be5bd45 /MdeModulePkg/Library/DxeNetLib
parent04e12c21476db29e8f92030ed00122fa4e1e56cc (diff)
downloadedk2-platforms-36ee91ca3661d3d020a7841aacbf858d885c4728.tar.xz
1. Add DPC protocol and DpcLib library in MdeModulePkg.
2. Add DpcDxe module and DxeDpcLib module in MdeModulePkg 3. Port network stack module to use DPC. 4. Use MIN, and MAX defined in MdePkg to replace NET_MIN and NET_MAX. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4307 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Library/DxeNetLib')
-rw-r--r--MdeModulePkg/Library/DxeNetLib/DxeNetLib.c72
-rw-r--r--MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf3
2 files changed, 73 insertions, 2 deletions
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index 0eee6076f7..f65489e7ed 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -36,6 +36,8 @@ Abstract:
#include <Library/MemoryAllocationLib.h>
+EFI_DPC_PROTOCOL *mDpc = NULL;
+
//
// All the supported IP4 maskes in host byte order.
//
@@ -227,7 +229,7 @@ NetRandomInitSeed (
UINT32 Seed;
gRT->GetTime (&Time, NULL);
- Seed = (~Time.Hour << 24 | Time.Second << 16 | Time.Minute << 8 | Time.Day);
+ Seed = (~Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second);
Seed ^= Time.Nanosecond;
Seed ^= Time.Year << 7;
@@ -1276,3 +1278,71 @@ NetLibGetNicHandle (
return Handle;
}
+/**
+ Add a Deferred Procedure Call to the end of the DPC queue.
+
+ @DpcTpl The EFI_TPL that the DPC should be invoked.
+ @DpcProcedure Pointer to the DPC's function.
+ @DpcContext Pointer to the DPC's context. Passed to DpcProcedure
+ when DpcProcedure is invoked.
+
+ @retval EFI_SUCCESS The DPC was queued.
+ @retval EFI_INVALID_PARAMETER DpcTpl is not a valid EFI_TPL.
+ DpcProcedure is NULL.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources available to
+ add the DPC to the queue.
+
+**/
+EFI_STATUS
+NetLibQueueDpc (
+ IN EFI_TPL DpcTpl,
+ IN EFI_DPC_PROCEDURE DpcProcedure,
+ IN VOID *DpcContext OPTIONAL
+ )
+{
+ return mDpc->QueueDpc (mDpc, DpcTpl, DpcProcedure, DpcContext);
+}
+
+/**
+ Add a Deferred Procedure Call to the end of the DPC queue.
+
+ @retval EFI_SUCCESS One or more DPCs were invoked.
+ @retval EFI_NOT_FOUND No DPCs were invoked.
+
+**/
+EFI_STATUS
+NetLibDispatchDpc (
+ VOID
+ )
+{
+ return mDpc->DispatchDpc(mDpc);
+}
+
+
+/**
+ The constructor function caches the pointer to DPC protocol.
+
+ The constructor function locates DPC protocol from protocol database.
+ It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+NetLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (&gEfiDpcProtocolGuid, NULL, (VOID**) &mDpc);
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (mDpc != NULL);
+
+ return Status;
+}
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
index 2bd876e9a0..deb8949924 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
@@ -25,6 +25,7 @@
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
+ CONSTRUCTOR = NetLibConstructor
#
# The following information is for reference only and not required by the build tools.
@@ -43,7 +44,6 @@
[LibraryClasses]
- NetLib
BaseLib
DebugLib
BaseMemoryLib
@@ -55,3 +55,4 @@
[Protocols]
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiNicIp4ConfigProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiDpcProtocolGuid # PROTOCOL ALWAYS_CONSUMED