]> git.proxmox.com Git - mirror_edk2.git/blob - EdkNt32Pkg/Pei/Autoscan/WinntAutoscan.c
1) Add PcatSingleSegmentPciCfg2Pei in MdeModulePkg.
[mirror_edk2.git] / EdkNt32Pkg / Pei / Autoscan / 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 EFI_STATUS
23 EFIAPI
24 PeimInitializeWinNtAutoScan (
25 IN EFI_FFS_FILE_HEADER *FfsHeader,
26 IN EFI_PEI_SERVICES **PeiServices
27 )
28 /*++
29
30 Routine Description:
31 Perform a call-back into the SEC simulator to get a memory value
32
33 Arguments:
34 FfsHeader - General purpose data available to every PEIM
35 PeiServices - General purpose services available to every PEIM.
36
37 Returns:
38 None
39
40 --*/
41 {
42 EFI_STATUS Status;
43 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
44 PEI_NT_AUTOSCAN_PPI *PeiNtService;
45 UINT64 MemorySize;
46 EFI_PHYSICAL_ADDRESS MemoryBase;
47 PEI_BASE_MEMORY_TEST_PPI *MemoryTestPpi;
48 EFI_PHYSICAL_ADDRESS ErrorAddress;
49 UINTN Index;
50 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
51
52
53 DEBUG ((EFI_D_ERROR, "NT 32 Autoscan PEIM Loaded\n"));
54
55 //
56 // Get the PEI NT Autoscan PPI
57 //
58 Status = (**PeiServices).LocatePpi (
59 PeiServices,
60 &gPeiNtAutoScanPpiGuid, // GUID
61 0, // INSTANCE
62 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
63 &PeiNtService // PPI
64 );
65 ASSERT_EFI_ERROR (Status);
66
67 //
68 // Get the Memory Test PPI
69 //
70 Status = (**PeiServices).LocatePpi (
71 PeiServices,
72 &gPeiBaseMemoryTestPpiGuid,
73 0,
74 NULL,
75 &MemoryTestPpi
76 );
77 ASSERT_EFI_ERROR (Status);
78
79 Index = 0;
80 do {
81 Status = PeiNtService->NtAutoScan (Index, &MemoryBase, &MemorySize);
82 if (!EFI_ERROR (Status)) {
83 Attributes =
84 (
85 EFI_RESOURCE_ATTRIBUTE_PRESENT |
86 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
87 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
88 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
89 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
90 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
91 );
92
93 if (Index == 0) {
94 //
95 // For the first area register it as PEI tested memory
96 //
97 Status = MemoryTestPpi->BaseMemoryTest (
98 PeiServices,
99 MemoryTestPpi,
100 MemoryBase,
101 MemorySize,
102 Quick,
103 &ErrorAddress
104 );
105 ASSERT_EFI_ERROR (Status);
106
107 //
108 // Register the "tested" memory with the PEI Core
109 //
110 Status = (**PeiServices).InstallPeiMemory (PeiServices, MemoryBase, MemorySize);
111 ASSERT_EFI_ERROR (Status);
112
113 Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;
114 }
115
116 BuildResourceDescriptorHob (
117 EFI_RESOURCE_SYSTEM_MEMORY,
118 Attributes,
119 MemoryBase,
120 MemorySize
121 );
122 }
123 Index++;
124 } while (!EFI_ERROR (Status));
125
126 //
127 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
128 //
129 BuildCpuHob (36, 16);
130
131 return Status;
132 }