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