]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/DxeHobLib/HobLib.c
Detab
[mirror_edk2.git] / MdePkg / Library / DxeHobLib / HobLib.c
index 41baba2847714d457d7e1eef11f0a94d70e7618b..2e41453a16a4fbd05ccfbe9f7dfa7d9286c7bc12 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
-  HOB Library.\r
+  HOB Library implemenation for Dxe Phase.\r
 \r
-  Copyright (c) 2006, Intel Corporation<BR>\r
+  Copyright (c) 2006 - 2008, Intel Corporation<BR>\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
   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.c\r
-\r
 **/\r
 \r
 \r
 \r
-STATIC VOID  *mHobList = NULL;\r
+#include <PiDxe.h>\r
+\r
+#include <Guid/HobList.h>\r
+\r
+#include <Library/HobLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+VOID  *mHobList = NULL;\r
 \r
 /**\r
   The constructor function caches the pointer to HOB list.\r
@@ -27,7 +34,8 @@ STATIC VOID  *mHobList = NULL;
   @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
+  @retval EFI_SUCCESS   The constructor successfully gets HobList.\r
+  @retval Other value   The constructor can't get HobList.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -42,11 +50,13 @@ HobLibConstructor (
   Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList);\r
   ASSERT_EFI_ERROR (Status);\r
   ASSERT (mHobList != NULL);\r
+\r
   return Status;\r
 }\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
@@ -59,6 +69,7 @@ GetHobList (
   VOID\r
   )\r
 {\r
+  ASSERT (mHobList != NULL);\r
   return mHobList;\r
 }\r
 \r
@@ -189,6 +200,30 @@ GetFirstGuidHob (
   return GetNextGuidHob (Guid, HobList);\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. If PHIT HOB is NULL, then ASSERT().\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
+  EFI_HOB_HANDOFF_INFO_TABLE    *HandOffHob;\r
+\r
+  HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();\r
+\r
+  return  HandOffHob->BootMode;\r
+}\r
+\r
 /**\r
   Builds a HOB for a loaded PE32 module.\r
 \r
@@ -201,7 +236,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's entry point.\r
 \r
 **/\r
 VOID\r
@@ -258,7 +293,7 @@ BuildResourceDescriptorHob (
   for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.\r
   If Guid is NULL, then ASSERT().\r
   If there is no additional space for HOB creation, then ASSERT().\r
-  If DataLength > (0x10000 - sizeof (EFI_HOB_TYPE_GUID)), then ASSERT().\r
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
 \r
   @param  Guid          The GUID to tag the customized HOB.\r
   @param  DataLength    The size of the data payload for the GUID HOB.\r
@@ -291,7 +326,7 @@ BuildGuidHob (
   If Guid is NULL, then ASSERT().\r
   If Data is NULL and DataLength > 0, then ASSERT().\r
   If there is no additional space for HOB creation, then ASSERT().\r
-  If DataLength > (0x10000 - sizeof (EFI_HOB_TYPE_GUID)), then ASSERT().\r
+  If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().\r
 \r
   @param  Guid          The GUID to tag the customized HOB.\r
   @param  Data          The data to be copied into the data field of the GUID HOB.\r
@@ -340,6 +375,33 @@ BuildFvHob (
   ASSERT (FALSE);\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
+  ASSERT (FALSE);\r
+}\r
+\r
+\r
 /**\r
   Builds a Capsule Volume HOB.\r
 \r