]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
MdePkg/BasePeCoffLib: Add more check for relocation data
[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
19388d29 8 This program and the accompanying materials\r
e386b444 9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
2fc59a00 11 http://opensource.org/licenses/bsd-license.php.\r
e386b444 12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
e386b444 16**/\r
17\r
c7d265a9 18#include <PiPei.h>\r
c7d265a9 19#include <Library/PeiServicesTablePointerLib.h>\r
20#include <Library/DebugLib.h>\r
e386b444 21\r
fe467413 22CONST EFI_PEI_SERVICES **gPeiServices;\r
e386b444 23\r
81c7803c 24/**\r
9095d37b
LG
25 Caches a pointer PEI Services Table.\r
26\r
27 Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer\r
28 in a CPU specific manner as specified in the CPU binding section of the Platform Initialization\r
29 Pre-EFI Initialization Core Interface Specification.\r
30\r
4b8157f9 31 If PeiServicesTablePointer is NULL, then ASSERT().\r
9095d37b 32\r
f38fdc74 33 @param PeiServicesTablePointer The address of PeiServices pointer.\r
81c7803c 34**/\r
b0d803fe 35VOID\r
36EFIAPI\r
37SetPeiServicesTablePointer (\r
f38fdc74 38 IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
b0d803fe 39 )\r
40{\r
4b8157f9 41 ASSERT (PeiServicesTablePointer != NULL);\r
6c448d5b 42 gPeiServices = PeiServicesTablePointer;\r
b0d803fe 43}\r
44\r
e386b444 45/**\r
4b8157f9 46 Retrieves the cached value of the PEI Services Table pointer.\r
e386b444 47\r
9095d37b
LG
48 Returns the cached value of the PEI Services Table pointer in a CPU specific manner\r
49 as specified in the CPU binding section of the Platform Initialization Pre-EFI\r
4b8157f9 50 Initialization Core Interface Specification.\r
9095d37b 51\r
4b8157f9 52 If the cached PEI Services Table pointer is NULL, then ASSERT().\r
e386b444 53\r
4b8157f9 54 @return The pointer to PeiServices.\r
e386b444 55\r
56**/\r
5240b97c 57CONST EFI_PEI_SERVICES **\r
2884e3df 58EFIAPI\r
e386b444 59GetPeiServicesTablePointer (\r
60 VOID\r
61 )\r
62{\r
63 ASSERT (gPeiServices != NULL);\r
a86fda43 64 return gPeiServices;\r
e386b444 65}\r
66\r
67\r
68/**\r
69 The constructor function caches the pointer to PEI services.\r
9095d37b 70\r
e386b444 71 The constructor function caches the pointer to PEI services.\r
72 It will always return EFI_SUCCESS.\r
73\r
58380e9c 74 @param FileHandle The handle of FFS header the loaded driver.\r
75 @param PeiServices The pointer to the PEI services.\r
e386b444 76\r
58380e9c 77 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
e386b444 78\r
79**/\r
80EFI_STATUS\r
81EFIAPI\r
82PeiServicesTablePointerLibConstructor (\r
a86fda43 83 IN EFI_PEI_FILE_HANDLE FileHandle,\r
84 IN CONST EFI_PEI_SERVICES **PeiServices\r
e386b444 85 )\r
86{\r
87 gPeiServices = PeiServices;\r
88 return EFI_SUCCESS;\r
89}\r
81c7803c 90\r
ffdb421c 91/**\r
9095d37b 92 Perform CPU specific actions required to migrate the PEI Services Table\r
ffdb421c
LG
93 pointer from temporary RAM to permanent RAM.\r
94\r
9095d37b 95 For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes\r
ffdb421c 96 immediately preceding the Interrupt Descriptor Table (IDT) in memory.\r
9095d37b 97 For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes\r
ffdb421c
LG
98 immediately preceding the Interrupt Descriptor Table (IDT) in memory.\r
99 For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in\r
9095d37b
LG
100 a dedicated CPU register. This means that there is no memory storage\r
101 associated with storing the PEI Services Table pointer, so no additional\r
ffdb421c 102 migration actions are required for Itanium or ARM CPUs.\r
81c7803c 103\r
ffdb421c
LG
104**/\r
105VOID\r
106EFIAPI\r
107MigratePeiServicesTablePointer (\r
8a835340 108 VOID\r
ffdb421c
LG
109 )\r
110{\r
111 //\r
9095d37b 112 // PEI Services Table pointer is cached in the global variable. No additional\r
ffdb421c
LG
113 // migration actions are required.\r
114 //\r
115 return;\r
116}\r