404
|
1
|
|
2 ; This file contains the low level assembly code required for interrupt
|
|
3 ; handling and virtual memory.
|
340
|
4
|
385
|
5 section reset
|
375
|
6
|
|
7 interrupt_vector_table:
|
389
|
8 ivt_reset: B start ; 0x0 reset
|
|
9 ivt_undef: B undef_handler ; 0x4 undefined instruction
|
|
10 ivt_svc: B undef_handler ; 0x08 Supervisor call
|
375
|
11 ivt_prefetch: B undef_handler ; 0x0C prefetch abort
|
389
|
12 ivt_data: B undef_handler ; 0x10 data abort
|
|
13 ivt_hyptrap: B undef_handler ; 0x14 not used
|
|
14 ivt_irq: B undef_handler ; 0x18 IRQ
|
|
15 ivt_fiq: B undef_handler ; 0x18 FIQ
|
375
|
16
|
|
17
|
|
18 start:
|
|
19
|
404
|
20 ; Setup the memory manager and the stack before entering kernel
|
|
21
|
406
|
22 ; Output an 'A' to indicate aliveness:
|
|
23 ldr r0, txtA
|
|
24 ldr r1, DRreg
|
|
25 str r0, [r1, 0]
|
|
26
|
375
|
27 ; Setup TTBR1 (translation table base register)
|
|
28
|
406
|
29
|
|
30 ldr r0, =kernel_table0 ; Load address of label
|
381
|
31 ; -KERNEL_BASE
|
406
|
32 mcr p15, 0, r0, c2, c0, 0 ; TTBR0
|
375
|
33 mcr p15, 0, r0, c2, c0, 1 ; TTBR1
|
|
34
|
|
35 ; Prepare the TTBCR (translation table base control register)
|
|
36 mov r0, 0x1 ; TBD: why set this to 1?
|
|
37 mcr p15, 0, r0, c2, c0, 2
|
|
38
|
386
|
39
|
|
40 ; Set domain 0 to manager:
|
|
41 mov r0, 3
|
|
42 mcr p15, 0, r0, c3, c0, 0
|
|
43
|
406
|
44 ldr r0, txtB
|
|
45 ldr r1, DRreg
|
|
46 str r0, [r1, 0]
|
386
|
47
|
375
|
48 ; Enable the VMSA (Virtual memory system architecture):
|
|
49 mrc p15, 0, r0, c1, c0, 0
|
388
|
50 mov r1, 0x1
|
406
|
51 orr r0, r0, r1
|
375
|
52 mcr p15, 0, r0, c1, c0, 0
|
|
53
|
406
|
54 ldr r0, txtA
|
|
55 ldr r1, DRregmapped
|
|
56 str r0, [r1, 0]
|
|
57
|
375
|
58 ; Setup stack:
|
352
|
59 mov sp, 0x30000
|
404
|
60 BL kernel_start ; Branch to main (this is actually in the interrupt vector)
|
352
|
61 local_loop:
|
|
62 B local_loop
|
362
|
63
|
|
64
|
375
|
65 ; Interrupt handlers:
|
|
66
|
|
67 undef_handler:
|
|
68 B undef_handler
|
|
69
|
381
|
70
|
|
71 ; Assembly language helpers:
|
362
|
72 ; Called to identify the proc:
|
381
|
73 arch_pfr0:
|
362
|
74 mrc p15, 0, r0, c0, c1, 0
|
|
75 mov pc, lr
|
|
76
|
381
|
77 arch_pfr1:
|
362
|
78 mrc p15, 0, r0, c0, c1, 1
|
|
79 mov pc, lr
|
|
80
|
381
|
81 arch_mmfr0:
|
362
|
82 mrc p15, 0, r0, c0, c1, 4
|
|
83 mov pc, lr
|
|
84
|
381
|
85 arch_mpuir:
|
362
|
86 mrc p15, 0, r0, c0, c0, 4
|
|
87 mov pc, lr
|
381
|
88
|
406
|
89 ; data:
|
|
90 txtA:
|
|
91 dcd 65
|
|
92 txtB:
|
|
93 dcd 66
|
|
94 DRreg:
|
|
95 dcd 0x10009000
|
|
96 DRregmapped:
|
|
97 dcd 0x109000
|
381
|
98
|
|
99 ; Memory map tables:
|
|
100
|
406
|
101 ; Possibly, we are loaded into highmem at address 0x6000 0000,
|
|
102 ; or it may as well be 0x0000 0000 as an alias.
|
|
103 ; In any case, we must put an alias at 0x6000 0000 virtual.
|
|
104
|
381
|
105 section mem_tables
|
|
106
|
|
107 kernel_table0:
|
406
|
108 dcd 0x60000402 ; Identity map first 1 MB
|
388
|
109 dcd 0x10000402 ; Map to peripheral space 1 MB
|
|
110 repeat 0x5FE
|
386
|
111 dcd 0
|
|
112 endrepeat
|
381
|
113
|
406
|
114 dcd 0x60000402 ; Alias to 0x0
|
388
|
115
|
|
116 repeat 0x9FF
|
|
117 dcd 0
|
|
118 endrepeat
|
|
119
|