summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/unix/posix
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/unix/posix')
-rw-r--r--c/src/lib/libbsp/unix/posix/console/console.c69
-rw-r--r--c/src/lib/libbsp/unix/posix/include/bsp.h19
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/bspstart.c74
3 files changed, 139 insertions, 23 deletions
diff --git a/c/src/lib/libbsp/unix/posix/console/console.c b/c/src/lib/libbsp/unix/posix/console/console.c
index 07cb033958..61bbe08c78 100644
--- a/c/src/lib/libbsp/unix/posix/console/console.c
+++ b/c/src/lib/libbsp/unix/posix/console/console.c
@@ -3,6 +3,8 @@
*
* These provide UNIX-like read and write calls for the C library.
*
+ * NOTE: For the most part, this is just a space holder.
+ *
* COPYRIGHT (c) 1994 by Division Incorporated
*
* To anyone who acknowledges that this file is provided "AS IS"
@@ -31,6 +33,71 @@ console_initialize(rtems_device_major_number major,
void * arg
)
{
- return RTEMS_SUCCESSFUL;
+ return 0;
+}
+
+
+/*
+ * Open entry point
+ */
+
+rtems_device_driver console_open(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_SUCCESSFUL;
}
+
+/*
+ * Close entry point
+ */
+
+rtems_device_driver console_close(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_SUCCESSFUL;
+}
+
+/*
+ * read bytes from the serial port. We only have stdin.
+ */
+rtems_device_driver console_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_UNSATISFIED;
+}
+
+/*
+ * write bytes to the serial port. Stdout and stderr are the same.
+ */
+
+rtems_device_driver console_write(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return -1;
+}
+
+/*
+ * IO Control entry point
+ */
+
+rtems_device_driver console_control(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_SUCCESSFUL;
+}
diff --git a/c/src/lib/libbsp/unix/posix/include/bsp.h b/c/src/lib/libbsp/unix/posix/include/bsp.h
index 3bf43ca0c8..6ebec41276 100644
--- a/c/src/lib/libbsp/unix/posix/include/bsp.h
+++ b/c/src/lib/libbsp/unix/posix/include/bsp.h
@@ -22,6 +22,7 @@ extern "C" {
#include <rtems.h>
#include <clockdrv.h>
+#include <console.h>
#include <iosupp.h>
#include <libcsupport.h>
#include <signal.h>
@@ -80,19 +81,23 @@ extern rtems_configuration_table BSP_Configuration;
/* #define INTERRUPT_EXTERNAL_MPCI SIGUSR1 */
/*
- * Console driver init
+ * Device Driver Table Entries
+ */
+
+/*
+ * NOTE: Use the standard Console driver entry
*/
-
-rtems_device_driver console_initialize(
- rtems_device_major_number, rtems_device_minor_number minor, void *);
-
-#define CONSOLE_DRIVER_TABLE_ENTRY \
- { console_initialize, NULL, NULL, NULL, NULL, NULL }
/*
* NOTE: Use the standard Clock driver entry
*/
+/*
+ * How many libio files we want
+ */
+
+#define BSP_LIBIO_MAX_FDS 20
+
/* functions */
rtems_isr_entry set_vector(rtems_isr_entry, rtems_vector_number, int);
diff --git a/c/src/lib/libbsp/unix/posix/startup/bspstart.c b/c/src/lib/libbsp/unix/posix/startup/bspstart.c
index d4279c5818..ed687f7319 100644
--- a/c/src/lib/libbsp/unix/posix/startup/bspstart.c
+++ b/c/src/lib/libbsp/unix/posix/startup/bspstart.c
@@ -37,6 +37,8 @@
#include <bsp.h>
#include <libcsupport.h>
+#include <rtems/libio.h>
+
#ifdef STACK_CHECKER_ON
#include <stackchk.h>
#endif
@@ -112,6 +114,14 @@ bsp_libc_init(void)
RTEMS_Malloc_Initialize((void *)heap_start, Heap_size, 1024 * 1024);
+ /*
+ * 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();
+
libc_init(1);
}
@@ -162,6 +172,34 @@ bsp_pretasking_hook(void)
}
/*
+ * 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)
+{
+#if 0
+ 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');
+#endif
+}
+
+/*
* Function: bsp_start
* Created: 94/12/6
*
@@ -261,7 +299,7 @@ bsp_start(void)
Cpu_table.predriver_hook = NULL;
- Cpu_table.postdriver_hook = NULL;
+ Cpu_table.postdriver_hook = bsp_postdriver_hook;
Cpu_table.idle_task = NULL; /* do not override system IDLE task */
@@ -301,22 +339,28 @@ bsp_start(void)
BSP_Configuration.maximum_extensions++;
#endif
- /*
- * Add 1 extension for MPCI_fatal
- */
+ /*
+ * Tell libio how many fd's we want and allow it to tweak config
+ */
- if (BSP_Configuration.User_multiprocessing_table)
- BSP_Configuration.maximum_extensions++;
+ rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
- CPU_CLICKS_PER_TICK = 1;
+ /*
+ * Add 1 extension for MPCI_fatal
+ */
- /*
- * Start most of RTEMS
- * main() will start the rest
- */
+ if (BSP_Configuration.User_multiprocessing_table)
+ BSP_Configuration.maximum_extensions++;
+
+ CPU_CLICKS_PER_TICK = 1;
+
+ /*
+ * Start most of RTEMS
+ * main() will start the rest
+ */
- bsp_isr_level = rtems_initialize_executive_early(
- &BSP_Configuration,
- &Cpu_table
- );
+ bsp_isr_level = rtems_initialize_executive_early(
+ &BSP_Configuration,
+ &Cpu_table
+ );
}