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>
19 CONST EFI_PEI_SERVICES
**gPeiServices
= NULL
;
22 Caches a pointer PEI Services Table.
24 Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
25 in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
26 Pre-EFI Initialization Core Interface Specification.
28 If PeiServicesTablePointer is NULL, then ASSERT().
30 @param PeiServicesTablePointer The address of PeiServices pointer.
34 SetPeiServicesTablePointer (
35 IN CONST EFI_PEI_SERVICES
**PeiServicesTablePointer
38 ASSERT (PeiServicesTablePointer
!= NULL
);
39 ASSERT (*PeiServicesTablePointer
!= NULL
);
40 gPeiServices
= PeiServicesTablePointer
;
44 Retrieves the cached value of the PEI Services Table pointer.
46 Returns the cached value of the PEI Services Table pointer in a CPU specific manner
47 as specified in the CPU binding section of the Platform Initialization Pre-EFI
48 Initialization Core Interface Specification.
50 If the cached PEI Services Table pointer is NULL, then ASSERT().
52 @return The pointer to PeiServices.
55 CONST EFI_PEI_SERVICES
**
57 GetPeiServicesTablePointer (
61 ASSERT (gPeiServices
!= NULL
);
62 ASSERT (*gPeiServices
!= NULL
);
67 Notification service to be called when gEmuThunkPpiGuid is installed.
69 @param PeiServices Indirect reference to the PEI Services Table.
70 @param NotifyDescriptor Address of the notification descriptor data structure. Type
71 EFI_PEI_NOTIFY_DESCRIPTOR is defined above.
72 @param Ppi Address of the PPI that was installed.
74 @retval EFI_STATUS This function will install a PPI to PPI database. The status
75 code will be the code for (*PeiServices)->InstallPpi.
80 PeiServicesTablePointerNotifyCallback (
81 IN EFI_PEI_SERVICES
**PeiServices
,
82 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
86 gPeiServices
= (CONST EFI_PEI_SERVICES
**)PeiServices
;
91 EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList
= {
92 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
93 &gEfiPeiMemoryDiscoveredPpiGuid
,
94 PeiServicesTablePointerNotifyCallback
98 Constructor register notification on when PPI updates. If PPI is
99 alreay installed registering the notify will cause the handle to
102 @param FileHandle The handle of FFS header the loaded driver.
103 @param PeiServices The pointer to the PEI services.
105 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
110 PeiServicesTablePointerLibConstructor (
111 IN EFI_PEI_FILE_HANDLE FileHandle
,
112 IN CONST EFI_PEI_SERVICES
**PeiServices
117 gPeiServices
= (CONST EFI_PEI_SERVICES
**)PeiServices
;
119 // register to be told when PeiServices pointer is updated
120 Status
= (*PeiServices
)->NotifyPpi (PeiServices
, &mNotifyOnThunkList
);
121 ASSERT_EFI_ERROR (Status
);
126 Perform CPU specific actions required to migrate the PEI Services Table
127 pointer from temporary RAM to permanent RAM.
129 For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
130 immediately preceding the Interrupt Descriptor Table (IDT) in memory.
131 For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
132 immediately preceding the Interrupt Descriptor Table (IDT) in memory.
133 For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
134 a dedicated CPU register. This means that there is no memory storage
135 associated with storing the PEI Services Table pointer, so no additional
136 migration actions are required for Itanium or ARM CPUs.
141 MigratePeiServicesTablePointer (
146 // PEI Services Table pointer is cached in the global variable. No additional
147 // migration actions are required.