annotate kernel/arch/qemu_vexpress/start.asm @ 410:6aa9743ed362 tip

Reflect change in c3 public modifier
author Windel Bouwman
date Mon, 23 Feb 2015 21:06:04 +0100
parents ad6be5454067
children
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
408
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
5
385
d056b552d3f4 Made better use of layout
Windel Bouwman
parents: 381
diff changeset
6 section reset
408
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
7 ; The reset vector:
375
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
8
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
9 interrupt_vector_table:
389
2ec730e45ea1 Added check for recursive struct
Windel Bouwman
parents: 388
diff changeset
10 ivt_reset: B start ; 0x0 reset
2ec730e45ea1 Added check for recursive struct
Windel Bouwman
parents: 388
diff changeset
11 ivt_undef: B undef_handler ; 0x4 undefined instruction
2ec730e45ea1 Added check for recursive struct
Windel Bouwman
parents: 388
diff changeset
12 ivt_svc: B undef_handler ; 0x08 Supervisor call
375
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
13 ivt_prefetch: B undef_handler ; 0x0C prefetch abort
389
2ec730e45ea1 Added check for recursive struct
Windel Bouwman
parents: 388
diff changeset
14 ivt_data: B undef_handler ; 0x10 data abort
2ec730e45ea1 Added check for recursive struct
Windel Bouwman
parents: 388
diff changeset
15 ivt_hyptrap: B undef_handler ; 0x14 not used
2ec730e45ea1 Added check for recursive struct
Windel Bouwman
parents: 388
diff changeset
16 ivt_irq: B undef_handler ; 0x18 IRQ
2ec730e45ea1 Added check for recursive struct
Windel Bouwman
parents: 388
diff changeset
17 ivt_fiq: B undef_handler ; 0x18 FIQ
375
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
18
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
19
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
20 start:
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
21
404
a284749c5729 Improved build scripts
Windel Bouwman
parents: 389
diff changeset
22 ; Setup the memory manager and the stack before entering kernel
a284749c5729 Improved build scripts
Windel Bouwman
parents: 389
diff changeset
23
406
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
24 ; Output an 'A' to indicate aliveness:
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
25 ldr r0, txtA
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
26 ldr r1, DRreg
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
27 str r0, [r1, 0]
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
28
375
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
29 ; Setup TTBR1 (translation table base register)
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
30
408
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
31 ldr r0, =kernel_table0 ; Load address of table
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:
408
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
59 ldr r0, =stack_top
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
60 mov sp, r0
404
a284749c5729 Improved build scripts
Windel Bouwman
parents: 389
diff changeset
61 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
62 local_loop:
899ae3aea803 First kernel run for vexpressA9
Windel Bouwman
parents: 340
diff changeset
63 B local_loop
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
64
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
65
375
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
66 ; Interrupt handlers:
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
67
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
68 undef_handler:
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
69 B undef_handler
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
70
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
71
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
72 ; Assembly language helpers:
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
73 ; Called to identify the proc:
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
74 arch_pfr0:
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
75 mrc p15, 0, r0, c0, c1, 0
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
76 mov pc, lr
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
77
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
78 arch_pfr1:
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
79 mrc p15, 0, r0, c0, c1, 1
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
80 mov pc, lr
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
81
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
82 arch_mmfr0:
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
83 mrc p15, 0, r0, c0, c1, 4
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
84 mov pc, lr
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
85
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
86 arch_mpuir:
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
87 mrc p15, 0, r0, c0, c0, 4
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
88 mov pc, lr
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
89
408
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
90 arch_get_image_address:
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
91 ldr r0, =ramdisk_start
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
92 mov pc, lr
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
93
406
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
94 ; data:
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
95 txtA:
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
96 dcd 65
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
97 txtB:
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
98 dcd 66
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
99 DRreg:
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
100 dcd 0x10009000
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
101 DRregmapped:
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
102 dcd 0x109000
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
103
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
104 ; Memory map tables:
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
105
406
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
106 ; Possibly, we are loaded into highmem at address 0x6000 0000,
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
107 ; or it may as well be 0x0000 0000 as an alias.
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
108 ; In any case, we must put an alias at 0x6000 0000 virtual.
b1daa462ee17 Made kernel run again
Windel Bouwman
parents: 404
diff changeset
109
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
110 section mem_tables
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
111
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
112 kernel_table0:
408
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
113 dcd 0
388
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
114 dcd 0x10000402 ; Map to peripheral space 1 MB
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
115 repeat 0x5FE
386
2a970e7270e2 Added repeat assembler macro
Windel Bouwman
parents: 385
diff changeset
116 dcd 0
2a970e7270e2 Added repeat assembler macro
Windel Bouwman
parents: 385
diff changeset
117 endrepeat
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
118
408
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
119 dcd 0x60000402 ; Identity map this!
388
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
120
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
121 repeat 0x9FF
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
122 dcd 0
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
123 endrepeat
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
124
408
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
125 ; Create a label to indicate the ramdisk:
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
126 section ramdisk
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
127 ramdisk_start:
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
128
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
129 ; Create stack space:
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
130 section stack
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
131
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
132 stack_bot:
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
133 ds 0x1000
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
134 stack_top:
ad6be5454067 Added image build task
Windel Bouwman
parents: 406
diff changeset
135