/** @file\r
This module provide Hand-Off Block manupulation.\r
\r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, 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
return EFI_SUCCESS; \r
}\r
\r
+/**\r
+ Install SEC HOB data to the HOB List.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param SecHobList Pointer to SEC HOB List.\r
+\r
+ @return EFI_SUCCESS Success to install SEC HOB data.\r
+ @retval EFI_OUT_OF_RESOURCES If there is no more memory to grow the Hoblist.\r
+\r
+**/\r
+EFI_STATUS\r
+PeiInstallSecHobData (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_HOB_GENERIC_HEADER *SecHobList\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;\r
+ EFI_PEI_HOB_POINTERS HobStart;\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+ UINTN SecHobListLength;\r
+ EFI_PHYSICAL_ADDRESS FreeMemory;\r
+ EFI_HOB_GENERIC_HEADER *HobEnd;\r
+\r
+ HandOffHob = NULL;\r
+ Status = PeiGetHobList (PeiServices, (VOID **) &HandOffHob);\r
+ if (EFI_ERROR(Status)) {\r
+ return Status;\r
+ }\r
+ ASSERT (HandOffHob != NULL);\r
+\r
+ HobStart.Raw = (UINT8 *) SecHobList;\r
+ //\r
+ // The HobList must not contain a EFI_HOB_HANDOFF_INFO_TABLE HOB (PHIT) HOB.\r
+ //\r
+ ASSERT (HobStart.Header->HobType != EFI_HOB_TYPE_HANDOFF);\r
+ //\r
+ // Calculate the SEC HOB List length,\r
+ // not including the terminated HOB(EFI_HOB_TYPE_END_OF_HOB_LIST).\r
+ //\r
+ for (Hob.Raw = HobStart.Raw; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob));\r
+ SecHobListLength = (UINTN) Hob.Raw - (UINTN) HobStart.Raw;\r
+ //\r
+ // The length must be 8-bytes aligned.\r
+ //\r
+ ASSERT ((SecHobListLength & 0x7) == 0);\r
+\r
+ FreeMemory = HandOffHob->EfiFreeMemoryTop -\r
+ HandOffHob->EfiFreeMemoryBottom;\r
+\r
+ if (FreeMemory < SecHobListLength) {\r
+ DEBUG ((DEBUG_ERROR, "PeiInstallSecHobData fail: SecHobListLength - 0x%08x\n", SecHobListLength));\r
+ DEBUG ((DEBUG_ERROR, " FreeMemoryTop - 0x%08x\n", (UINTN)HandOffHob->EfiFreeMemoryTop));\r
+ DEBUG ((DEBUG_ERROR, " FreeMemoryBottom - 0x%08x\n", (UINTN)HandOffHob->EfiFreeMemoryBottom));\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ Hob.Raw = (UINT8 *) (UINTN) HandOffHob->EfiEndOfHobList;\r
+ CopyMem (Hob.Raw, HobStart.Raw, SecHobListLength);\r
+\r
+ HobEnd = (EFI_HOB_GENERIC_HEADER *) ((UINTN) Hob.Raw + SecHobListLength);\r
+ HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;\r
+\r
+ HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;\r
+ HobEnd->HobLength = (UINT16) sizeof (EFI_HOB_GENERIC_HEADER);\r
+ HobEnd->Reserved = 0;\r
+ HobEnd++;\r
+ HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
/**\r
\r
Builds a Handoff Information Table HOB\r