]>
Commit | Line | Data |
---|---|---|
bf231ea6 A |
1 | /** @file\r |
2 | PEI Services Table Pointer Library for IA-32 and X64.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r | |
5 | All rights reserved. This program and the accompanying materials \r | |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
12 | \r | |
13 | **/\r | |
c7d265a9 | 14 | \r |
5dd39dc6 | 15 | #include <PiPei.h>\r |
16 | \r | |
17 | #include <Library/BaseLib.h>\r | |
18 | #include <Library/PeiServicesTablePointerLib.h>\r | |
19 | #include <Library/DebugLib.h>\r | |
c7d265a9 | 20 | \r |
21 | /**\r | |
22 | \r | |
23 | The function returns the pointer to PeiServicee following\r | |
24 | PI1.0.\r | |
25 | \r | |
26 | For IA32, the four-bytes field immediately prior to new IDT\r | |
27 | base addres is used to save the EFI_PEI_SERVICES**.\r | |
28 | For x64, the eight-bytes field immediately prior to new IDT\r | |
bf231ea6 | 29 | base addres is used to save the EFI_PEI_SERVICES**\r |
373b5cf9 | 30 | \r |
31 | @return The pointer to PeiServices.\r | |
c7d265a9 | 32 | \r |
33 | **/\r | |
34 | EFI_PEI_SERVICES **\r | |
35 | EFIAPI\r | |
36 | GetPeiServicesTablePointer (\r | |
37 | VOID\r | |
38 | )\r | |
39 | {\r | |
40 | EFI_PEI_SERVICES **PeiServices;\r | |
81c7803c | 41 | IA32_DESCRIPTOR Idtr;\r |
42 | \r | |
43 | AsmReadIdtr (&Idtr);\r | |
5dd39dc6 | 44 | PeiServices = (EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - sizeof (UINTN)));\r |
c7d265a9 | 45 | ASSERT (PeiServices != NULL);\r |
46 | return PeiServices;\r | |
47 | }\r | |
48 | \r | |
81c7803c | 49 | /**\r |
50 | \r | |
373b5cf9 | 51 | The function sets the pointer to PeiServicee following\r |
81c7803c | 52 | PI1.0.\r |
53 | \r | |
54 | For IA32, the four-bytes field immediately prior to new IDT\r | |
55 | base addres is used to save the EFI_PEI_SERVICES**.\r | |
56 | For x64, the eight-bytes field immediately prior to new IDT\r | |
57 | base addres is used to save the EFI_PEI_SERVICES**\r | |
373b5cf9 | 58 | \r |
59 | @param PeiServicesTablePointer The pointer to PeiServices.\r | |
81c7803c | 60 | \r |
61 | **/\r | |
62 | VOID\r | |
63 | EFIAPI\r | |
64 | SetPeiServicesTablePointer (\r | |
65 | EFI_PEI_SERVICES ** PeiServicesTablePointer\r | |
66 | )\r | |
67 | {\r | |
68 | IA32_DESCRIPTOR Idtr;\r | |
69 | \r | |
70 | AsmReadIdtr (&Idtr);\r | |
5dd39dc6 | 71 | (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;\r |
81c7803c | 72 | }\r |
73 | \r | |
81c7803c | 74 | \r |