]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointer.c
Minor grammatical work--mostly adding periods. Items with ONLY period added did...
[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 - 2008, Intel Corporation. All rights reserved.<BR>
8 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 Retrieves the cached value of the PEI Services Table pointer.
26
27 Returns the cached value of the PEI Services Table pointer in a CPU specific manner
28 as specified in the CPU binding section of the Platform Initialization Pre-EFI
29 Initialization Core Interface Specification.
30
31 If the cached PEI Services Table pointer is NULL, then ASSERT().
32
33 @return The pointer to PeiServices.
34
35 **/
36 CONST EFI_PEI_SERVICES **
37 EFIAPI
38 GetPeiServicesTablePointer (
39 VOID
40 )
41 {
42 CONST EFI_PEI_SERVICES **PeiServices;
43 IA32_DESCRIPTOR Idtr;
44
45 AsmReadIdtr (&Idtr);
46 PeiServices = (CONST EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - sizeof (UINTN)));
47 ASSERT (PeiServices != NULL);
48 return PeiServices;
49 }
50
51 /**
52 Caches a pointer PEI Services Table.
53
54 Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
55 in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
56 Pre-EFI Initialization Core Interface Specification.
57 The function set the pointer of PEI services immediately preceding the IDT table
58 according to PI specification.
59
60 If PeiServicesTablePointer is NULL, then ASSERT().
61
62 @param PeiServicesTablePointer The address of PeiServices pointer.
63 **/
64 VOID
65 EFIAPI
66 SetPeiServicesTablePointer (
67 IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
68 )
69 {
70 IA32_DESCRIPTOR Idtr;
71
72 ASSERT (PeiServicesTablePointer != NULL);
73 AsmReadIdtr (&Idtr);
74 (*(UINTN*)(Idtr.Base - sizeof (UINTN))) = (UINTN)PeiServicesTablePointer;
75 }
76
77