]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | PEI Services Table Pointer Library.\r | |
3 | \r | |
4 | This library is used for PEIM which does executed from flash device directly but\r | |
5 | executed in memory.\r | |
6 | \r | |
7 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
9 | \r | |
10 | **/\r | |
11 | \r | |
12 | #include <PiPei.h>\r | |
13 | #include <Library/PeiServicesTablePointerLib.h>\r | |
14 | #include <Library/DebugLib.h>\r | |
15 | \r | |
16 | CONST EFI_PEI_SERVICES **gPeiServices;\r | |
17 | \r | |
18 | /**\r | |
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 | |
25 | If PeiServicesTablePointer is NULL, then ASSERT().\r | |
26 | \r | |
27 | @param PeiServicesTablePointer The address of PeiServices pointer.\r | |
28 | **/\r | |
29 | VOID\r | |
30 | EFIAPI\r | |
31 | SetPeiServicesTablePointer (\r | |
32 | IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r | |
33 | )\r | |
34 | {\r | |
35 | ASSERT (PeiServicesTablePointer != NULL);\r | |
36 | gPeiServices = PeiServicesTablePointer;\r | |
37 | }\r | |
38 | \r | |
39 | /**\r | |
40 | Retrieves the cached value of the PEI Services Table pointer.\r | |
41 | \r | |
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 | |
44 | Initialization Core Interface Specification.\r | |
45 | \r | |
46 | If the cached PEI Services Table pointer is NULL, then ASSERT().\r | |
47 | \r | |
48 | @return The pointer to PeiServices.\r | |
49 | \r | |
50 | **/\r | |
51 | CONST EFI_PEI_SERVICES **\r | |
52 | EFIAPI\r | |
53 | GetPeiServicesTablePointer (\r | |
54 | VOID\r | |
55 | )\r | |
56 | {\r | |
57 | ASSERT (gPeiServices != NULL);\r | |
58 | return gPeiServices;\r | |
59 | }\r | |
60 | \r | |
61 | \r | |
62 | /**\r | |
63 | The constructor function caches the pointer to PEI services.\r | |
64 | \r | |
65 | The constructor function caches the pointer to PEI services.\r | |
66 | It will always return EFI_SUCCESS.\r | |
67 | \r | |
68 | @param FileHandle The handle of FFS header the loaded driver.\r | |
69 | @param PeiServices The pointer to the PEI services.\r | |
70 | \r | |
71 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
72 | \r | |
73 | **/\r | |
74 | EFI_STATUS\r | |
75 | EFIAPI\r | |
76 | PeiServicesTablePointerLibConstructor (\r | |
77 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
78 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
79 | )\r | |
80 | {\r | |
81 | gPeiServices = PeiServices;\r | |
82 | return EFI_SUCCESS;\r | |
83 | }\r | |
84 | \r | |
85 | /**\r | |
86 | Perform CPU specific actions required to migrate the PEI Services Table\r | |
87 | pointer from temporary RAM to permanent RAM.\r | |
88 | \r | |
89 | For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes\r | |
90 | immediately preceding the Interrupt Descriptor Table (IDT) in memory.\r | |
91 | For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes\r | |
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 | |
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 | |
96 | migration actions are required for Itanium or ARM CPUs.\r | |
97 | \r | |
98 | **/\r | |
99 | VOID\r | |
100 | EFIAPI\r | |
101 | MigratePeiServicesTablePointer (\r | |
102 | VOID\r | |
103 | )\r | |
104 | {\r | |
105 | //\r | |
106 | // PEI Services Table pointer is cached in the global variable. No additional\r | |
107 | // migration actions are required.\r | |
108 | //\r | |
109 | return;\r | |
110 | }\r | |
111 | \r |