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