3 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2011, Apple Inc. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Ppi/EmuThunk.h>
17 #include <Ppi/MemoryDiscovered.h>
19 #include <Library/DebugLib.h>
20 #include <Library/PeimEntryPoint.h>
21 #include <Library/BaseLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/HobLib.h>
24 #include <Library/PeiServicesLib.h>
25 #include <Library/PeiServicesTablePointerLib.h>
29 PeimInitializeAutoScanPei (
30 IN EFI_PEI_FILE_HANDLE FileHandle
,
31 IN CONST EFI_PEI_SERVICES
**PeiServices
36 Perform a call-back into the SEC simulator to get a memory value
39 FfsHeader - General purpose data available to every PEIM
40 PeiServices - General purpose services available to every PEIM.
48 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
51 EFI_PHYSICAL_ADDRESS MemoryBase
;
53 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes
;
56 DEBUG ((EFI_D_ERROR
, "Emu Autoscan PEIM Loaded\n"));
59 // Get the PEI UNIX Autoscan PPI
61 Status
= PeiServicesLocatePpi (
62 &gEmuThunkPpiGuid
, // GUID
64 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
65 (VOID
**)&Thunk
// PPI
67 ASSERT_EFI_ERROR (Status
);
71 Status
= Thunk
->MemoryAutoScan (Index
, &MemoryBase
, &MemorySize
);
72 if (!EFI_ERROR (Status
)) {
75 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
76 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
77 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
78 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE
|
79 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE
|
80 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
85 // Register the memory with the PEI Core
87 Status
= PeiServicesInstallPeiMemory (MemoryBase
, MemorySize
);
88 ASSERT_EFI_ERROR (Status
);
90 Attributes
|= EFI_RESOURCE_ATTRIBUTE_TESTED
;
93 BuildResourceDescriptorHob (
94 EFI_RESOURCE_SYSTEM_MEMORY
,
101 } while (!EFI_ERROR (Status
));
104 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
106 BuildCpuHob (36, 16);