summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c')
-rw-r--r--c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c63
1 files changed, 58 insertions, 5 deletions
diff --git a/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c b/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c
index e66abc9ad2..4079ee4a8e 100644
--- a/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c
+++ b/c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c
@@ -21,11 +21,17 @@
* $Id$
*/
-#include <rtems.h>
#include <bsp.h>
+#include <rtems/libio.h>
+
#include <libcsupport.h>
-#include <vmeintr.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
* some changes.
@@ -36,6 +42,8 @@ rtems_configuration_table BSP_Configuration;
rtems_cpu_table Cpu_table;
+char *rtems_progname;
+
/* Initialize whatever libc we are using
* called from postdriver hook
*/
@@ -52,6 +60,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.
*/
@@ -69,7 +85,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
@@ -79,6 +121,11 @@ int bsp_start(
int index;
void *vbr;
+ if ((argc > 0) && argv && argv[0])
+ rtems_progname = argv[0];
+ else
+ rtems_progname = "RTEMS";
+
monitors_vector_table = (m68k_isr_entry *)0; /* Monitor Vectors are at 0 */
m68k_set_vbr( monitors_vector_table );
@@ -115,7 +162,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 */
@@ -159,6 +206,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);
+
rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
/* does not return */