]> git.proxmox.com Git - mirror_edk2.git/blob - ArmEbPkg/Sec/ModuleEntryPoint.asm
d9d5bb64f2e9d4e12471e83d36a0c1105055f9d7
[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 msr FPEXC,r0
41
42
43 // Set CPU vectors to start of DRAM
44 LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress) ,r0) // Get vector base
45 mcr p15, 0, r0, c12, c0, 0
46 isb // Sync changes to control registers
47
48 // Fill vector table with branchs to current pc (jmp $)
49 // CPU DXE driver likes known values so it can let GDB stub hook vectors
50 ldr r1, ShouldNeverGetHere
51 movs r2, #0
52 FillVectors
53 str r1, [r0, r2]
54 adds r2, r2, #4
55 cmp r2, #32
56 bne FillVectors
57
58 //
59 // Set stack based on PCD values. Need to do it this way to make C code work
60 // when it runs from FLASH.
61 //
62 LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2) // stack base arg2
63 LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) // stack size arg3
64 add r4, r2, r3
65 mov r13, r4
66
67 // Call C entry point
68 LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) // memory size arg1
69 LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) // memory size arg0
70 blx CEntryPoint
71
72 ShouldNeverGetHere
73 // _CEntryPoint should never return
74 b ShouldNeverGetHere
75
76 END
77
78