2011-05-11 20:31:20 +02:00
|
|
|
/*++ @file
|
|
|
|
|
2018-08-24 07:20:32 +02:00
|
|
|
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
2011-05-11 20:31:20 +02:00
|
|
|
Portions copyright (c) 2011, Apple Inc. All rights reserved.
|
2019-04-04 01:03:44 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2011-05-11 20:31:20 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "PiPei.h"
|
|
|
|
#include <Ppi/EmuThunk.h>
|
|
|
|
#include <Ppi/MemoryDiscovered.h>
|
|
|
|
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/PeimEntryPoint.h>
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/HobLib.h>
|
|
|
|
#include <Library/PeiServicesLib.h>
|
|
|
|
#include <Library/PeiServicesTablePointerLib.h>
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PeimInitializeAutoScanPei (
|
|
|
|
IN EFI_PEI_FILE_HANDLE FileHandle,
|
|
|
|
IN CONST EFI_PEI_SERVICES **PeiServices
|
|
|
|
)
|
2021-12-05 23:53:57 +01:00
|
|
|
|
2011-05-11 20:31:20 +02:00
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
Perform a call-back into the SEC simulator to get a memory value
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
FfsHeader - General purpose data available to every PEIM
|
|
|
|
PeiServices - General purpose services available to every PEIM.
|
2011-06-28 18:50:26 +02:00
|
|
|
|
2011-05-11 20:31:20 +02:00
|
|
|
Returns:
|
|
|
|
None
|
|
|
|
|
|
|
|
**/
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
|
|
|
|
EMU_THUNK_PPI *Thunk;
|
|
|
|
UINT64 MemorySize;
|
|
|
|
EFI_PHYSICAL_ADDRESS MemoryBase;
|
|
|
|
UINTN Index;
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
|
|
|
|
|
2021-11-17 04:21:21 +01:00
|
|
|
DEBUG ((DEBUG_ERROR, "Emu Autoscan PEIM Loaded\n"));
|
2011-05-11 20:31:20 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Get the PEI UNIX Autoscan PPI
|
|
|
|
//
|
|
|
|
Status = PeiServicesLocatePpi (
|
|
|
|
&gEmuThunkPpiGuid, // GUID
|
|
|
|
0, // INSTANCE
|
|
|
|
&PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
|
|
|
|
(VOID **)&Thunk // PPI
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Index = 0;
|
|
|
|
do {
|
|
|
|
Status = Thunk->MemoryAutoScan (Index, &MemoryBase, &MemorySize);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Attributes =
|
|
|
|
(
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_PRESENT |
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
|
|
|
|
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
|
|
|
|
);
|
|
|
|
|
|
|
|
if (Index == 0) {
|
|
|
|
//
|
|
|
|
// Register the memory with the PEI Core
|
|
|
|
//
|
|
|
|
Status = PeiServicesInstallPeiMemory (MemoryBase, MemorySize);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;
|
|
|
|
}
|
2011-06-28 18:50:26 +02:00
|
|
|
|
2011-05-11 20:31:20 +02:00
|
|
|
BuildResourceDescriptorHob (
|
|
|
|
EFI_RESOURCE_SYSTEM_MEMORY,
|
|
|
|
Attributes,
|
|
|
|
MemoryBase,
|
|
|
|
MemorySize
|
|
|
|
);
|
|
|
|
}
|
2021-12-05 23:53:57 +01:00
|
|
|
|
2011-05-11 20:31:20 +02:00
|
|
|
Index++;
|
|
|
|
} while (!EFI_ERROR (Status));
|
|
|
|
|
|
|
|
//
|
2018-08-24 07:20:32 +02:00
|
|
|
// Build the CPU hob with 57-bit addressing and 16-bits of IO space.
|
2011-05-11 20:31:20 +02:00
|
|
|
//
|
2018-08-24 07:20:32 +02:00
|
|
|
BuildCpuHob (57, 16);
|
2011-06-28 18:50:26 +02:00
|
|
|
|
2011-05-11 20:31:20 +02:00
|
|
|
return Status;
|
|
|
|
}
|