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