2 PEI Services Table Pointer Library.
4 This library is used for PEIM which does executed from flash device directly but
7 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
8 Portiions copyrigth (c) 2011, Apple Inc. All rights reserved.
9 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Library/PeiServicesTablePointerLib.h>
15 #include <Library/DebugLib.h>
17 #include <Ppi/MemoryDiscovered.h>
20 CONST EFI_PEI_SERVICES
**gPeiServices
= NULL
;
23 Caches a pointer PEI Services Table.
25 Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
26 in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
27 Pre-EFI Initialization Core Interface Specification.
29 If PeiServicesTablePointer is NULL, then ASSERT().
31 @param PeiServicesTablePointer The address of PeiServices pointer.
35 SetPeiServicesTablePointer (
36 IN CONST EFI_PEI_SERVICES
** PeiServicesTablePointer
39 ASSERT (PeiServicesTablePointer
!= NULL
);
40 ASSERT (*PeiServicesTablePointer
!= NULL
);
41 gPeiServices
= PeiServicesTablePointer
;
45 Retrieves the cached value of the PEI Services Table pointer.
47 Returns the cached value of the PEI Services Table pointer in a CPU specific manner
48 as specified in the CPU binding section of the Platform Initialization Pre-EFI
49 Initialization Core Interface Specification.
51 If the cached PEI Services Table pointer is NULL, then ASSERT().
53 @return The pointer to PeiServices.
56 CONST EFI_PEI_SERVICES
**
58 GetPeiServicesTablePointer (
62 ASSERT (gPeiServices
!= NULL
);
63 ASSERT (*gPeiServices
!= NULL
);
70 Notification service to be called when gEmuThunkPpiGuid is installed.
72 @param PeiServices Indirect reference to the PEI Services Table.
73 @param NotifyDescriptor Address of the notification descriptor data structure. Type
74 EFI_PEI_NOTIFY_DESCRIPTOR is defined above.
75 @param Ppi Address of the PPI that was installed.
77 @retval EFI_STATUS This function will install a PPI to PPI database. The status
78 code will be the code for (*PeiServices)->InstallPpi.
83 PeiServicesTablePointerNotifyCallback (
84 IN EFI_PEI_SERVICES
**PeiServices
,
85 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
89 gPeiServices
= (CONST EFI_PEI_SERVICES
**)PeiServices
;
95 EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList
= {
96 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
97 &gEfiPeiMemoryDiscoveredPpiGuid
,
98 PeiServicesTablePointerNotifyCallback
103 Constructor register notification on when PPI updates. If PPI is
104 alreay installed registering the notify will cause the handle to
107 @param FileHandle The handle of FFS header the loaded driver.
108 @param PeiServices The pointer to the PEI services.
110 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
115 PeiServicesTablePointerLibConstructor (
116 IN EFI_PEI_FILE_HANDLE FileHandle
,
117 IN CONST EFI_PEI_SERVICES
**PeiServices
122 gPeiServices
= (CONST EFI_PEI_SERVICES
**)PeiServices
;
124 // register to be told when PeiServices pointer is updated
125 Status
= (*PeiServices
)->NotifyPpi (PeiServices
, &mNotifyOnThunkList
);
126 ASSERT_EFI_ERROR (Status
);
131 Perform CPU specific actions required to migrate the PEI Services Table
132 pointer from temporary RAM to permanent RAM.
134 For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
135 immediately preceding the Interrupt Descriptor Table (IDT) in memory.
136 For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
137 immediately preceding the Interrupt Descriptor Table (IDT) in memory.
138 For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
139 a dedicated CPU register. This means that there is no memory storage
140 associated with storing the PEI Services Table pointer, so no additional
141 migration actions are required for Itanium or ARM CPUs.
146 MigratePeiServicesTablePointer (
151 // PEI Services Table pointer is cached in the global variable. No additional
152 // migration actions are required.