PeiServicesTablePointer.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /** @file
  2. PEI Services Table Pointer Library.
  3. This library is used for PEIM which does executed from flash device directly but
  4. executed in memory.
  5. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
  6. SPDX-License-Identifier: BSD-2-Clause-Patent
  7. **/
  8. #include <PiPei.h>
  9. #include <Library/PeiServicesTablePointerLib.h>
  10. #include <Library/DebugLib.h>
  11. CONST EFI_PEI_SERVICES **gPeiServices;
  12. /**
  13. Caches a pointer PEI Services Table.
  14. Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
  15. in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
  16. Pre-EFI Initialization Core Interface Specification.
  17. If PeiServicesTablePointer is NULL, then ASSERT().
  18. @param PeiServicesTablePointer The address of PeiServices pointer.
  19. **/
  20. VOID
  21. EFIAPI
  22. SetPeiServicesTablePointer (
  23. IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
  24. )
  25. {
  26. ASSERT (PeiServicesTablePointer != NULL);
  27. gPeiServices = PeiServicesTablePointer;
  28. }
  29. /**
  30. Retrieves the cached value of the PEI Services Table pointer.
  31. Returns the cached value of the PEI Services Table pointer in a CPU specific manner
  32. as specified in the CPU binding section of the Platform Initialization Pre-EFI
  33. Initialization Core Interface Specification.
  34. If the cached PEI Services Table pointer is NULL, then ASSERT().
  35. @return The pointer to PeiServices.
  36. **/
  37. CONST EFI_PEI_SERVICES **
  38. EFIAPI
  39. GetPeiServicesTablePointer (
  40. VOID
  41. )
  42. {
  43. ASSERT (gPeiServices != NULL);
  44. return gPeiServices;
  45. }
  46. /**
  47. The constructor function caches the pointer to PEI services.
  48. The constructor function caches the pointer to PEI services.
  49. It will always return EFI_SUCCESS.
  50. @param FileHandle The handle of FFS header the loaded driver.
  51. @param PeiServices The pointer to the PEI services.
  52. @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
  53. **/
  54. EFI_STATUS
  55. EFIAPI
  56. PeiServicesTablePointerLibConstructor (
  57. IN EFI_PEI_FILE_HANDLE FileHandle,
  58. IN CONST EFI_PEI_SERVICES **PeiServices
  59. )
  60. {
  61. gPeiServices = PeiServices;
  62. return EFI_SUCCESS;
  63. }
  64. /**
  65. Perform CPU specific actions required to migrate the PEI Services Table
  66. pointer from temporary RAM to permanent RAM.
  67. For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
  68. immediately preceding the Interrupt Descriptor Table (IDT) in memory.
  69. For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
  70. immediately preceding the Interrupt Descriptor Table (IDT) in memory.
  71. For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
  72. a dedicated CPU register. This means that there is no memory storage
  73. associated with storing the PEI Services Table pointer, so no additional
  74. migration actions are required for Itanium or ARM CPUs.
  75. **/
  76. VOID
  77. EFIAPI
  78. MigratePeiServicesTablePointer (
  79. VOID
  80. )
  81. {
  82. //
  83. // PEI Services Table pointer is cached in the global variable. No additional
  84. // migration actions are required.
  85. //
  86. return;
  87. }