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 (
110 // Create Memory Type Information HOB
113 &gEfiMemoryTypeInformationGuid
,
114 mDefaultMemoryTypeInformation
,
115 sizeof(mDefaultMemoryTypeInformation
)
119 // Add PCI IO Port space available for PCI resource allocations.
121 BuildResourceDescriptorHob (
123 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
124 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
,
130 // Add PCI MMIO space available to PCI resource allocations
132 AddIoMemoryBaseSizeHob (0x80000000, 0xFEC00000 - 0x80000000);
137 AddIoMemoryBaseSizeHob (0xFEC80000, 0x80000);
142 AddIoMemoryBaseSizeHob (0xFEC00000, 0x80000);
145 // Video memory + Legacy BIOS region
147 AddIoMemoryRangeHob (0x0A0000, 0x100000);
158 IoWrite8 (0x92, (UINT8
) (IoRead8 (0x92) | 0x02));
161 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
163 BuildCpuHob (36, 16);
168 ReserveEmuVariableNvStore (
171 EFI_PHYSICAL_ADDRESS VariableStore
;
174 // Allocate storage for NV variables early on so it will be
175 // at a consistent address. Since VM memory is preserved
176 // across reboots, this allows the NV variable storage to survive
180 (EFI_PHYSICAL_ADDRESS
)(UINTN
)
181 AllocateRuntimePool (
182 2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize
)
185 "Reserved variable store memory: 0x%lX; size: %dkb\n",
187 (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize
)) / 1024
189 PcdSet64 (PcdEmuVariableNvStoreReserved
, VariableStore
);
194 Perform Platform PEI initialization.
196 @param FileHandle Handle of the file being invoked.
197 @param PeiServices Describes the list of possible PEI Services.
199 @return EFI_SUCCESS The PEIM initialized successfully.
205 IN EFI_PEI_FILE_HANDLE FileHandle
,
206 IN CONST EFI_PEI_SERVICES
**PeiServices
209 DEBUG ((EFI_D_ERROR
, "Platform PEIM Loaded\n"));
213 ReserveEmuVariableNvStore ();
215 PeiFvInitialization ();
217 MemMapInitialization ();
219 MiscInitialization ();