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