Remove ArmEbPkg and replace with ArmRealViewEbPkg. Ported ArmRealViewEbPkg to have a PEI phase, and added place holder CPU PEIM to ArmPkg. This ArmRealViewEbPkg now boots from SEC, PEI, DXE, BDS, to EBL in the ARM RealView system emulator that comes with RealView Pro.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10621 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish
2010-07-02 12:00:00 +00:00
parent 7ee525b2c1
commit afdfe8f02b
60 changed files with 2494 additions and 759 deletions

View File

@@ -0,0 +1,79 @@
#------------------------------------------------------------------------------
#
# ARM EB Entry point. Reset vector in FV header will brach to
# _ModuleEntryPoint.
#
# We use crazy macros, like LoadConstantToReg, since Xcode assembler
# does not support = assembly syntax for ldr.
#
# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
#
# This program and the accompanying materials
# 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
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#------------------------------------------------------------------------------
#include <AsmMacroIoLib.h>
#include <Base.h>
#include <Library/PcdLib.h>
#include <ArmEb/ArmEb.h>
.text
.align 3
.globl ASM_PFX(CEntryPoint)
.globl ASM_PFX(_ModuleEntryPoint)
.globl ASM_PFX(StartupAddr)
ASM_PFX(_ModuleEntryPoint):
// Turn off remapping NOR to 0. We can now use DRAM in low memory
// CAN'T DO THIS HERE -- BRANCH FROM RESET VECTOR IS RELATIVE AND REMAINS IN REMAPPED NOR
//MmioOr32 (0x10001000 ,BIT8) //EB_SP810_CTRL_BASE
// Enable NEON register in case folks want to use them for optimizations (CopyMem)
mrc p15, 0, r0, c1, c0, 2
orr r0, r0, #0x00f00000 // Enable VFP access (V* instructions)
mcr p15, 0, r0, c1, c0, 2
mov r0, #0x40000000 // Set EN bit in FPEXC
mcr p10,#0x7,r0,c8,c0,#0 // msr FPEXC,r0 in ARM assembly
// Set CPU vectors to 0 (which is currently flash)
LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress) ,r0) // Get vector base
mcr p15, 0, r0, c12, c0, 0
isb // Sync changes to control registers
//
// Set stack based on PCD values. Need to do it this way to make C code work
// when it runs from FLASH.
//
LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r0) // temp ram base arg 0 TODO: change "stackbase" to "temprambase"
LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r1) // temp ram size arg 1
lsr r3, r1, #1 // r4 = size of temp mem / 2
add r3, r3, r0 // r2 = temp ram base + r4
mov r13, r3 // result: stack pointer = temp ram base + (size of temp mem / 2)
// lr points to area in reset vector block containing PEI core address
ldr r2, [lr] // pei core arg 3
// move sec startup address into a data register
// ensure we're jumping to FV version of the code (not boot remapped alias)
#ifndef __APPLE__
// This does not generate a valid relocation for Xcode. Fix me...
ldr r4, ASM_PFX(StartupAddr)
// jump to SEC C code
blx r4
#endif
ASM_PFX(ShouldNeverGetHere):
// _CEntryPoint should never return
b ASM_PFX(ShouldNeverGetHere)

View File

@@ -0,0 +1,80 @@
//------------------------------------------------------------------------------
//
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
//
// This program and the accompanying materials
// 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
// http://opensource.org/licenses/bsd-license.php
//
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
//------------------------------------------------------------------------------
#include <AsmMacroIoLib.h>
#include <Base.h>
#include <Library/PcdLib.h>
#include <ArmEb/ArmEb.h>
#include <AutoGen.h>
INCLUDE AsmMacroIoLib.inc
IMPORT CEntryPoint
EXPORT _ModuleEntryPoint
PRESERVE8
AREA ModuleEntryPoint, CODE, READONLY
StartupAddr DCD CEntryPoint
_ModuleEntryPoint
// Turn off remapping NOR to 0. We can now use DRAM in low memory
// CAN'T DO THIS HERE -- BRANCH FROM RESET VECTOR IS RELATIVE AND REMAINS IN REMAPPED NOR
//MmioOr32 (0x10001000 ,BIT8) //EB_SP810_CTRL_BASE
// Enable NEON register in case folks want to use them for optimizations (CopyMem)
mrc p15, 0, r0, c1, c0, 2
orr r0, r0, #0x00f00000 // Enable VFP access (V* instructions)
mcr p15, 0, r0, c1, c0, 2
mov r0, #0x40000000 // Set EN bit in FPEXC
mcr p10,#0x7,r0,c8,c0,#0 // msr FPEXC,r0 in ARM assembly
// Set CPU vectors to 0 (which is currently flash)
LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress) ,r0) // Get vector base
mcr p15, 0, r0, c12, c0, 0
isb // Sync changes to control registers
//
// Set stack based on PCD values. Need to do it this way to make C code work
// when it runs from FLASH.
//
LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r0) // temp ram base arg 0 TODO: change "stackbase" to "temprambase"
LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r1) // temp ram size arg 1
lsr r3, r1, #1 // r4 = size of temp mem / 2
add r3, r3, r0 // r2 = temp ram base + r4
mov r13, r3 // result: stack pointer = temp ram base + (size of temp mem / 2)
// lr points to area in reset vector block containing PEI core address
ldr r2, [lr] // pei core arg 3
// move sec startup address into a data register
// ensure we're jumping to FV version of the code (not boot remapped alias)
ldr r4, StartupAddr
// jump to SEC C code
blx r4
// Call C entry point
// THIS DOESN'T WORK, WE NEED A LONG JUMP
// blx CEntryPoint
ShouldNeverGetHere
// _CEntryPoint should never return
b ShouldNeverGetHere
END

