]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | PEI Services Table Pointer Library for IA-32 and x64.\r | |
3 | \r | |
4 | According to PI specification, the peiservice pointer is stored prior at IDT\r | |
5 | table in IA32 and x64 architecture.\r | |
6 | \r | |
7 | Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r | |
8 | All rights reserved. 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 | \r | |
20 | #include <Library/BaseLib.h>\r | |
21 | #include <Library/PeiServicesTablePointerLib.h>\r | |
22 | #include <Library/DebugLib.h>\r | |
23 | \r | |
24 | /**\r | |
25 | Retrieves the cached value of the PEI Services Table pointer.\r | |
26 | \r | |
27 | Returns the cached value of the PEI Services Table pointer in a CPU specific manner \r | |
28 | as specified in the CPU binding section of the Platform Initialization Pre-EFI \r | |
29 | Initialization Core Interface Specification.\r | |
30 | \r | |
31 | If the cached PEI Services Table pointer is NULL, then ASSERT().\r | |
32 | \r | |
33 | @return The pointer to PeiServices.\r | |
34 | \r | |
35 | **/\r | |
36 | CONST EFI_PEI_SERVICES **\r | |
37 | EFIAPI\r | |
38 | GetPeiServicesTablePointer (\r | |
39 | VOID\r | |
40 | )\r | |
41 | {\r | |
42 | CONST EFI_PEI_SERVICES **PeiServices;\r | |
43 | IA32_DESCRIPTOR Idtr;\r | |
44 | \r | |
45 | AsmReadIdtr (&Idtr);\r | |
46 | PeiServices = (CONST EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - sizeof (UINTN)));\r | |
47 | ASSERT (PeiServices != NULL);\r | |
48 | return PeiServices;\r | |
49 | }\r | |
50 | \r | |
51 | /**\r | |
52 | Caches a pointer PEI Services Table. \r | |
53 | \r | |
54 | Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer \r | |
55 | in a CPU specific manner as specified in the CPU binding section of the Platform Initialization \r | |
56 | Pre-EFI Initialization Core Interface Specification. \r | |
57 | The function set the pointer of PEI services immediately preceding the IDT table\r | |
58 | according to PI specification.\r | |
59 | \r | |
60 | If PeiServicesTablePointer is NULL, then ASSERT().\r | |
61 | \r | |
62 | @param PeiServicesTablePointer The address of PeiServices pointer.\r | |
63 | **/\r | |
64 | VOID\r | |
65 | EFIAPI\r | |
66 | SetPeiServicesTablePointer (\r | |
67 | IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r | |
68 | )\r | |
69 | {\r | |
70 | IA32_DESCRIPTOR Idtr;\r | |
71 | \r | |
72 | ASSERT (PeiServicesTablePointer != NULL);\r | |
73 | AsmReadIdtr (&Idtr);\r | |
74 | (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;\r | |
75 | }\r | |
76 | \r | |
77 | \r |