340
|
1
|
385
|
2 section reset
|
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
|
386
|
28
|
|
29 ; Set domain 0 to manager:
|
|
30 mov r0, 3
|
|
31 mcr p15, 0, r0, c3, c0, 0
|
|
32
|
|
33
|
375
|
34 ; Enable the VMSA (Virtual memory system architecture):
|
|
35 mrc p15, 0, r0, c1, c0, 0
|
|
36 ; TODO:
|
388
|
37 mov r1, 0x1
|
|
38 orr r0, r0, r1 ; TODO: implement orr r0, r0, 1
|
375
|
39 mcr p15, 0, r0, c1, c0, 0
|
|
40
|
|
41 ; Setup stack:
|
352
|
42 mov sp, 0x30000
|
|
43 BL kernel_start ; Branch to main (this is actually in the interrupt vector)
|
|
44 local_loop:
|
|
45 B local_loop
|
362
|
46
|
|
47
|
375
|
48 ; Interrupt handlers:
|
|
49
|
|
50 undef_handler:
|
|
51 B undef_handler
|
|
52
|
381
|
53
|
|
54 ; Assembly language helpers:
|
362
|
55 ; Called to identify the proc:
|
381
|
56 arch_pfr0:
|
362
|
57 mrc p15, 0, r0, c0, c1, 0
|
386
|
58 ldr r0, =kernel_table0
|
362
|
59 mov pc, lr
|
|
60
|
381
|
61 arch_pfr1:
|
362
|
62 mrc p15, 0, r0, c0, c1, 1
|
|
63 mov pc, lr
|
|
64
|
381
|
65 arch_mmfr0:
|
362
|
66 mrc p15, 0, r0, c0, c1, 4
|
|
67 mov pc, lr
|
|
68
|
|
69
|
381
|
70 arch_mpuir:
|
362
|
71 mrc p15, 0, r0, c0, c0, 4
|
|
72 mov pc, lr
|
381
|
73
|
|
74
|
|
75 ; Memory map tables:
|
|
76
|
|
77 section mem_tables
|
|
78
|
|
79 kernel_table0:
|
388
|
80 dcd 0x00000402 ; Identity map first 1 MB
|
|
81 dcd 0x10000402 ; Map to peripheral space 1 MB
|
|
82 repeat 0x5FE
|
386
|
83 dcd 0
|
|
84 endrepeat
|
381
|
85
|
388
|
86 dcd 0x00000402 ; Alias to 0x0
|
|
87
|
|
88 repeat 0x9FF
|
|
89 dcd 0
|
|
90 endrepeat
|
|
91
|