2009-05-14 21:31:47 +03:00
|
|
|
// The kernel stack.
|
|
|
|
.lcomm kernel_stack, KERNEL_STACK_SIZE
|
|
|
|
|
|
|
|
.globl __start
|
2009-05-22 23:48:49 +03:00
|
|
|
.globl thread_start
|
2009-05-14 21:31:47 +03:00
|
|
|
.set noreorder
|
|
|
|
|
|
|
|
#define Status 12
|
|
|
|
#define Config 16
|
|
|
|
|
|
|
|
__start:
|
|
|
|
bal 1f
|
|
|
|
nop
|
|
|
|
.word _gp
|
|
|
|
// For some reason the disassembler considers everything
|
|
|
|
// after __start non-code until the next label. So I add a label.
|
|
|
|
start_hack_for_disassembler:
|
|
|
|
1: lw $gp, 0($ra)
|
|
|
|
|
|
|
|
la $sp, kernel_stack + KERNEL_STACK_SIZE
|
|
|
|
|
|
|
|
// Disable interrupts during bootstrap.
|
|
|
|
mtc0 $zero, $Status
|
|
|
|
|
|
|
|
// TODO: flush cache and optionally refill it.
|
|
|
|
|
|
|
|
// Set kseg0 cachable.
|
|
|
|
li $k0, 0x3
|
|
|
|
mtc0 $k0, $Config, 0
|
|
|
|
|
|
|
|
// Jump into cached code.
|
|
|
|
la $t9, 1f
|
|
|
|
jr $t9
|
|
|
|
nop
|
|
|
|
1:
|
|
|
|
|
|
|
|
// Clear .bss
|
|
|
|
la $a0, _edata
|
|
|
|
la $a1, _end
|
|
|
|
1: sw $zero, 0($a0)
|
|
|
|
bne $a1, $a0, 1b
|
|
|
|
addu $a0, 4
|
|
|
|
|
|
|
|
la $t9, init
|
|
|
|
jr $t9
|
|
|
|
nop
|
2009-05-22 23:48:49 +03:00
|
|
|
|
2009-05-23 21:55:31 +03:00
|
|
|
thread_start:
|
2009-05-22 23:48:49 +03:00
|
|
|
.word thread0
|
|
|
|
.word thread1
|
|
|
|
.word thread2
|