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