PeiServicesTablePointer.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /** @file
  2. PEI Services Table Pointer Library.
  3. Store PEI Services Table pointer via gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage.
  4. This emulates a platform SRAM. The PI mechaism does not work in the emulator due to
  5. lack of privledge.
  6. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
  7. Portiions copyrigth (c) 2011, Apple Inc. All rights reserved.
  8. SPDX-License-Identifier: BSD-2-Clause-Patent
  9. **/
  10. #include <PiPei.h>
  11. #include <Library/PeiServicesTablePointerLib.h>
  12. #include <Library/DebugLib.h>
  13. #include <Library/EmuMagicPageLib.h>
  14. /**
  15. Caches a pointer PEI Services Table.
  16. Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
  17. in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
  18. Pre-EFI Initialization Core Interface Specification.
  19. If PeiServicesTablePointer is NULL, then ASSERT().
  20. @param PeiServicesTablePointer The address of PeiServices pointer.
  21. **/
  22. VOID
  23. EFIAPI
  24. SetPeiServicesTablePointer (
  25. IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
  26. )
  27. {
  28. ASSERT (PeiServicesTablePointer != NULL);
  29. ASSERT (*PeiServicesTablePointer != NULL);
  30. EMU_MAGIC_PAGE ()->PeiServicesTablePointer = PeiServicesTablePointer;
  31. }
  32. /**
  33. Retrieves the cached value of the PEI Services Table pointer.
  34. Returns the cached value of the PEI Services Table pointer in a CPU specific manner
  35. as specified in the CPU binding section of the Platform Initialization Pre-EFI
  36. Initialization Core Interface Specification.
  37. If the cached PEI Services Table pointer is NULL, then ASSERT().
  38. @return The pointer to PeiServices.
  39. **/
  40. CONST EFI_PEI_SERVICES **
  41. EFIAPI
  42. GetPeiServicesTablePointer (
  43. VOID
  44. )
  45. {
  46. CONST EFI_PEI_SERVICES **PeiServicesTablePointer;
  47. PeiServicesTablePointer = EMU_MAGIC_PAGE ()->PeiServicesTablePointer;
  48. ASSERT (PeiServicesTablePointer != NULL);
  49. ASSERT (*PeiServicesTablePointer != NULL);
  50. return PeiServicesTablePointer;
  51. }
  52. /**
  53. Perform CPU specific actions required to migrate the PEI Services Table
  54. pointer from temporary RAM to permanent RAM.
  55. For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
  56. immediately preceding the Interrupt Descriptor Table (IDT) in memory.
  57. For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
  58. immediately preceding the Interrupt Descriptor Table (IDT) in memory.
  59. For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
  60. a dedicated CPU register. This means that there is no memory storage
  61. associated with storing the PEI Services Table pointer, so no additional
  62. migration actions are required for Itanium or ARM CPUs.
  63. **/
  64. VOID
  65. EFIAPI
  66. MigratePeiServicesTablePointer (
  67. VOID
  68. )
  69. {
  70. //
  71. // PEI Services Table pointer is cached in SRAM. No additional
  72. // migration actions are required.
  73. //
  74. return;
  75. }