forked from Imagelibrary/rtems
2001-04-16 Joel Sherrill <joel@OARcorp.com>
* start/start.S, startup/bspstart.c, startup/linkcmds: Modifications made with Gregory Menke <gregory.menke@gsfc.nasa.gov> as he debugged this BSP using a logic analyzer.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2001-04-16 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* start/start.S, startup/bspstart.c, startup/linkcmds:
|
||||
Modifications made with Gregory Menke <gregory.menke@gsfc.nasa.gov>
|
||||
as he debugged this BSP using a logic analyzer.
|
||||
|
||||
2001-03-14 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* clock/clockdrv.c, console/conscfg.c, include/bsp.h, start/start.S,
|
||||
|
||||
@@ -27,17 +27,8 @@
|
||||
.set nomips16
|
||||
#endif
|
||||
|
||||
#include <asm.h>
|
||||
#include "regs.S"
|
||||
|
||||
/*
|
||||
* Set up some room for a stack. We just grab a chunk of memory.
|
||||
*/
|
||||
#define STACK_SIZE 0x4000
|
||||
#define GLOBAL_SIZE 0x2000
|
||||
|
||||
#define STARTUP_STACK_SIZE 0x0100
|
||||
|
||||
/* This is for referencing addresses that are not in the .sdata or
|
||||
.sbss section under embedded-pic, or before we've set up gp. */
|
||||
#ifdef __mips_embedded_pic
|
||||
@@ -50,10 +41,43 @@
|
||||
# define LA(t,x) la t,x
|
||||
#endif /* __mips_embedded_pic */
|
||||
|
||||
.comm __memsize, 12
|
||||
.comm __lstack, STARTUP_STACK_SIZE
|
||||
.comm __stackbase,4
|
||||
#define zero $0
|
||||
#define AT $1 /* assembler temporaries */
|
||||
#define v0 $2 /* value holders */
|
||||
#define v1 $3
|
||||
#define a0 $4 /* arguments */
|
||||
#define a1 $5
|
||||
#define a2 $6
|
||||
#define a3 $7
|
||||
#define t0 $8 /* temporaries */
|
||||
#define t1 $9
|
||||
#define t2 $10
|
||||
#define t3 $11
|
||||
#define t4 $12
|
||||
#define t5 $13
|
||||
#define t6 $14
|
||||
#define t7 $15
|
||||
#define s0 $16 /* saved registers */
|
||||
#define s1 $17
|
||||
#define s2 $18
|
||||
#define s3 $19
|
||||
#define s4 $20
|
||||
#define s5 $21
|
||||
#define s6 $22
|
||||
#define s7 $23
|
||||
#define t8 $24 /* temporaries */
|
||||
#define t9 $25
|
||||
#define k0 $26 /* kernel registers */
|
||||
#define k1 $27
|
||||
#define gp $28 /* global pointer */
|
||||
#define sp $29 /* stack pointer */
|
||||
#define s8 $30 /* saved register */
|
||||
#define fp $30 /* frame pointer (old usage) */
|
||||
#define ra $31 /* return address */
|
||||
|
||||
|
||||
|
||||
|
||||
.text
|
||||
.align 2
|
||||
|
||||
@@ -62,11 +86,43 @@
|
||||
* start of the .text section.
|
||||
*/
|
||||
nop
|
||||
|
||||
|
||||
.globl _start
|
||||
.ent _start
|
||||
_start:
|
||||
.set noreorder
|
||||
# Get the address of start into $5 in a position independent fashion.
|
||||
# This lets us know whether we have been relocated or not.
|
||||
|
||||
$LF1 = . + 8
|
||||
bal $LF1
|
||||
nop
|
||||
_branch:
|
||||
move $5, $31 # $5 == where are we
|
||||
li $6, 0x8002000c # $6 == where we want to be
|
||||
beq $5, $6, _start_in_ram
|
||||
nop
|
||||
# relocate the code from EEPROM to RAM
|
||||
la $7, _edata
|
||||
relocate:
|
||||
lw $8, ($5) # $8 = *EEPROM
|
||||
addu $5, $5, 4 # EEPROM++
|
||||
sw $8, ($6) # *RAM = $8
|
||||
addu $6, $6, 4 # RAM++
|
||||
bne $6, $7, relocate # copied all the way to edata?
|
||||
nop
|
||||
|
||||
la $6, _start_in_ram
|
||||
jr $6
|
||||
nop
|
||||
.end _start
|
||||
|
||||
|
||||
.globl _start_in_ram
|
||||
.ent _start_in_ram
|
||||
_start_in_ram:
|
||||
nop
|
||||
|
||||
#ifdef __mips_embedded_pic
|
||||
PICBASE = .+8
|
||||
bal PICBASE
|
||||
@@ -116,9 +172,6 @@ _start:
|
||||
* zero out the bss section.
|
||||
*/
|
||||
.globl __memsize
|
||||
.globl get_mem_info .text
|
||||
.globl __stack
|
||||
.globl __global
|
||||
.globl zerobss
|
||||
.ent zerobss
|
||||
zerobss:
|
||||
@@ -129,22 +182,7 @@ zerobss:
|
||||
bltu v0,v1,3b
|
||||
addiu v0,v0,4 # executed in delay slot
|
||||
|
||||
la t0, __lstack # make a small stack so we
|
||||
addiu sp, t0, STARTUP_STACK_SIZE # can run some C code
|
||||
la a0, __memsize # get the usable memory size
|
||||
jal get_mem_info
|
||||
nop
|
||||
|
||||
/* setup the stack pointer */
|
||||
LA (t0, __stack) # is __stack set ?
|
||||
bne t0,zero,4f
|
||||
nop
|
||||
|
||||
/* NOTE: a0[0] contains the amount of memory available, and
|
||||
not the last memory address. */
|
||||
lw t0,0(a0) # last address of memory available
|
||||
la t1,K0BASE # cached kernel memory
|
||||
addu t0,t0,t1 # get the end of memory address
|
||||
la t0, _stack_init # initialize stack so we
|
||||
/* We must subtract 24 bytes for the 3 8 byte arguments to main, in
|
||||
case main wants to write them back to the stack. The caller is
|
||||
supposed to allocate stack space for parameters in registers in
|
||||
@@ -154,73 +192,36 @@ zerobss:
|
||||
Some ports need a larger alignment for the stack, so we subtract
|
||||
32, which satisifes the stack for the arguments and keeps the
|
||||
stack pointer better aligned. */
|
||||
subu t0,t0,32 # and generate a starting stack-pointer
|
||||
4:
|
||||
subu t0,t0,32
|
||||
move sp,t0 # set stack pointer
|
||||
sw sp,__stackbase # keep this for future ref
|
||||
.end zerobss
|
||||
|
||||
/*
|
||||
* initialize target specific stuff. Only execute these
|
||||
* functions it they exist.
|
||||
*/
|
||||
#if 0
|
||||
.globl hardware_init_hook .text
|
||||
.globl software_init_hook .text
|
||||
.globl __do_global_dtors .text
|
||||
.globl atexit .text
|
||||
#endif
|
||||
.globl exit .text
|
||||
.globl init
|
||||
.ent init
|
||||
init:
|
||||
#if 0
|
||||
LA (t9, hardware_init_hook) # init the hardware if needed
|
||||
beq t9,zero,6f
|
||||
nop
|
||||
jal t9
|
||||
nop
|
||||
6:
|
||||
LA (t9, software_init_hook) # init the hardware if needed
|
||||
beq t9,zero,7f
|
||||
nop
|
||||
jal t9
|
||||
nop
|
||||
7:
|
||||
LA (a0, __do_global_dtors)
|
||||
jal atexit
|
||||
nop
|
||||
#endif
|
||||
|
||||
#ifdef GCRT0
|
||||
.globl _ftext
|
||||
.globl _extext
|
||||
LA (a0, _ftext)
|
||||
LA (a1, _etext)
|
||||
jal monstartup
|
||||
nop
|
||||
#endif
|
||||
|
||||
move a0,zero # set argc to 0
|
||||
jal boot_card # call the program start function
|
||||
nop
|
||||
|
||||
# fall through to the "exit" routine
|
||||
jal exit # call libc exit to run the G++
|
||||
jal _sys_exit # call libc exit to run the G++
|
||||
# destructors
|
||||
move a0,v0 # pass through the exit code
|
||||
.end init
|
||||
|
||||
/*
|
||||
* Exit from the application. Normally we cause a user trap
|
||||
* to return to the ROM monitor for another run. NOTE: This is
|
||||
* the only other routine we provide in the crt0.o object, since
|
||||
* it may be tied to the "_start" routine. It also allows
|
||||
* executables that contain a complete world to be linked with
|
||||
* just the crt0.o object.
|
||||
* _sys_exit -- Exit from the application. Normally we cause a user trap
|
||||
* to return to the ROM monitor for another run. NOTE: This is
|
||||
* the only other routine we provide in the crt0.o object, since
|
||||
* it may be tied to the "_start" routine. It also allows
|
||||
* executables that contain a complete world to be linked with
|
||||
* just the crt0.o object.
|
||||
*/
|
||||
|
||||
FRAME(_sys_exit,sp,0,ra)
|
||||
.globl _sys_exit
|
||||
.ent _sys_exit
|
||||
_sys_exit:
|
||||
7:
|
||||
#ifdef GCRT0
|
||||
jal _mcleanup
|
||||
@@ -231,6 +232,44 @@ FRAME(_sys_exit,sp,0,ra)
|
||||
nop
|
||||
b 7b # but loop back just in-case
|
||||
nop
|
||||
ENDFRAME(_sys_exit)
|
||||
.end _sys_exit
|
||||
|
||||
#define FRAME(name,frm_reg,offset,ret_reg) \
|
||||
.globl name; \
|
||||
.ent name; \
|
||||
name:; \
|
||||
.frame frm_reg,offset,ret_reg
|
||||
#define ENDFRAME(name) \
|
||||
.end name
|
||||
|
||||
FRAME(mips_enable_interrupts,sp,0,ra)
|
||||
mfc0 t0,C0_SR /* get status reg */
|
||||
nop
|
||||
or t0,t0,a0
|
||||
mtc0 t0,C0_SR /* save updated status reg */
|
||||
j ra
|
||||
nop
|
||||
ENDFRAME(mips_enable_interrupts)
|
||||
#define SR_IEC 0x00000001 /* cur interrupt enable, 1 => enable */
|
||||
#define C0_SR $12 /* status register */
|
||||
|
||||
/*
|
||||
FRAME(_CPU_ISR_Set_level,sp,0,ra)
|
||||
nop
|
||||
mfc0 t0,C0_SR
|
||||
andi a0, SR_IEC
|
||||
or t0, a0
|
||||
mtc0 t0,C0_SR
|
||||
nop
|
||||
j ra
|
||||
ENDFRAME(_CPU_ISR_Set_level)
|
||||
*/
|
||||
|
||||
.section vectors
|
||||
.align 2
|
||||
|
||||
FRAME(__ISR_MAIN,sp,0,ra)
|
||||
|
||||
ENDFRAME(__ISR_MAIN)
|
||||
|
||||
/* EOF crt0.S */
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <bsp.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/libcsupport.h>
|
||||
#include <libcpu/mongoose-v.h>
|
||||
|
||||
|
||||
/*
|
||||
* The original table from the application and our copy of it with
|
||||
@@ -69,6 +71,7 @@ void bsp_pretasking_hook(void)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* bsp_start
|
||||
@@ -92,6 +95,7 @@ void bsp_start( void )
|
||||
|
||||
BSP_Configuration.work_space_start = (void *) &WorkspaceBase;
|
||||
|
||||
MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_CAUSE_REGISTER, 0 );
|
||||
mips_set_sr( 0xff00 ); /* all interrupts unmasked but globally off */
|
||||
/* depend on the IRC to take care of things */
|
||||
mips_install_isr_entries();
|
||||
|
||||
Reference in New Issue
Block a user