View File

@@ -0,0 +1,43 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials
# 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
# http://opensource.org/licenses/bsd-license.php.
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#------------------------------------------------------------------------------
.text
.align 3
.globl ASM_PFX(SecSwitchStack)
#/**
# This allows the caller to switch the stack and return
#
# @param StackDelta Signed amount by which to modify the stack pointer
#
# @return Nothing. Goes to the Entry Point passing in the new parameters
#
#**/
#VOID
#EFIAPI
#SecSwitchStack (
# VOID *StackDelta
# )#
#
ASM_PFX(SecSwitchStack):
mov R1, R13
add R1, R0, R1
mov R13, R1
bx LR

View File

@@ -0,0 +1,38 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
; Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
; This program and the accompanying materials
; 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
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
;------------------------------------------------------------------------------
EXPORT SecSwitchStack
AREA Switch_Stack, CODE, READONLY
;/**
; This allows the caller to switch the stack and return
;
; @param StackDelta Signed amount by which to modify the stack pointer
;
; @return Nothing. Goes to the Entry Point passing in the new parameters
;
;**/
;VOID
;EFIAPI
;SecSwitchStack (
; VOID *StackDelta
; );
;
SecSwitchStack
MOV R1, SP
ADD R1, R0, R1
MOV SP, R1
BX LR
END

119
ArmRealViewEbPkg/SecForPei/Sec.c Executable file
View File

@@ -0,0 +1,119 @@
/** @file
C Entry point for the SEC. First C code after the reset vector.
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials
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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <PiPei.h>
#include <Ppi/TemporaryRamSupport.h>
#include <Library/PcdLib.h>
#include <Library/IoLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <ArmEb/ArmEb.h>
EFI_STATUS
EFIAPI
SecTemporaryRamSupport (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
IN UINTN CopySize
);
VOID
SecSwitchStack (
INTN StackDelta
);
TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport};
EFI_PEI_PPI_DESCRIPTOR gSecPpiTable[] = {
{
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gEfiTemporaryRamSupportPpiGuid,
&mSecTemporaryRamSupportPpi
}
};
VOID
EFIAPI
_ModuleEntryPoint(
VOID
);
VOID
CEntryPoint (
IN UINTN TempRamBase,
IN UINTN TempRamSize,
IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint
)
{
EFI_SEC_PEI_HAND_OFF SecCoreData;
// Turn off remapping NOR to 0. We can will now see DRAM in low memory (although it is not yet initialized)
// note: this makes SEC platform-specific for the EB platform
MmioOr32 (0x10001000 ,BIT8); //EB_SP810_CTRL_BASE
//
// Bind this information into the SEC hand-off state
// Note: this must be in sync with the stuff in the asm file
// Note also: HOBs (pei temp ram) MUST be above stack
//
SecCoreData.DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);
SecCoreData.BootFirmwareVolumeBase = (VOID *)(UINTN)PcdGet32 (PcdEmbeddedFdBaseAddress);
SecCoreData.BootFirmwareVolumeSize = PcdGet32 (PcdEmbeddedFdSize);
SecCoreData.TemporaryRamBase = (VOID*)(UINTN)TempRamBase;
SecCoreData.TemporaryRamSize = TempRamSize;
SecCoreData.PeiTemporaryRamBase = (VOID *)(UINTN)(SecCoreData.TemporaryRamBase + (SecCoreData.TemporaryRamSize / 2));
SecCoreData.PeiTemporaryRamSize = SecCoreData.TemporaryRamSize / 2;
SecCoreData.StackBase = (VOID *)(UINTN)(SecCoreData.TemporaryRamBase);
SecCoreData.StackSize = SecCoreData.TemporaryRamSize - SecCoreData.PeiTemporaryRamSize;
// jump to pei core entry point
(PeiCoreEntryPoint)(&SecCoreData, (VOID *)&gSecPpiTable);
}
EFI_STATUS
EFIAPI
SecTemporaryRamSupport (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
IN UINTN CopySize
)
{
//
// Migrate the whole temporary memory to permenent memory.
//
CopyMem (
(VOID*)(UINTN)PermanentMemoryBase,
(VOID*)(UINTN)TemporaryMemoryBase,
CopySize
);
SecSwitchStack((UINTN)(PermanentMemoryBase - TemporaryMemoryBase));
//
// We need *not* fix the return address because currently,
// The PeiCore is excuted in flash.
//
//
// Simulate to invalid temporary memory, terminate temporary memory
//
//ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
return EFI_SUCCESS;
}

View File

@@ -0,0 +1,57 @@
#/** @file
# SEC - Reset vector code that jumps to C and loads DXE core
#
# Copyright (c) 2008, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials
# 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
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ArmRealViewEbSec
FILE_GUID = d959e387-7b91-452c-90e0-a1dbac90ddb8
MODULE_TYPE = SEC
VERSION_STRING = 1.0
[Sources.ARM]
Sec.c
Arm/SwitchStack.asm
Arm/SwitchStack.S
Arm/ModuleEntryPoint.S
Arm/ModuleEntryPoint.asm
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
ArmPkg/ArmPkg.dec
ArmRealViewEbPkg/ArmRealViewEbPkg.dec
[LibraryClasses]
BaseLib
BaseMemoryLib
DebugLib
IoLib
[Ppis]
gEfiTemporaryRamSupportPpiGuid
[FeaturePcd]
[FixedPcd]
gArmTokenSpaceGuid.PcdCpuVectorBaseAddress
gEmbeddedTokenSpaceGuid.PcdPrePiStackSize
gEmbeddedTokenSpaceGuid.PcdPrePiStackBase
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdSize
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress