]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiHobLib/HobLib.c
Refine code.
[mirror_edk2.git] / MdePkg / Library / PeiHobLib / HobLib.c
index f0cc665085bc46dc5a4b4143a0e6e7b3e67148b4..604cee996c8622f904f7f3cf6b8ce6de267ca98a 100644 (file)
@@ -1,11 +1,11 @@
 /** @file\r
   Provide Hob Library functions for Pei phase.\r
 \r
-Copyright (c) 2007 - 2009, Intel Corporation<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+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
-http://opensource.org/licenses/bsd-license.php\r
+http://opensource.org/licenses/bsd-license.php.\r
 \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
@@ -127,7 +127,7 @@ GetFirstHob (
   its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid. \r
   If there does not exist such HOB from the starting HOB pointer, it will return NULL. \r
   Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
-  to extract the data section and its size info respectively.\r
+  to extract the data section and its size information, respectively.\r
   In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer\r
   unconditionally: it returns HobStart back if HobStart itself meets the requirement;\r
   caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.\r
@@ -168,7 +168,7 @@ GetNextGuidHob (
   its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.\r
   If there does not exist such HOB from the starting HOB pointer, it will return NULL.\r
   Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()\r
-  to extract the data section and its size info respectively.\r
+  to extract the data section and its size information, respectively.\r
   \r
   If the pointer to the HOB list is NULL, then ASSERT().\r
   If Guid is NULL, then ASSERT().\r
@@ -198,7 +198,7 @@ GetFirstGuidHob (
 \r
   If the pointer to the HOB list is NULL, then ASSERT().\r
   \r
-  @param  VOID\r
+  @param  VOID.\r
 \r
   @return The Boot Mode.\r
 \r
@@ -277,7 +277,7 @@ BuildModuleHob (
   ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&\r
           ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));\r
 \r
   CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);\r
   Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;\r
@@ -319,7 +319,7 @@ BuildResourceDescriptorHob (
 {\r
   EFI_HOB_RESOURCE_DESCRIPTOR  *Hob;\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, (UINT16) sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));\r
 \r
   Hob->ResourceType      = ResourceType;\r
   Hob->ResourceAttribute = ResourceAttribute;\r
@@ -428,7 +428,7 @@ BuildFvHob (
 {\r
   EFI_HOB_FIRMWARE_VOLUME  *Hob;\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME));\r
 \r
   Hob->BaseAddress = BaseAddress;\r
   Hob->Length      = Length;\r
@@ -460,7 +460,7 @@ BuildFv2Hob (
 {\r
   EFI_HOB_FIRMWARE_VOLUME2  *Hob;\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV2, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME2));\r
 \r
   Hob->BaseAddress = BaseAddress;\r
   Hob->Length      = Length;\r
@@ -489,7 +489,12 @@ BuildCvHob (
   IN UINT64                      Length\r
   )\r
 {\r
-  ASSERT (FALSE);\r
+  EFI_HOB_UEFI_CAPSULE  *Hob;\r
+\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_UEFI_CAPSULE, (UINT16) sizeof (EFI_HOB_UEFI_CAPSULE));\r
+\r
+  Hob->BaseAddress  = BaseAddress;\r
+  Hob->Length       = Length;\r
 }\r
 \r
 /**\r
@@ -514,7 +519,7 @@ BuildCpuHob (
 {\r
   EFI_HOB_CPU  *Hob;\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, (UINT16) sizeof (EFI_HOB_CPU));\r
 \r
   Hob->SizeOfMemorySpace = SizeOfMemorySpace;\r
   Hob->SizeOfIoSpace     = SizeOfIoSpace;\r
@@ -550,7 +555,7 @@ BuildStackHob (
   ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r
           ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));\r
 \r
   CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);\r
   Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
@@ -574,7 +579,7 @@ BuildStackHob (
 \r
   @param  BaseAddress   The 64 bit physical address of the BSP.\r
   @param  Length        The length of the BSP store in bytes.\r
-  @param  MemoryType    Type of memory allocated by this HOB.\r
+  @param  MemoryType    The type of memory allocated by this HOB.\r
 \r
 **/\r
 VOID\r
@@ -590,7 +595,7 @@ BuildBspStoreHob (
   ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r
           ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));\r
 \r
   CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid);\r
   Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
@@ -614,7 +619,7 @@ BuildBspStoreHob (
 \r
   @param  BaseAddress   The 64 bit physical address of the memory.\r
   @param  Length        The length of the memory allocation in bytes.\r
-  @param  MemoryType    Type of memory allocated by this HOB.\r
+  @param  MemoryType    The type of memory allocated by this HOB.\r
 \r
 **/\r
 VOID\r
@@ -630,7 +635,7 @@ BuildMemoryAllocationHob (
   ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r
           ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r
   \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION));\r
   \r
   ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));\r
   Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
@@ -641,30 +646,3 @@ BuildMemoryAllocationHob (
   //\r
   ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));\r
 }\r
-\r
-/**\r
-  Builds an UEFI Capsule HOB.\r
-\r
-  This function builds an UEFI Capsule 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 physical memory-mapped base address of an UEFI capsule.\r
-  @param  Length        The length of the contiguous memory in bytes.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BuildCapsuleHob (\r
-  IN EFI_PHYSICAL_ADDRESS        BaseAddress,\r
-  IN UINT64                      Length\r
-  )\r
-{\r
-  EFI_HOB_UEFI_CAPSULE  *Hob;\r
-\r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_UEFI_CAPSULE, sizeof (EFI_HOB_UEFI_CAPSULE));\r
-\r
-  Hob->BaseAddress  = BaseAddress;\r
-  Hob->Length       = Length;\r
-}\r