]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ArmPkg / Library / PeiServicesTablePointerLib / PeiServicesTablePointer.c
1 /** @file
2 PEI Services Table Pointer Library.
3
4 This library is used for PEIM which does executed from flash device directly but
5 executed in memory.
6
7 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
8 Copyright (c) 2011 Hewlett-Packard Corporation. All rights reserved.<BR>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
10
11 **/
12
13 #include <PiPei.h>
14 #include <Library/PeiServicesTablePointerLib.h>
15 #include <Library/ArmLib.h>
16 #include <Library/DebugLib.h>
17
18 /**
19 Caches a pointer PEI Services Table.
20
21 Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
22 in a platform specific manner.
23
24 If PeiServicesTablePointer is NULL, then ASSERT().
25
26 @param PeiServicesTablePointer The address of PeiServices pointer.
27 **/
28 VOID
29 EFIAPI
30 SetPeiServicesTablePointer (
31 IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
32 )
33 {
34 ArmWriteTpidrurw((UINTN)PeiServicesTablePointer);
35 }
36
37 /**
38 Retrieves the cached value of the PEI Services Table pointer.
39
40 Returns the cached value of the PEI Services Table pointer in a CPU specific manner
41 as specified in the CPU binding section of the Platform Initialization Pre-EFI
42 Initialization Core Interface Specification.
43
44 If the cached PEI Services Table pointer is NULL, then ASSERT().
45
46 @return The pointer to PeiServices.
47
48 **/
49 CONST EFI_PEI_SERVICES **
50 EFIAPI
51 GetPeiServicesTablePointer (
52 VOID
53 )
54 {
55 return (CONST EFI_PEI_SERVICES **)ArmReadTpidrurw();
56 }
57
58 /**
59 Perform CPU specific actions required to migrate the PEI Services Table
60 pointer from temporary RAM to permanent RAM.
61
62 For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
63 immediately preceding the Interrupt Descriptor Table (IDT) in memory.
64 For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
65 immediately preceding the Interrupt Descriptor Table (IDT) in memory.
66 For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
67 a dedicated CPU register. This means that there is no memory storage
68 associated with storing the PEI Services Table pointer, so no additional
69 migration actions are required for Itanium or ARM CPUs.
70
71 **/
72 VOID
73 EFIAPI
74 MigratePeiServicesTablePointer(
75 VOID
76 )
77 {
78 return;
79 }