1 /* 2 * Initialisation code for the stage 2 payload. 3 * 4 * Copyright 2009 (C) Qi Hardware Inc. 5 * Author: Wolfgang Spraul <wolfgang@sharism.cc> 6 * 7 * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk> 8 * 9 * This program is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation, either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 .text 24 .extern c_main 25 .globl _start 26 .set noreorder 27 28 _start: 29 /* Initialise the stack. */ 30 31 la $sp, 0x80080000 32 33 /* Initialise the globals pointer. */ 34 35 lui $gp, %hi(_GLOBAL_OFFSET_TABLE_) 36 ori $gp, $gp, %lo(_GLOBAL_OFFSET_TABLE_) 37 38 /* Initialise interrupts. */ 39 40 mfc0 $t3, $12 /* CP0_STATUS */ 41 nop 42 li $t4, 0xffbf00e4 /* BEV = 0 (not bootloader vectors); IM = disable all */ 43 and $t3, $t3, $t4 /* ... KSU = 0 (kernel mode); EXL = 0; IE = 0 */ 44 li $t4, 0x0000ff00 /* IM = enable IM7..IM0 */ 45 or $t3, $t3, $t4 46 mtc0 $t3, $12 47 nop 48 49 li $t3, 0x00800000 /* IV = 1 (use 0x80000200 for interrupts) */ 50 mtc0 $t3, $13 /* CP0_CAUSE */ 51 nop 52 53 mtc0 $zero, $15 /* CP0_EBASE (should be zero anyway) */ 54 nop 55 56 /* Start the program. */ 57 58 j c_main 59 nop 60 61 .set reorder