3 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2011, Apple Inc. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Ppi/EmuThunk.h>
11 #include <Ppi/MemoryDiscovered.h>
13 #include <Library/DebugLib.h>
14 #include <Library/PeimEntryPoint.h>
15 #include <Library/BaseLib.h>
16 #include <Library/BaseMemoryLib.h>
17 #include <Library/HobLib.h>
18 #include <Library/PeiServicesLib.h>
19 #include <Library/PeiServicesTablePointerLib.h>
23 PeimInitializeAutoScanPei (
24 IN EFI_PEI_FILE_HANDLE FileHandle
,
25 IN CONST EFI_PEI_SERVICES
**PeiServices
30 Perform a call-back into the SEC simulator to get a memory value
33 FfsHeader - General purpose data available to every PEIM
34 PeiServices - General purpose services available to every PEIM.
42 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
45 EFI_PHYSICAL_ADDRESS MemoryBase
;
47 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes
;
50 DEBUG ((EFI_D_ERROR
, "Emu Autoscan PEIM Loaded\n"));
53 // Get the PEI UNIX Autoscan PPI
55 Status
= PeiServicesLocatePpi (
56 &gEmuThunkPpiGuid
, // GUID
58 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
59 (VOID
**)&Thunk
// PPI
61 ASSERT_EFI_ERROR (Status
);
65 Status
= Thunk
->MemoryAutoScan (Index
, &MemoryBase
, &MemorySize
);
66 if (!EFI_ERROR (Status
)) {
69 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
70 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
71 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
72 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE
|
73 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE
|
74 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
79 // Register the memory with the PEI Core
81 Status
= PeiServicesInstallPeiMemory (MemoryBase
, MemorySize
);
82 ASSERT_EFI_ERROR (Status
);
84 Attributes
|= EFI_RESOURCE_ATTRIBUTE_TESTED
;
87 BuildResourceDescriptorHob (
88 EFI_RESOURCE_SYSTEM_MEMORY
,
95 } while (!EFI_ERROR (Status
));
98 // Build the CPU hob with 57-bit addressing and 16-bits of IO space.
100 BuildCpuHob (57, 16);