340
|
1
|
385
|
2 section reset
|
375
|
3
|
|
4 interrupt_vector_table:
|
389
|
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
|
375
|
8 ivt_prefetch: B undef_handler ; 0x0C prefetch abort
|
389
|
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
|
375
|
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
|
|
58 mov pc, lr
|
|
59
|
381
|
60 arch_pfr1:
|
362
|
61 mrc p15, 0, r0, c0, c1, 1
|
|
62 mov pc, lr
|
|
63
|
381
|
64 arch_mmfr0:
|
362
|
65 mrc p15, 0, r0, c0, c1, 4
|
|
66 mov pc, lr
|
|
67
|
381
|
68 arch_mpuir:
|
362
|
69 mrc p15, 0, r0, c0, c0, 4
|
|
70 mov pc, lr
|
381
|
71
|
|
72
|
|
73 ; Memory map tables:
|
|
74
|
|
75 section mem_tables
|
|
76
|
|
77 kernel_table0:
|
388
|
78 dcd 0x00000402 ; Identity map first 1 MB
|
|
79 dcd 0x10000402 ; Map to peripheral space 1 MB
|
|
80 repeat 0x5FE
|
386
|
81 dcd 0
|
|
82 endrepeat
|
381
|
83
|
388
|
84 dcd 0x00000402 ; Alias to 0x0
|
|
85
|
|
86 repeat 0x9FF
|
|
87 dcd 0
|
|
88 endrepeat
|
|
89
|