3 Copyright (c) 2006 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 This PEIM to abstract memory auto-scan in an Unix environment.
23 #include <Ppi/UnixAutoScan.h>
24 #include <Ppi/MemoryDiscovered.h>
26 #include <Library/DebugLib.h>
27 #include <Library/PeimEntryPoint.h>
28 #include <Library/BaseLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/HobLib.h>
31 #include <Library/PeiServicesLib.h>
32 #include <Library/PeiServicesTablePointerLib.h>
36 PeimInitializeUnixAutoScan (
37 IN EFI_PEI_FILE_HANDLE FileHandle
,
38 IN CONST EFI_PEI_SERVICES
**PeiServices
43 Perform a call-back into the SEC simulator to get a memory value
46 FfsHeader - General purpose data available to every PEIM
47 PeiServices - General purpose services available to every PEIM.
55 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
56 PEI_UNIX_AUTOSCAN_PPI
*PeiUnixService
;
58 EFI_PHYSICAL_ADDRESS MemoryBase
;
60 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes
;
63 DEBUG ((EFI_D_ERROR
, "Unix Autoscan PEIM Loaded\n"));
66 // Get the PEI UNIX Autoscan PPI
68 Status
= PeiServicesLocatePpi (
69 &gPeiUnixAutoScanPpiGuid
, // GUID
71 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
72 (VOID
**)&PeiUnixService
// PPI
74 ASSERT_EFI_ERROR (Status
);
78 Status
= PeiUnixService
->UnixAutoScan (Index
, &MemoryBase
, &MemorySize
);
79 if (!EFI_ERROR (Status
)) {
82 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
83 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
84 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
85 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE
|
86 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE
|
87 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
92 // Register the memory with the PEI Core
94 Status
= PeiServicesInstallPeiMemory (MemoryBase
, MemorySize
);
95 ASSERT_EFI_ERROR (Status
);
97 Attributes
|= EFI_RESOURCE_ATTRIBUTE_TESTED
;
100 BuildResourceDescriptorHob (
101 EFI_RESOURCE_SYSTEM_MEMORY
,
108 } while (!EFI_ERROR (Status
));
111 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
113 BuildCpuHob (36, 16);