2008-09-14 Joel Sherrill <joel.sherrill@oarcorp.com>

* Makefile.am, configure.ac, startup/bspstart.c, startup/linkcmds:
	Split out bsp_get_work_area() into its own file and user BSP
	Framework to perform more initialization.
	* startup/bspgetworkarea.c: New file.
This commit is contained in:
Joel Sherrill
2008-09-14 21:26:23 +00:00
parent 25e4d24f12
commit 58eee41c11
6 changed files with 95 additions and 101 deletions

View File

@@ -1,3 +1,10 @@
2008-09-14 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac, startup/bspstart.c, startup/linkcmds:
Split out bsp_get_work_area() into its own file and user BSP
Framework to perform more initialization.
* startup/bspgetworkarea.c: New file.
2008-09-10 Joel Sherrill <joel.sherrill@oarcorp.com>
* include/bsp.h: Review of all bsp_cleanup() implementations. In this

View File

@@ -26,11 +26,11 @@ project_lib_DATA = start.$(OBJEXT)
dist_project_lib_DATA += startup/linkcmds
startup_SOURCES = ../../shared/bspclean.c \
startup_SOURCES = ../../shared/bspclean.c ../../shared/bsppretaskinghook.c \
../../shared/bsppredriverhook.c ../../shared/bsplibc.c \
../../shared/bsppost.c startup/bspstart.c ../../shared/bootcard.c \
../../shared/sbrk.c ../../shared/gnatinstallhandler.c \
../../shared/setvec.c
../../shared/setvec.c startup/bspgetworkarea.c
clock_SOURCES = clock/clockdrv.c
console_SOURCES = console/conscfg.c ../../shared/console.c
timer_SOURCES = timer/timer.c

View File

@@ -16,6 +16,8 @@ RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm])
RTEMS_CANONICALIZE_TOOLS
RTEMS_PROG_CCAS
RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@@ -0,0 +1,43 @@
/*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#include <bsp.h>
#include <bsp/bootcard.h>
#include <stdint.h>
extern void *WorkspaceBase;
extern void *_RamBase;
extern void *_RamSize;
/*
* This method returns the base address and size of the area which
* is to be allocated between the RTEMS Workspace and the C Program
* Heap.
*/
void bsp_get_work_area(
void **work_area_start,
size_t *work_area_size,
void **heap_start,
size_t *heap_size
)
{
uintptr_t size;
/*
* Old code had hard-coded heap size of 0x20000 and a comment indicating
* something about the undefined symbol MEM_NOCACHE_SIZE.
*/
size = (uintptr_t)&_RamBase + (uintptr_t)&_RamSize
- (uintptr_t)&WorkspaceBase;
*work_area_start = (void *)&WorkspaceBase;
*work_area_size = size;
*heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
*heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT;
}

View File

