Index: c/src/lib/libbsp/sh/shsim/ChangeLog
===================================================================
--- c/src/lib/libbsp/sh/shsim/ChangeLog	(revision 4e568769d337e3681f99cba97feed7b572700829)
+++ c/src/lib/libbsp/sh/shsim/ChangeLog	(revision f0ef873cca7d6cc07ad7b81a1459d64fae18c723)
@@ -1,2 +1,11 @@
+2001-05-09	Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+	* scitab/.cvsignore: Add.
+	* configure.in: Add --enable-console, CPU_CLOCK_RATE_HZ, autoheader
+	bspopt.h.
+	* include/bsp.h: Complete rewrite based on the AMOS-BSP.
+	* README: Update.
+	* bsp_specs: copy from gensh1
+
 2001-01-29	Ralf Corsepius <corsepiu@faw.uni-ulm.de>
 
Index: c/src/lib/libbsp/sh/shsim/README
===================================================================
--- c/src/lib/libbsp/sh/shsim/README	(revision 4e568769d337e3681f99cba97feed7b572700829)
+++ c/src/lib/libbsp/sh/shsim/README	(revision f0ef873cca7d6cc07ad7b81a1459d64fae18c723)
@@ -24,6 +24,6 @@
 and non-consecutive memory. I.e. access to memory areas besides area 0 will 
 (bogusly) generate SIGBUS exceptions.  This includes access to area 5 
-(On-chip peripherials) and prevents simulation of configuration of
-accesses to on-chip peripherials.
+(On-chip peripherials) and prevents simulation of configuration and access
+to on-chip peripherials.
 
 * Due to limitations of the simulator you will only be able to run
@@ -33,4 +33,14 @@
 devices, i.e. almost any real world application.
 
-* The simulator currently uses gdb's trap34 interface for console I/O. This
-could be replaced with polled sci1 I/O for SHes > SH1.
+* This BSP supports 3 different console devices (cf. configure --help):
+- trap34, an interface base on gdb's trap34 emulation. Known to work with
+  gdb-5.0.
+- gdbsci1, a stripped down sci device driver adapted to apply gdb's sci1
+emulation. This is known to fail with gdb-5.0, because of a bug in gdb-5.0's 
+sh-sim, a patch is submitted, but .. ~==
+- devnull, redirection of console io to /dev/null. Try to single step this,
+if you want to understand the details on how SH-RTEMS console redirection
+works.
+
+NOTE: the trap34 interface is incomplete and is temporarily disabled
+inside of configure.in.
Index: c/src/lib/libbsp/sh/shsim/bsp_specs
===================================================================
--- c/src/lib/libbsp/sh/shsim/bsp_specs	(revision 4e568769d337e3681f99cba97feed7b572700829)
+++ c/src/lib/libbsp/sh/shsim/bsp_specs	(revision f0ef873cca7d6cc07ad7b81a1459d64fae18c723)
@@ -9,15 +9,14 @@
 
 *lib:
-%{!qrtems: %(old_lib)} %{qrtems: --start-group \
-%{!qrtems_debug: -lrtemsall} %{qrtems_debug: -lrtemsall_g} \
--lc -lgcc --end-group \
-%{!qnolinkcmds: -T linkcmds%s}}
+%{!qrtems: %(old_lib)} \
+%{qrtems: --start-group %{!qrtems_debug: -lrtemsall } %{qrtems_debug: -lrtemsall_g} \
+ -lc -lgcc --end-group \
+ %{!qnolinkcmds: -T linkcmds%s}}
 
 *startfile:
-%{!qrtems: %(old_startfile)} %{qrtems: \
-%{!qrtems_debug: start.o%s} \
-%{qrtems_debug: start_g.o%s}}
+%{!qrtems: %(old_startfile)} \
+%{qrtems: %{qrtems_debug: start_g.o%s} %{!qrtems_debug: start.o%s}}
 
 *link:
-%(old_link) %{!qrtems: %(old_link)} %{qrtems: -dc -dp -N -e _start}
+%(old_link) %{qrtems: -dc -dp -N -e _start}
 
