From 8f95b5f67b59eef4aa392b6be72f59af720d9ea2 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 30 Mar 1998 14:01:19 +0000 Subject: Moved bsp_postdriver_hook() to a shared file and made it a common component. --- c/src/lib/libbsp/shared/bsppost.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 c/src/lib/libbsp/shared/bsppost.c (limited to 'c/src/lib/libbsp/shared') diff --git a/c/src/lib/libbsp/shared/bsppost.c b/c/src/lib/libbsp/shared/bsppost.c new file mode 100644 index 0000000000..d3d14786ce --- /dev/null +++ b/c/src/lib/libbsp/shared/bsppost.c @@ -0,0 +1,37 @@ +/* + * This is a basic BSP post driver hook. + * + * 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) + * + * $Id$ + */ + +#include +#include +#include + +void +bsp_postdriver_hook(void) +{ + int stdin_fd, stdout_fd, stderr_fd; + int error_code; + + error_code = 'S' << 24 | 'T' << 16; + + if ((stdin_fd = __rtems_open("/dev/console", O_RDONLY, 0)) == -1) + rtems_fatal_error_occurred( error_code | 'D' << 8 | '0' ); + + if ((stdout_fd = __rtems_open("/dev/console", O_WRONLY, 0)) == -1) + rtems_fatal_error_occurred( error_code | 'D' << 8 | '1' ); + + if ((stderr_fd = __rtems_open("/dev/console", O_WRONLY, 0)) == -1) + rtems_fatal_error_occurred( error_code | 'D' << 8 | '2' ); + + if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2)) + rtems_fatal_error_occurred( error_code | 'I' << 8 | 'O' ); +} + -- cgit v1.2.3