summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ArmEbPkg/ArmEbPkg.dsc12
-rwxr-xr-xArmEbPkg/ArmEbPkg.fdf14
-rwxr-xr-xArmEbPkg/Sec/ModuleEntryPoint.S56
-rwxr-xr-xArmEbPkg/Sec/ModuleEntryPoint.asm47
-rwxr-xr-xArmEbPkg/Sec/Sec.inf3
5 files changed, 92 insertions, 40 deletions
diff --git a/ArmEbPkg/ArmEbPkg.dsc b/ArmEbPkg/ArmEbPkg.dsc
index dd0d24c4fe..911d7ae302 100644
--- a/ArmEbPkg/ArmEbPkg.dsc
+++ b/ArmEbPkg/ArmEbPkg.dsc
@@ -300,14 +300,14 @@
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|10
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0
- gEmbeddedTokenSpaceGuid.PcdPrePiHobBase|0x80001000
- gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0x87FE0000 # stack at top of memory
+ gEmbeddedTokenSpaceGuid.PcdPrePiHobBase|0x00001000
+ gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0x07FE0000 # stack at top of memory
gEmbeddedTokenSpaceGuid.PcdPrePiStackSize|0x20000 # 128K stack
- gEmbeddedTokenSpaceGuid.PcdMemoryBase|0x80000000
- gEmbeddedTokenSpaceGuid.PcdMemorySize|0x10000000
+ gEmbeddedTokenSpaceGuid.PcdMemoryBase|0x00000000
+ gEmbeddedTokenSpaceGuid.PcdMemorySize|0x10000000 # 256 MB
- gArmTokenSpaceGuid.PcdCpuVectorBaseAddress|0x80000000
- gArmTokenSpaceGuid.PcdCpuResetAddress|0x80008000
+ gArmTokenSpaceGuid.PcdCpuVectorBaseAddress|0x00000000
+ gArmTokenSpaceGuid.PcdCpuResetAddress|0x40000000 # set to start of NOR
gEmbeddedTokenSpaceGuid.PcdTimerPeriod|100000
gEmbeddedTokenSpaceGuid.PcdEmbeddedPerformanceCounterPeriodInNanoseconds|77
diff --git a/ArmEbPkg/ArmEbPkg.fdf b/ArmEbPkg/ArmEbPkg.fdf
index aebc44c858..beb103bedc 100755
--- a/ArmEbPkg/ArmEbPkg.fdf
+++ b/ArmEbPkg/ArmEbPkg.fdf
@@ -27,12 +27,11 @@
[FD.ArmEb_EFI]
-####BaseAddress = 0x80208000|gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress #The base address of the FLASH Device.
-BaseAddress = 0x80008000|gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress #The base address of the FLASH Device.
-Size = 0x00080000|gEmbeddedTokenSpaceGuid.PcdEmbeddedFdSize #The size in bytes of the FLASH Device
+BaseAddress = 0x40000000|gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress #The base address of the FLASH Device.
+Size = 0x00200000|gEmbeddedTokenSpaceGuid.PcdEmbeddedFdSize #The size in bytes of the FLASH Device
ErasePolarity = 1
-BlockSize = 0x40
-NumBlocks = 0x2000
+BlockSize = 0x00001000
+NumBlocks = 0x200
################################################################################
#
@@ -50,10 +49,7 @@ NumBlocks = 0x2000
#
################################################################################
-# 512 bytes of configuration header & 8 bytes of image header
-0x00000000|0x00000208
-
-0x00000208|0x0007FDF8
+0x00000000|0x00200000
gEmbeddedTokenSpaceGuid.PcdFlashFvMainBase|gEmbeddedTokenSpaceGuid.PcdFlashFvMainSize
FV = FVMAIN_COMPACT
diff --git a/ArmEbPkg/Sec/ModuleEntryPoint.S b/ArmEbPkg/Sec/ModuleEntryPoint.S
index a586b8947e..27b5cff9da 100755
--- a/ArmEbPkg/Sec/ModuleEntryPoint.S
+++ b/ArmEbPkg/Sec/ModuleEntryPoint.S
@@ -1,5 +1,11 @@
#------------------------------------------------------------------------------
#
+# 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
@@ -13,7 +19,9 @@
#------------------------------------------------------------------------------
#include <AsmMacroIoLib.h>
+#include <Base.h>
#include <Library/PcdLib.h>
+#include <ArmEb/ArmEb.h>
.text
.align 3
@@ -22,29 +30,49 @@
.globl ASM_PFX(_ModuleEntryPoint)
ASM_PFX(_ModuleEntryPoint):
+
+ // Turn off remapping NOR to 0. We can now use DRAM in low memory
+ MmioOr32 (EB_SP810_CTRL_BASE ,BIT8)
+
+ // 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 VPF access (V* instructions)
+ mcr p15, 0, r0, c1, c0, 2
+ mov r0, #0x40000000 // Set EN bit in FPEXC
+ msr FPEXC,r0
+
+
+ // Set CPU vectors to start of DRAM
+ LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress) ,r0) // Get vector base
+ mcr p15, 0, r0, c12, c0, 0
+ isb // Sync changes to control registers
+
+ // Fill vector table with branchs to current pc (jmp $)
+ // CPU DXE driver likes known values so it can let GDB stub hook vectors
+ ldr r1, ShouldNeverGetHere
+ movs r2, #0
+FillVectors
+ str r1, [r0, r2]
+ adds r2, r2, #4
+ cmp r2, #32
+ bne FillVectors
//
// 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) ,r2) /* stack base arg2 */
- LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) /* stack size arg3 */
+ LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2) // stack base arg2
+ LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) // stack size arg3
add r4, r2, r3
-
- //Enter SVC mode and set up SVC stack pointer
- mov r0,#0x13|0x80|0x40
- msr CPSR_c,r0
- sub r4, r4, #0x400
- mov r13,r4
+ mov r13, r4
// Call C entry point
- LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) /* memory size arg1 */
- LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) /* memory size arg0 */
-
- blx ASM_PFX(CEntryPoint) /* Assume C code is ARM */
+ LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) // memory size arg1
+ LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) // memory size arg0
+ blx ASM_PFX(CEntryPoint)
ShouldNeverGetHere:
- /* _CEntryPoint should never return */
+ // _CEntryPoint should never return
b ShouldNeverGetHere
-
+
diff --git a/ArmEbPkg/Sec/ModuleEntryPoint.asm b/ArmEbPkg/Sec/ModuleEntryPoint.asm
index b669f2f7c1..d9d5bb64f2 100755
--- a/ArmEbPkg/Sec/ModuleEntryPoint.asm
+++ b/ArmEbPkg/Sec/ModuleEntryPoint.asm
@@ -13,8 +13,11 @@
//------------------------------------------------------------------------------
#include <AsmMacroIoLib.h>
+#include <Base.h>
#include <Library/PcdLib.h>
+#include <ArmEb/ArmEb.h>
#include <AutoGen.h>
+
INCLUDE AsmMacroIoLib.inc
IMPORT CEntryPoint
@@ -26,28 +29,50 @@
_ModuleEntryPoint
+ // Turn off remapping NOR to 0. We can now use DRAM in low memory
+ 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 VPF access (V* instructions)
+ mcr p15, 0, r0, c1, c0, 2
+ mov r0, #0x40000000 // Set EN bit in FPEXC
+ msr FPEXC,r0
+
+
+ // Set CPU vectors to start of DRAM
+ LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress) ,r0) // Get vector base
+ mcr p15, 0, r0, c12, c0, 0
+ isb // Sync changes to control registers
+
+ // Fill vector table with branchs to current pc (jmp $)
+ // CPU DXE driver likes known values so it can let GDB stub hook vectors
+ ldr r1, ShouldNeverGetHere
+ movs r2, #0
+FillVectors
+ str r1, [r0, r2]
+ adds r2, r2, #4
+ cmp r2, #32
+ bne FillVectors
//
// 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) ,r2) /* stack base arg2 */
- LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) /* stack size arg3 */
+ LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2) // stack base arg2
+ LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) // stack size arg3
add r4, r2, r3
-
- //Enter SVC mode and set up SVC stack pointer
- mov r0,#0x13|0x80|0x40
- msr CPSR_c,r0
- mov r13,r4
+ mov r13, r4
// Call C entry point
- LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) /* memory size arg1 */
- LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) /* memory size arg0 */
- blx CEntryPoint /* Assume C code is thumb */
+ LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) // memory size arg1
+ LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) // memory size arg0
+ blx CEntryPoint
ShouldNeverGetHere
- /* _CEntryPoint should never return */
+ // _CEntryPoint should never return
b ShouldNeverGetHere
END
+
diff --git a/ArmEbPkg/Sec/Sec.inf b/ArmEbPkg/Sec/Sec.inf
index ed46f96f21..6c416729fb 100755
--- a/ArmEbPkg/Sec/Sec.inf
+++ b/ArmEbPkg/Sec/Sec.inf
@@ -62,4 +62,7 @@
gEmbeddedTokenSpaceGuid.PcdPrePiStackBase
gEmbeddedTokenSpaceGuid.PcdMemoryBase
gEmbeddedTokenSpaceGuid.PcdMemorySize
+
+ gArmTokenSpaceGuid.PcdCpuVectorBaseAddress
+