]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c
1) Sync EdkCompatibilityPkg with EDK 1.04. The changes includes:
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Pei / Hob / PeiHobLib.c
index c28fd0386f1f2c831aef26fd5605be8f3ea808e0..02ffcda34d419d1570a71dea73d3ccecd8c33f3b 100644 (file)
@@ -420,7 +420,7 @@ Returns:
   CopyMem(&(Hob.MemoryAllocationStack->AllocDescriptor.Name), &gEfiHobMemeryAllocStackGuid, sizeof(EFI_GUID));\r
   (Hob.MemoryAllocationStack->AllocDescriptor).MemoryBaseAddress = BaseAddress;\r
   (Hob.MemoryAllocationStack->AllocDescriptor).MemoryLength      = Length;\r
-  (Hob.MemoryAllocationStack->AllocDescriptor).MemoryType  = EfiConventionalMemory;\r
+  (Hob.MemoryAllocationStack->AllocDescriptor).MemoryType  = EfiBootServicesData;\r
 \r
   Hob.MemoryAllocationStack++;\r
   HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;\r
@@ -601,3 +601,121 @@ Returns:
 \r
   return Status;\r
 }\r
+\r
+VOID *\r
+GetHob (\r
+  IN UINT16  Type,\r
+  IN VOID    *HobStart\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  This function returns the first instance of a HOB type in a HOB list.\r
+  \r
+Arguments:\r
+\r
+  Type          The HOB type to return.\r
+  HobStart      The first HOB in the HOB list.\r
+    \r
+Returns:\r
+\r
+  HobStart      There were no HOBs found with the requested type.\r
+  else          Returns the first HOB with the matching type.\r
+\r
+--*/\r
+{\r
+  EFI_PEI_HOB_POINTERS  Hob;\r
+\r
+  Hob.Raw = HobStart;\r
+  //\r
+  // Return input if not found\r
+  //\r
+  if (HobStart == NULL) {\r
+    return HobStart;\r
+  }\r
+\r
+  //\r
+  // Parse the HOB list, stop if end of list or matching type found.\r
+  //\r
+  while (!END_OF_HOB_LIST (Hob)) {\r
+\r
+    if (Hob.Header->HobType == Type) {\r
+      break;\r
+    }\r
+\r
+    Hob.Raw = GET_NEXT_HOB (Hob);\r
+  }\r
+  \r
+  //\r
+  // Return input if not found\r
+  //\r
+  if (END_OF_HOB_LIST (Hob)) {\r
+    return HobStart;\r
+  }\r
+\r
+  return (VOID *) (Hob.Raw);\r
+}\r
+\r
+EFI_STATUS\r
+GetNextGuidHob (\r
+  IN OUT VOID      **HobStart,\r
+  IN     EFI_GUID  * Guid,\r
+  OUT    VOID      **Buffer,\r
+  OUT    UINTN     *BufferSize OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Get the next guid hob.\r
+  \r
+Arguments:\r
+  HobStart        A pointer to the start hob.\r
+  Guid            A pointer to a guid.\r
+  Buffer          A pointer to the buffer.\r
+  BufferSize      Buffer size.\r
+  \r
+Returns:\r
+  Status code.\r
+\r
+  EFI_NOT_FOUND          - Next Guid hob not found\r
+  \r
+  EFI_SUCCESS            - Next Guid hob found and data for this Guid got\r
+  \r
+  EFI_INVALID_PARAMETER  - invalid parameter\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PEI_HOB_POINTERS  GuidHob;\r
+\r
+  if (Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {\r
+\r
+    GuidHob.Raw = *HobStart;\r
+    if (END_OF_HOB_LIST (GuidHob)) {\r
+      return EFI_NOT_FOUND;\r
+    }\r
+\r
+    GuidHob.Raw = GetHob (EFI_HOB_TYPE_GUID_EXTENSION, *HobStart);\r
+    if (GuidHob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {\r
+      if ( ((INT32 *)Guid)[0] == ((INT32 *)&GuidHob.Guid->Name)[0] &&\r
+           ((INT32 *)Guid)[1] == ((INT32 *)&GuidHob.Guid->Name)[1] &&\r
+           ((INT32 *)Guid)[2] == ((INT32 *)&GuidHob.Guid->Name)[2] &&\r
+           ((INT32 *)Guid)[3] == ((INT32 *)&GuidHob.Guid->Name)[3] ) {\r
+        Status  = EFI_SUCCESS;\r
+        *Buffer = (VOID *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));\r
+        if (BufferSize != NULL) {\r
+          *BufferSize = GuidHob.Header->HobLength - sizeof (EFI_HOB_GUID_TYPE);\r
+        }\r
+      }\r
+    }\r
+\r
+    *HobStart = GET_NEXT_HOB (GuidHob);\r
+  }\r
+\r
+  return Status;\r
+}\r