2 #include "include/assembly.h"
4 KERNEL_BASE = 0x80000000
5 PCI_PADDR = 0x60000000 @ Realview
6 UART0_PADDR = 0x10009000 @ Realview
8 @ Exception defs taken from ARM DDI 0406B
11 interrupt_vector_table:
12 ivt_reset: b _start @ Reset
14 ivt_svc: b SyscallHandler @ SVC (SWI assume)
15 ivt_prefetch: b DataAbort @ Prefetch abort
16 ivt_data: b DataAbort @ Data abort
17 ivt_unused: b . @ Not Used
18 ivt_irq: b IRQHandler @ IRQ
19 ivt_fiq: b . @ FIQ (Fast interrupt)
23 ldr r0, =kernel_table0-KERNEL_BASE
24 mcr p15, 0, r0, c2, c0, 1 @ Set TTBR1 to r0
25 mcr p15, 0, r0, c2, c0, 0 @ Set TTBR0 to r0 too (for identity)
28 mcr p15, 0, r0, c2, c0, 2 @ Set TTCR to 1 (50/50 split)
31 mcr p15, 0, r0, c3, c0, 0 @ Set Domain 0 to Manager
33 mrc p15, 0, r0, c1, c0, 0
36 mcr p15, 0, r0, c1, c0, 0
38 @ Prepare for interrupts
40 ldr sp, =irqstack+0x1000 @ Set up stack
43 ldr sp, =stack+0x10000 @ Set up stack
46 1: b 1b @ Infinite loop
50 .comm stack, 0x10000 @ ; 64KiB Stack
51 .comm irqstack, 0x1000 @ ; 4KiB Stack
62 sub lr, #4 @ Adjust LR to the correct value
63 srsdb sp!, #19 @ Switch to supervisor mode (DDI0406B D1.6.5) (actually SRSFD)
73 @ Call the registered handler
80 rfeia sp! @ Pop state (actually RFEFD)
85 sub lr, #8 @ Adjust LR to the correct value
86 srsdb sp!, #19 @ Switch to supervisor mode (DDI0406B D1.6.5) (actually SRSFD)
91 ldr r1, =csDataAbort_Fmt
92 ldr r0, =csDataAbort_Tag
98 rfeia sp! @ Pop state (actually RFEFD)
107 .asciz "Data Abort at %p"
109 .comm irqstack, 0x1000
115 .long 0x00000002 @ Identity map the first 1 MiB
119 .long user_table1_map + 0x000 - KERNEL_BASE + 1
120 .long user_table1_map + 0x400 - KERNEL_BASE + 1
121 .long 0 @ user_table1_map + 0x800 - KERNEL_BASE + 1
122 .long 0 @ user_table1_map + 0xC00 - KERNEL_BASE + 1
123 @ 0x80000000 - User/Kernel split
124 .long 0x00000002 @ Map first 4 MiB to 2GiB
128 .rept 0xF00 - 0x800 - 4
132 .long PCI_PADDR + 0*(1 << 20) + 2 @ Map PCI config space
133 .long PCI_PADDR + 1*(1 << 20) + 2
134 .long PCI_PADDR + 2*(1 << 20) + 2
135 .long PCI_PADDR + 3*(1 << 20) + 2
136 .long PCI_PADDR + 4*(1 << 20) + 2
137 .long PCI_PADDR + 5*(1 << 20) + 2
138 .long PCI_PADDR + 6*(1 << 20) + 2
139 .long PCI_PADDR + 7*(1 << 20) + 2
140 .long PCI_PADDR + 8*(1 << 20) + 2
141 .long PCI_PADDR + 9*(1 << 20) + 2
142 .long PCI_PADDR + 10*(1 << 20) + 2
143 .long PCI_PADDR + 11*(1 << 20) + 2
144 .long PCI_PADDR + 12*(1 << 20) + 2
145 .long PCI_PADDR + 13*(1 << 20) + 2
146 .long PCI_PADDR + 14*(1 << 20) + 2
147 .long PCI_PADDR + 15*(1 << 20) + 2
153 .long hwmap_table_0 + 0x000 - KERNEL_BASE + 1
154 .long hwmap_table_0 + 0x400 - KERNEL_BASE + 1
155 .long hwmap_table_0 + 0x800 - KERNEL_BASE + 1
156 .long hwmap_table_0 + 0xC00 - KERNEL_BASE + 1
157 .rept 0xFF8 - 0xF00 - 16 - 4
161 .long kernel_table1_map + 0x000 - KERNEL_BASE + 1
162 .long kernel_table1_map + 0x400 - KERNEL_BASE + 1
163 .long kernel_table1_map + 0x800 - KERNEL_BASE + 1
164 .long kernel_table1_map + 0xC00 - KERNEL_BASE + 1
166 .long 0 @ removed for alignment constraints, using the KERNEL_BASE identity mapping instead
167 .rept 0x1000 - 0xFF8 - 5
172 .globl user_table1_map
173 user_table1_map: @ Size = 4KiB
177 .long kernel_table0 - KERNEL_BASE + (1 << 4) + 3
178 .long user_table1_map - KERNEL_BASE + (1 << 4) + 3
183 .globl kernel_table1_map
184 kernel_table1_map: @ Size = 4KiB
188 .long hwmap_table_0 - KERNEL_BASE + (1 << 4) + 3
189 .rept 0xFF8/4 - 0xF00/4 - 1
192 .long kernel_table1_map - KERNEL_BASE + (1 << 4) + 3
198 .long UART0_PADDR + (1 << 4) + 3 @ UART0