]>
Commit | Line | Data |
---|---|---|
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 | 16 | CONST 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 | 29 | VOID\r |
30 | EFIAPI\r | |
31 | SetPeiServicesTablePointer (\r | |
2f88bd3a | 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 | 51 | CONST EFI_PEI_SERVICES **\r |
2884e3df | 52 | EFIAPI\r |
e386b444 | 53 | GetPeiServicesTablePointer (\r |
54 | VOID\r | |
55 | )\r | |
56 | {\r | |
57 | ASSERT (gPeiServices != NULL);\r | |
a86fda43 | 58 | return gPeiServices;\r |
e386b444 | 59 | }\r |
60 | \r | |
e386b444 | 61 | /**\r |
62 | The constructor function caches the pointer to PEI services.\r | |
9095d37b | 63 | \r |
e386b444 | 64 | The constructor function caches the pointer to PEI services.\r |
65 | It will always return EFI_SUCCESS.\r | |
66 | \r | |
58380e9c | 67 | @param FileHandle The handle of FFS header the loaded driver.\r |
68 | @param PeiServices The pointer to the PEI services.\r | |
e386b444 | 69 | \r |
58380e9c | 70 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r |
e386b444 | 71 | \r |
72 | **/\r | |
73 | EFI_STATUS\r | |
74 | EFIAPI\r | |
75 | PeiServicesTablePointerLibConstructor (\r | |
2f88bd3a MK |
76 | IN EFI_PEI_FILE_HANDLE FileHandle,\r |
77 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
e386b444 | 78 | )\r |
79 | {\r | |
80 | gPeiServices = PeiServices;\r | |
81 | return EFI_SUCCESS;\r | |
82 | }\r | |
81c7803c | 83 | \r |
ffdb421c | 84 | /**\r |
9095d37b | 85 | Perform CPU specific actions required to migrate the PEI Services Table\r |
ffdb421c LG |
86 | pointer from temporary RAM to permanent RAM.\r |
87 | \r | |
9095d37b | 88 | For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes\r |
ffdb421c | 89 | immediately preceding the Interrupt Descriptor Table (IDT) in memory.\r |
9095d37b | 90 | For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes\r |
ffdb421c LG |
91 | immediately preceding the Interrupt Descriptor Table (IDT) in memory.\r |
92 | For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in\r | |
9095d37b LG |
93 | a dedicated CPU register. This means that there is no memory storage\r |
94 | associated with storing the PEI Services Table pointer, so no additional\r | |
ffdb421c | 95 | migration actions are required for Itanium or ARM CPUs.\r |
81c7803c | 96 | \r |
ffdb421c LG |
97 | **/\r |
98 | VOID\r | |
99 | EFIAPI\r | |
100 | MigratePeiServicesTablePointer (\r | |
8a835340 | 101 | VOID\r |
ffdb421c LG |
102 | )\r |
103 | {\r | |
104 | //\r | |
9095d37b | 105 | // PEI Services Table pointer is cached in the global variable. No additional\r |
ffdb421c LG |
106 | // migration actions are required.\r |
107 | //\r | |
108 | return;\r | |
109 | }\r |