@@ -25,99 +25,66 @@
#include <rtems/libcsupport.h>
#include <libcpu/mongoose-v.h>
/*
* Use the shared implementations of the following routines
*/
void bsp_libc_init( void *, uint32_t, int );
/*
* Function: bsp_pretasking_hook
* Created: 95/03/10
*
* Description:
* BSP pretasking hook. Called just before drivers are initialized.
* Used to setup libc and install any BSP extensions.
*
* NOTES:
* Must not use libc (to do io) from here, since drivers are
* not yet initialized.
*
*/
void bsp_pretasking_hook(void)
{
extern int HeapBase;
extern int HeapSize;
void *heapStart = &HeapBase;
unsigned long heapSize = (unsigned long)&HeapSize;
bsp_libc_init(heapStart, (uint32_t) heapSize, 0);
}
extern void _sys_exit(int);
extern void mips_install_isr_entries(void);
extern void mips_gdb_stub_install(void);
/*
* bsp_start
*
* This routine does the bulk of the system initialization.
*/
void bsp_start( void )
{
extern void _sys_exit(int);
extern int WorkspaceBase;
extern void mips_install_isr_entries(void);
extern void mips_gdb_stub_install(void);
/* mask off any interrupts */
MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_MASK_REGISTER, 0 );
/* HACK -- tied to value linkcmds */
if ( rtems_configuration_get_work_space_size() > (4096*1024) )
_sys_exit( 1 );
/* reset the config register & clear any pending peripheral interrupts */
MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
MONGOOSEV_WRITE(
MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, MONGOOSEV_UART_CMD_RESET_BOTH_PORTS );
MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
Configuration.work_space_start = (void *) &WorkspaceBase;
/* reset both timers */
MONGOOSEV_WRITE_REGISTER(
MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff);
MONGOOSEV_WRITE_REGISTER(
MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
/* mask off any interrupts */
MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_MASK_REGISTER, 0 );
MONGOOSEV_WRITE_REGISTER(
MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff);
MONGOOSEV_WRITE_REGISTER(
MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
/* reset the config register & clear any pending peripheral interrupts */
MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, MONGOOSEV_UART_CMD_RESET_BOTH_PORTS );
MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 );
/* clear any pending interrupts */
MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_STATUS_REGISTER, 0xffffffff );
/* reset both timers */
MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff );
MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
/* clear any writable bits in the cause register */
mips_set_cause( 0 );
MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff );
MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0);
/* set interrupt mask, but globally off. */
/* clear any pending interrupts */
MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_STATUS_REGISTER, 0xffffffff );
/*
* Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit 9 | Bit 8 |
* periph | unused | FPU | unused | timer2 | timer1 | swint1 | swint2 |
* extern | | | | | | | |
*
* 1 0 1 0 0 1 0 0
*
* 0x8C00 Enable only internal Mongoose V timers.
* 0xA400 Enable Peripherial ints, FPU and timer1
* 0x0400 Timer1 only
*/
/* clear any writable bits in the cause register */
mips_set_cause( 0 );
/* mips_set_sr( (SR_CU0 | SR_CU1 | 0xA400) ); */
/* set interrupt mask, but globally off. */
/*
** Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit 9 | Bit 8 |
** periph | unused | FPU | unused | timer2 | timer1 | swint1 | swint2 |
** extern | | | | | | | |
**
** 1 0 1 0 0 1 0 0
**
** 0x8C00 Enable only internal Mongoose V timers.
** 0xA400 Enable Peripherial ints, FPU and timer1
** 0x0400 Timer1 only
/* to start up, only enable coprocessor 0 & timer int. per-task
* processor settings will be applied as they are created, this
* is just to configure the processor for startup
*/
mips_set_sr( (SR_CU0 | 0x400) );
/* mips_set_sr( (SR_CU0 | SR_CU1 | 0xA400) ); */
/* to start up, only enable coprocessor 0 & timer int. per-task
** processor settings will be applied as they are created, this
** is just to configure the processor for startup
*/
mips_set_sr( (SR_CU0 | 0x400) );
mips_install_isr_entries();
mips_install_isr_entries();
}
void clear_cache( void )
@@ -128,25 +95,3 @@ void clear_cache( void )
promCopyIcacheFlush();
promCopyDcacheFlush();
}
#if 0
/* Structure filled in by get_mem_info. */
struct s_mem
{
unsigned int size;
unsigned int icsize;
unsigned int dcsize;
};
extern uint32_t _RamSize;
void get_mem_info ( struct s_mem *mem )
{
mem->size = (uint32_t)&_RamSize;
mem->icsize = MONGOOSEV_IC_SIZE;
mem->dcsize = MONGOOSEV_DC_SIZE;
}
#endif

View File

@@ -13,7 +13,6 @@
_RamBase = DEFINED(_RamBase) ? _RamBase : 0x80000000;
_RamSize = DEFINED(_RamSize) ? _RamSize : 32M;
HeapSize = DEFINED(HeapSize) ? HeapSize : 0x40000;
_StackSize = DEFINED(_StackSize) ? _StackSize : 0x4000;
ClockRate = DEFINED(ClockRate) ? ClockRate : 12000000;
@@ -170,8 +169,6 @@ SECTIONS
__stack = .;
_stack_init = .;
_clear_end = .;
HeapBase = .;
. += HeapSize; /* reserve some memory for heap */
WorkspaceBase = .;
end = .;
_end = .;