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