]>
Commit | Line | Data |
---|---|---|
bf231ea6 | 1 | /** @file\r |
030cd1a2 | 2 | PEI Services Table Pointer Library for IA-32 and x64.\r |
bf231ea6 | 3 | \r |
ce02b0b9 | 4 | According to PI specification, the peiservice pointer is stored prior at IDT\r |
5 | table in IA32 and x64 architecture.\r | |
6 | \r | |
373ade0e | 7 | Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r |
bf231ea6 A |
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 | |
c7d265a9 | 17 | \r |
5dd39dc6 | 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 | |
c7d265a9 | 23 | \r |
24 | /**\r | |
4b8157f9 | 25 | Retrieves the cached value of the PEI Services Table pointer.\r |
f38fdc74 | 26 | \r |
4b8157f9 | 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 | |
f38fdc74 | 32 | \r |
4b8157f9 | 33 | @return The pointer to PeiServices.\r |
c7d265a9 | 34 | \r |
35 | **/\r | |
5240b97c | 36 | CONST EFI_PEI_SERVICES **\r |
c7d265a9 | 37 | EFIAPI\r |
38 | GetPeiServicesTablePointer (\r | |
39 | VOID\r | |
40 | )\r | |
41 | {\r | |
5240b97c | 42 | CONST EFI_PEI_SERVICES **PeiServices;\r |
81c7803c | 43 | IA32_DESCRIPTOR Idtr;\r |
44 | \r | |
45 | AsmReadIdtr (&Idtr);\r | |
5240b97c | 46 | PeiServices = (CONST EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - sizeof (UINTN)));\r |
c7d265a9 | 47 | ASSERT (PeiServices != NULL);\r |
48 | return PeiServices;\r | |
49 | }\r | |
50 | \r | |
81c7803c | 51 | /**\r |
4b8157f9 | 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 | |
f38fdc74 | 57 | The function set the pointer of PEI services immediately preceding the IDT table\r |
58 | according to PI specification.\r | |
81c7803c | 59 | \r |
4b8157f9 | 60 | If PeiServicesTablePointer is NULL, then ASSERT().\r |
61 | \r | |
f38fdc74 | 62 | @param PeiServicesTablePointer The address of PeiServices pointer.\r |
81c7803c | 63 | **/\r |
64 | VOID\r | |
65 | EFIAPI\r | |
66 | SetPeiServicesTablePointer (\r | |
a86fda43 | 67 | IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r |
81c7803c | 68 | )\r |
69 | {\r | |
70 | IA32_DESCRIPTOR Idtr;\r | |
71 | \r | |
4b8157f9 | 72 | ASSERT (PeiServicesTablePointer != NULL);\r |
81c7803c | 73 | AsmReadIdtr (&Idtr);\r |
5dd39dc6 | 74 | (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;\r |
81c7803c | 75 | }\r |
76 | \r | |
81c7803c | 77 | \r |