1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/** @file
This library supports a PEI Service table Pointer library implementation that
allows code dependent upon PEI Service to operate in an isolated execution environment
such as within the context of a host-based unit test framework.
Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "UnitTestPeiServicesTablePointerLib.h"
///
/// Pei service instance
///
EFI_PEI_SERVICES mPeiServices = {
{
PEI_SERVICES_SIGNATURE,
PEI_SERVICES_REVISION,
sizeof (EFI_PEI_SERVICES),
0,
0
},
UnitTestInstallPpi, // InstallPpi
UnitTestReInstallPpi, // ReInstallPpi
UnitTestLocatePpi, // LocatePpi
UnitTestNotifyPpi, // NotifyPpi
UnitTestGetBootMode, // GetBootMode
UnitTestSetBootMode, // SetBootMode
UnitTestGetHobList, // GetHobList
UnitTestCreateHob, // CreateHob
UnitTestFfsFindNextVolume, // FfsFindNextVolume
UnitTestFfsFindNextFile, // FfsFindNextFile
UnitTestFfsFindSectionData, // FfsFindSectionData
UnitTestInstallPeiMemory, // InstallPeiMemory
UnitTestPeiAllocatePages, // AllocatePages
UnitTestPeiAllocatePool, // AllocatePool
(EFI_PEI_COPY_MEM)CopyMem,
(EFI_PEI_SET_MEM)SetMem,
UnitTestReportStatusCode, // ReportStatusCode
UnitTestResetSystem, // ResetSystem
NULL, // CpuIo
NULL, // PciCfg
UnitTestFfsFindFileByName, // FfsFindFileByName
UnitTestFfsGetFileInfo, // FfsGetFileInfo
UnitTestFfsGetVolumeInfo, // FfsGetVolumeInfo
UnitTestRegisterForShadow, // RegisterForShadow
UnitTestFfsFindSectionData3, // FfsFindSectionData3
UnitTestFfsGetFileInfo2, // FfsGetFileInfo2
UnitTestResetSystem2, // ResetSystem2
UnitTestPeiFreePages, // FreePages
};
PEI_CORE_INSTANCE mPrivateData;
UINT8 mHobBuffer[MAX_HOB_SIZE];
VOID *mPeiServicesPointer;
/**
Clear Buffer For Global Data.
**/
VOID
ClearGlobalData (
VOID
)
{
ZeroMem (&mPrivateData, sizeof (mPrivateData));
mPrivateData.PpiData.PpiList.MaxCount = MAX_PPI_COUNT;
mPrivateData.PpiData.CallbackNotifyList.MaxCount = MAX_PPI_COUNT;
mPrivateData.PpiData.DispatchNotifyList.MaxCount = MAX_PPI_COUNT;
ZeroMem (mHobBuffer, MAX_HOB_SIZE);
mPrivateData.HobList.Raw = mHobBuffer;
UnitTestCoreBuildHobHandoffInfoTable (0, (EFI_PHYSICAL_ADDRESS)(UINTN)mHobBuffer, MAX_HOB_SIZE);
}
/**
Resets the entire platform.
@param[in] ResetType The type of reset to perform.
@param[in] ResetStatus The status code for the reset.
@param[in] DataSize The size, in bytes, of ResetData.
@param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
the data buffer starts with a Null-terminated string, optionally
followed by additional binary data. The string is a description
that the caller may use to further indicate the reason for the
system reset.
**/
VOID
EFIAPI
UnitTestResetSystem2 (
IN EFI_RESET_TYPE ResetType,
IN EFI_STATUS ResetStatus,
IN UINTN DataSize,
IN VOID *ResetData OPTIONAL
)
{
ClearGlobalData ();
}
/**
Retrieves the cached value of the PEI Services Table pointer.
Returns the cached value of the PEI Services Table pointer in a CPU specific manner
as specified in the CPU binding section of the Platform Initialization Pre-EFI
Initialization Core Interface Specification.
If the cached PEI Services Table pointer is NULL, then ASSERT().
@return The pointer to PeiServices.
**/
CONST EFI_PEI_SERVICES **
EFIAPI
GetPeiServicesTablePointer (
VOID
)
{
mPeiServicesPointer = &mPeiServices;
return (CONST EFI_PEI_SERVICES **)&mPeiServicesPointer;
}
/**
Caches a pointer PEI Services Table.
Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
Pre-EFI Initialization Core Interface Specification.
If PeiServicesTablePointer is NULL, then ASSERT().
@param PeiServicesTablePointer The address of PeiServices pointer.
**/
VOID
EFIAPI
SetPeiServicesTablePointer (
IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
)
{
ASSERT (FALSE);
}
/**
Perform CPU specific actions required to migrate the PEI Services Table
pointer from temporary RAM to permanent RAM.
For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
immediately preceding the Interrupt Descriptor Table (IDT) in memory.
For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
immediately preceding the Interrupt Descriptor Table (IDT) in memory.
For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
a dedicated CPU register. This means that there is no memory storage
associated with storing the PEI Services Table pointer, so no additional
migration actions are required for Itanium or ARM CPUs.
**/
VOID
EFIAPI
MigratePeiServicesTablePointer (
VOID
)
{
ASSERT (FALSE);
}
/**
The constructor function init PeiServicesTable with clean buffer.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
UnitTestPeiServicesTablePointerLibConstructor (
VOID
)
{
ClearGlobalData ();
return EFI_SUCCESS;
}
|