]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/HobLib.h
Update HobLib and PeCoffLib according to MDE Lib Spec 0.61c
[mirror_edk2.git] / MdePkg / Include / Library / HobLib.h
index 4b2745dcefa7fb2c99f774c4f42740af73187620..ae1fb16f8845292fb8d14868658d5e38720f2a85 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Public include file for the HOB Library\r
 \r
-  Copyright (c) 2006, Intel Corporation                                                         \r
+  Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
   All rights reserved. This program and the accompanying materials                          \r
   are licensed and made available under the terms and conditions of the BSD License         \r
   which accompanies this distribution.  The full text of the license may be found at        \r
@@ -10,8 +10,6 @@
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
-  Module Name:  HobLib.h\r
-\r
 **/\r
 \r
 #ifndef __HOB_LIB_H__\r
 \r
 /**\r
   Returns the pointer to the HOB list.\r
+  ASSERT() if the HOB list returned by GetHobList() is NULL.\r
 \r
   This function returns the pointer to first HOB in the list.\r
-\r
+  \r
   @return The pointer to the HOB list.\r
 \r
 **/\r
@@ -29,8 +28,7 @@ VOID *
 EFIAPI\r
 GetHobList (\r
   VOID\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Returns the next instance of a HOB type from the starting HOB.\r
@@ -53,8 +51,7 @@ EFIAPI
 GetNextHob (\r
   IN UINT16                 Type,\r
   IN CONST VOID             *HobStart\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Returns the first instance of a HOB type among the whole HOB list.\r
@@ -71,8 +68,7 @@ VOID *
 EFIAPI\r
 GetFirstHob (\r
   IN UINT16                 Type\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   This function searches the first instance of a HOB from the starting HOB pointer. \r
@@ -98,8 +94,7 @@ EFIAPI
 GetNextGuidHob (\r
   IN CONST EFI_GUID         *Guid,\r
   IN CONST VOID             *HobStart\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   This function searches the first instance of a HOB among the whole HOB list. \r
@@ -119,8 +114,24 @@ VOID *
 EFIAPI\r
 GetFirstGuidHob (\r
   IN CONST EFI_GUID         *Guid\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Get the Boot Mode from the HOB list.\r
+\r
+  This function returns the system boot mode information from the \r
+  PHIT HOB in HOB list.\r
+\r
+  @param  VOID\r
+\r
+  @return The Boot Mode.\r
+\r
+**/\r
+EFI_BOOT_MODE\r
+EFIAPI\r
+GetBootModeHob (\r
+  VOID\r
+  );\r
 \r
 /**\r
   Builds a HOB for a loaded PE32 module.\r
@@ -134,7 +145,7 @@ GetFirstGuidHob (
   @param  ModuleName              The GUID File Name of the module.\r
   @param  MemoryAllocationModule  The 64 bit physical address of the module.\r
   @param  ModuleLength            The length of the module in bytes.\r
-  @param  EntryPoint              The 64 bit physical address of the module\92s entry point.\r
+  @param  EntryPoint              The 64 bit physical address of the module entry point.\r
 \r
 **/\r
 VOID\r
@@ -144,8 +155,7 @@ BuildModuleHob (
   IN EFI_PHYSICAL_ADDRESS   MemoryAllocationModule,\r
   IN UINT64                 ModuleLength,\r
   IN EFI_PHYSICAL_ADDRESS   EntryPoint\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Builds a HOB that describes a chunk of system memory.\r
@@ -168,8 +178,7 @@ BuildResourceDescriptorHob (
   IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,\r
   IN EFI_PHYSICAL_ADDRESS         PhysicalStart,\r
   IN UINT64                       NumberOfBytes\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Builds a GUID HOB with a certain data length.\r
@@ -194,8 +203,7 @@ EFIAPI
 BuildGuidHob (\r
   IN CONST EFI_GUID              *Guid,\r
   IN UINTN                       DataLength\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Copies a data buffer to a newly-built HOB.\r
@@ -223,8 +231,7 @@ BuildGuidDataHob (
   IN CONST EFI_GUID              *Guid,\r
   IN VOID                        *Data,\r
   IN UINTN                       DataLength\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Builds a Firmware Volume HOB.\r
@@ -243,8 +250,30 @@ EFIAPI
 BuildFvHob (\r
   IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
   IN UINT64                      Length\r
-  )\r
-;\r
+  );\r
+\r
+/**\r
+  Builds a EFI_HOB_TYPE_FV2 HOB.\r
+\r
+  This function builds a EFI_HOB_TYPE_FV2 HOB.\r
+  It can only be invoked during PEI phase;\r
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
+  If there is no additional space for HOB creation, then ASSERT().\r
+\r
+  @param  BaseAddress   The base address of the Firmware Volume.\r
+  @param  Length        The size of the Firmware Volume in bytes.\r
+  @param  FvName       The name of the Firmware Volume.\r
+  @param  FileName      The name of the file.\r
+  \r
+**/\r
+VOID\r
+EFIAPI\r
+BuildFv2Hob (\r
+  IN          EFI_PHYSICAL_ADDRESS        BaseAddress,\r
+  IN          UINT64                      Length,\r
+  IN CONST    EFI_GUID                    *FvName,\r
+  IN CONST    EFI_GUID                    *FileName\r
+  );\r
 \r
 /**\r
   Builds a Capsule Volume HOB.\r
@@ -263,8 +292,7 @@ EFIAPI
 BuildCvHob (\r
   IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
   IN UINT64                      Length\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Builds a HOB for the CPU.\r
@@ -283,8 +311,7 @@ EFIAPI
 BuildCpuHob (\r
   IN UINT8                       SizeOfMemorySpace,\r
   IN UINT8                       SizeOfIoSpace\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Builds a HOB for the Stack.\r
@@ -303,8 +330,7 @@ EFIAPI
 BuildStackHob (\r
   IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
   IN UINT64                      Length\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Builds a HOB for the BSP store.\r
@@ -325,8 +351,7 @@ BuildBspStoreHob (
   IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
   IN UINT64                      Length,\r
   IN EFI_MEMORY_TYPE             MemoryType\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Builds a HOB for the memory allocation.\r
@@ -347,7 +372,36 @@ BuildMemoryAllocationHob (
   IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
   IN UINT64                      Length,\r
   IN EFI_MEMORY_TYPE             MemoryType\r
-  )\r
-;\r
+  );\r
+\r
+///\r
+/// Get a HOB's type from HOB header\r
+///\r
+#define GET_HOB_TYPE(Hob)     ((Hob).Header->HobType)\r
+\r
+///\r
+/// Get a HOB's length from HOB header\r
+///\r
+#define GET_HOB_LENGTH(Hob)   ((Hob).Header->HobLength)\r
+\r
+///\r
+/// Get the pointer to next HOB in HOB List\r
+///\r
+#define GET_NEXT_HOB(Hob)     ((Hob).Raw + GET_HOB_LENGTH (Hob))\r
+\r
+///\r
+/// Judge if the HOB is the end of HOB List\r
+///\r
+#define END_OF_HOB_LIST(Hob)  (GET_HOB_TYPE (Hob) == (UINT16)EFI_HOB_TYPE_END_OF_HOB_LIST)\r
+\r
+///\r
+/// Get the pointer to data field of GUID HOB \r
+///\r
+#define GET_GUID_HOB_DATA(GuidHob)      ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))\r
+\r
+///\r
+/// Get the data size of GUID HOB\r
+///\r
+#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))\r
 \r
 #endif\r