aboutsummaryrefslogtreecommitdiff
path: root/src/sys/kernel.S
blob: 6452a4f6c9515500eb61d7739c1b0aee1760bf8a (plain)
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
.section ".text.kernel"

.include "macros.inc"

.globl kernel_main
kernel_main:
	///https://wiki.osdev.org/ARM_Paging
	// Query the ID_MMFR0 register
	mrc p15, 0, r0, c0, c1, 4
	bl sysinit

	assign_ctask testf, 2
	assign_ctask testf, 1
	assign_ctask testf, 2
	assign_ctask testf, 3
	assign_ctask testf, 1
	// Intentional undefined instruction
	// .word 0xf7f0a000
	cpsie aif, #0x10
	svc #2 // Start scheduling!
1:
	wfe
	b 1b

testf:
	push {lr}
	cmp r0, #2
	blo 1f
	beq 2f
	bgt 3f
1:
	ldr r0, =t1
	bl uart_print
	pop {pc}
2:
	ldr r0, =t2
	bl uart_print
	pop {pc}
3:
	ldr r0, =t3
	bl uart_print
	pop {pc}

.section .data
t1: .asciz "C1\n"
t2: .asciz "C2\n"
t3: .asciz "C3\n"