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