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