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