4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 // The package level header files this module uses
21 // The Library classes this module consumes
23 #include <Library/DebugLib.h>
24 #include <Library/HobLib.h>
25 #include <Library/IoLib.h>
26 #include <Library/MemoryAllocationLib.h>
27 #include <Library/PcdLib.h>
28 #include <Library/PciLib.h>
29 #include <Library/PeimEntryPoint.h>
30 #include <Library/ResourcePublicationLib.h>
31 #include <Guid/MemoryTypeInformation.h>
35 EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation
[] = {
36 { EfiACPIMemoryNVS
, 0x004 },
37 { EfiACPIReclaimMemory
, 0x008 },
38 { EfiReservedMemoryType
, 0x004 },
39 { EfiRuntimeServicesData
, 0x024 },
40 { EfiRuntimeServicesCode
, 0x030 },
41 { EfiBootServicesCode
, 0x180 },
42 { EfiBootServicesData
, 0xF00 },
43 { EfiMaxMemoryType
, 0x000 }
48 AddIoMemoryBaseSizeHob (
49 EFI_PHYSICAL_ADDRESS MemoryBase
,
53 BuildResourceDescriptorHob (
54 EFI_RESOURCE_MEMORY_MAPPED_IO
,
55 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
56 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
57 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
58 EFI_RESOURCE_ATTRIBUTE_TESTED
,
67 EFI_PHYSICAL_ADDRESS MemoryBase
,
68 EFI_PHYSICAL_ADDRESS MemoryLimit
71 AddIoMemoryBaseSizeHob (MemoryBase
, (UINT64
)(MemoryLimit
- MemoryBase
));
76 AddMemoryBaseSizeHob (
77 EFI_PHYSICAL_ADDRESS MemoryBase
,
81 BuildResourceDescriptorHob (
82 EFI_RESOURCE_SYSTEM_MEMORY
,
83 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
84 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
85 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
86 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE
|
87 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE
|
88 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
|
89 EFI_RESOURCE_ATTRIBUTE_TESTED
,
98 EFI_PHYSICAL_ADDRESS MemoryBase
,
99 EFI_PHYSICAL_ADDRESS MemoryLimit
102 AddMemoryBaseSizeHob (MemoryBase
, (UINT64
)(MemoryLimit
- MemoryBase
));
106 MemMapInitialization (
107 EFI_PHYSICAL_ADDRESS TopOfMemory
111 // Create Memory Type Information HOB
114 &gEfiMemoryTypeInformationGuid
,
115 mDefaultMemoryTypeInformation
,
116 sizeof(mDefaultMemoryTypeInformation
)
120 // Add PCI IO Port space available for PCI resource allocations.
122 BuildResourceDescriptorHob (
124 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
125 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
,
131 // Add PCI MMIO space available to PCI resource allocations
133 if (TopOfMemory
< BASE_2GB
) {
134 AddIoMemoryBaseSizeHob (BASE_2GB
, 0xFEC00000 - BASE_2GB
);
136 AddIoMemoryBaseSizeHob (TopOfMemory
, 0xFEC00000 - TopOfMemory
);
142 AddIoMemoryBaseSizeHob (0xFEC80000, SIZE_512KB
);
147 AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_512KB
);
150 // Video memory + Legacy BIOS region
152 AddIoMemoryRangeHob (0x0A0000, BASE_1MB
);
166 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
168 BuildCpuHob (36, 16);
173 ReserveEmuVariableNvStore (
176 EFI_PHYSICAL_ADDRESS VariableStore
;
179 // Allocate storage for NV variables early on so it will be
180 // at a consistent address. Since VM memory is preserved
181 // across reboots, this allows the NV variable storage to survive
185 (EFI_PHYSICAL_ADDRESS
)(UINTN
)
186 AllocateRuntimePool (
187 2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize
)
190 "Reserved variable store memory: 0x%lX; size: %dkb\n",
192 (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize
)) / 1024
194 PcdSet64 (PcdEmuVariableNvStoreReserved
, VariableStore
);
199 Perform Platform PEI initialization.
201 @param FileHandle Handle of the file being invoked.
202 @param PeiServices Describes the list of possible PEI Services.
204 @return EFI_SUCCESS The PEIM initialized successfully.
210 IN EFI_PEI_FILE_HANDLE FileHandle
,
211 IN CONST EFI_PEI_SERVICES
**PeiServices
214 EFI_PHYSICAL_ADDRESS TopOfMemory
;
216 DEBUG ((EFI_D_ERROR
, "Platform PEIM Loaded\n"));
218 TopOfMemory
= MemDetect ();
220 ReserveEmuVariableNvStore ();
222 PeiFvInitialization ();
224 MemMapInitialization (TopOfMemory
);
226 MiscInitialization ();