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>
38 #include <Library/PeiServicesLib.h>
42 PeimInitializeWinNtAutoScan (
43 IN EFI_PEI_FILE_HANDLE FileHandle
,
44 IN CONST EFI_PEI_SERVICES
**PeiServices
49 Perform a call-back into the SEC simulator to get a memory value
52 FfsHeader - General purpose data available to every PEIM
53 PeiServices - General purpose services available to every PEIM.
61 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
62 PEI_NT_AUTOSCAN_PPI
*PeiNtService
;
64 EFI_PHYSICAL_ADDRESS MemoryBase
;
65 PEI_BASE_MEMORY_TEST_PPI
*MemoryTestPpi
;
66 EFI_PHYSICAL_ADDRESS ErrorAddress
;
68 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes
;
71 DEBUG ((EFI_D_ERROR
, "NT 32 Autoscan PEIM Loaded\n"));
74 // Get the PEI NT Autoscan PPI
76 Status
= PeiServicesLocatePpi (
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
= PeiServicesLocatePpi (
88 &gPeiBaseMemoryTestPpiGuid
,
91 (VOID
**)&MemoryTestPpi
93 ASSERT_EFI_ERROR (Status
);
97 Status
= PeiNtService
->NtAutoScan (Index
, &MemoryBase
, &MemorySize
);
98 if (!EFI_ERROR (Status
)) {
101 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
102 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
103 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
104 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE
|
105 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE
|
106 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
111 // For the first area register it as PEI tested memory
113 Status
= MemoryTestPpi
->BaseMemoryTest (
114 (EFI_PEI_SERVICES
**) PeiServices
,
121 ASSERT_EFI_ERROR (Status
);
124 // Register the "tested" memory with the PEI Core
126 Status
= PeiServicesInstallPeiMemory (MemoryBase
, MemorySize
);
127 ASSERT_EFI_ERROR (Status
);
129 Attributes
|= EFI_RESOURCE_ATTRIBUTE_TESTED
;
132 BuildResourceDescriptorHob (
133 EFI_RESOURCE_SYSTEM_MEMORY
,
140 } while (!EFI_ERROR (Status
));
143 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
145 BuildCpuHob (36, 16);