1 //------------------------------------------------------------------------------
3 // Copyright (c) 2008-2009 Apple Inc. All rights reserved.
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.
13 //------------------------------------------------------------------------------
15 #include <AsmMacroIoLib.h>
16 #include <Library/PcdLib.h>
18 INCLUDE AsmMacroIoLib.inc
21 EXPORT _ModuleEntryPoint
24 AREA ModuleEntryPoint, CODE, READONLY
30 mrc p15, 0, r0, c1, c0, 1 // read Auxiliary Control Register
31 bic r0, r0, #0x00000002 // disable L2 cache
32 mcr p15, 0, r0, c1, c0, 1 // store Auxiliary Control Register
34 //Enable Strict alignment checking & Instruction cache
35 mrc p15, 0, r0, c1, c0, 0
36 bic r0, r0, #0x00002300 /* clear bits 13, 9:8 (--V- --RS) */
37 bic r0, r0, #0x00000005 /* clear bits 0, 2 (---- -C-M) */
38 orr r0, r0, #0x00000002 /* set bit 1 (A) Align */
39 orr r0, r0, #0x00001000 /* set bit 12 (I) enable I-Cache */
40 mcr p15, 0, r0, c1, c0, 0
42 // Set CPU vectors to start of DRAM
43 LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) /* memory size arg0 */
44 mcr p15, 0, r0, c12, c0, 0
45 isb // Sync changes to control registers
47 // Fill vector table with branchs to current pc (jmp $)
48 ldr r1, ShouldNeverGetHere
56 /* before we call C code, lets setup the stack pointer in internal RAM*/
60 // Set stack based on PCD values. Need to do it this way to make C code work
61 // when it runs from FLASH.
63 LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2) /* stack base arg2 */
64 LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) /* stack size arg3 */
67 //Enter SVC mode and set up SVC stack pointer
68 mov r5,#0x13|0x80|0x40
73 LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) /* memory size arg1 */
74 // LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) Done above
75 blx CEntryPoint /* Assume C code is thumb */
78 /* _CEntryPoint should never return */