]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
1. Add DPC protocol and DpcLib library in MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Library / DxeNetLib / DxeNetLib.c
index 0eee6076f71ea52028a42167ccef3e5865201c13..f65489e7ed71b4c89ebaecfa06b1c2cc07629d60 100644 (file)
@@ -36,6 +36,8 @@ Abstract:
 #include <Library/MemoryAllocationLib.h>\r
 \r
 \r
+EFI_DPC_PROTOCOL *mDpc = NULL;\r
+\r
 //\r
 // All the supported IP4 maskes in host byte order.\r
 //\r
@@ -227,7 +229,7 @@ NetRandomInitSeed (
   UINT32                    Seed;\r
 \r
   gRT->GetTime (&Time, NULL);\r
-  Seed = (~Time.Hour << 24 | Time.Second << 16 | Time.Minute << 8 | Time.Day);\r
+  Seed = (~Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second);\r
   Seed ^= Time.Nanosecond;\r
   Seed ^= Time.Year << 7;\r
 \r
@@ -1276,3 +1278,71 @@ NetLibGetNicHandle (
   return Handle;\r
 }\r
 \r
+/**\r
+  Add a Deferred Procedure Call to the end of the DPC queue.\r
+\r
+  @DpcTpl           The EFI_TPL that the DPC should be invoked.\r
+  @DpcProcedure     Pointer to the DPC's function.\r
+  @DpcContext       Pointer to the DPC's context.  Passed to DpcProcedure\r
+                    when DpcProcedure is invoked.\r
+\r
+  @retval  EFI_SUCCESS              The DPC was queued.\r
+  @retval  EFI_INVALID_PARAMETER    DpcTpl is not a valid EFI_TPL.\r
+                                    DpcProcedure is NULL.\r
+  @retval  EFI_OUT_OF_RESOURCES     There are not enough resources available to\r
+                                    add the DPC to the queue.\r
+\r
+**/\r
+EFI_STATUS\r
+NetLibQueueDpc (\r
+  IN EFI_TPL            DpcTpl,\r
+  IN EFI_DPC_PROCEDURE  DpcProcedure,\r
+  IN VOID               *DpcContext    OPTIONAL\r
+  )\r
+{\r
+  return mDpc->QueueDpc (mDpc, DpcTpl, DpcProcedure, DpcContext);\r
+}\r
+\r
+/**\r
+  Add a Deferred Procedure Call to the end of the DPC queue.\r
+\r
+  @retval  EFI_SUCCESS              One or more DPCs were invoked.\r
+  @retval  EFI_NOT_FOUND            No DPCs were invoked.\r
+\r
+**/\r
+EFI_STATUS\r
+NetLibDispatchDpc (\r
+  VOID\r
+  )\r
+{\r
+  return mDpc->DispatchDpc(mDpc);\r
+}\r
+\r
+\r
+/**\r
+  The constructor function caches the pointer to DPC protocol.\r
+\r
+  The constructor function locates DPC protocol from protocol database.\r
+  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+NetLibConstructor (\r
+  IN EFI_HANDLE                ImageHandle,\r
+  IN EFI_SYSTEM_TABLE          *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiDpcProtocolGuid, NULL, (VOID**) &mDpc);\r
+  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (mDpc != NULL);\r
+\r
+  return Status;\r
+}\r