]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c
modify the format of DynamicHii type pcd in DSC file. We directly use Unicode string...
[mirror_edk2.git] / Nt32Pkg / WinNtAutoScanPei / WinNtAutoScan.c
1 /**@file
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/NtAutoscan.h>
31 //
32 // The Library classes this module consumes
33 //
34 #include <Library/DebugLib.h>
35 #include <Library/PeimEntryPoint.h>
36 #include <Library/HobLib.h>
37 #include <Library/PeiServicesLib.h>
38
39 EFI_STATUS
40 EFIAPI
41 PeimInitializeWinNtAutoScan (
42 IN EFI_PEI_FILE_HANDLE FileHandle,
43 IN CONST 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 UINTN Index;
65 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
66
67
68 DEBUG ((EFI_D_ERROR, "NT 32 Autoscan PEIM Loaded\n"));
69
70 //
71 // Get the PEI NT Autoscan PPI
72 //
73 Status = PeiServicesLocatePpi (
74 &gPeiNtAutoScanPpiGuid, // GUID
75 0, // INSTANCE
76 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
77 (VOID**)&PeiNtService // PPI
78 );
79 ASSERT_EFI_ERROR (Status);
80
81 Index = 0;
82 do {
83 Status = PeiNtService->NtAutoScan (Index, &MemoryBase, &MemorySize);
84 if (!EFI_ERROR (Status)) {
85 Attributes =
86 (
87 EFI_RESOURCE_ATTRIBUTE_PRESENT |
88 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
89 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
90 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
91 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
92 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
93 );
94
95 if (Index == 0) {
96 //
97 // Register the memory with the PEI Core
98 //
99 Status = PeiServicesInstallPeiMemory (MemoryBase, MemorySize);
100 ASSERT_EFI_ERROR (Status);
101
102 Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;
103 }
104
105 BuildResourceDescriptorHob (
106 EFI_RESOURCE_SYSTEM_MEMORY,
107 Attributes,
108 MemoryBase,
109 MemorySize
110 );
111 }
112 Index++;
113 } while (!EFI_ERROR (Status));
114
115 //
116 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
117 //
118 BuildCpuHob (36, 16);
119
120 return Status;
121 }