2009-06-01 15:26:42 +03:00
|
|
|
// Iris: micro-kernel for a capability-based operating system.
|
2009-09-27 11:23:33 +03:00
|
|
|
// mips/trendtac/boot.S: Kernel entry point, called by the boot loader.
|
2009-06-01 15:26:42 +03:00
|
|
|
// Copyright 2009 Bas Wijnen <wijnen@debian.org>
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2009-09-27 11:23:33 +03:00
|
|
|
#define ASM
|
|
|
|
#define ARCH
|
|
|
|
#include "arch.hh"
|
|
|
|
|
2009-06-01 15:26:42 +03:00
|
|
|
// The kernel stack.
|
|
|
|
.lcomm kernel_stack, KERNEL_STACK_SIZE
|
|
|
|
|
|
|
|
.globl __start
|
|
|
|
.set noreorder
|
|
|
|
|
2009-07-20 01:23:45 +03:00
|
|
|
// Note that this code starts at 0xa0000000, even though it is linked for
|
|
|
|
// 0x80000000. This means that until the jump below, it must be PIC.
|
2009-06-01 15:26:42 +03:00
|
|
|
__start:
|
|
|
|
bal 1f
|
|
|
|
// For some reason the disassembler considers everything
|
|
|
|
// after __start non-code until the next label. So I add a label.
|
|
|
|
start_hack_for_disassembler:
|
2009-07-20 01:23:45 +03:00
|
|
|
nop
|
|
|
|
.word _gp
|
2009-06-01 15:26:42 +03:00
|
|
|
1: lw $gp, 0($ra)
|
|
|
|
|
|
|
|
la $sp, kernel_stack + KERNEL_STACK_SIZE
|
|
|
|
|
2009-07-21 13:17:52 +03:00
|
|
|
// Flush cache.
|
|
|
|
lui $v1, 0x8000
|
|
|
|
ori $v0, $v1, 0x8000
|
|
|
|
1:
|
|
|
|
cache 0, 0($v1)
|
|
|
|
cache 1, 0($v1)
|
|
|
|
bne $v1, $v0, 1b
|
|
|
|
addiu $v1, $v1, 32
|
2009-06-01 15:26:42 +03:00
|
|
|
|
|
|
|
// Set kseg0 cachable.
|
|
|
|
li $k0, 0x3
|
2009-09-27 11:23:33 +03:00
|
|
|
mtc0 $k0, $CP0_CONFIG, 0
|
2009-06-01 15:26:42 +03:00
|
|
|
|
|
|
|
// Jump into cached code.
|
|
|
|
la $t9, 1f
|
|
|
|
jr $t9
|
|
|
|
nop
|
|
|
|
1:
|
2009-09-27 11:23:33 +03:00
|
|
|
// From here, the code no longer needs to be PIC.
|
2009-06-01 15:26:42 +03:00
|
|
|
|
|
|
|
// Clear .bss
|
|
|
|
la $a0, _edata
|
|
|
|
la $a1, _end
|
|
|
|
1: sw $zero, 0($a0)
|
|
|
|
bne $a1, $a0, 1b
|
|
|
|
addu $a0, 4
|
|
|
|
|
2009-09-27 11:23:33 +03:00
|
|
|
// First argument is the memory size.
|
2009-06-01 15:26:42 +03:00
|
|
|
la $t9, init
|
|
|
|
jr $t9
|
2009-09-27 11:23:33 +03:00
|
|
|
li $a0, MEMORY_SIZE
|