]>
Commit | Line | Data |
---|---|---|
bf231ea6 A |
1 | /** @file\r |
2 | PEI Services Table Pointer Library for IA-32 and X64.\r | |
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 | |
bf231ea6 A |
7 | Copyright (c) 2006 - 2007, 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 | |
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 | |
25 | \r | |
26 | The function returns the pointer to PeiServicee following\r | |
27 | PI1.0.\r | |
28 | \r | |
29 | For IA32, the four-bytes field immediately prior to new IDT\r | |
30 | base addres is used to save the EFI_PEI_SERVICES**.\r | |
31 | For x64, the eight-bytes field immediately prior to new IDT\r | |
bf231ea6 | 32 | base addres is used to save the EFI_PEI_SERVICES**\r |
373b5cf9 | 33 | \r |
34 | @return The pointer to PeiServices.\r | |
c7d265a9 | 35 | \r |
36 | **/\r | |
5240b97c | 37 | CONST EFI_PEI_SERVICES **\r |
c7d265a9 | 38 | EFIAPI\r |
39 | GetPeiServicesTablePointer (\r | |
40 | VOID\r | |
41 | )\r | |
42 | {\r | |
5240b97c | 43 | CONST EFI_PEI_SERVICES **PeiServices;\r |
81c7803c | 44 | IA32_DESCRIPTOR Idtr;\r |
45 | \r | |
46 | AsmReadIdtr (&Idtr);\r | |
5240b97c | 47 | PeiServices = (CONST EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - sizeof (UINTN)));\r |
c7d265a9 | 48 | ASSERT (PeiServices != NULL);\r |
49 | return PeiServices;\r | |
50 | }\r | |
51 | \r | |
81c7803c | 52 | /**\r |
53 | \r | |
373b5cf9 | 54 | The function sets the pointer to PeiServicee following\r |
81c7803c | 55 | PI1.0.\r |
56 | \r | |
57 | For IA32, the four-bytes field immediately prior to new IDT\r | |
58 | base addres is used to save the EFI_PEI_SERVICES**.\r | |
59 | For x64, the eight-bytes field immediately prior to new IDT\r | |
60 | base addres is used to save the EFI_PEI_SERVICES**\r | |
373b5cf9 | 61 | \r |
62 | @param PeiServicesTablePointer The pointer to PeiServices.\r | |
81c7803c | 63 | \r |
64 | **/\r | |
65 | VOID\r | |
66 | EFIAPI\r | |
67 | SetPeiServicesTablePointer (\r | |
f944ec32 | 68 | IN EFI_PEI_SERVICES ** PeiServicesTablePointer\r |
81c7803c | 69 | )\r |
70 | {\r | |
71 | IA32_DESCRIPTOR Idtr;\r | |
72 | \r | |
73 | AsmReadIdtr (&Idtr);\r | |
5dd39dc6 | 74 | (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;\r |
81c7803c | 75 | }\r |
76 | \r | |
81c7803c | 77 | \r |