]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/UnixAutoScanPei/UnixAutoScan.c
Remove BaseMemoryTest PPI and related producers and consumers.
[mirror_edk2.git] / UnixPkg / UnixAutoScanPei / UnixAutoScan.c
1 /*++
2
3 Copyright (c) 2006 - 2008, 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 UnixAutoscan.c
14
15 Abstract:
16 This PEIM to abstract memory auto-scan in an Unix environment.
17
18 Revision History
19
20 --*/
21
22 #include "PiPei.h"
23 #include <Ppi/UnixAutoScan.h>
24 #include <Ppi/MemoryDiscovered.h>
25
26 #include <Library/DebugLib.h>
27 #include <Library/PeimEntryPoint.h>
28 #include <Library/BaseLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/HobLib.h>
31 #include <Library/PeiServicesLib.h>
32 #include <Library/PeiServicesTablePointerLib.h>
33
34 EFI_STATUS
35 EFIAPI
36 PeimInitializeUnixAutoScan (
37 IN EFI_PEI_FILE_HANDLE FileHandle,
38 IN CONST EFI_PEI_SERVICES **PeiServices
39 )
40 /*++
41
42 Routine Description:
43 Perform a call-back into the SEC simulator to get a memory value
44
45 Arguments:
46 FfsHeader - General purpose data available to every PEIM
47 PeiServices - General purpose services available to every PEIM.
48
49 Returns:
50 None
51
52 --*/
53 {
54 EFI_STATUS Status;
55 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
56 PEI_UNIX_AUTOSCAN_PPI *PeiUnixService;
57 UINT64 MemorySize;
58 EFI_PHYSICAL_ADDRESS MemoryBase;
59 UINTN Index;
60 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
61
62
63 DEBUG ((EFI_D_ERROR, "Unix Autoscan PEIM Loaded\n"));
64
65 //
66 // Get the PEI UNIX Autoscan PPI
67 //
68 Status = PeiServicesLocatePpi (
69 &gPeiUnixAutoScanPpiGuid, // GUID
70 0, // INSTANCE
71 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
72 (VOID **)&PeiUnixService // PPI
73 );
74 ASSERT_EFI_ERROR (Status);
75
76 Index = 0;
77 do {
78 Status = PeiUnixService->UnixAutoScan (Index, &MemoryBase, &MemorySize);
79 if (!EFI_ERROR (Status)) {
80 Attributes =
81 (
82 EFI_RESOURCE_ATTRIBUTE_PRESENT |
83 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
84 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
85 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
86 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
87 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
88 );
89
90 if (Index == 0) {
91 //
92 // Register the memory with the PEI Core
93 //
94 Status = PeiServicesInstallPeiMemory (MemoryBase, MemorySize);
95 ASSERT_EFI_ERROR (Status);
96
97 Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;
98 }
99
100 BuildResourceDescriptorHob (
101 EFI_RESOURCE_SYSTEM_MEMORY,
102 Attributes,
103 MemoryBase,
104 MemorySize
105 );
106 }
107 Index++;
108 } while (!EFI_ERROR (Status));
109
110 //
111 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
112 //
113 BuildCpuHob (36, 16);
114
115 return Status;
116 }