MemDetect.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /** @file
  2. Memory Detection for Virtual Machines.
  3. Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
  4. Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. Module Name:
  7. MemDetect.c
  8. **/
  9. //
  10. // The package level header files this module uses
  11. //
  12. #include <PiPei.h>
  13. //
  14. // The Library classes this module consumes
  15. //
  16. #include <Library/BaseMemoryLib.h>
  17. #include <Library/DebugLib.h>
  18. #include <Library/HobLib.h>
  19. #include <Library/IoLib.h>
  20. #include <Library/PcdLib.h>
  21. #include <Library/PeimEntryPoint.h>
  22. #include <Library/ResourcePublicationLib.h>
  23. #include "Platform.h"
  24. /**
  25. Publish PEI core memory.
  26. @return EFI_SUCCESS The PEIM initialized successfully.
  27. **/
  28. EFI_STATUS
  29. PublishPeiMemory (
  30. VOID
  31. )
  32. {
  33. EFI_STATUS Status;
  34. EFI_PHYSICAL_ADDRESS MemoryBase;
  35. UINT64 MemorySize;
  36. //
  37. // TODO: This value should come from platform
  38. // configuration or the memory sizing code.
  39. //
  40. MemoryBase = 0x40000000UL + 0x1000000UL;
  41. MemorySize = 0x40000000UL - 0x1000000UL; // 1GB - 16MB
  42. DEBUG ((DEBUG_INFO, "%a: MemoryBase:0x%x MemorySize:%x\n", __FUNCTION__, MemoryBase, MemorySize));
  43. //
  44. // Publish this memory to the PEI Core
  45. //
  46. Status = PublishSystemMemory (MemoryBase, MemorySize);
  47. ASSERT_EFI_ERROR (Status);
  48. return Status;
  49. }
  50. /**
  51. Publish system RAM and reserve memory regions.
  52. **/
  53. VOID
  54. InitializeRamRegions (
  55. VOID
  56. )
  57. {
  58. //
  59. // TODO: This value should come from platform
  60. // configuration or the memory sizing code.
  61. //
  62. AddMemoryRangeHob (0x41000000UL, 0x41000000UL + 0x3F000000UL);
  63. }