Index: c/src/lib/libbsp/sh/shsim/configure.in
===================================================================
--- c/src/lib/libbsp/sh/shsim/configure.in	(revision 4e568769d337e3681f99cba97feed7b572700829)
+++ c/src/lib/libbsp/sh/shsim/configure.in	(revision f0ef873cca7d6cc07ad7b81a1459d64fae18c723)
@@ -20,4 +20,56 @@
 RTEMS_CANONICAL_HOST
 
+RTEMS_BSP_ARG_ENABLE([console],
+[  --enable-console=[[null|gdbsci1]]],[
+  case $enable_console in
+  null)
+    BSP_CONSOLE_DEVNAME=\"/dev/null\"
+    BSP_CONSOLE_DRIVER_TABLE_ENTRY=DEVNULL_DRIVER_TABLE_ENTRY
+    ;;
+# Not yet
+#  trap34)
+#    BSP_CONSOLE_DEVNAME=\"/dev/trap34\"
+#    BSP_CONSOLE_DRIVER_TABLE_ENTRY=DEVTRAP34_DRIVER_TABLE_ENTRY
+#    ;;
+  yes|gdbsci1)
+    BSP_CONSOLE_DEVNAME=\"/dev/gdbsci1\"
+    BSP_CONSOLE_DRIVER_TABLE_ENTRY=DEVGDBSCI_DRIVER_TABLE_ENTRY
+    ;;
+  *) AC_MSG_WARN([bad value $enable_console for --enable-console=<value>])
+    ;;
+  esac],[
+    BSP_CONSOLE_DEVNAME=\"/dev/gdbsci1\"
+    BSP_CONSOLE_DRIVER_TABLE_ENTRY=DEVGDBSCI_DRIVER_TABLE_ENTRY
+])
+AC_DEFINE_UNQUOTED(
+  [BSP_CONSOLE_DEVNAME],
+  [${BSP_CONSOLE_DEVNAME}],
+  [device name to redirect the console to])
+AC_DEFINE_UNQUOTED(
+  [BSP_CONSOLE_DRIVER_TABLE_ENTRY],
+  [${BSP_CONSOLE_DRIVER_TABLE_ENTRY}],
+  [Driver table entry for the console device])
+
+##
+RTEMS_BSP_ARG_ENABLE([iomem-patch],
+[  --enable-iomem-patch=[[yes|no]]])
+if test x"$enable_iomem_patch" = x"yes"; then
+AC_DEFINE_UNQUOTED(
+  [HAVE_SHSIM_IOMEM_PATCH],
+  [1],
+  [whether support for functional IOMEM in shsim/gdb shall be enabled])
+fi
+
+## setup environment variable
+CPU_CLOCK_RATE_HZ=${CPU_CLOCK_RATE_HZ-20000000}
+AC_SUBST(CPU_CLOCK_RATE_HZ)
+## Propagate option to config header
+AC_DEFINE_UNQUOTED(
+  [CPU_CLOCK_RATE_HZ],
+  [$CPU_CLOCK_RATE_HZ],
+  [cpu clock rate in HZ])
+
+AM_CONFIG_HEADER(include/bspopts.h)
+
 RTEMS_PROJECT_ROOT
 
@@ -28,4 +80,6 @@
 console/Makefile
 include/Makefile
+scitab/Makefile
+gdbsci/Makefile
 start/Makefile
 startup/Makefile
Index: c/src/lib/libbsp/sh/shsim/include/bsp.h
===================================================================
--- c/src/lib/libbsp/sh/shsim/include/bsp.h	(revision 4e568769d337e3681f99cba97feed7b572700829)
+++ c/src/lib/libbsp/sh/shsim/include/bsp.h	(revision f0ef873cca7d6cc07ad7b81a1459d64fae18c723)
@@ -1,8 +1,16 @@
-/*  bsp.h
+/*
+ *  This include file contains all board IO definitions.
  *
- *  This include file contains some definitions specific to the
- *  JMR3904 simulator in gdb.
+ *  SH-gdb simulator BSP
  *
- *  COPYRIGHT (c) 1989-2000.
+ *  Author: Ralf Corsepius (corsepiu@faw.uni-ulm.de)
+ *
+ *  COPYRIGHT (c) 2001, Ralf Corsepius, Ulm, Germany
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * 
+ *  COPYRIGHT (c) 2001.
  *  On-Line Applications Research Corporation (OAR).
  *
@@ -11,9 +19,9 @@
  *  http://www.OARcorp.com/rtems/license.html.
  *
- *  $Id$
+ * $Id$
  */
 
