From b6394ae43432a3c69f1737d1ed1e23db8e7896ba Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 15 Apr 1998 15:13:01 +0000 Subject: Transitioned to shared bsp_libc_init() and cleaned up comments. --- c/src/lib/libbsp/i386/force386/startup/Makefile.in | 2 +- c/src/lib/libbsp/i386/force386/startup/bspstart.c | 63 ++++++------------- c/src/lib/libbsp/i386/go32/startup/Makefile.in | 2 +- c/src/lib/libbsp/i386/go32/startup/bspstart.c | 73 +++++++--------------- c/src/lib/libbsp/i386/i386ex/startup/Makefile.in | 2 +- c/src/lib/libbsp/i386/i386ex/startup/bspstart.c | 66 +++++++------------ c/src/lib/libbsp/i386/pc386/startup/Makefile.in | 2 +- c/src/lib/libbsp/i386/pc386/startup/bspstart.c | 51 +++------------ 8 files changed, 77 insertions(+), 184 deletions(-) (limited to 'c/src/lib/libbsp/i386') diff --git a/c/src/lib/libbsp/i386/force386/startup/Makefile.in b/c/src/lib/libbsp/i386/force386/startup/Makefile.in index 3da58a3ab9..bda5bb88da 100644 --- a/c/src/lib/libbsp/i386/force386/startup/Makefile.in +++ b/c/src/lib/libbsp/i386/force386/startup/Makefile.in @@ -11,7 +11,7 @@ PROJECT_ROOT = @PROJECT_ROOT@ PGM=${ARCH}/startup.rel # C source names, if any, go here -- minus the .c -C_PIECES=bspclean bsppost bspstart main sbrk setvec +C_PIECES=bspclean bsplibc bsppost bspstart main sbrk setvec C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) diff --git a/c/src/lib/libbsp/i386/force386/startup/bspstart.c b/c/src/lib/libbsp/i386/force386/startup/bspstart.c index 12fcaa7c4d..f32fc798f1 100644 --- a/c/src/lib/libbsp/i386/force386/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/force386/startup/bspstart.c @@ -1,14 +1,9 @@ -/* bsp_start() - * +/* * This routine starts the application. It includes application, * board, and monitor specific initialization and configuration. * The generic CPU dependent initialization has been performed * before this routine is invoked. * - * INPUT: NONE - * - * OUTPUT: NONE - * * COPYRIGHT (c) 1989-1998. * On-Line Applications Research Corporation (OAR). * Copyright assigned to U.S. Government, 1994. @@ -37,38 +32,12 @@ rtems_cpu_table Cpu_table; char *rtems_progname; -/* Initialize whatever libc we are using - * called from postdriver hook +/* + * Use the shared implementations of the following routines */ - -void bsp_libc_init() -{ - extern int end; - rtems_unsigned32 heap_start; - - heap_start = (rtems_unsigned32) &end; - if (heap_start & (CPU_ALIGNMENT-1)) - heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); - - RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); - - /* - * Init the RTEMS libio facility to provide UNIX-like system - * calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc) - * Uses malloc() to get area for the iops, so must be after malloc init - */ - - rtems_libio_init(); - - /* - * Set up for the libc handling. - */ - - if (BSP_Configuration.ticks_per_timeslice > 0) - libc_init(1); /* reentrant if possible */ - else - libc_init(0); /* non-reentrant */ -} + +void bsp_postdriver_hook(void); +void bsp_libc_init( void *, unsigned32, int ); /* * Function: bsp_pretasking_hook @@ -84,22 +53,28 @@ void bsp_libc_init() * */ -void -bsp_pretasking_hook(void) +void bsp_pretasking_hook(void) { - bsp_libc_init(); + extern int end; + rtems_unsigned32 heap_start; + + heap_start = (rtems_unsigned32) &end; + if (heap_start & (CPU_ALIGNMENT-1)) + heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); + + bsp_libc_init((void *) heap_start, 64 * 1024, 0); + #ifdef RTEMS_DEBUG rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); #endif } - /* - * Use the shared bsp_postdriver_hook() implementation + * bsp_start + * + * This routine does the bulk of the system initialization. */ - -void bsp_postdriver_hook(void); void bsp_start( void ) { diff --git a/c/src/lib/libbsp/i386/go32/startup/Makefile.in b/c/src/lib/libbsp/i386/go32/startup/Makefile.in index 86a047cec5..5942446090 100644 --- a/c/src/lib/libbsp/i386/go32/startup/Makefile.in +++ b/c/src/lib/libbsp/i386/go32/startup/Makefile.in @@ -11,7 +11,7 @@ PROJECT_ROOT = @PROJECT_ROOT@ PGM=${ARCH}/startup.rel # C source names, if any, go here -- minus the .c -C_PIECES=bsppost bspstart sbrk setvec +C_PIECES=bsplibc bsppost bspstart sbrk setvec C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) diff --git a/c/src/lib/libbsp/i386/go32/startup/bspstart.c b/c/src/lib/libbsp/i386/go32/startup/bspstart.c index f84d871a35..eeef55eed9 100644 --- a/c/src/lib/libbsp/i386/go32/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/go32/startup/bspstart.c @@ -1,14 +1,9 @@ -/* bsp_start() - * +/* * This routine starts the application. It includes application, * board, and monitor specific initialization and configuration. * The generic CPU dependent initialization has been performed * before this routine is invoked. * - * INPUT: NONE - * - * OUTPUT: NONE - * * COPYRIGHT (c) 1989-1998. * On-Line Applications Research Corporation (OAR). * Copyright assigned to U.S. Government, 1994. @@ -40,44 +35,13 @@ rtems_cpu_table Cpu_table; char *rtems_progname; -/* Initialize whatever libc we are using - * called from postdriver hook +/* + * Use the shared implementations of the following routines */ - -void bsp_libc_init() -{ - rtems_unsigned32 heap_start; - -#if 0 - extern int end; - heap_start = (rtems_unsigned32) &end; -#else - void * sbrk( int ); - heap_start = (rtems_unsigned32) sbrk( 64 * 1024 + CPU_ALIGNMENT ); -#endif - if (heap_start & (CPU_ALIGNMENT-1)) - heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); - - RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); - - /* - * Init the RTEMS libio facility to provide UNIX-like system - * calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc) - * Uses malloc() to get area for the iops, so must be after malloc init - */ - - rtems_libio_init(); - - /* - * Set up for the libc handling. - */ - - if (BSP_Configuration.ticks_per_timeslice > 0) - libc_init(1); /* reentrant if possible */ - else - libc_init(0); /* non-reentrant */ -} +void bsp_postdriver_hook(void); +void bsp_libc_init( void *, unsigned32, int ); + /* * Function: bsp_pretasking_hook * Created: 95/03/10 @@ -92,22 +56,33 @@ void bsp_libc_init() * */ -void -bsp_pretasking_hook(void) +void bsp_pretasking_hook(void) { - bsp_libc_init(); + rtems_unsigned32 heap_start; + +#if 0 + extern int end; + heap_start = (rtems_unsigned32) &end; +#else + void * sbrk( int ); + heap_start = (rtems_unsigned32) sbrk( 64 * 1024 + CPU_ALIGNMENT ); +#endif + if (heap_start & (CPU_ALIGNMENT-1)) + heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); + + bsp_libc_init((void *) heap_start, 64 * 1024, 0); + #ifdef RTEMS_DEBUG rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); #endif } - /* - * Use the shared bsp_postdriver_hook() implementation + * main/bsp_start + * + * This routine does the bulk of the system initialization. */ - -void bsp_postdriver_hook(void); /* This is the original command line passed from DOS */ char ** Go32_Argv; diff --git a/c/src/lib/libbsp/i386/i386ex/startup/Makefile.in b/c/src/lib/libbsp/i386/i386ex/startup/Makefile.in index b62746f5bd..9f4b9ae2fb 100644 --- a/c/src/lib/libbsp/i386/i386ex/startup/Makefile.in +++ b/c/src/lib/libbsp/i386/i386ex/startup/Makefile.in @@ -11,7 +11,7 @@ PROJECT_ROOT = @PROJECT_ROOT@ PGM=${ARCH}/startup.rel # C source names, if any, go here -- minus the .c -C_PIECES=bspclean bsppost bspstart main sbrk setvec +C_PIECES=bspclean bsplibc bsppost bspstart main sbrk setvec C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) diff --git a/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c b/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c index 2bda7165fe..9fc13e0262 100644 --- a/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c @@ -43,45 +43,11 @@ rtems_cpu_table Cpu_table; extern rtems_unsigned32 rdb_start; /* - * bsp_libc_init - * - * Initialize whatever libc we are using called from bsp_postdriver_hook. + * Use the shared implementations of the following routines */ - - -void bsp_libc_init() -{ - extern int heap_bottom; - rtems_unsigned32 heap_start; - rtems_unsigned32 heap_size; - - heap_start = (rtems_unsigned32) &heap_bottom; - if (heap_start & (CPU_ALIGNMENT-1)) - heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); - - heap_size = BSP_Configuration.work_space_start -(void *) heap_start ; - heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ - - heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ - RTEMS_Malloc_Initialize((void *) heap_start, heap_size, 0); - - /* - * Init the RTEMS libio facility to provide UNIX-like system - * calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc) - * Uses malloc() to get area for the iops, so must be after malloc init - */ - - rtems_libio_init(); - /* - * Set up for the libc handling. - */ - - if (BSP_Configuration.ticks_per_timeslice > 0) - libc_init(1); /* reentrant if possible */ - else - libc_init(0); /* non-reentrant */ -} +void bsp_postdriver_hook(void); +void bsp_libc_init( void *, unsigned32, int ); /* * Function: bsp_pretasking_hook @@ -97,22 +63,32 @@ void bsp_libc_init() * */ -void -bsp_pretasking_hook(void) +void bsp_pretasking_hook(void) { - bsp_libc_init(); - + extern int heap_bottom; + rtems_unsigned32 heap_start; + rtems_unsigned32 heap_size; + + heap_start = (rtems_unsigned32) &heap_bottom; + if (heap_start & (CPU_ALIGNMENT-1)) + heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); + + heap_size = BSP_Configuration.work_space_start -(void *) heap_start ; + heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ + + heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ + bsp_libc_init((void *) heap_start, heap_size, 0); + #ifdef RTEMS_DEBUG rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); #endif } - /* - * Use the shared bsp_postdriver_hook() implementation + * bsp_start + * + * This routine does the bulk of the system initialization. */ - -void bsp_postdriver_hook(void); void bsp_start( void ) { diff --git a/c/src/lib/libbsp/i386/pc386/startup/Makefile.in b/c/src/lib/libbsp/i386/pc386/startup/Makefile.in index cf3371536c..1c8f298249 100644 --- a/c/src/lib/libbsp/i386/pc386/startup/Makefile.in +++ b/c/src/lib/libbsp/i386/pc386/startup/Makefile.in @@ -11,7 +11,7 @@ PROJECT_ROOT = @PROJECT_ROOT@ PGM=${ARCH}/startup.rel # C source names, if any, go here -- minus the .c -C_PIECES=bspclean bsppost bspstart exit irq main sbrk +C_PIECES=bspclean bsplibc bsppost bspstart exit irq main sbrk C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c index 18f36d61a1..773d3ba804 100644 --- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c @@ -66,38 +66,8 @@ char *rtems_progname; /* Program name - from main(). */ | External Prototypes +--------------------------------------------------------------------------*/ extern void _exit(int); /* define in exit.c */ - -/*-------------------------------------------------------------------------+ -| Function: bsp_libc_init -| Description: Initialize whatever libc we are using. Called from -| pretasking hook. -| Global Variables: rtemsFreeMemStart. -| Arguments: None. -| Returns: Nothing. -+--------------------------------------------------------------------------*/ -static void -bsp_libc_init(void) -{ - if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1)) /* not aligned => align it */ - rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); - - RTEMS_Malloc_Initialize((void *)rtemsFreeMemStart, HEAP_SIZE << 10, 0); - rtemsFreeMemStart += HEAP_SIZE << 10; /* HEAP_SIZE is in KBytes */ - - /* Init the RTEMS libio facility to provide UNIX-like system calls for use by - newlib (ie: provide __rtems_open, __rtems_close, etc). Uses malloc() - to get area for the iops, so must be after malloc initialization. */ - - rtems_libio_init(); - - /* Set up for the libc handling. */ - - if (BSP_Configuration.ticks_per_timeslice > 0) - libc_init(1); /* reentrant if possible */ - else - libc_init(0); /* non-reentrant */ -} /* bsp_libc_init */ - +void bsp_libc_init( void *, unsigned32, int ); +void bsp_postdriver_hook(void); /*-------------------------------------------------------------------------+ | Function: bsp_pretasking_hook @@ -109,10 +79,14 @@ bsp_libc_init(void) | Arguments: None. | Returns: Nothing. +--------------------------------------------------------------------------*/ -void -bsp_pretasking_hook(void) +void bsp_pretasking_hook(void) { - bsp_libc_init(); + if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1)) /* not aligned => align it */ + rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); + + bsp_libc_init((void *)rtemsFreeMemStart, HEAP_SIZE << 10, 0); + rtemsFreeMemStart += HEAP_SIZE << 10; /* HEAP_SIZE is in KBytes */ + #ifdef RTEMS_DEBUG @@ -122,13 +96,6 @@ bsp_pretasking_hook(void) } /* bsp_pretasking_hook */ -/* - * Use the shared bsp_postdriver_hook() implementation - */ - -void bsp_postdriver_hook(void); - - /*-------------------------------------------------------------------------+ | Function: bsp_start | Description: Called before main is invoked. -- cgit v1.2.3