4 Copyright (c) 2006 - 2010, Intel Corporation
5 All rights reserved. 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
, 0x01C },
38 { EfiRuntimeServicesData
, 0x050 },
39 { EfiRuntimeServicesCode
, 0x020 },
40 { EfiBootServicesCode
, 0x0F0 },
41 { EfiBootServicesData
, 0xA00 },
42 { EfiMaxMemoryType
, 0x000 }
47 AddIoMemoryBaseSizeHob (
48 EFI_PHYSICAL_ADDRESS MemoryBase
,
52 STATIC EFI_RESOURCE_ATTRIBUTE_TYPE Attributes
=
54 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
55 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
56 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
57 EFI_RESOURCE_ATTRIBUTE_TESTED
60 BuildResourceDescriptorHob (
61 EFI_RESOURCE_MEMORY_MAPPED_IO
,
71 EFI_PHYSICAL_ADDRESS MemoryBase
,
72 EFI_PHYSICAL_ADDRESS MemoryLimit
75 AddIoMemoryBaseSizeHob (MemoryBase
, (UINT64
)(MemoryLimit
- MemoryBase
));
80 AddMemoryBaseSizeHob (
81 EFI_PHYSICAL_ADDRESS MemoryBase
,
85 STATIC EFI_RESOURCE_ATTRIBUTE_TYPE Attributes
=
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 EFI_RESOURCE_ATTRIBUTE_TESTED
96 BuildResourceDescriptorHob (
97 EFI_RESOURCE_SYSTEM_MEMORY
,
107 EFI_PHYSICAL_ADDRESS MemoryBase
,
108 EFI_PHYSICAL_ADDRESS MemoryLimit
111 AddMemoryBaseSizeHob (MemoryBase
, (UINT64
)(MemoryLimit
- MemoryBase
));
116 MemMapInitialization (
120 // Create Memory Type Information HOB
123 &gEfiMemoryTypeInformationGuid
,
124 mDefaultMemoryTypeInformation
,
125 sizeof(mDefaultMemoryTypeInformation
)
131 AddIoMemoryBaseSizeHob (0xFEC80000, 0x80000);
136 AddIoMemoryBaseSizeHob (0xFEC00000, 0x80000);
139 // Video memory + Legacy BIOS region
141 AddIoMemoryRangeHob (0x0A0000, 0x100000);
152 IoWrite8 (0x92, (UINT8
) (IoRead8 (0x92) | 0x02));
155 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
157 BuildCpuHob (36, 16);
162 ReserveEmuVariableNvStore (
165 EFI_PHYSICAL_ADDRESS VariableStore
;
168 // Allocate storage for NV variables early on so it will be
169 // at a consistent address. Since VM memory is preserved
170 // across reboots, this allows the NV variable storage to survive
174 (EFI_PHYSICAL_ADDRESS
)(UINTN
)
175 AllocateRuntimePool (
176 2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize
)
179 "Reserved variable store memory: 0x%lX; size: %dkb\n",
181 (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize
)) / 1024
183 PcdSet64 (PcdEmuVariableNvStoreReserved
, VariableStore
);
188 Perform Platform PEI initialization.
190 @param FileHandle Handle of the file being invoked.
191 @param PeiServices Describes the list of possible PEI Services.
193 @return EFI_SUCCESS The PEIM initialized successfully.
199 IN EFI_PEI_FILE_HANDLE FileHandle
,
200 IN CONST EFI_PEI_SERVICES
**PeiServices
203 DEBUG ((EFI_D_ERROR
, "Platform PEIM Loaded\n"));
207 ReserveEmuVariableNvStore ();
209 PeiFvInitialization ();
211 MemMapInitialization ();
213 MiscInitialization ();