|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
大家好,我是一个embedded system方面的初学者,前阵子阅读完邵贝贝关于ucos的书,就开始练习porting ucosii on MIPS。
我所用的开发板上主IC是一款source decoder,面向的是low cost的STB或者DTV应用,它内嵌了一个32-bit MIPS RISC架构的CPU,兼容MIPS-II ISA和MIPS16指令集。
作为porting的第一阶段,我是想让ucosii kernel能够正常的运行,创建两个简单的task,相互之间通过通过一个semophore进行通信,打印出一些字符(我是在cygwin下建立的交叉编译环境)。
但是现在我遇到的问题是,在assembly code里做完一系列CPU和外围相关的初始化工作之后,跳转到C的main函数里面Initialize board和ucosii kernel时,程序就会dead,
我怀疑是create stack,exception,interrupt的问题,查阅了seemipsrun的相关章节,仍然没有得到答案 。
所以,希望MIPS开发的大虾们能够给我一些指点,以下是我entry的assembly code,大家给些建议把,谢谢啦。
#include <archdefs.h>
#include <frmwrk.h>
#include <cpu1910.h>
#include <derk_board.h>
#include <memory.h>
/* ********************************************************************* */
/* Global definitions */
.extern InitDebug
.extern Erase_Sdram
/*
*********************************************************************************************
* _start
*
* Description: This routine configs MIPS CPU, enable big endianess,
* and starts the application C code.
*
* Arguments : none
*
* Return : none.
*
* Note(s) : Function linked to application start address.
*********************************************************************************************
*/
.globl _start
.ent _start
_start:
.set noreorder
nop
nop
nop
nop
nop
nop
nop
nop
b 1f
nop
1: nop
nop
nop
# Setup gp #
la gp, _gp
#*********************************************************************
# Basic configuration of the CPU *
#*********************************************************************
# CONFIG REGISTER #
mfc0 t0, C0_CONFIG_1910 # Read config register
nop # Branch delay slot
or t0, END_CONFIG_REG # big endianess
or t0, (DSU_CONFIG_REG | MIPS16_CONFIG_REG) # Enable Debug Support
# Unit and MIPS16 inst
and t0, ~(MAP_CONFIG_REG ) # MAP translation sheme 2
# Disable
or t0, (ICD_CONFIG_REG | DCD_CONFIG_REG) # Disable both caches
# access
and t0, ~(ST1_CONFIG_REG | ST2_CONFIG_REG) # Enable the counter1 and the counter 2
mtc0 t0, C0_CONFIG_1910 # Write config register
nop # Branch delay slot
# initialize the general purpose registers
or $1, $0, $0
or $2, $0, $0
or $3, $0, $0
or $4, $0, $0
or $5, $0, $0
or $6, $0, $0
or $7, $0, $0
or $8, $0, $0
or $9, $0, $0
or $10, $0, $0
or $11, $0, $0
or $12, $0, $0
or $13, $0, $0
or $14, $0, $0
or $15, $0, $0
or $16, $0, $0
or $17, $0, $0
or $18, $0, $0
or $19, $0, $0
or $20, $0, $0
or $21, $0, $0
or $22, $0, $0
or $23, $0, $0
or $24, $0, $0
or $25, $0, $0
or $26, $0, $0
or $27, $0, $0
or $28, $0, $0
or $29, $0, $0
or $30, $0, $0
or $31, $0, $0
# initialize the CP0 Read registers.
mtc0 $0, C0_CAUSE
mtc0 $0, C0_EPC
mtc0 $0, C0_DESAVE_1910
#************************************************************************
#* Disable the interrupt and init boot strap. *
#************************************************************************
# STATUS REGISTER #
mfc0 t0, C0_Status # Read Status register
nop # Branch delay slot
and t0, ~(SR_IT_MASK | SR_BEV) # Mask ITs and
# boot strap vector
# locations are used
mtc0 t0, C0_Status # Write Status register
nop # Branch delay slot
# Enable the GPIO to output the UARTS signals
li t1, GPIO_SEL_RESET_VALUE
li t2, GPIO_BASE_ADDRESS
sw t1, GPIO_SEL_OFFSET(t2)
# Erase SDRAM -- not working so far #
jal Erase_Sdram
nop
# create temporary stack on the top of uncached memory#
la sp, _freemem # put stack pointer on top
# of memory
li t5, KSEG1BASE
or sp, sp, t5 # Uncache stack pointer
subu t0, sp, _SYS_STKSIZE # substract stack size to
# stack pointer
2:
sw zero, 0(t0) # clear stack
bltu t0, sp, 2b # Loop
addiu t0, 4 # Branch delay slot
# Print the debug infos #
jal InitDebug # already work
nop
# Initialize caches
jal InitCaches
nop
#************************************************************************
#* Do startup initialization that can't be done in C. *
#************************************************************************
# Clear bss #
la t0, _fbss /* First address */
la t1, _end /* Last address */
1:
sw zero, 0(t0)
bne t0, t1, 1b
addiu t0, 4
# Install exceptions handlers
jal EXCEP_vInstallExcInRam
nop
jal EXCEP_vInstallIntInRam
nop
# Create stack on the top of cached memory
la sp, _freemem
subu t0, sp, STACKSIZE # substract stack size to
# stack pointer
2:
sw zero, 0(t0) # clear stack
bltu t0, sp, 2b # Loop
addiu t0, 4 # Branch delay slot
# Align sp to 16 byte boundary (required by Cygnus) #
li t0, ~0xf
and sp, t0
# Get ready to jump to main #
move s0, ra
la t0, C_vMain
# Jump to main #
jalr t0
nop
# Return #
jr s0
nop
.set reorder
.end _start |
|