3 Copyright (c) 2006, 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 a Windows NT environment.
23 // The package level header files this module uses
26 #include <WinNtPeim.h>
28 // The protocols, PPI and GUID defintions for this module
30 #include <Ppi/BaseMemoryTest.h>
31 #include <Ppi/NtAutoscan.h>
33 // The Library classes this module consumes
35 #include <Library/DebugLib.h>
36 #include <Library/PeimEntryPoint.h>
37 #include <Library/HobLib.h>
41 PeimInitializeWinNtAutoScan (
42 IN EFI_FFS_FILE_HEADER
*FfsHeader
,
43 IN EFI_PEI_SERVICES
**PeiServices
48 Perform a call-back into the SEC simulator to get a memory value
51 FfsHeader - General purpose data available to every PEIM
52 PeiServices - General purpose services available to every PEIM.
60 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
61 PEI_NT_AUTOSCAN_PPI
*PeiNtService
;
63 EFI_PHYSICAL_ADDRESS MemoryBase
;
64 PEI_BASE_MEMORY_TEST_PPI
*MemoryTestPpi
;
65 EFI_PHYSICAL_ADDRESS ErrorAddress
;
67 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes
;
70 DEBUG ((EFI_D_ERROR
, "NT 32 Autoscan PEIM Loaded\n"));
73 // Get the PEI NT Autoscan PPI
75 Status
= (**PeiServices
).LocatePpi (
76 (const EFI_PEI_SERVICES
**)PeiServices
,
77 &gPeiNtAutoScanPpiGuid
, // GUID
79 &PpiDescriptor
, // EFI_PEI_PPI_DESCRIPTOR
80 (VOID
**)&PeiNtService
// PPI
82 ASSERT_EFI_ERROR (Status
);
85 // Get the Memory Test PPI
87 Status
= (**PeiServices
).LocatePpi (
88 (const EFI_PEI_SERVICES
**)PeiServices
,
89 &gPeiBaseMemoryTestPpiGuid
,
92 (VOID
**)&MemoryTestPpi
94 ASSERT_EFI_ERROR (Status
);
98 Status
= PeiNtService
->NtAutoScan (Index
, &MemoryBase
, &MemorySize
);
99 if (!EFI_ERROR (Status
)) {
102 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
103 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
104 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
105 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE
|
106 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE
|
107 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
112 // For the first area register it as PEI tested memory
114 Status
= MemoryTestPpi
->BaseMemoryTest (
122 ASSERT_EFI_ERROR (Status
);
125 // Register the "tested" memory with the PEI Core
127 Status
= (**PeiServices
).InstallPeiMemory ((const EFI_PEI_SERVICES
**)PeiServices
, MemoryBase
, MemorySize
);
128 ASSERT_EFI_ERROR (Status
);
130 Attributes
|= EFI_RESOURCE_ATTRIBUTE_TESTED
;
133 BuildResourceDescriptorHob (
134 EFI_RESOURCE_SYSTEM_MEMORY
,
141 } while (!EFI_ERROR (Status
));
144 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
146 BuildCpuHob (36, 16);