ArmPkg/CpuPei: Get the System Memory from the Resource Memory HOB

Declare the system memory provided by the first Resource Memory HOB
as cached memory to the MMU.
All the remaining memory space is declared as Device Memory.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11861 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2011-06-20 21:32:46 +00:00
parent d7b6c49b78
commit fbcd5cea83
2 changed files with 74 additions and 20 deletions

View File

@ -1,6 +1,7 @@
/**@file /**@file
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2011 Hewlett Packard Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -45,11 +46,40 @@ Abstract:
#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK #define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
#define DDR_ATTRIBUTES_UNCACHED ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED #define DDR_ATTRIBUTES_UNCACHED ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED
VOID EFI_STATUS
JamArmMmuConfig ( VOID ) FindMainMemory(
OUT UINT32 *PhysicalBase,
OUT UINT32 *Length
)
{ {
EFI_PEI_HOB_POINTERS NextHob;
// look at the resource descriptor hobs, choose the first system memory one
NextHob.Raw = GetHobList ();
while ((NextHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, NextHob.Raw)) != NULL) {
if(NextHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY)
{
*PhysicalBase = (UINT32)NextHob.ResourceDescriptor->PhysicalStart;
*Length = (UINT32)NextHob.ResourceDescriptor->ResourceLength;
return EFI_SUCCESS;
}
NextHob.Raw = GET_NEXT_HOB (NextHob);
}
return EFI_NOT_FOUND;
}
VOID
ConfigureMmu ( VOID )
{
EFI_STATUS Status;
UINTN Idx;
UINT32 CacheAttributes; UINT32 CacheAttributes;
ARM_MEMORY_REGION_DESCRIPTOR MemoryTable[3]; UINT32 SystemMemoryBase;
UINT32 SystemMemoryLength;
UINT32 SystemMemoryLastAddress;
ARM_MEMORY_REGION_DESCRIPTOR MemoryTable[4];
VOID *TranslationTableBase; VOID *TranslationTableBase;
UINTN TranslationTableSize; UINTN TranslationTableSize;
@ -59,23 +89,47 @@ JamArmMmuConfig ( VOID )
CacheAttributes = DDR_ATTRIBUTES_UNCACHED; CacheAttributes = DDR_ATTRIBUTES_UNCACHED;
} }
// DDR Idx = 0;
MemoryTable[0].PhysicalBase = 0;
MemoryTable[0].VirtualBase = 0;
MemoryTable[0].Length = 0x10000000;
MemoryTable[0].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)CacheAttributes;
// SOC Registers. L3 interconnects // Main Memory
MemoryTable[1].PhysicalBase = 0x10000000; Status = FindMainMemory (&SystemMemoryBase, &SystemMemoryLength);
MemoryTable[1].VirtualBase = 0x10000000; ASSERT_EFI_ERROR (Status);
MemoryTable[1].Length = 0xF0000000;
MemoryTable[1].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE; SystemMemoryLastAddress = SystemMemoryBase + (SystemMemoryLength-1);
// if system memory does not begin at 0
if(SystemMemoryBase > 0) {
MemoryTable[Idx].PhysicalBase = 0;
MemoryTable[Idx].VirtualBase = 0;
MemoryTable[Idx].Length = SystemMemoryBase;
MemoryTable[Idx].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
Idx++;
}
MemoryTable[Idx].PhysicalBase = SystemMemoryBase;
MemoryTable[Idx].VirtualBase = SystemMemoryBase;
MemoryTable[Idx].Length = SystemMemoryLength;
MemoryTable[Idx].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)CacheAttributes;
Idx++;
// if system memory does not go to the last address (0xFFFFFFFF)
if( SystemMemoryLastAddress < MAX_ADDRESS ) {
MemoryTable[Idx].PhysicalBase = SystemMemoryLastAddress + 1;
MemoryTable[Idx].VirtualBase = MemoryTable[Idx].PhysicalBase;
MemoryTable[Idx].Length = MAX_ADDRESS - MemoryTable[Idx].PhysicalBase + 1;
MemoryTable[Idx].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
Idx++;
}
// End of Table // End of Table
MemoryTable[2].PhysicalBase = 0; MemoryTable[Idx].PhysicalBase = 0;
MemoryTable[2].VirtualBase = 0; MemoryTable[Idx].VirtualBase = 0;
MemoryTable[2].Length = 0; MemoryTable[Idx].Length = 0;
MemoryTable[2].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0; MemoryTable[Idx].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)0;
DEBUG ((EFI_D_INFO, "Enabling MMU, setting 0x%08x + %d MB to %a\n",
SystemMemoryBase, SystemMemoryLength/1024/1024,
(CacheAttributes == DDR_ATTRIBUTES_CACHED) ? "cacheable" : "uncacheable"));
ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize); ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);
@ -109,7 +163,7 @@ Returns:
// Enable program flow prediction, if supported. // Enable program flow prediction, if supported.
ArmEnableBranchPrediction (); ArmEnableBranchPrediction ();
JamArmMmuConfig(); ConfigureMmu();
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -26,7 +26,7 @@
# #
# The following information is for reference only and not required by the build tools. # The following information is for reference only and not required by the build tools.
# #
# VALID_ARCHITECTURES = IA32 X64 IPF EBC # VALID_ARCHITECTURES = ARM
# #
[Sources] [Sources]