This repository has been archived by the owner on May 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.S
70 lines (54 loc) · 1.45 KB
/
start.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@ SkordalOS Start File
@ (c) Kristian K. Skordal 2011 - 2012 <kristian.skordal@gmail.com>
.section .text
#include "hardware/processor.h"
#include "hardware/sctlr.h"
@ This is the kernel entry point.
.global start
start:
@ Set up a temporary stack until the MMU has been initialized:
ldr sp, =0x80008000
@ Zero the .bss section:
ldr r0, =bss_start
ldr r1, =bss_end
eor r2, r2, r2
1:
cmp r0, r1
strne r2, [r0], #4
bne 1b
@ Clear the local monitor to prevent faults when using spinlocks:
clrex
@ Enable neon and vfp instructions:
mov r0, #CPACR_FULL_ACCESS << CPACR_COPROC(10)|CPACR_FULL_ACCESS << CPACR_COPROC(11)
mcr p15, 0, r0, c1, c0, 2
isb
vmrs r0, FPEXC
orr r0, #(1 << 30)
vmsr FPEXC, r0
@ Print a short message to show we are working:
ldr r0, =boot_message
bl debug_print_string
bl debug_print_newline
bl debug_print_newline
@ Set up the kernel memory manager. This also initializes the MMU.
bl mm_init
@ Enable the MMU, caches and branch prediction:
mrc p15, 0, r0, c1, c0, 0
ldr r1, =(SCTLR_M|SCTLR_C|SCTLR_Z|SCTLR_I)
orr r0, r0, r1
mcr p15, 0, r0, c1, c0, 0
@ Set the new stack pointer:
ldr sp, =kernel_stack_top @ kernel stack
@ Set up interrupt handlers:
bl interrupts_init
@ Initialize the kernel:
bl kernel_init
@ Run the kernel main loop:
bl kernel_main
loopy: @ A little loop here, in case the kernel main function should return
@ by accident.
wfi
b loopy
.section .rodata
boot_message:
.asciz "SkordalOS booting..."