summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/m68k/mvme162
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1995-09-11 19:35:39 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1995-09-11 19:35:39 +0000
commit3a4ae6c210bcc37754767966f1128ae23c77b6af (patch)
tree8804983e5b92bec788d548df13db7513118d351d /c/src/lib/libbsp/m68k/mvme162
parentnew file -- split from inlines (diff)
downloadrtems-3a4ae6c210bcc37754767966f1128ae23c77b6af.tar.bz2
The word "RTEMS" almost completely removed from the core.
Configuration Table Template file added and all tests modified to use this. All gvar.h and conftbl.h files removed from test directories. Configuration parameter maximum_devices added. Core semaphore and mutex handlers added and RTEMS API Semaphore Manager updated to reflect this. Initialization sequence changed to invoke API specific initialization routines. Initialization tasks table now owned by RTEMS Tasks Manager. Added user extension for post-switch. Utilized user extensions to implement API specific functionality like signal dispatching. Added extensions to the System Initialization Thread so that an API can register a function to be invoked while the system is being initialized. These are largely equivalent to the pre-driver and post-driver hooks. Added the Modules file oar-go32_p5, modified oar-go32, and modified the file make/custom/go32.cfg to look at an environment varable which determines what CPU model is being used. All BSPs updated to reflect named devices and clock driver's IOCTL used by the Shared Memory Driver. Also merged clock isr into main file and removed ckisr.c where possible. Updated spsize to reflect new and moved variables. Makefiles for the executive source and include files updated to show break down of files into Core, RTEMS API, and Neither. Header and inline files installed into subdirectory based on whether logically in the Core or a part of the RTEMS API.
Diffstat (limited to 'c/src/lib/libbsp/m68k/mvme162')
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c100
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/console/console.c158
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/include/bsp.h20
-rw-r--r--c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c62
4 files changed, 283 insertions, 57 deletions
diff --git a/c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c b/c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c
index 4118b4d360..df0a13d52f 100644
--- a/c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c
+++ b/c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c
@@ -27,9 +27,8 @@
#include <stdlib.h>
-#include <rtems.h>
#include <bsp.h>
-#include <clockdrv.h>
+#include <rtems/libio.h>
#define MS_COUNT 1000 /* T2's countdown constant (1 ms) */
#define CLOCK_INT_LEVEL 6 /* T2's interrupt level */
@@ -38,24 +37,33 @@ rtems_unsigned32 Clock_isrs; /* ISRs until next tick */
volatile rtems_unsigned32 Clock_driver_ticks; /* ticks since initialization */
rtems_isr_entry Old_ticker;
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp,
- rtems_id tid,
- rtems_unsigned32 *rval
-)
-{
- Install_clock( Clock_isr );
-}
+void Clock_exit( void );
+
+#define CLOCK_VECTOR (VBR0 * 0x10 + 0x9)
+/*
+ * These are set by clock driver during its init
+ */
+
+rtems_device_major_number rtems_clock_major = ~0;
+rtems_device_minor_number rtems_clock_minor;
+
-void ReInstall_clock(rtems_isr_entry clock_isr)
+/*
+ * ISR Handler
+ */
+
+rtems_isr Clock_isr(rtems_vector_number vector)
{
- rtems_unsigned32 isrlevel;
+ Clock_driver_ticks += 1;
+ lcsr->timer_cnt_2 = 0; /* clear counter */
+ lcsr->intr_clear |= 0x02000000;
- rtems_interrupt_disable( isrlevel );
- (void) set_vector( clock_isr, VBR0 * 0x10 + 0x9, 1 );
- rtems_interrupt_enable( isrlevel );
+ if ( Clock_isrs == 1 ) {
+ rtems_clock_tick();
+ Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
+ }
+ else
+ Clock_isrs -= 1;
}
void Install_clock(rtems_isr_entry clock_isr )
@@ -66,7 +74,7 @@ void Install_clock(rtems_isr_entry clock_isr )
if ( BSP_Configuration.ticks_per_timeslice ) {
Old_ticker =
- (rtems_isr_entry) set_vector( clock_isr, VBR0 * 0x10 + 0x9, 1 );
+ (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
lcsr->vector_base |= MASK_INT; /* unmask VMEchip2 interrupts */
lcsr->to_ctl = 0xE7; /* prescaler to 1 MHz (see Appendix A1) */
lcsr->timer_cmp_2 = MS_COUNT;
@@ -79,10 +87,66 @@ void Install_clock(rtems_isr_entry clock_isr )
atexit( Clock_exit );
}
+}
+void ReInstall_clock(rtems_isr_entry clock_isr)
+{
+ rtems_unsigned32 isrlevel;
+
+ rtems_interrupt_disable( isrlevel );
+ (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
+ rtems_interrupt_enable( isrlevel );
}
void Clock_exit( void )
{
/* Dummy for now. See other m68k BSP's for code examples */
}
+
+rtems_device_driver Clock_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp
+)
+{
+ Install_clock( Clock_isr );
+
+ /*
+ * make major/minor avail to others such as shared memory driver
+ */
+
+ rtems_clock_major = major;
+ rtems_clock_minor = minor;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver Clock_control(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp
+)
+{
+ rtems_libio_ioctl_args_t *args = pargp;
+
+ if (args == 0)
+ goto done;
+
+ /*
+ * This is hokey, but until we get a defined interface
+ * to do this, it will just be this simple...
+ */
+
+ if (args->command == rtems_build_name('I', 'S', 'R', ' '))
+ {
+ Clock_isr(CLOCK_VECTOR);
+ }
+ else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
+ {
+ ReInstall_clock(args->buffer);
+ }
+
+done:
+ return RTEMS_SUCCESSFUL;
+}
+
diff --git a/c/src/lib/libbsp/m68k/mvme162/console/console.c b/c/src/lib/libbsp/m68k/mvme162/console/console.c
index 0892f5f200..72595f3bce 100644
--- a/c/src/lib/libbsp/m68k/mvme162/console/console.c
+++ b/c/src/lib/libbsp/m68k/mvme162/console/console.c
@@ -21,10 +21,9 @@
#define M162_INIT
-#include <rtems.h>
-#include "console.h"
-#include "bsp.h"
-#include "ringbuf.h"
+#include <bsp.h>
+#include <rtems/libio.h>
+#include <ringbuf.h>
Ring_buffer_t Buffer[2];
@@ -54,12 +53,11 @@ rtems_isr C_Receive_ISR(rtems_vector_number vector)
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
)
{
int i;
+ rtems_status_code status;
/*
* Initialise receiver interrupts on both ports
@@ -79,7 +77,34 @@ rtems_device_driver console_initialize(
mcchip->gen_control = 2; /* MIEN */
mcchip->SCC_int_ctl = 0x13; /* SCC IEN, IPL3 */
- *status = RTEMS_SUCCESSFUL;
+ status = rtems_io_register_name(
+ "/dev/console",
+ major,
+ (rtems_device_minor_number) 0
+ );
+
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(status);
+
+ status = rtems_io_register_name(
+ "/dev/tty00",
+ major,
+ (rtems_device_minor_number) 0
+ );
+
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(status);
+
+ status = rtems_io_register_name(
+ "/dev/tty01",
+ major,
+ (rtems_device_minor_number) 0
+ );
+
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(status);
+
+ return RTEMS_SUCCESSFUL;
}
/*
@@ -100,7 +125,7 @@ rtems_boolean char_ready(int port, char *ch)
* Block on char input
*/
-char char_wait(int port)
+char inbyte(int port)
{
unsigned char tmp_char;
@@ -113,7 +138,7 @@ char char_wait(int port)
* XON/XOFF flow control.
*/
-void char_put(int port, char ch)
+void outbyte(int port, char ch)
{
while (1) {
if (ZREAD0(port) & TX_BUFFER_EMPTY) break;
@@ -122,45 +147,108 @@ void char_put(int port, char ch)
}
/*
- * Map port A (1) to stdin, stdout, and stderr.
- * Map everything else to port B (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.
*/
-int __read(int fd, char *buf, int nbytes)
+rtems_device_driver console_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
{
- int i, port;
+ rtems_libio_rw_args_t *rw_args;
+ char *buffer;
+ int maximum;
+ int count = 0;
+
+ rw_args = (rtems_libio_rw_args_t *) arg;
- if ( fd <= 2 ) port = 1;
- else port = 0;
+ buffer = rw_args->buffer;
+ maximum = rw_args->count;
- for (i = 0; i < nbytes; i++) {
- *(buf + i) = char_wait(port);
- if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
- (*(buf + i++)) = '\n';
- (*(buf + i)) = 0;
+ if ( minor > 1 )
+ return RTEMS_INVALID_NUMBER;
+
+ for (count = 0; count < maximum; count++) {
+ buffer[ count ] = inbyte( minor );
+ 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;
}
/*
- * Map port A (1) to stdin, stdout, and stderr.
- * Map everything else to port B (0).
+ * 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, port;
-
- if ( fd <= 2 ) port = 1;
- else port = 0;
-
- for (i = 0; i < nbytes; i++) {
- if (*(buf + i) == '\n') {
- char_put (port, '\r');
+ int count;
+ int maximum;
+ rtems_libio_rw_args_t *rw_args;
+ char *buffer;
+
+ rw_args = (rtems_libio_rw_args_t *) arg;
+
+ buffer = rw_args->buffer;
+ maximum = rw_args->count;
+
+ if ( minor > 1 )
+ return RTEMS_INVALID_NUMBER;
+
+ for (count = 0; count < maximum; count++) {
+ if ( buffer[ count ] == '\n') {
+ outbyte('\r', minor );
}
- char_put (port, *(buf + i));
+ outbyte( buffer[ count ], minor );
}
- 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/m68k/mvme162/include/bsp.h b/c/src/lib/libbsp/m68k/mvme162/include/bsp.h
index b11ac753b8..54e74da532 100644
--- a/c/src/lib/libbsp/m68k/mvme162/include/bsp.h
+++ b/c/src/lib/libbsp/m68k/mvme162/include/bsp.h
@@ -28,6 +28,8 @@ extern "C" {
#endif
#include <rtems.h>
+#include <clockdrv.h>
+#include <console.h>
#include <iosupp.h>
/*
@@ -248,6 +250,24 @@ typedef volatile struct gcsr_regs {
#define EXTERN extern
#endif
+/*
+ * Device Driver Table Entries
+ */
+
+/*
+ * NOTE: Use the standard Console driver entry
+ */
+
+/*
+ * NOTE: Use the standard Clock driver entry
+ */
+
+/*
+ * How many libio files we want
+ */
+
+#define BSP_LIBIO_MAX_FDS 20
+
/* miscellaneous stuff assumed to exist */
extern rtems_configuration_table BSP_Configuration;
diff --git a/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c
index efbb89cb67..973a78a9f4 100644
--- a/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c
+++ b/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c
@@ -27,10 +27,17 @@
* $Id$
*/
-#include <rtems.h>
#include <bsp.h>
+#include <rtems/libio.h>
+
#include <libcsupport.h>
-#include <z8036.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
@@ -42,6 +49,8 @@ rtems_configuration_table BSP_Configuration;
rtems_cpu_table Cpu_table;
+char *rtems_progname;
+
/* Initialize whatever libc we are using
* called from postdriver hook
*/
@@ -58,6 +67,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.
*/
@@ -75,7 +92,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
@@ -84,6 +127,11 @@ int bsp_start(
m68k_isr_entry *monitors_vector_table;
int index;
+ if ((argc > 0) && argv && argv[0])
+ rtems_progname = argv[0];
+ else
+ rtems_progname = "RTEMS";
+
/*
* 162Bug Vectors are at 0xFFE00000
*/
@@ -121,7 +169,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 */
@@ -161,6 +209,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);