Root/mips/boot.S

1// Iris: micro-kernel for a capability-based operating system.
2// mips/boot.S: Kernel entry point, called by the boot loader.
3// Copyright 2009 Bas Wijnen <wijnen@debian.org>
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18    #define ASM
19    #define ARCH
20    #include "arch.hh"
21
22#define MEMORY_SIZE (32 << 20)
23#define KERNEL_STACK_SIZE 0x1000
24    // The kernel stack.
25    .lcomm kernel_stack, KERNEL_STACK_SIZE
26
27    .globl __start
28    .set noreorder
29
30__start:
31    bal 1f
32// For some reason the disassembler considers everything
33// after __start non-code until the next label. So I add a label.
34start_hack_for_disassembler:
35    nop
36    .word _gp
371: lw $gp, 0($ra)
38
39    // Flush cache.
40    mtc0 $zero, $CP0_TAG_LO
41    lui $v1, 0x8000
42    ori $v0, $v1, 0x8000
431:
44    // i-cache index invalidate.
45    cache 0, 0($v1)
46    // d-cache store tag. TagLo has the valid bit cleared, so this clears the d-cache.
47    cache 9, 0($v1)
48    bne $v1, $v0, 1b
49    addiu $v1, $v1, 32
50
51    // Set kseg0 cachable.
52    li $k0, 0x3
53    mtc0 $k0, $CP0_CONFIG, 0
54
55    la $sp, kernel_stack + KERNEL_STACK_SIZE
56
57    // Clear .bss
58    la $a0, _bss
59    la $a1, _end
601: sw $zero, 0($a0)
61    bne $a1, $a0, 1b
62    addiu $a0, 4
63
64    // First argument is the memory size.
65    la $t9, init
66    jr $t9
67    li $a0, MEMORY_SIZE
68

Archive Download this file

Branches:
master



interactive