2N/A/* startup.S - Startup code for the MIPS. */
2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2009 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#include <grub/symbol.h>
2N/A#include <grub/offsets.h>
2N/A#include <grub/machine/memory.h>
2N/A#include <grub/machine/kernel.h>
2N/A#include <grub/offsets.h>
2N/A
2N/A#define BASE_ADDR 8
2N/A
2N/A .globl __start, _start, start
2N/A .set noreorder
2N/A .set nomacro
2N/A__start:
2N/A_start:
2N/Astart:
2N/A.extern __bss_start
2N/A.extern _end
2N/A bal cont
2N/A nop
2N/A
2N/A . = _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
2N/AVARIABLE(grub_total_modules_size)
2N/A .long 0
2N/A
2N/AVARIABLE (grub_arch_busclock)
2N/A .long 0
2N/AVARIABLE (grub_arch_cpuclock)
2N/A .long 0
2N/AVARIABLE (grub_arch_memsize)
2N/A .long 0
2N/AVARIABLE (grub_arch_highmemsize)
2N/A .long 0
2N/A#ifdef GRUB_MACHINE_MIPS_LOONGSON
2N/AVARIABLE (grub_arch_machine)
2N/A .long GRUB_ARCH_MACHINE_FULOONG2F
2N/A#endif
2N/Acont:
2N/A /* Save our base. */
2N/A move $s0, $ra
2N/A
2N/A#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
2N/A lui $t1, %hi(grub_arch_busclock)
2N/A addiu $t1, %lo(grub_arch_busclock)
2N/A sw $s4, 8($t1)
2N/A#endif
2N/A
2N/A#ifdef GRUB_MACHINE_MIPS_LOONGSON
2N/A lui $t1, %hi(grub_arch_busclock)
2N/A addiu $t1, %lo(grub_arch_busclock)
2N/A sw $s2, 0($t1)
2N/A sw $s3, 4($t1)
2N/A sw $s4, 8($t1)
2N/A sw $s5, 12($t1)
2N/A sw $s7, 16($t1)
2N/A#endif
2N/A
2N/A /* Move the modules out of BSS. */
2N/A#ifndef GRUB_MACHINE_ARC
2N/A lui $t2, %hi(__bss_start)
2N/A addiu $t2, %lo(__bss_start)
2N/A
2N/A lui $t1, %hi(_end)
2N/A addiu $t1, %lo(_end)
2N/A addiu $t1, (GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
2N/A li $t3, (GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
2N/A nor $t3, $t3, $0
2N/A and $t1, $t1, $t3
2N/A
2N/A lw $t3, (GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE - BASE_ADDR)($s0)
2N/A
2N/A /* Backward copy. */
2N/A add $t1, $t1, $t3
2N/A add $t2, $t2, $t3
2N/A addiu $t1, $t1, -1
2N/A addiu $t2, $t2, -1
2N/A
2N/A /* $t2 is source. $t1 is destination. $t3 is size. */
2N/Amodulesmovcont:
2N/A beq $t3, $0, modulesmovdone
2N/A nop
2N/A lb $t4, 0($t2)
2N/A sb $t4, 0($t1)
2N/A addiu $t2, $t2, -1
2N/A addiu $t1, $t1, -1
2N/A b modulesmovcont
2N/A addiu $t3, $t3, -1
2N/Amodulesmovdone:
2N/A#endif
2N/A
2N/A /* Clean BSS. */
2N/A
2N/A lui $t1, %hi(__bss_start)
2N/A addiu $t1, $t1, %lo(__bss_start)
2N/A lui $t2, %hi(_end)
2N/A addiu $t2, $t2, %lo(_end)
2N/Absscont:
2N/A sb $0,0($t1)
2N/A addiu $t1, $t1, 1
2N/A sltu $t3, $t1, $t2
2N/A bne $t3, $0, bsscont
2N/A nop
2N/A
2N/A lui $t1, %hi(grub_main)
2N/A addiu $t1, %lo(grub_main)
2N/A
2N/A lui $sp, %hi(GRUB_MACHINE_MEMORY_STACK_HIGH)
2N/A jr $t1
2N/A addiu $sp, $sp, %lo(GRUB_MACHINE_MEMORY_STACK_HIGH)
2N/A