diff options
Diffstat (limited to 'c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c')
-rw-r--r-- | c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c index efbb89cb67..973a78a9f4 100644 --- a/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c @@ -27,10 +27,17 @@ * $Id$ */ -#include <rtems.h> #include <bsp.h> +#include <rtems/libio.h> + #include <libcsupport.h> -#include <z8036.h> + +#include <string.h> +#include <fcntl.h> + +#ifdef STACK_CHECKER_ON +#include <stackchk.h> +#endif /* * The original table from the application and our copy of it with @@ -42,6 +49,8 @@ rtems_configuration_table BSP_Configuration; rtems_cpu_table Cpu_table; +char *rtems_progname; + /* Initialize whatever libc we are using * called from postdriver hook */ @@ -58,6 +67,14 @@ void bsp_libc_init() 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 __open, __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. */ @@ -75,7 +92,33 @@ void bsp_libc_init() #endif } -int bsp_start( +/* + * After drivers are setup, register some "filenames" + * and open stdin, stdout, stderr files + * + * Newlib will automatically associate the files with these + * (it hardcodes the numbers) + */ + +void +bsp_postdriver_hook(void) +{ + int stdin_fd, stdout_fd, stderr_fd; + + if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1) + rtems_fatal_error_occurred('STD0'); + + if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1) + rtems_fatal_error_occurred('STD1'); + + if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1) + rtems_fatal_error_occurred('STD2'); + + if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2)) + rtems_fatal_error_occurred('STIO'); +} + +int main( int argc, char **argv, char **environp @@ -84,6 +127,11 @@ int bsp_start( m68k_isr_entry *monitors_vector_table; int index; + if ((argc > 0) && argv && argv[0]) + rtems_progname = argv[0]; + else + rtems_progname = "RTEMS"; + /* * 162Bug Vectors are at 0xFFE00000 */ @@ -121,7 +169,7 @@ int bsp_start( Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ - Cpu_table.postdriver_hook = NULL; /* Call our main() for constructors */ + Cpu_table.postdriver_hook = bsp_postdriver_hook; Cpu_table.idle_task = NULL; /* do not override system IDLE task */ @@ -161,6 +209,12 @@ int bsp_start( BSP_Configuration.maximum_extensions++; #endif + /* + * Tell libio how many fd's we want and allow it to tweak config + */ + + rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); + BSP_Configuration.work_space_start = (void *) (RAM_END - BSP_Configuration.work_space_size); |