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/BaseMemoryTest.h>
25 #include <Ppi/MemoryDiscovered.h>
27 #include <Library/DebugLib.h>
28 #include <Library/PeimEntryPoint.h>
29 #include <Library/BaseLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/HobLib.h>
32 #include <Library/PeiServicesLib.h>
33 #include <Library/PeiServicesTablePointerLib.h>
37 PeimInitializeUnixAutoScan (
38 IN EFI_FFS_FILE_HEADER
*FfsHeader
,
39 IN EFI_PEI_SERVICES
**PeiServices
44 Perform a call-back into the SEC simulator to get a memory value
47 FfsHeader - General purpose data available to every PEIM
48 PeiServices - General purpose services available to every PEIM.
56 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
57 PEI_UNIX_AUTOSCAN_PPI
*PeiUnixService
;
59 EFI_PHYSICAL_ADDRESS MemoryBase
;
60 PEI_BASE_MEMORY_TEST_PPI
*MemoryTestPpi
;
61 EFI_PHYSICAL_ADDRESS ErrorAddress
;
63 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes
;
66 DEBUG ((EFI_D_ERROR
, "Unix Autoscan PEIM Loaded\n"));
69 // Get the PEI UNIX Autoscan PPI
71 Status
= (**PeiServices
).LocatePpi (
73 &gPeiUnixAutoScanPpiGuid
, // GUID
75 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
76 (VOID
**)&PeiUnixService
// PPI
78 ASSERT_EFI_ERROR (Status
);
81 // Get the Memory Test PPI
83 Status
= (**PeiServices
).LocatePpi (
85 &gPeiBaseMemoryTestPpiGuid
,
88 (VOID
**)&MemoryTestPpi
90 ASSERT_EFI_ERROR (Status
);
94 Status
= PeiUnixService
->UnixAutoScan (Index
, &MemoryBase
, &MemorySize
);
95 if (!EFI_ERROR (Status
)) {
98 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
99 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
100 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
101 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE
|
102 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE
|
103 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
108 // For the first area register it as PEI tested memory
110 Status
= MemoryTestPpi
->BaseMemoryTest (
118 ASSERT_EFI_ERROR (Status
);
121 // Register the "tested" memory with the PEI Core
123 Status
= (**PeiServices
).InstallPeiMemory (PeiServices
, MemoryBase
, MemorySize
);
124 ASSERT_EFI_ERROR (Status
);
126 Attributes
|= EFI_RESOURCE_ATTRIBUTE_TESTED
;
129 BuildResourceDescriptorHob (
130 EFI_RESOURCE_SYSTEM_MEMORY
,
137 } while (!EFI_ERROR (Status
));
140 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
142 BuildCpuHob (36, 16);