340
|
1
|
381
|
2 section code
|
375
|
3
|
|
4 interrupt_vector_table:
|
|
5 ivt_reset: B start ; 0x0 reset
|
|
6 ivt_undef: B undef_handler ; 0x4 undefined instruction
|
|
7 ivt_svc: B undef_handler ; 0x08 Supervisor call
|
|
8 ivt_prefetch: B undef_handler ; 0x0C prefetch abort
|
|
9 ivt_data: B undef_handler ; 0x10 data abort
|
|
10 ivt_hyptrap: B undef_handler ; 0x14 not used
|
|
11 ivt_irq: B undef_handler ; 0x18 IRQ
|
|
12 ivt_fiq: B undef_handler ; 0x18 FIQ
|
|
13
|
|
14
|
|
15 start:
|
|
16
|
|
17 ; Setup TTBR1 (translation table base register)
|
|
18
|
381
|
19 ldr r0, =kernel_table0 ; pseudo instruction which loads the value of the symbol
|
|
20 ; -KERNEL_BASE
|
375
|
21 mcr p15, 0, r0, c2, c0, 1 ; TTBR1
|
|
22 mcr p15, 0, r0, c2, c0, 0 ; TTBR0
|
|
23
|
|
24 ; Prepare the TTBCR (translation table base control register)
|
|
25 mov r0, 0x1 ; TBD: why set this to 1?
|
|
26 mcr p15, 0, r0, c2, c0, 2
|
|
27
|
|
28 ; Enable the VMSA (Virtual memory system architecture):
|
|
29 mrc p15, 0, r0, c1, c0, 0
|
|
30 ; TODO:
|
|
31 ; orr r0, r0, 0x1
|
|
32 mcr p15, 0, r0, c1, c0, 0
|
|
33
|
|
34 ; Setup stack:
|
352
|
35 mov sp, 0x30000
|
|
36 BL kernel_start ; Branch to main (this is actually in the interrupt vector)
|
|
37 local_loop:
|
|
38 B local_loop
|
362
|
39
|
|
40
|
375
|
41 ; Interrupt handlers:
|
|
42
|
|
43 undef_handler:
|
|
44 B undef_handler
|
|
45
|
381
|
46
|
|
47 ; Assembly language helpers:
|
362
|
48 ; Called to identify the proc:
|
381
|
49 arch_pfr0:
|
362
|
50 mrc p15, 0, r0, c0, c1, 0
|
|
51 mov pc, lr
|
|
52
|
381
|
53 arch_pfr1:
|
362
|
54 mrc p15, 0, r0, c0, c1, 1
|
|
55 mov pc, lr
|
|
56
|
381
|
57 arch_mmfr0:
|
362
|
58 mrc p15, 0, r0, c0, c1, 4
|
|
59 mov pc, lr
|
|
60
|
|
61
|
381
|
62 arch_mpuir:
|
362
|
63 mrc p15, 0, r0, c0, c0, 4
|
|
64 mov pc, lr
|
381
|
65
|
|
66
|
|
67 ; Memory map tables:
|
|
68
|
|
69 section mem_tables
|
|
70
|
|
71 kernel_table0:
|
|
72 dcd 0x000402
|
|
73
|