StandaloneMmCoreHobLibInternal.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /** @file
  2. HOB Library implementation for Standalone MM Core.
  3. Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
  4. Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <PiMm.h>
  8. #include <Library/HobLib.h>
  9. #include <Library/DebugLib.h>
  10. #include <Library/BaseMemoryLib.h>
  11. #include <Guid/MemoryAllocationHob.h>
  12. //
  13. // Cache copy of HobList pointer.
  14. //
  15. extern VOID *gHobList;
  16. EFI_HOB_HANDOFF_INFO_TABLE*
  17. HobConstructor (
  18. IN VOID *EfiMemoryBegin,
  19. IN UINTN EfiMemoryLength,
  20. IN VOID *EfiFreeMemoryBottom,
  21. IN VOID *EfiFreeMemoryTop
  22. )
  23. {
  24. EFI_HOB_HANDOFF_INFO_TABLE *Hob;
  25. EFI_HOB_GENERIC_HEADER *HobEnd;
  26. Hob = EfiFreeMemoryBottom;
  27. HobEnd = (EFI_HOB_GENERIC_HEADER *)(Hob+1);
  28. Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
  29. Hob->Header.HobLength = sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
  30. Hob->Header.Reserved = 0;
  31. HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
  32. HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
  33. HobEnd->Reserved = 0;
  34. Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
  35. Hob->BootMode = BOOT_WITH_FULL_CONFIGURATION;
  36. Hob->EfiMemoryTop = (UINTN)EfiMemoryBegin + EfiMemoryLength;
  37. Hob->EfiMemoryBottom = (UINTN)EfiMemoryBegin;
  38. Hob->EfiFreeMemoryTop = (UINTN)EfiFreeMemoryTop;
  39. Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
  40. Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
  41. gHobList = Hob;
  42. return Hob;
  43. }