]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/WinNtAutoScanPeim/WinNtAutoScan.c
Add WinNtSimpleFileSystemDxe driver into Nt32Pkg.
[mirror_edk2.git] / Nt32Pkg / WinNtAutoScanPeim / WinNtAutoScan.c
1 /*++
2
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
8
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.
11
12 Module Name:
13 WinNtAutoscan.c
14
15 Abstract:
16 This PEIM to abstract memory auto-scan in a Windows NT environment.
17
18 Revision History
19
20 --*/
21
22 //
23 // The package level header files this module uses
24 //
25 #include <PiPei.h>
26 #include <WinNtPeim.h>
27 //
28 // The protocols, PPI and GUID defintions for this module
29 //
30 #include <Ppi/BaseMemoryTest.h>
31 #include <Ppi/NtAutoscan.h>
32 //
33 // The Library classes this module consumes
34 //
35 #include <Library/DebugLib.h>
36 #include <Library/PeimEntryPoint.h>
37 #include <Library/HobLib.h>
38
39 EFI_STATUS
40 EFIAPI
41 PeimInitializeWinNtAutoScan (
42 IN EFI_FFS_FILE_HEADER *FfsHeader,
43 IN EFI_PEI_SERVICES **PeiServices
44 )
45 /*++
46
47 Routine Description:
48 Perform a call-back into the SEC simulator to get a memory value
49
50 Arguments:
51 FfsHeader - General purpose data available to every PEIM
52 PeiServices - General purpose services available to every PEIM.
53
54 Returns:
55 None
56
57 --*/
58 {
59 EFI_STATUS Status;
60 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
61 PEI_NT_AUTOSCAN_PPI *PeiNtService;
62 UINT64 MemorySize;
63 EFI_PHYSICAL_ADDRESS MemoryBase;
64 PEI_BASE_MEMORY_TEST_PPI *MemoryTestPpi;
65 EFI_PHYSICAL_ADDRESS ErrorAddress;
66 UINTN Index;
67 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
68
69
70 DEBUG ((EFI_D_ERROR, "NT 32 Autoscan PEIM Loaded\n"));
71
72 //
73 // Get the PEI NT Autoscan PPI
74 //
75 Status = (**PeiServices).LocatePpi (
76 PeiServices,
77 &gPeiNtAutoScanPpiGuid, // GUID
78 0, // INSTANCE
79 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
80 &PeiNtService // PPI
81 );
82 ASSERT_EFI_ERROR (Status);
83
84 //
85 // Get the Memory Test PPI
86 //
87 Status = (**PeiServices).LocatePpi (
88 PeiServices,
89 &gPeiBaseMemoryTestPpiGuid,
90 0,
91 NULL,
92 &MemoryTestPpi
93 );
94 ASSERT_EFI_ERROR (Status);
95
96 Index = 0;
97 do {
98 Status = PeiNtService->NtAutoScan (Index, &MemoryBase, &MemorySize);
99 if (!EFI_ERROR (Status)) {
100 Attributes =
101 (
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
108 );
109
110 if (Index == 0) {
111 //
112 // For the first area register it as PEI tested memory
113 //
114 Status = MemoryTestPpi->BaseMemoryTest (
115 PeiServices,
116 MemoryTestPpi,
117 MemoryBase,
118 MemorySize,
119 Quick,
120 &ErrorAddress
121 );
122 ASSERT_EFI_ERROR (Status);
123
124 //
125 // Register the "tested" memory with the PEI Core
126 //
127 Status = (**PeiServices).InstallPeiMemory (PeiServices, MemoryBase, MemorySize);
128 ASSERT_EFI_ERROR (Status);
129
130 Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;
131 }
132
133 BuildResourceDescriptorHob (
134 EFI_RESOURCE_SYSTEM_MEMORY,
135 Attributes,
136 MemoryBase,
137 MemorySize
138 );
139 }
140 Index++;
141 } while (!EFI_ERROR (Status));
142
143 //
144 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
145 //
146 BuildCpuHob (36, 16);
147
148 return Status;
149 }