annotate kernel/arch/qemu_vexpress/start.asm @ 407:9eb1fc6aad6c

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