-#ifndef __JMR3904_h
-#define __JMR3904_h
+#ifndef __bsp_h
+#define __bsp_h
 
 #ifdef __cplusplus
@@ -22,7 +30,23 @@
 
 #include <rtems.h>
-#include <iosupp.h>
+#include <clockdrv.h>
 #include <console.h>
-#include <clockdrv.h>
+
+/*
+ *  confdefs.h overrides for this BSP:
+ *   - number of termios serial ports (defaults to 1)
+ *   - Interrupt stack space is not minimum if defined.
+ */
+
+#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 0
+#define CONFIGURE_INTERRUPT_STACK_MEMORY  (4 * 1024)
+
+#include <bspopts.h>
+
+/*
+ * FIXME: One of these would be enough.
+ */
+#include <gdbsci.h>
+#include <rtems/devnull.h>
 
 /*
@@ -32,4 +56,5 @@
  *  application.
  *
+ * FIXME: This should not be here.
  */
 
@@ -38,25 +63,45 @@
 
 /*
- *  Define the interrupt mechanism for Time Test 27
+ *  Stuff for Time Test 27
  *
- *  NOTE: Following are for XXX and are board independent
- *
+ * FIXME: This should not be here.
  */
 
 #define MUST_WAIT_FOR_INTERRUPT 0
 
-#define Install_tm27_vector( handler ) 
-
-#define Cause_tm27_intr()  
-
-#define Clear_tm27_intr()  
-
-#define Lower_tm27_intr()
+#define Install_tm27_vector( handler )
+#define Cause_tm27_intr()
+#define Clear_tm27_intr()
 
 /* Constants */
 
+/*
+ *  Simple spin delay in microsecond units for device drivers.
+ *  This is very dependent on the clock speed of the target.
+ * 
+ * FIXME: Not applicable with gdb's simulator
+ * Kept for sourcecode compatibility with other sh-BSPs 
+ */
+#define delay( microseconds ) CPU_delay(microseconds)
+#define sh_delay( microseconds ) CPU_delay(microseconds)
+
+/*
+ * Defined in the linker script 'linkcmds'
+ */
+
+extern unsigned32       HeapStart ;
+extern unsigned32       HeapEnd ;
+extern unsigned32       WorkSpaceStart ;
+extern unsigned32       WorkSpaceEnd ;
+
+extern void *CPU_Interrupt_stack_low ;
+extern void *CPU_Interrupt_stack_high ;
+
+  
 /* miscellaneous stuff assumed to exist */
 
 extern rtems_configuration_table BSP_Configuration;
+
+extern void bsp_cleanup( void );
 
 /*
@@ -65,16 +110,15 @@
 
 /*
- * NOTE: Use the standard Console driver entry
+ * Redefine CONSOLE_DRIVER_TABLE_ENTRY to redirect /dev/console
  */
+#undef CONSOLE_DRIVER_TABLE_ENTRY
+#define CONSOLE_DRIVER_TABLE_ENTRY \
+  BSP_CONSOLE_DRIVER_TABLE_ENTRY, \
+  { console_initialize, console_open, console_close, \
+      console_read, console_write, console_control }
  
 /*
  * NOTE: Use the standard Clock driver entry
  */
-
-/* functions */
-
-void bsp_cleanup( void );
-
-/* i960_isr_entry set_vector( rtems_isr_entry, unsigned int, unsigned int ); */
 
 #ifdef __cplusplus
Index: c/src/lib/libbsp/sh/shsim/scitab/.cvsignore
===================================================================
--- c/src/lib/libbsp/sh/shsim/scitab/.cvsignore	(revision f0ef873cca7d6cc07ad7b81a1459d64fae18c723)
+++ c/src/lib/libbsp/sh/shsim/scitab/.cvsignore	(revision f0ef873cca7d6cc07ad7b81a1459d64fae18c723)
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
