]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/DxeHobLib/HobLib.c
Update HobLib and PeCoffLib according to MDE Lib Spec 0.61c
[mirror_edk2.git] / MdePkg / Library / DxeHobLib / HobLib.c
index b4ad4ff2f0448d362ec3ab14ceb42436604241e3..d6e9e5fed699ac0460eb14a6dae925baab73124e 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
+#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
 STATIC VOID  *mHobList = NULL;\r
 \r
 /**\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
@@ -39,14 +47,16 @@ HobLibConstructor (
 {\r
   EFI_STATUS  Status;\r
 \r
-  Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList);\r
+       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
@@ -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