]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c
Update PeiServicesTablePointerLib instance to add new API MigratePeiServicesTablePointer
[mirror_edk2.git] / EmulatorPkg / Library / PeiCoreServicesTablePointerLib / PeiServicesTablePointer.c
CommitLineData
949f388f 1/** @file\r
65e3f333 2 PEI Services Table Pointer Library.\r
d18d8a1d 3\r
65e3f333 4 This library is used for PEIM which does executed from flash device directly but\r
5 executed in memory.\r
949f388f 6\r
7 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
949f388f 8 This program and the accompanying materials\r
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
11 http://opensource.org/licenses/bsd-license.php.\r
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
16**/\r
17\r
18#include <PiPei.h>\r
19#include <Library/PeiServicesTablePointerLib.h>\r
20#include <Library/DebugLib.h>\r
21\r
65e3f333 22CONST EFI_PEI_SERVICES **gPeiServices;\r
949f388f 23\r
24/**\r
d18d8a1d 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
949f388f 31 If PeiServicesTablePointer is NULL, then ASSERT().\r
d18d8a1d 32\r
949f388f 33 @param PeiServicesTablePointer The address of PeiServices pointer.\r
34**/\r
35VOID\r
36EFIAPI\r
37SetPeiServicesTablePointer (\r
65e3f333 38 IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
949f388f 39 )\r
40{\r
65e3f333 41 ASSERT (PeiServicesTablePointer != NULL);\r
42 gPeiServices = PeiServicesTablePointer;\r
949f388f 43}\r
44\r
45/**\r
46 Retrieves the cached value of the PEI Services Table pointer.\r
47\r
d18d8a1d 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
949f388f 50 Initialization Core Interface Specification.\r
d18d8a1d 51\r
949f388f 52 If the cached PEI Services Table pointer is NULL, then ASSERT().\r
53\r
54 @return The pointer to PeiServices.\r
55\r
56**/\r
57CONST EFI_PEI_SERVICES **\r
58EFIAPI\r
59GetPeiServicesTablePointer (\r
60 VOID\r
61 )\r
62{\r
63 ASSERT (gPeiServices != NULL);\r
949f388f 64 return gPeiServices;\r
65}\r
66\r
67\r
65e3f333 68/**\r
69 The constructor function caches the pointer to PEI services.\r
d18d8a1d 70\r
65e3f333 71 The constructor function caches the pointer to PEI services.\r
72 It will always return EFI_SUCCESS.\r
73\r
74 @param FileHandle The handle of FFS header the loaded driver.\r
75 @param PeiServices The pointer to the PEI services.\r
76\r
77 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
78\r
79**/\r
80EFI_STATUS\r
81EFIAPI\r
82PeiServicesTablePointerLibConstructor (\r
83 IN EFI_PEI_FILE_HANDLE FileHandle,\r
84 IN CONST EFI_PEI_SERVICES **PeiServices\r
85 )\r
86{\r
87 gPeiServices = PeiServices;\r
88 return EFI_SUCCESS;\r
89}\r
90\r
95c2e69a
LG
91/**\r
92 Perform CPU specific actions required to migrate the PEI Services Table \r
93 pointer from temporary RAM to permanent RAM.\r
94\r
95 For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes \r
96 immediately preceding the Interrupt Descriptor Table (IDT) in memory.\r
97 For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes \r
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
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
102 migration actions are required for Itanium or ARM CPUs.\r
103\r
104**/\r
105VOID\r
106EFIAPI\r
107MigratePeiServicesTablePointer (\r
108 VOID\r
109 )\r
110{\r
111 //\r
112 // PEI Services Table pointer is cached in the global variable. No additional \r
113 // migration actions are required.\r
114 //\r
115 return;\r
116}\r
65e3f333 117\r