]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
1) Update file header.
[mirror_edk2.git] / MdePkg / Library / PeiServicesTablePointerLibIdt / PeiServicesTablePointer.c
CommitLineData
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
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
f38fdc74 25 The function returns the pointer to PEI services.\r
26\r
27 The function returns the pointer to PEI services.\r
28 It will ASSERT() if the pointer to PEI services is NULL.\r
29\r
30 @retval The pointer to PeiServices.\r
c7d265a9 31\r
32**/\r
5240b97c 33CONST EFI_PEI_SERVICES **\r
c7d265a9 34EFIAPI\r
35GetPeiServicesTablePointer (\r
36 VOID\r
37 )\r
38{\r
5240b97c 39 CONST EFI_PEI_SERVICES **PeiServices;\r
81c7803c 40 IA32_DESCRIPTOR Idtr;\r
41 \r
42 AsmReadIdtr (&Idtr);\r
5240b97c 43 PeiServices = (CONST EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - sizeof (UINTN)));\r
c7d265a9 44 ASSERT (PeiServices != NULL);\r
45 return PeiServices;\r
46}\r
47\r
81c7803c 48/**\r
f38fdc74 49 The function set the pointer of PEI services immediately preceding the IDT table\r
50 according to PI specification.\r
81c7803c 51 \r
f38fdc74 52 @param PeiServicesTablePointer The address of PeiServices pointer.\r
81c7803c 53**/\r
54VOID\r
55EFIAPI\r
56SetPeiServicesTablePointer (\r
a86fda43 57 IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer\r
81c7803c 58 )\r
59{\r
60 IA32_DESCRIPTOR Idtr;\r
61 \r
62 AsmReadIdtr (&Idtr);\r
5dd39dc6 63 (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;\r
81c7803c 64}\r
65\r
81c7803c 66\r