1 /** @file 2 PEI Services Table Pointer Library. 3 4 Store PEI Services Table pointer via gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage. 5 This emulates a platform SRAM. The PI mechaism does not work in the emulator due to 6 lack of privledge. 7 8 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> 9 Portiions copyrigth (c) 2011, Apple Inc. All rights reserved. 10 This program and the accompanying materials 11 are licensed and made available under the terms and conditions of the BSD License 12 which accompanies this distribution. The full text of the license may be found at 13 http://opensource.org/licenses/bsd-license.php. 14 15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 17 18 **/ 19 20 #include <PiPei.h> 21 #include <Library/PeiServicesTablePointerLib.h> 22 #include <Library/DebugLib.h> 23 #include <Library/EmuMagicPageLib.h> 24 25 26 /** 27 Caches a pointer PEI Services Table. 28 29 Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer 30 in a CPU specific manner as specified in the CPU binding section of the Platform Initialization 31 Pre-EFI Initialization Core Interface Specification. 32 33 If PeiServicesTablePointer is NULL, then ASSERT(). 34 35 @param PeiServicesTablePointer The address of PeiServices pointer. 36 **/ 37 VOID 38 EFIAPI 39 SetPeiServicesTablePointer ( 40 IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer 41 ) 42 { 43 ASSERT (PeiServicesTablePointer != NULL); 44 ASSERT (*PeiServicesTablePointer != NULL); 45 EMU_MAGIC_PAGE()->PeiServicesTablePointer = PeiServicesTablePointer; 46 } 47 48 /** 49 Retrieves the cached value of the PEI Services Table pointer. 50 51 Returns the cached value of the PEI Services Table pointer in a CPU specific manner 52 as specified in the CPU binding section of the Platform Initialization Pre-EFI 53 Initialization Core Interface Specification. 54 55 If the cached PEI Services Table pointer is NULL, then ASSERT(). 56 57 @return The pointer to PeiServices. 58 59 **/ 60 CONST EFI_PEI_SERVICES ** 61 EFIAPI 62 GetPeiServicesTablePointer ( 63 VOID 64 ) 65 { 66 CONST EFI_PEI_SERVICES **PeiServicesTablePointer; 67 68 PeiServicesTablePointer = EMU_MAGIC_PAGE()->PeiServicesTablePointer; 69 ASSERT (PeiServicesTablePointer != NULL); 70 ASSERT (*PeiServicesTablePointer != NULL); 71 return PeiServicesTablePointer; 72 } 73 74 /** 75 Perform CPU specific actions required to migrate the PEI Services Table 76 pointer from temporary RAM to permanent RAM. 77 78 For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes 79 immediately preceding the Interrupt Descriptor Table (IDT) in memory. 80 For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes 81 immediately preceding the Interrupt Descriptor Table (IDT) in memory. 82 For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in 83 a dedicated CPU register. This means that there is no memory storage 84 associated with storing the PEI Services Table pointer, so no additional 85 migration actions are required for Itanium or ARM CPUs. 86 87 **/ 88 VOID 89 EFIAPI 90 MigratePeiServicesTablePointer ( 91 VOID 92 ) 93 { 94 // 95 // PEI Services Table pointer is cached in SRAM. No additional 96 // migration actions are required. 97 // 98 return; 99 } 100 101 102