2011-08-08 17:24:44 +08:00
|
|
|
/*
|
|
|
|
* File : start_gcc.S
|
|
|
|
* This file is part of RT-Thread RTOS
|
|
|
|
* COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* The license and distribution terms for this file may be
|
|
|
|
* found in the file LICENSE in this distribution or at
|
|
|
|
* http://www.rt-thread.org/license/LICENSE
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2010-05-17 swkyer first version
|
|
|
|
* 2010-09-04 bernard porting to Jz47xx
|
|
|
|
*/
|
2012-05-15 14:16:37 +08:00
|
|
|
|
2011-08-08 17:24:44 +08:00
|
|
|
#include "../common/mips.inc"
|
|
|
|
#include "../common/stackframe.h"
|
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
.section ".start", "ax"
|
|
|
|
.set noreorder
|
2011-08-08 17:24:44 +08:00
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
/* the program entry */
|
|
|
|
.globl _start
|
2011-08-08 17:24:44 +08:00
|
|
|
_start:
|
2012-05-15 14:16:37 +08:00
|
|
|
.set noreorder
|
|
|
|
la ra, _start
|
2011-08-08 17:24:44 +08:00
|
|
|
|
|
|
|
/* disable interrupt */
|
|
|
|
mfc0 t0, CP0_STATUS
|
|
|
|
and t0, 0xfffffffe # By default it will be disabled.
|
|
|
|
mtc0 t0, CP0_STATUS # Set CPU to disable interrupt.
|
|
|
|
nop
|
|
|
|
|
|
|
|
/* disable cache */
|
|
|
|
mfc0 t0, CP0_CONFIG
|
2012-05-15 14:16:37 +08:00
|
|
|
and t0, 0xfffffff8
|
|
|
|
or t0, 0x2 # disable,!default value is not it!
|
2011-08-08 17:24:44 +08:00
|
|
|
mtc0 t0, CP0_CONFIG # Set CPU to disable cache.
|
|
|
|
nop
|
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
/* setup stack pointer */
|
|
|
|
li sp, SYSTEM_STACK
|
|
|
|
la gp, _gp
|
2011-08-08 17:24:44 +08:00
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
/* clear bss */
|
|
|
|
la t0, __bss_start
|
|
|
|
la t1, __bss_end
|
2011-08-08 17:24:44 +08:00
|
|
|
_clr_bss_loop:
|
2012-05-15 14:16:37 +08:00
|
|
|
sw zero, 0(t0)
|
|
|
|
bne t0, t1, _clr_bss_loop
|
|
|
|
addiu t0, t0, 4
|
2011-08-08 17:24:44 +08:00
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
/* jump to RT-Thread RTOS */
|
|
|
|
jal rtthread_startup
|
|
|
|
nop
|
2011-08-08 17:24:44 +08:00
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
/* restart, never die */
|
|
|
|
j _start
|
|
|
|
nop
|
|
|
|
.set reorder
|
2011-08-08 17:24:44 +08:00
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
.globl cp0_get_cause
|
2011-08-08 17:24:44 +08:00
|
|
|
cp0_get_cause:
|
2012-05-15 14:16:37 +08:00
|
|
|
mfc0 v0, CP0_CAUSE
|
|
|
|
jr ra
|
|
|
|
nop
|
2011-08-08 17:24:44 +08:00
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
.globl cp0_get_status
|
2011-08-08 17:24:44 +08:00
|
|
|
cp0_get_status:
|
2012-05-15 14:16:37 +08:00
|
|
|
mfc0 v0, CP0_STATUS
|
|
|
|
jr ra
|
|
|
|
nop
|
2011-08-08 17:24:44 +08:00
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
.globl cp0_get_hi
|
2011-08-08 17:24:44 +08:00
|
|
|
cp0_get_hi:
|
2012-05-15 14:16:37 +08:00
|
|
|
mfhi v0
|
|
|
|
jr ra
|
|
|
|
nop
|
2011-08-08 17:24:44 +08:00
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
.globl cp0_get_lo
|
2011-08-08 17:24:44 +08:00
|
|
|
cp0_get_lo:
|
2012-05-15 14:16:37 +08:00
|
|
|
mflo v0
|
|
|
|
jr ra
|
|
|
|
nop
|
2011-08-08 17:24:44 +08:00
|
|
|
|
|
|
|
.extern tlb_refill_handler
|
|
|
|
.extern cache_error_handler
|
|
|
|
|
|
|
|
/* Exception Handler */
|
2012-05-15 14:16:37 +08:00
|
|
|
|
2011-08-08 17:24:44 +08:00
|
|
|
/* 0x0 - TLB refill handler */
|
2012-05-15 14:16:37 +08:00
|
|
|
.section .vectors.1, "ax", %progbits
|
2011-08-08 17:24:44 +08:00
|
|
|
.global tlb_refill_exception
|
|
|
|
.type tlb_refill_exception,@function
|
|
|
|
tlb_refill_exception:
|
2012-05-15 14:16:37 +08:00
|
|
|
j tlb_refill_handler
|
|
|
|
nop
|
2011-08-08 17:24:44 +08:00
|
|
|
|
|
|
|
/* 0x100 - Cache error handler */
|
2012-05-15 14:16:37 +08:00
|
|
|
.section .vectors.2, "ax", %progbits
|
|
|
|
j cache_error_handler
|
|
|
|
nop
|
2011-08-08 17:24:44 +08:00
|
|
|
|
|
|
|
/* 0x180 - Exception/Interrupt handler */
|
2012-05-15 14:16:37 +08:00
|
|
|
.section .vectors.3, "ax", %progbits
|
2011-08-08 17:24:44 +08:00
|
|
|
.global general_exception
|
|
|
|
.type general_exception,@function
|
|
|
|
general_exception:
|
2012-05-15 14:16:37 +08:00
|
|
|
j _general_exception_handler
|
|
|
|
nop
|
2011-08-08 17:24:44 +08:00
|
|
|
|
|
|
|
/* 0x200 - Special Exception Interrupt handler (when IV is set in CP0_CAUSE) */
|
2012-05-15 14:16:37 +08:00
|
|
|
.section .vectors.4, "ax", %progbits
|
2011-08-08 17:24:44 +08:00
|
|
|
.global irq_exception
|
|
|
|
.type irq_exception,@function
|
|
|
|
irq_exception:
|
2012-05-15 14:16:37 +08:00
|
|
|
j _irq_handler
|
|
|
|
nop
|
2011-08-08 17:24:44 +08:00
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
.section .vectors, "ax", %progbits
|
2011-08-08 17:24:44 +08:00
|
|
|
.extern mips_irq_handle
|
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
/* general exception handler */
|
2011-08-08 17:24:44 +08:00
|
|
|
_general_exception_handler:
|
2012-05-15 14:16:37 +08:00
|
|
|
.set noreorder
|
|
|
|
la k0, mips_irq_handle
|
|
|
|
jr k0
|
|
|
|
nop
|
|
|
|
.set reorder
|
2011-08-08 17:24:44 +08:00
|
|
|
|
2012-05-15 14:16:37 +08:00
|
|
|
/* interrupt handler */
|
2011-08-08 17:24:44 +08:00
|
|
|
_irq_handler:
|
2012-05-15 14:16:37 +08:00
|
|
|
.set noreorder
|
|
|
|
la k0, mips_irq_handle
|
|
|
|
jr k0
|
|
|
|
nop
|
|
|
|
.set reorder
|