]>
Commit | Line | Data |
---|---|---|
949f388f | 1 | /** @file\r |
2 | PEI Services Table Pointer Library for PEI Core.\r | |
3 | \r | |
4 | This library is used for PEI Core which does executed from flash device directly but\r | |
5 | executed in memory. When the PEI Core does a Set of the PEI Service table pointer \r | |
6 | a PPI is reinstalled so that PEIMs can update the copy of the PEI Services table \r | |
7 | they have cached. \r | |
8 | \r | |
9 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
10 | Portiions copyrigth (c) 2011, Apple Inc. All rights reserved. \r | |
11 | This program and the accompanying materials\r | |
12 | are licensed and made available under the terms and conditions of the BSD License\r | |
13 | which accompanies this distribution. The full text of the license may be found at\r | |
14 | http://opensource.org/licenses/bsd-license.php.\r | |
15 | \r | |
16 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
17 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
18 | \r | |
19 | **/\r | |
20 | \r | |
21 | #include <PiPei.h>\r | |
22 | #include <Library/PeiServicesTablePointerLib.h>\r | |
23 | #include <Library/DebugLib.h>\r | |
24 | \r | |
25 | #include <Ppi/EmuPeiServicesTableUpdate.h>\r | |
26 | \r | |
27 | \r | |
28 | CONST EFI_PEI_SERVICES **gPeiServices = NULL;\r | |
29 | \r | |
30 | /**\r | |
31 | Caches a pointer PEI Services Table. \r | |
32 | \r | |
33 | Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer \r | |
34 | in a CPU specific manner as specified in the CPU binding section of the Platform Initialization \r | |
35 | Pre-EFI Initialization Core Interface Specification. \r | |
36 | \r | |
37 | If PeiServicesTablePointer is NULL, then ASSERT().\r | |
38 | \r | |
39 | @param PeiServicesTablePointer The address of PeiServices pointer.\r | |
40 | **/\r | |
41 | VOID\r | |
42 | EFIAPI\r | |
43 | SetPeiServicesTablePointer (\r | |
44 | IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer\r | |
45 | )\r | |
46 | {\r | |
47 | EFI_STATUS Status;\r | |
48 | EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r | |
49 | VOID *NotUsed;\r | |
50 | \r | |
51 | gPeiServices = PeiServicesTablePointer; \r | |
52 | \r | |
53 | Status = (*PeiServicesTablePointer)->LocatePpi (\r | |
54 | PeiServicesTablePointer,\r | |
55 | &gEmuPeiServicesTableUpdatePpiGuid, // GUID\r | |
56 | 0, // INSTANCE\r | |
57 | &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r | |
58 | &NotUsed // PPI\r | |
59 | );\r | |
60 | if (!EFI_ERROR (Status)) {\r | |
61 | //\r | |
62 | // Standard PI Mechanism is to use negative offset from IDT. \r | |
63 | // We can't do that in the emulator, so we make up a constant location\r | |
64 | // that every one can use. The first try may fail as the PEI Core is still\r | |
65 | // initializing its self, but that is OK. \r | |
66 | //\r | |
67 | \r | |
68 | // Reinstall PPI to consumers know to update PEI Services pointer\r | |
69 | Status = (*PeiServicesTablePointer)->ReInstallPpi (\r | |
70 | PeiServicesTablePointer,\r | |
71 | PpiDescriptor,\r | |
72 | PpiDescriptor\r | |
73 | );\r | |
74 | \r | |
75 | }\r | |
76 | \r | |
77 | }\r | |
78 | \r | |
79 | /**\r | |
80 | Retrieves the cached value of the PEI Services Table pointer.\r | |
81 | \r | |
82 | Returns the cached value of the PEI Services Table pointer in a CPU specific manner \r | |
83 | as specified in the CPU binding section of the Platform Initialization Pre-EFI \r | |
84 | Initialization Core Interface Specification.\r | |
85 | \r | |
86 | If the cached PEI Services Table pointer is NULL, then ASSERT().\r | |
87 | \r | |
88 | @return The pointer to PeiServices.\r | |
89 | \r | |
90 | **/\r | |
91 | CONST EFI_PEI_SERVICES **\r | |
92 | EFIAPI\r | |
93 | GetPeiServicesTablePointer (\r | |
94 | VOID\r | |
95 | )\r | |
96 | {\r | |
97 | ASSERT (gPeiServices != NULL);\r | |
98 | ASSERT (*gPeiServices != NULL);\r | |
99 | return gPeiServices;\r | |
100 | }\r | |
101 | \r | |
102 | \r |