summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/no_cpu/no_bsp
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/no_cpu/no_bsp')
-rw-r--r--c/src/lib/libbsp/no_cpu/no_bsp/clock/ckinit.c64
-rw-r--r--c/src/lib/libbsp/no_cpu/no_bsp/console/console.c129
-rw-r--r--c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h19
-rw-r--r--c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c70
4 files changed, 217 insertions, 65 deletions
diff --git a/c/src/lib/libbsp/no_cpu/no_bsp/clock/ckinit.c b/c/src/lib/libbsp/no_cpu/no_bsp/clock/ckinit.c
index e4e695ad82..efe0225520 100644
--- a/c/src/lib/libbsp/no_cpu/no_bsp/clock/ckinit.c
+++ b/c/src/lib/libbsp/no_cpu/no_bsp/clock/ckinit.c
@@ -60,28 +60,25 @@ rtems_device_minor_number rtems_clock_minor;
rtems_isr_entry Old_ticker;
+void Clock_exit( void );
+
+
/*
- * Reinstall_clock
- *
- * Install a clock tick handler without reprogramming the chip. This
- * is used by the polling shared memory device driver.
+ * Isr Handler
*/
-void ReInstall_clock(
- rtems_isr_entry clock_isr
+rtems_isr Clock_isr(
+ rtems_vector_number vector
)
{
- rtems_unsigned32 isrlevel = 0;
-
- /*
- * Disable interrupts and install the clock ISR vector using the
- * BSP dependent set_vector routine. In the below example, the clock
- * ISR is on vector 4 and is an RTEMS interrupt.
- */
-
- rtems_interrupt_disable( isrlevel );
- (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
- rtems_interrupt_enable( isrlevel );
+/*
+ * bump the number of clock driver ticks since initialization
+ *
+ * determine if it is time to announce the passing of tick as configured
+ * to RTEMS through the rtems_clock_tick directive
+ *
+ * perform any timer dependent tasks
+ */
}
/*
@@ -124,6 +121,30 @@ void Install_clock(
}
/*
+ * Reinstall_clock
+ *
+ * Install a clock tick handler without reprogramming the chip. This
+ * is used by the polling shared memory device driver.
+ */
+
+void ReInstall_clock(
+ rtems_isr_entry clock_isr
+)
+{
+ rtems_unsigned32 isrlevel = 0;
+
+ /*
+ * Disable interrupts and install the clock ISR vector using the
+ * BSP dependent set_vector routine. In the below example, the clock
+ * ISR is on vector 4 and is an RTEMS interrupt.
+ */
+
+ rtems_interrupt_disable( isrlevel );
+ (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
+ rtems_interrupt_enable( isrlevel );
+}
+
+/*
* Clean up before the application exits
*/
@@ -149,14 +170,15 @@ rtems_device_driver Clock_initialize(
void *pargp
)
{
- Install_clock((rtems_isr_entry) Clock_isr);
-
+ Install_clock( Clock_isr );
+
/*
* make major/minor avail to others such as shared memory driver
*/
+
rtems_clock_major = major;
- rtems_clock_minor = minor;
-
+ rtems_clock_minor = minor;
+
return RTEMS_SUCCESSFUL;
}
diff --git a/c/src/lib/libbsp/no_cpu/no_bsp/console/console.c b/c/src/lib/libbsp/no_cpu/no_bsp/console/console.c
index c115e256a3..4b1ca4a0e3 100644
--- a/c/src/lib/libbsp/no_cpu/no_bsp/console/console.c
+++ b/c/src/lib/libbsp/no_cpu/no_bsp/console/console.c
@@ -14,9 +14,8 @@
#define NO_BSP_INIT
-#include <rtems.h>
-#include "console.h"
-#include "bsp.h"
+#include <bsp.h>
+#include <rtems/libio.h>
/* console_initialize
*
@@ -32,12 +31,21 @@
rtems_device_driver console_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
- void *arg,
- rtems_id self,
- rtems_unsigned32 *status
+ void *arg
)
{
- *status = RTEMS_SUCCESSFUL;
+ rtems_status_code status;
+
+ status = rtems_io_register_name(
+ "/dev/console",
+ major,
+ (rtems_device_minor_number) 0
+ );
+
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(status);
+
+ return RTEMS_SUCCESSFUL;
}
@@ -110,49 +118,104 @@ void outbyte(
outbyte( '\r' );
}
+
+/*
+ * Open entry point
+ */
+
+rtems_device_driver console_open(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return RTEMS_SUCCESSFUL;
+}
+
/*
- * __read -- read bytes from the serial port. Ignore fd, since
- * we only have stdin.
+ * Close entry point
*/
-int __read(
- int fd,
- char *buf,
- int nbytes
+rtems_device_driver console_close(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
)
{
- int i = 0;
+ return RTEMS_SUCCESSFUL;
+}
+
+/*
+ * read bytes from the serial port. We only have stdin.
+ */
- for (i = 0; i < nbytes; i++) {
- *(buf + i) = inbyte();
- if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
- (*(buf + i++)) = '\n';
- (*(buf + i)) = 0;
+rtems_device_driver console_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ rtems_libio_rw_args_t *rw_args;
+ char *buffer;
+ int maximum;
+ int count = 0;
+
+ rw_args = (rtems_libio_rw_args_t *) arg;
+
+ buffer = rw_args->buffer;
+ maximum = rw_args->count;
+
+ for (count = 0; count < maximum; count++) {
+ buffer[ count ] = inbyte();
+ if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
+ buffer[ count++ ] = '\n';
+ buffer[ count ] = 0;
break;
}
}
- return (i);
+
+ rw_args->bytes_moved = count;
+ return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
}
/*
- * __write -- write bytes to the serial port. Ignore fd, since
- * stdout and stderr are the same. Since we have no filesystem,
- * open will only return an error.
+ * write bytes to the serial port. Stdout and stderr are the same.
*/
-int __write(
- int fd,
- char *buf,
- int nbytes
+rtems_device_driver console_write(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
)
{
- int i;
+ int count;
+ int maximum;
+ rtems_libio_rw_args_t *rw_args;
+ char *buffer;
+
+ rw_args = (rtems_libio_rw_args_t *) arg;
- for (i = 0; i < nbytes; i++) {
- if (*(buf + i) == '\n') {
- outbyte ('\r');
+ buffer = rw_args->buffer;
+ maximum = rw_args->count;
+
+ for (count = 0; count < maximum; count++) {
+ if ( buffer[ count ] == '\n') {
+ outbyte('\r');
}
- outbyte (*(buf + i));
+ outbyte( buffer[ count ] );
}
- return (nbytes);
+ return maximum;
+}
+
+/*
+ * 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/no_cpu/no_bsp/include/bsp.h b/c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h
index 5bb7c62577..fa09cbb5bf 100644
--- a/c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h
+++ b/c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h
@@ -23,6 +23,7 @@ extern "C" {
#endif
#include <rtems.h>
+#include <console.h>
#include <clockdrv.h>
/*
@@ -69,19 +70,23 @@ extern "C" {
extern rtems_configuration_table BSP_Configuration;
/*
- * 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 */
void bsp_cleanup( void );
diff --git a/c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c b/c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c
index 4d3d3a7175..75739aa39b 100644
--- a/c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c
+++ b/c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c
@@ -20,10 +20,17 @@
* $Id$
*/
-#include <rtems.h>
#include <bsp.h>
-#include <shm.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
@@ -36,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
*/
@@ -59,6 +68,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.
*/
@@ -76,12 +93,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";
+
/*
* Allocate the memory for the RTEMS Work Space. This can come from
* a variety of places: hard coded address, malloc'ed from outside
@@ -118,6 +166,20 @@ int bsp_start(
BSP_Configuration.maximum_extensions++;
#endif
+#ifdef STACK_CHECKER_ON
+ /*
+ * Add 1 extension for stack checker
+ */
+
+ 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);
+
/*
* Need to "allocate" the memory for the RTEMS Workspace and
* tell the RTEMS configuration where it is. This memory is
@@ -138,7 +200,7 @@ int bsp_start(
Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */
- Cpu_table.postdriver_hook = NULL;
+ Cpu_table.postdriver_hook = bsp_postdriver_hook;
Cpu_table.idle_task = NULL; /* do not override system IDLE task */