andrewfish | 1fde2f6 | 2010-02-25 20:31:00 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------
|
| 2 | #
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 3 | # ARM EB Entry point. Reset vector in FV header will brach to
|
| 4 | # _ModuleEntryPoint.
|
| 5 | #
|
| 6 | # We use crazy macros, like LoadConstantToReg, since Xcode assembler
|
| 7 | # does not support = assembly syntax for ldr.
|
| 8 | #
|
hhtian | cf748a1 | 2010-04-29 11:32:42 +0000 | [diff] [blame] | 9 | # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
andrewfish | 1fde2f6 | 2010-02-25 20:31:00 +0000 | [diff] [blame] | 10 | #
|
hhtian | cf748a1 | 2010-04-29 11:32:42 +0000 | [diff] [blame] | 11 | # This program and the accompanying materials
|
andrewfish | 1fde2f6 | 2010-02-25 20:31:00 +0000 | [diff] [blame] | 12 | # are licensed and made available under the terms and conditions of the BSD License
|
| 13 | # which accompanies this distribution. The full text of the license may be found at
|
| 14 | # http://opensource.org/licenses/bsd-license.php
|
| 15 | #
|
| 16 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
| 17 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
| 18 | #
|
| 19 | #------------------------------------------------------------------------------
|
| 20 |
|
| 21 | #include <AsmMacroIoLib.h>
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 22 | #include <Base.h>
|
andrewfish | 1fde2f6 | 2010-02-25 20:31:00 +0000 | [diff] [blame] | 23 | #include <Library/PcdLib.h>
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 24 | #include <ArmEb/ArmEb.h>
|
andrewfish | 1fde2f6 | 2010-02-25 20:31:00 +0000 | [diff] [blame] | 25 |
|
| 26 | .text
|
| 27 | .align 3
|
| 28 |
|
| 29 | .globl ASM_PFX(CEntryPoint)
|
| 30 | .globl ASM_PFX(_ModuleEntryPoint)
|
| 31 |
|
| 32 | ASM_PFX(_ModuleEntryPoint):
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 33 |
|
| 34 | // Turn off remapping NOR to 0. We can now use DRAM in low memory
|
| 35 | MmioOr32 (EB_SP810_CTRL_BASE ,BIT8)
|
| 36 |
|
| 37 | // Enable NEON register in case folks want to use them for optimizations (CopyMem)
|
| 38 | mrc p15, 0, r0, c1, c0, 2
|
| 39 | orr r0, r0, #0x00f00000 // Enable VPF access (V* instructions)
|
| 40 | mcr p15, 0, r0, c1, c0, 2
|
| 41 | mov r0, #0x40000000 // Set EN bit in FPEXC
|
andrewfish | fe21112 | 2010-05-20 05:36:46 +0000 | [diff] [blame^] | 42 | mcr p10,#0x7,r0,c8,c0,#0 // msr FPEXC,r0 in ARM assembly
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 43 |
|
| 44 |
|
| 45 | // Set CPU vectors to start of DRAM
|
| 46 | LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress) ,r0) // Get vector base
|
| 47 | mcr p15, 0, r0, c12, c0, 0
|
| 48 | isb // Sync changes to control registers
|
| 49 |
|
| 50 | // Fill vector table with branchs to current pc (jmp $)
|
| 51 | // CPU DXE driver likes known values so it can let GDB stub hook vectors
|
| 52 | ldr r1, ShouldNeverGetHere
|
| 53 | movs r2, #0
|
andrewfish | a9dfdf4 | 2010-05-19 01:47:25 +0000 | [diff] [blame] | 54 | FillVectors:
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 55 | str r1, [r0, r2]
|
| 56 | adds r2, r2, #4
|
| 57 | cmp r2, #32
|
| 58 | bne FillVectors
|
andrewfish | 1fde2f6 | 2010-02-25 20:31:00 +0000 | [diff] [blame] | 59 |
|
| 60 | //
|
| 61 | // Set stack based on PCD values. Need to do it this way to make C code work
|
| 62 | // when it runs from FLASH.
|
| 63 | //
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 64 | LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2) // stack base arg2
|
| 65 | LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) // stack size arg3
|
andrewfish | 1fde2f6 | 2010-02-25 20:31:00 +0000 | [diff] [blame] | 66 | add r4, r2, r3
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 67 | mov r13, r4
|
andrewfish | 1fde2f6 | 2010-02-25 20:31:00 +0000 | [diff] [blame] | 68 |
|
| 69 | // Call C entry point
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 70 | LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) // memory size arg1
|
| 71 | LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) // memory size arg0
|
| 72 | blx ASM_PFX(CEntryPoint)
|
andrewfish | 1fde2f6 | 2010-02-25 20:31:00 +0000 | [diff] [blame] | 73 |
|
| 74 | ShouldNeverGetHere:
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 75 | // _CEntryPoint should never return
|
andrewfish | 1fde2f6 | 2010-02-25 20:31:00 +0000 | [diff] [blame] | 76 | b ShouldNeverGetHere
|
| 77 |
|
andrewfish | 4ade93d | 2010-05-19 01:44:13 +0000 | [diff] [blame] | 78 |
|