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