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_PEI_FILE_HANDLE FileHandle
,
39 IN CONST 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
= PeiServicesLocatePpi (
72 &gPeiUnixAutoScanPpiGuid
, // GUID
74 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
75 (VOID
**)&PeiUnixService
// PPI
77 ASSERT_EFI_ERROR (Status
);
80 // Get the Memory Test PPI
82 Status
= PeiServicesLocatePpi (
83 &gPeiBaseMemoryTestPpiGuid
,
86 (VOID
**)&MemoryTestPpi
88 ASSERT_EFI_ERROR (Status
);
92 Status
= PeiUnixService
->UnixAutoScan (Index
, &MemoryBase
, &MemorySize
);
93 if (!EFI_ERROR (Status
)) {
96 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
97 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
98 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
99 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE
|
100 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE
|
101 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
106 // For the first area register it as PEI tested memory
108 Status
= MemoryTestPpi
->BaseMemoryTest (
116 ASSERT_EFI_ERROR (Status
);
119 // Register the "tested" memory with the PEI Core
121 Status
= PeiServicesInstallPeiMemory (MemoryBase
, MemorySize
);
122 ASSERT_EFI_ERROR (Status
);
124 Attributes
|= EFI_RESOURCE_ATTRIBUTE_TESTED
;
127 BuildResourceDescriptorHob (
128 EFI_RESOURCE_SYSTEM_MEMORY
,
135 } while (!EFI_ERROR (Status
));
138 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
140 BuildCpuHob (36, 16);