]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
EmulatorPkg: Replace BSD License with BSD+Patent License
[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 /**
21 Caches a pointer PEI Services Table.
22
23 Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
24 in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
25 Pre-EFI Initialization Core Interface Specification.
26
27 If PeiServicesTablePointer is NULL, then ASSERT().
28
29 @param PeiServicesTablePointer The address of PeiServices pointer.
30 **/
31 VOID
32 EFIAPI
33 SetPeiServicesTablePointer (
34 IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
35 )
36 {
37 ASSERT (PeiServicesTablePointer != NULL);
38 ASSERT (*PeiServicesTablePointer != NULL);
39 EMU_MAGIC_PAGE()->PeiServicesTablePointer = PeiServicesTablePointer;
40 }
41
42 /**
43 Retrieves the cached value of the PEI Services Table pointer.
44
45 Returns the cached value of the PEI Services Table pointer in a CPU specific manner
46 as specified in the CPU binding section of the Platform Initialization Pre-EFI
47 Initialization Core Interface Specification.
48
49 If the cached PEI Services Table pointer is NULL, then ASSERT().
50
51 @return The pointer to PeiServices.
52
53 **/
54 CONST EFI_PEI_SERVICES **
55 EFIAPI
56 GetPeiServicesTablePointer (
57 VOID
58 )
59 {
60 CONST EFI_PEI_SERVICES **PeiServicesTablePointer;
61
62 PeiServicesTablePointer = EMU_MAGIC_PAGE()->PeiServicesTablePointer;
63 ASSERT (PeiServicesTablePointer != NULL);
64 ASSERT (*PeiServicesTablePointer != NULL);
65 return PeiServicesTablePointer;
66 }
67
68 /**
69 Perform CPU specific actions required to migrate the PEI Services Table
70 pointer from temporary RAM to permanent RAM.
71
72 For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
73 immediately preceding the Interrupt Descriptor Table (IDT) in memory.
74 For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
75 immediately preceding the Interrupt Descriptor Table (IDT) in memory.
76 For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
77 a dedicated CPU register. This means that there is no memory storage
78 associated with storing the PEI Services Table pointer, so no additional
79 migration actions are required for Itanium or ARM CPUs.
80
81 **/
82 VOID
83 EFIAPI
84 MigratePeiServicesTablePointer (
85 VOID
86 )
87 {
88 //
89 // PEI Services Table pointer is cached in SRAM. No additional
90 // migration actions are required.
91 //
92 return;
93 }
94
95