add a error macro to prevent this file from included for now #error "UEFI 2.1 HII...
[mirror_edk2.git] / EdkNt32Pkg / Pei / Autoscan / WinntAutoscan.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13 WinNtAutoscan.c\r
14\r
15Abstract:\r
c2a77067 16 This PEIM to abstract memory auto-scan in a Windows NT environment.\r
878ddf1f 17\r
18Revision History\r
19\r
20--*/\r
21\r
22EFI_STATUS\r
23EFIAPI\r
24PeimInitializeWinNtAutoScan (\r
25 IN EFI_FFS_FILE_HEADER *FfsHeader,\r
26 IN EFI_PEI_SERVICES **PeiServices\r
27 )\r
28/*++\r
29\r
30Routine Description:\r
31 Perform a call-back into the SEC simulator to get a memory value\r
32\r
33Arguments:\r
34 FfsHeader - General purpose data available to every PEIM\r
35 PeiServices - General purpose services available to every PEIM.\r
36 \r
37Returns:\r
38 None\r
39\r
40--*/\r
41{\r
42 EFI_STATUS Status;\r
43 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
44 PEI_NT_AUTOSCAN_PPI *PeiNtService;\r
45 UINT64 MemorySize;\r
46 EFI_PHYSICAL_ADDRESS MemoryBase;\r
47 PEI_BASE_MEMORY_TEST_PPI *MemoryTestPpi;\r
48 EFI_PHYSICAL_ADDRESS ErrorAddress;\r
49 UINTN Index;\r
50 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;\r
51\r
52\r
53 DEBUG ((EFI_D_ERROR, "NT 32 Autoscan PEIM Loaded\n"));\r
54\r
55 //\r
56 // Get the PEI NT Autoscan PPI\r
57 //\r
58 Status = (**PeiServices).LocatePpi (\r
59 PeiServices,\r
60 &gPeiNtAutoScanPpiGuid, // GUID\r
61 0, // INSTANCE\r
62 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
63 &PeiNtService // PPI\r
64 );\r
65 ASSERT_EFI_ERROR (Status);\r
66\r
67 //\r
68 // Get the Memory Test PPI\r
69 //\r
70 Status = (**PeiServices).LocatePpi (\r
71 PeiServices,\r
72 &gPeiBaseMemoryTestPpiGuid,\r
73 0,\r
74 NULL,\r
75 &MemoryTestPpi\r
76 );\r
77 ASSERT_EFI_ERROR (Status);\r
78\r
79 Index = 0;\r
80 do {\r
81 Status = PeiNtService->NtAutoScan (Index, &MemoryBase, &MemorySize);\r
82 if (!EFI_ERROR (Status)) {\r
83 Attributes =\r
84 (\r
85 EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
86 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
87 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
88 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
89 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
90 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
91 );\r
92\r
93 if (Index == 0) {\r
94 //\r
95 // For the first area register it as PEI tested memory\r
96 //\r
97 Status = MemoryTestPpi->BaseMemoryTest (\r
98 PeiServices,\r
99 MemoryTestPpi,\r
100 MemoryBase,\r
101 MemorySize,\r
102 Quick,\r
103 &ErrorAddress\r
104 );\r
105 ASSERT_EFI_ERROR (Status);\r
106\r
107 //\r
108 // Register the "tested" memory with the PEI Core\r
109 //\r
110 Status = (**PeiServices).InstallPeiMemory (PeiServices, MemoryBase, MemorySize);\r
111 ASSERT_EFI_ERROR (Status);\r
112\r
113 Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;\r
114 }\r
115 \r
116 BuildResourceDescriptorHob (\r
117 EFI_RESOURCE_SYSTEM_MEMORY,\r
118 Attributes,\r
119 MemoryBase,\r
120 MemorySize\r
121 );\r
122 }\r
123 Index++;\r
124 } while (!EFI_ERROR (Status));\r
125\r
126 //\r
127 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.\r
128 //\r
129 BuildCpuHob (36, 16);\r
130 \r
131 return Status;\r
132}\r