]> git.proxmox.com Git - mirror_edk2.git/blob - ArmEbPkg/Sec/ModuleEntryPoint.asm
Fix GCC build issue
[mirror_edk2.git] / ArmEbPkg / Sec / ModuleEntryPoint.asm
1 //------------------------------------------------------------------------------
2 //
3 // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 //
5 // 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
9 //
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.
12 //
13 //------------------------------------------------------------------------------
14
15 #include <AsmMacroIoLib.h>
16 #include <Base.h>
17 #include <Library/PcdLib.h>
18 #include <ArmEb/ArmEb.h>
19 #include <AutoGen.h>
20
21 INCLUDE AsmMacroIoLib.inc
22
23 IMPORT CEntryPoint
24 EXPORT _ModuleEntryPoint
25
26 PRESERVE8
27 AREA ModuleEntryPoint, CODE, READONLY
28
29
30 _ModuleEntryPoint
31
32 // Turn off remapping NOR to 0. We can now use DRAM in low memory
33 MmioOr32 (0x10001000 ,BIT8) //EB_SP810_CTRL_BASE
34
35 // Enable NEON register in case folks want to use them for optimizations (CopyMem)
36 mrc p15, 0, r0, c1, c0, 2
37 orr r0, r0, #0x00f00000 // Enable VPF access (V* instructions)
38 mcr p15, 0, r0, c1, c0, 2
39 mov r0, #0x40000000 // Set EN bit in FPEXC
40 mcr p10,#0x7,r0,c8,c0,#0 // msr FPEXC,r0 in ARM assembly
41
42 // Set CPU vectors to start of DRAM
43 LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress) ,r0) // Get vector base
44 mcr p15, 0, r0, c12, c0, 0
45 isb // Sync changes to control registers
46
47 // Fill vector table with branchs to current pc (jmp $)
48 // CPU DXE driver likes known values so it can let GDB stub hook vectors
49 ldr r1, ShouldNeverGetHere
50 movs r2, #0
51 FillVectors
52 str r1, [r0, r2]
53 adds r2, r2, #4
54 cmp r2, #32
55 bne FillVectors
56
57 //
58 // Set stack based on PCD values. Need to do it this way to make C code work
59 // when it runs from FLASH.
60 //
61 LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2) // stack base arg2
62 LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) // stack size arg3
63 add r4, r2, r3
64 mov r13, r4
65
66 // Call C entry point
67 LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) // memory size arg1
68 LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) // memory size arg0
69 blx CEntryPoint
70
71 ShouldNeverGetHere
72 // _CEntryPoint should never return
73 b ShouldNeverGetHere
74
75 END
76
77