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

* shared/startup/bspstart.c, shared/startup/pretaskinghook.c: Add use
	of bsp_get_work_area() in its own file and rely on BSP Framework to
	perform more initialization.
	* shared/startup/bspgetworkarea.c: New file.
This commit is contained in:
Joel Sherrill
2008-09-15 22:05:19 +00:00
parent f1359069e0
commit db77b92977
4 changed files with 57 additions and 55 deletions

View File

@@ -1,3 +1,10 @@
2008-09-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* shared/startup/bspstart.c, shared/startup/pretaskinghook.c: Add use
of bsp_get_work_area() in its own file and rely on BSP Framework to
perform more initialization.
* shared/startup/bspgetworkarea.c: New file.
2008-09-10 Joel Sherrill <joel.sherrill@oarcorp.com> 2008-09-10 Joel Sherrill <joel.sherrill@oarcorp.com>
* shared/startup/bspstart.c: Review of all bsp_cleanup() * shared/startup/bspstart.c: Review of all bsp_cleanup()

View File

@@ -0,0 +1,42 @@
/*
* 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 *__rtems_end;
extern uint32_t _bsp_sbrk_init(uint32_t, uint32_t*);
/*
* 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;
uintptr_t reserve;
uintptr_t spared;
reserve = (uintptr_t)BSP_INIT_STACK_SIZE;
reserve += rtems_configuration_get_interrupt_stack_size();
size = (uintptr_t)BSP_mem_size - (uintptr_t)&__rtems_end + reserve;
*work_area_start = (void *)(&__rtems_end + reserve);
*work_area_size = size;
spared = _bsp_sbrk_init( *work_area_start, work_area_size );
*heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
*heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT;
}

View File

@@ -22,8 +22,6 @@
#include <string.h> #include <string.h>
#include <bsp.h> #include <bsp.h>
#include <rtems/libio.h>
#include <rtems/libcsupport.h>
#include <rtems/bspIo.h> #include <rtems/bspIo.h>
#include <bsp/consoleIo.h> #include <bsp/consoleIo.h>
#include <libcpu/spr.h> #include <libcpu/spr.h>
@@ -76,10 +74,7 @@ char *BSP_commandline_string = loaderParam;
* Total memory using RESIDUAL DATA * Total memory using RESIDUAL DATA
*/ */
unsigned int BSP_mem_size; unsigned int BSP_mem_size;
/*
* Where the heap starts; is used by bsp_pretasking_hook;
*/
unsigned int BSP_heap_start;
/* /*
* PCI Bus Frequency * PCI Bus Frequency
*/ */
@@ -113,9 +108,12 @@ void _BSP_Fatal_error(unsigned int v)
* Use the shared implementations of the following routines * Use the shared implementations of the following routines
*/ */
void bsp_libc_init( void *, uint32_t, int ); void save_boot_params(
RESIDUAL *r3,
void save_boot_params(RESIDUAL* r3, void *r4, void* r5, char *additional_boot_options) void *r4,
void *r5,
char *additional_boot_options
)
{ {
residualCopy = *r3; residualCopy = *r3;
@@ -151,7 +149,6 @@ void bsp_start( void )
#endif #endif
uint32_t intrStackStart; uint32_t intrStackStart;
uint32_t intrStackSize; uint32_t intrStackSize;
unsigned char *work_space_start;
ppc_cpu_id_t myCpu; ppc_cpu_id_t myCpu;
ppc_cpu_revision_t myCpuRevision; ppc_cpu_revision_t myCpuRevision;
prep_t boardManufacturer; prep_t boardManufacturer;
@@ -230,7 +227,6 @@ void bsp_start( void )
*/ */
intrStackStart = (uint32_t) __rtems_end + INIT_STACK_SIZE; intrStackStart = (uint32_t) __rtems_end + INIT_STACK_SIZE;
intrStackSize = rtems_configuration_get_interrupt_stack_size(); intrStackSize = rtems_configuration_get_interrupt_stack_size();
BSP_heap_start = intrStackStart + intrStackSize;
/* /*
* Initialize default raw exception handlers. * Initialize default raw exception handlers.
@@ -358,22 +354,6 @@ void bsp_start( void )
*/ */
bsp_clicks_per_usec = BSP_bus_frequency/(BSP_time_base_divisor * 1000); bsp_clicks_per_usec = BSP_bus_frequency/(BSP_time_base_divisor * 1000);
#ifdef SHOW_MORE_INIT_SETTINGS
printk("rtems_configuration_get_work_space_size() = %x\n",
rtems_configuration_get_work_space_size());
#endif
work_space_start =
(unsigned char *)BSP_mem_size - rtems_configuration_get_work_space_size();
if ( work_space_start <= ((unsigned char *)__rtems_end) + INIT_STACK_SIZE +
rtems_configuration_get_interrupt_stack_size()) {
printk( "bspstart: Not enough RAM!!!\n" );
bsp_cleanup();
}
Configuration.work_space_start = work_space_start;
/* /*
* Initalize RTEMS IRQ system * Initalize RTEMS IRQ system
*/ */

View File

@@ -28,15 +28,11 @@
#include <rtems/malloc.h> #include <rtems/malloc.h>
void bsp_libc_init( void *, uint32_t, int );
/* /*
* Function: bsp_pretasking_hook * bsp_pretasking_hook
* Created: 95/03/10
* *
* Description: * Description:
* BSP pretasking hook. Called just before drivers are initialized. * BSP pretasking hook. Called just before drivers are initialized.
* Used to setup libc and install any BSP extensions.
* *
* NOTES: * NOTES:
* Must not use libc (to do io) from here, since drivers are * Must not use libc (to do io) from here, since drivers are
@@ -46,29 +42,6 @@ void bsp_libc_init( void *, uint32_t, int );
void bsp_pretasking_hook(void) void bsp_pretasking_hook(void)
{ {
uint32_t heap_size;
uint32_t heap_sbrk_spared;
extern uint32_t _bsp_sbrk_init(uint32_t, uint32_t*);
/* make sure it's properly aligned */
BSP_heap_start = (BSP_heap_start + CPU_ALIGNMENT - 1) & ~(CPU_ALIGNMENT-1);
heap_size = (BSP_mem_size - BSP_heap_start) - rtems_configuration_get_work_space_size();
heap_sbrk_spared=_bsp_sbrk_init(BSP_heap_start, &heap_size);
#ifdef SHOW_MORE_INIT_SETTINGS
printk( "HEAP start %x size %x (%x bytes spared for sbrk)\n",
BSP_heap_start, heap_size, heap_sbrk_spared);
#endif
/* Must install sbrk helpers since we rely on sbrk for giving
* us even the first chunk of memory (bsp_libc_init(heap start==NULL))
*/
rtems_malloc_sbrk_helpers = &rtems_malloc_sbrk_helpers_table;
bsp_libc_init((void *) 0, heap_size, heap_sbrk_spared);
/* Note that VME support may be omitted also by /* Note that VME support may be omitted also by
* providing a no-op BSP_vme_config routine * providing a no-op BSP_vme_config routine
*/ */