summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/i960/cvme961/startup/bspstart.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/i960/cvme961/startup/bspstart.c')
-rw-r--r--c/src/lib/libbsp/i960/cvme961/startup/bspstart.c66
1 files changed, 59 insertions, 7 deletions
diff --git a/c/src/lib/libbsp/i960/cvme961/startup/bspstart.c b/c/src/lib/libbsp/i960/cvme961/startup/bspstart.c
index afb9b7e733..8298efcffe 100644
--- a/c/src/lib/libbsp/i960/cvme961/startup/bspstart.c
+++ b/c/src/lib/libbsp/i960/cvme961/startup/bspstart.c
@@ -20,12 +20,17 @@
* $Id$
*/
-#include <rtems.h>
#include <bsp.h>
-#include "libcsupport.h"
-
-
-#include "stackchk.h"
+#include <rtems/libio.h>
+
+#include <libcsupport.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
@@ -38,6 +43,8 @@ rtems_configuration_table BSP_Configuration;
rtems_cpu_table Cpu_table;
+char *rtems_progname;
+
/* Initialize whatever libc we are using
* called from postdriver hook
*/
@@ -54,6 +61,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.
*/
@@ -70,12 +85,43 @@ 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
)
{
+ if ((argc > 0) && argv && argv[0])
+ rtems_progname = argv[0];
+ else
+ rtems_progname = "RTEMS";
+
/* set node number in SQSIO4 CTL REG */
*((rtems_unsigned32 *)0xc00000b0) =
@@ -110,7 +156,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 */
@@ -150,6 +196,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);