annotate kernel/arch/qemu_vexpress/start.asm @ 404:a284749c5729

Improved build scripts
author Windel Bouwman
date Thu, 19 Feb 2015 14:08:17 +0100
parents 2ec730e45ea1
children b1daa462ee17
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
375
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
22 ; Setup TTBR1 (translation table base register)
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
23
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
24 ldr r0, =kernel_table0 ; pseudo instruction which loads the value of the symbol
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
25 ; -KERNEL_BASE
375
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
26 mcr p15, 0, r0, c2, c0, 1 ; TTBR1
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
27 mcr p15, 0, r0, c2, c0, 0 ; TTBR0
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
28
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
29 ; Prepare the TTBCR (translation table base control register)
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
30 mov r0, 0x1 ; TBD: why set this to 1?
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
31 mcr p15, 0, r0, c2, c0, 2
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
32
386
2a970e7270e2 Added repeat assembler macro
Windel Bouwman
parents: 385
diff changeset
33
2a970e7270e2 Added repeat assembler macro
Windel Bouwman
parents: 385
diff changeset
34 ; Set domain 0 to manager:
2a970e7270e2 Added repeat assembler macro
Windel Bouwman
parents: 385
diff changeset
35 mov r0, 3
2a970e7270e2 Added repeat assembler macro
Windel Bouwman
parents: 385
diff changeset
36 mcr p15, 0, r0, c3, c0, 0
2a970e7270e2 Added repeat assembler macro
Windel Bouwman
parents: 385
diff changeset
37
2a970e7270e2 Added repeat assembler macro
Windel Bouwman
parents: 385
diff changeset
38
375
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
39 ; Enable the VMSA (Virtual memory system architecture):
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
40 mrc p15, 0, r0, c1, c0, 0
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
41 ; TODO:
388
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
42 mov r1, 0x1
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
43 orr r0, r0, r1 ; TODO: implement orr r0, r0, 1
375
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
44 mcr p15, 0, r0, c1, c0, 0
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
45
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
46 ; Setup stack:
352
899ae3aea803 First kernel run for vexpressA9
Windel Bouwman
parents: 340
diff changeset
47 mov sp, 0x30000
404
a284749c5729 Improved build scripts
Windel Bouwman
parents: 389
diff changeset
48 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
49 local_loop:
899ae3aea803 First kernel run for vexpressA9
Windel Bouwman
parents: 340
diff changeset
50 B local_loop
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
51
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
52
375
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
53 ; Interrupt handlers:
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
54
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
55 undef_handler:
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
56 B undef_handler
19eacf4f7270 Started on memory manager
Windel Bouwman
parents: 367
diff changeset
57
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
58
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
59 ; Assembly language helpers:
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
60 ; Called to identify the proc:
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
61 arch_pfr0:
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
62 mrc p15, 0, r0, c0, c1, 0
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
63 mov pc, lr
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
64
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
65 arch_pfr1:
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
66 mrc p15, 0, r0, c0, c1, 1
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
67 mov pc, lr
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
68
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
69 arch_mmfr0:
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
70 mrc p15, 0, r0, c0, c1, 4
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
71 mov pc, lr
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
72
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
73 arch_mpuir:
362
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
74 mrc p15, 0, r0, c0, c0, 4
c05ab629976a Added CPUID for arm
Windel Bouwman
parents: 352
diff changeset
75 mov pc, lr
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
76
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
77
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
78 ; Memory map tables:
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
79
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
80 section mem_tables
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
81
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
82 kernel_table0:
388
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
83 dcd 0x00000402 ; Identity map first 1 MB
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
84 dcd 0x10000402 ; Map to peripheral space 1 MB
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
85 repeat 0x5FE
386
2a970e7270e2 Added repeat assembler macro
Windel Bouwman
parents: 385
diff changeset
86 dcd 0
2a970e7270e2 Added repeat assembler macro
Windel Bouwman
parents: 385
diff changeset
87 endrepeat
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 377
diff changeset
88
388
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
89 dcd 0x00000402 ; Alias to 0x0
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
90
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
91 repeat 0x9FF
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
92 dcd 0
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
93 endrepeat
e07c2a9abac1 Enabled paging in kernel
Windel Bouwman
parents: 386
diff changeset
94