]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
0e6755d3aa015cdbaaefbf0d71869c339fa559ae
[mirror_edk2.git] / ArmPlatformPkg / 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 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 #include <Library/PeiServicesTablePointerLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/PcdLib.h>
22
23 /**
24 Caches a pointer PEI Services Table.
25
26 Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
27 in a platform specific manner.
28
29 If PeiServicesTablePointer is NULL, then ASSERT().
30
31 @param PeiServicesTablePointer The address of PeiServices pointer.
32 **/
33 VOID
34 EFIAPI
35 SetPeiServicesTablePointer (
36 IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
37 )
38 {
39 UINTN *PeiPtrLoc;
40 ASSERT (PeiServicesTablePointer != NULL);
41
42 PeiPtrLoc = (UINTN *)(UINTN)(PcdGet32 (PcdCPUCoresNonSecStackBase) +
43 (PcdGet32 (PcdCPUCoresNonSecStackSize) / 2) -
44 PcdGet32 (PcdPeiGlobalVariableSize) +
45 PcdGet32 (PcdPeiServicePtrGlobalOffset));
46 *PeiPtrLoc = (UINTN)PeiServicesTablePointer;
47 }
48
49 /**
50 Retrieves the cached value of the PEI Services Table pointer.
51
52 Returns the cached value of the PEI Services Table pointer in a CPU specific manner
53 as specified in the CPU binding section of the Platform Initialization Pre-EFI
54 Initialization Core Interface Specification.
55
56 If the cached PEI Services Table pointer is NULL, then ASSERT().
57
58 @return The pointer to PeiServices.
59
60 **/
61 CONST EFI_PEI_SERVICES **
62 EFIAPI
63 GetPeiServicesTablePointer (
64 VOID
65 )
66 {
67 UINTN *PeiPtrLoc;
68
69 PeiPtrLoc = (UINTN *)(UINTN)(PcdGet32 (PcdCPUCoresNonSecStackBase) +
70 (PcdGet32 (PcdCPUCoresNonSecStackSize) / 2) -
71 PcdGet32 (PcdPeiGlobalVariableSize) +
72 PcdGet32 (PcdPeiServicePtrGlobalOffset));
73 return (CONST EFI_PEI_SERVICES **)*PeiPtrLoc;
74 }
75
76