summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2005-10-05 19:26:00 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2005-10-05 19:26:00 +0000
commit1348869fbbd654c3a5f372d1dd007b701c315aa9 (patch)
treeb628299be00bf754eb57b9df6025fcf5659ec0dd
parent2005-10-05 Jiri Gaisler <jiri@gaisler.com> (diff)
downloadrtems-1348869fbbd654c3a5f372d1dd007b701c315aa9.tar.bz2
2005-10-05 Jiri Gaisler <jiri@gaisler.com>
Edvin Catovic <edvin@gaisler.com> Konrad Eisele <konrad@gaisler.com> PR 827/bsps * .cvsignore, ChangeLog, Makefile.am, README, bsp_specs, configure.ac, times, amba/.cvsignore, amba/Makefile.am, amba/amba.c, clock/.cvsignore, clock/Makefile.am, clock/ckinit.c, console/.cvsignore, console/Makefile.am, console/console.c, console/consolereserveresources.c, console/debugputs.c, gnatsupp/.cvsignore, gnatsupp/Makefile.am, gnatsupp/gnatsupp.c, include/.cvsignore, include/Makefile.am, include/amba.h, include/bsp.h, include/coverhd.h, include/leon.h, leon_open_eth/.cvsignore, leon_open_eth/Makefile.am, leon_open_eth/leon_open_eth.c, leon_smc91111/.cvsignore, leon_smc91111/Makefile.am, leon_smc91111/leon_smc91111.c, start/.cvsignore, start/Makefile.am, startup/.cvsignore, startup/Makefile.am, startup/bspstart.c, startup/ithread.S, startup/linkcmds, startup/setvec.c, startup/spurious.c, timer/.cvsignore, timer/Makefile.am, timer/timer.c, tools/.cvsignore, tools/ChangeLog, tools/Makefile.am, tools/configure.ac, tools/runtest.in, wrapup/.cvsignore, wrapup/Makefile.am: New files.
-rw-r--r--c/src/lib/libbsp/sparc/leon3/.cvsignore14
-rw-r--r--c/src/lib/libbsp/sparc/leon3/ChangeLog36
-rw-r--r--c/src/lib/libbsp/sparc/leon3/Makefile.am17
-rw-r--r--c/src/lib/libbsp/sparc/leon3/README37
-rw-r--r--c/src/lib/libbsp/sparc/leon3/amba/.cvsignore2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/amba/Makefile.am33
-rw-r--r--c/src/lib/libbsp/sparc/leon3/amba/amba.c101
-rw-r--r--c/src/lib/libbsp/sparc/leon3/bsp_specs22
-rw-r--r--c/src/lib/libbsp/sparc/leon3/clock/.cvsignore2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/clock/Makefile.am31
-rw-r--r--c/src/lib/libbsp/sparc/leon3/clock/ckinit.c269
-rw-r--r--c/src/lib/libbsp/sparc/leon3/configure.ac52
-rw-r--r--c/src/lib/libbsp/sparc/leon3/console/.cvsignore2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/console/Makefile.am31
-rw-r--r--c/src/lib/libbsp/sparc/leon3/console/console.c232
-rw-r--r--c/src/lib/libbsp/sparc/leon3/console/consolereserveresources.c21
-rw-r--r--c/src/lib/libbsp/sparc/leon3/console/debugputs.c104
-rw-r--r--c/src/lib/libbsp/sparc/leon3/gnatsupp/.cvsignore2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/gnatsupp/Makefile.am31
-rw-r--r--c/src/lib/libbsp/sparc/leon3/gnatsupp/gnatsupp.c20
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/.cvsignore6
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/Makefile.am18
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/amba.h84
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/bsp.h204
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/coverhd.h110
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/leon.h413
-rw-r--r--c/src/lib/libbsp/sparc/leon3/leon_open_eth/.cvsignore2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/leon_open_eth/Makefile.am35
-rw-r--r--c/src/lib/libbsp/sparc/leon3/leon_open_eth/leon_open_eth.c75
-rw-r--r--c/src/lib/libbsp/sparc/leon3/leon_smc91111/.cvsignore2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/leon_smc91111/Makefile.am35
-rw-r--r--c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c100
-rw-r--r--c/src/lib/libbsp/sparc/leon3/start/.cvsignore2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/start/Makefile.am34
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/.cvsignore2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/Makefile.am45
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/bspstart.c232
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/ithread.S31
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/linkcmds184
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/setvec.c64
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/spurious.c184
-rw-r--r--c/src/lib/libbsp/sparc/leon3/timer/.cvsignore2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/timer/Makefile.am31
-rw-r--r--c/src/lib/libbsp/sparc/leon3/timer/timer.c82
-rw-r--r--c/src/lib/libbsp/sparc/leon3/times193
-rw-r--r--c/src/lib/libbsp/sparc/leon3/tools/.cvsignore15
-rw-r--r--c/src/lib/libbsp/sparc/leon3/tools/ChangeLog52
-rw-r--r--c/src/lib/libbsp/sparc/leon3/tools/Makefile.am22
-rw-r--r--c/src/lib/libbsp/sparc/leon3/tools/configure.ac25
-rw-r--r--c/src/lib/libbsp/sparc/leon3/tools/runtest.in312
-rw-r--r--c/src/lib/libbsp/sparc/leon3/wrapup/.cvsignore2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/wrapup/Makefile.am31
52 files changed, 3688 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/.cvsignore b/c/src/lib/libbsp/sparc/leon3/.cvsignore
new file mode 100644
index 0000000000..bfdfd995be
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/.cvsignore
@@ -0,0 +1,14 @@
+aclocal.m4
+autom4te*.cache
+config.cache
+config.guess
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+Makefile
+Makefile.in
+missing
+mkinstalldirs
diff --git a/c/src/lib/libbsp/sparc/leon3/ChangeLog b/c/src/lib/libbsp/sparc/leon3/ChangeLog
new file mode 100644
index 0000000000..7abe3b271a
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/ChangeLog
@@ -0,0 +1,36 @@
+2005-10-05 Jiri Gaisler <jiri@gaisler.com>
+ Edvin Catovic <edvin@gaisler.com>
+ Konrad Eisele <konrad@gaisler.com>
+
+ PR 827/bsps
+ * .cvsignore, ChangeLog, Makefile.am, README, bsp_specs, configure.ac,
+ times, amba/.cvsignore, amba/Makefile.am, amba/amba.c,
+ clock/.cvsignore, clock/Makefile.am, clock/ckinit.c,
+ console/.cvsignore, console/Makefile.am, console/console.c,
+ console/consolereserveresources.c, console/debugputs.c,
+ gnatsupp/.cvsignore, gnatsupp/Makefile.am, gnatsupp/gnatsupp.c,
+ include/.cvsignore, include/Makefile.am, include/amba.h,
+ include/bsp.h, include/coverhd.h, include/leon.h,
+ leon_open_eth/.cvsignore, leon_open_eth/Makefile.am,
+ leon_open_eth/leon_open_eth.c, leon_smc91111/.cvsignore,
+ leon_smc91111/Makefile.am, leon_smc91111/leon_smc91111.c,
+ start/.cvsignore, start/Makefile.am, startup/.cvsignore,
+ startup/Makefile.am, startup/bspstart.c, startup/ithread.S,
+ startup/linkcmds, startup/setvec.c, startup/spurious.c,
+ timer/.cvsignore, timer/Makefile.am, timer/timer.c, tools/.cvsignore,
+ tools/ChangeLog, tools/Makefile.am, tools/configure.ac,
+ tools/runtest.in, wrapup/.cvsignore, wrapup/Makefile.am: New files.
+
+2005-01-20 Jiri Gaisler <jiri@gaisler.com>
+
+ Added support for printk in console/console.c
+
+2004-11-17 Edvin Catovic <edvin@gaisler.com>
+
+ Removed obsolete startup/boardinit.S
+ Added power-down support
+
+2004-06-16 Edvin Catovic <edvin@gaisler.com>
+
+ * Added LEON3 BSP.
+
diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am
new file mode 100644
index 0000000000..d015418893
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am
@@ -0,0 +1,17 @@
+##
+## $Id$
+##
+
+ACLOCAL_AMFLAGS = -I ../../../../../../aclocal
+
+# wrapup is the one that actually builds and installs the library
+# from the individual .rel files built in other directories
+SUBDIRS = . include start startup gnatsupp amba console clock timer \
+ leon_open_eth leon_smc91111 wrapup tools
+
+include $(top_srcdir)/../../bsp.am
+
+EXTRA_DIST = bsp_specs times
+
+include $(top_srcdir)/../../../../../../automake/subdirs.am
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/README b/c/src/lib/libbsp/sparc/leon3/README
new file mode 100644
index 0000000000..244a0377bb
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/README
@@ -0,0 +1,37 @@
+#
+# LEON3 BSP README
+#
+# $Id$
+#
+#
+#
+
+BSP NAME: leon3
+BUS: AMBA Plug & Play
+CPU FAMILY: sparc
+CPU: LEON3
+
+
+DRIVERS
+=======
+Timer Driver, Console Driver, Opencores Ethernet Driver
+
+Notes
+=====
+
+This BSP supports single LEON3-processor system with minimum peripheral
+configuration of one UART. BSP reads system configuration area to get
+information such as memory mapping and usage of interrupt resources and
+installs device drivers based on this information.
+
+There are no restrictions on memory mapping of UARTS. Console driver
+operates in polled mode.
+
+Console driver uses timer 0 of General Purpose Timer and must be configured
+to use separate interrupts for each timer. No restrictions on memory mapping.
+Interrupt request signal can not be shared with other devices.
+
+Ethernet MAC core can be mapped in arbitrary memory address space and use
+arbitrary interrupt request signal. Interrupt request signal can not be
+shared with other devices.
+
diff --git a/c/src/lib/libbsp/sparc/leon3/amba/.cvsignore b/c/src/lib/libbsp/sparc/leon3/amba/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/amba/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/sparc/leon3/amba/Makefile.am b/c/src/lib/libbsp/sparc/leon3/amba/Makefile.am
new file mode 100644
index 0000000000..0586f7b922
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/amba/Makefile.am
@@ -0,0 +1,33 @@
+##
+## $Id$
+##
+
+
+PGM = $(ARCH)/amba.rel
+
+include_HEADERS = ../include/amba.h
+
+C_FILES = amba.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+OBJS = $(C_O_FILES)
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+$(PGM): $(OBJS)
+ $(make-rel)
+
+# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+
+all-local: $(ARCH) $(OBJS) $(PGM)
+
+.PRECIOUS: $(PGM)
+
+EXTRA_DIST = amba.c
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
new file mode 100644
index 0000000000..466ca9cc43
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
@@ -0,0 +1,101 @@
+/*
+ * AMBA Plag & Play Bus Driver
+ *
+ * This driver hook performs bus scanning.
+ *
+ * COPYRIGHT (c) 2004.
+ * Gaisler Research
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+ *
+ */
+
+#include <leon.h>
+
+#define amba_insert_device(tab, address) \
+{ \
+ if (*(address)) \
+ { \
+ (tab)->addr[(tab)->devnr] = (address); \
+ (tab)->devnr ++; \
+ } \
+} while(0)
+
+
+/* Structure containing address to devices found on the Amba Plug&Play bus */
+amba_confarea_type amba_conf;
+
+/* Pointers to Interrupt Controller configuration registers */
+volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs;
+
+/*
+ * bsp_leon3_predriver_hook
+ *
+ * BSP predriver hook. Called just before drivers are initialized.
+ * Used to scan system bus. Probes for AHB masters, AHB slaves and
+ * APB slaves. Addresses to configuration areas of the AHB masters,
+ * AHB slaves, APB slaves and APB master are storeds in
+ * amba_ahb_masters, amba_ahb_slaves and amba.
+ */
+
+
+void bsp_leon3_predriver_hook(void)
+{
+ unsigned int *cfg_area; /* address to configuration area */
+ unsigned int mbar, iobar, conf;
+ int i, j;
+
+ amba_conf.ahbmst.devnr = 0; amba_conf.ahbslv.devnr = 0; amba_conf.apbslv.devnr = 0;
+ cfg_area = (unsigned int *) (LEON3_IO_AREA | LEON3_CONF_AREA);
+
+ for (i = 0; i < LEON3_AHB_MASTERS; i++)
+ {
+ amba_insert_device(&amba_conf.ahbmst, cfg_area);
+ cfg_area += LEON3_AHB_CONF_WORDS;
+ }
+
+ cfg_area = (unsigned int *) (LEON3_IO_AREA | LEON3_CONF_AREA | LEON3_AHB_SLAVE_CONF_AREA);
+ for (i = 0; i < LEON3_AHB_SLAVES; i++)
+ {
+ amba_insert_device(&amba_conf.ahbslv, cfg_area);
+ cfg_area += LEON3_AHB_CONF_WORDS;
+ }
+
+ for (i = 0; i < amba_conf.ahbslv.devnr; i ++)
+ {
+ conf = amba_get_confword(amba_conf.ahbslv, i, 0);
+ mbar = amba_ahb_get_membar(amba_conf.ahbslv, i, 0);
+ if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_APBMST))
+ {
+ amba_conf.apbmst = amba_membar_start(mbar);
+ cfg_area = (unsigned int *) (amba_conf.apbmst | LEON3_CONF_AREA);
+ for (j = amba_conf.apbslv.devnr; j < LEON3_APB_SLAVES; j++)
+ {
+ amba_insert_device(&amba_conf.apbslv, cfg_area);
+ cfg_area += LEON3_APB_CONF_WORDS;
+ }
+ }
+ }
+
+ /* Find LEON3 Interrupt controler */
+ i = 0;
+ while (i < amba_conf.apbslv.devnr)
+ {
+ conf = amba_get_confword(amba_conf.apbslv, i, 0);
+ if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_IRQMP))
+ {
+ iobar = amba_apb_get_membar(amba_conf.apbslv, i);
+ LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) amba_iobar_start(amba_conf.apbmst, iobar);
+ break;
+ }
+ i++;
+ }
+}
+
+
diff --git a/c/src/lib/libbsp/sparc/leon3/bsp_specs b/c/src/lib/libbsp/sparc/leon3/bsp_specs
new file mode 100644
index 0000000000..6fa79c0a98
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/bsp_specs
@@ -0,0 +1,22 @@
+%rename lib old_lib
+%rename endfile old_endfile
+%rename startfile old_startfile
+%rename link old_link
+
+*endfile:
+crtend.o%s crtn.o%s
+
+*lib:
+%{!qrtems: %(old_lib)} %{!nostdlib: %{qrtems: --start-group \
+%{!qrtems_debug: -lrtemsbsp -lrtemscpu} %{qrtems_debug: -lrtemsbsp_g -lrtemscpu_g} \
+-lc -lgcc --end-group \
+%{!qnolinkcmds: -T linkcmds%s}}}
+
+*startfile:
+%{!qrtems: %(old_startfile)} %{!nostdlib: %{qrtems: \
+%{!qrtems_debug: start.o%s crti.o%s crtbegin.o%s} \
+%{qrtems_debug: start_g.o%s crti.o%s crtbegin.o%s}}}
+
+*link:
+%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N -e start}
+
diff --git a/c/src/lib/libbsp/sparc/leon3/clock/.cvsignore b/c/src/lib/libbsp/sparc/leon3/clock/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/clock/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/sparc/leon3/clock/Makefile.am b/c/src/lib/libbsp/sparc/leon3/clock/Makefile.am
new file mode 100644
index 0000000000..43dbc6aadc
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/clock/Makefile.am
@@ -0,0 +1,31 @@
+##
+## $Id$
+##
+
+
+PGM = $(ARCH)/clock.rel
+
+C_FILES = ckinit.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+OBJS = $(C_O_FILES)
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+$(PGM): $(OBJS)
+ $(make-rel)
+
+# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+
+all-local: $(ARCH) $(OBJS) $(PGM)
+
+.PRECIOUS: $(PGM)
+
+EXTRA_DIST = ckinit.c
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
new file mode 100644
index 0000000000..28dd173ac4
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
@@ -0,0 +1,269 @@
+/*
+ * Clock Tick Device Driver
+ *
+ * This routine initializes LEON timer 1 which used for the clock tick.
+ *
+ * The tick frequency is directly programmed to the configured number of
+ * microseconds per tick.
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * Modified for LEON3 BSP.
+ * COPYRIGHT (c) 2004.
+ * Gaisler Research.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ *
+ * $Id$
+ */
+
+#include <stdlib.h>
+
+#include <bsp.h>
+#include <rtems/libio.h>
+
+/*
+ * The Real Time Clock Counter Timer uses this trap type.
+ */
+
+#define CLOCK_VECTOR LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 )
+
+/*
+ * Clock ticks since initialization
+ */
+
+volatile rtems_unsigned32 Clock_driver_ticks;
+volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs = 0;
+static int clkirq;
+
+/*
+ * This is the value programmed into the count down timer. It
+ * is artificially lowered when SIMSPARC_FAST_IDLE is defined to
+ * cut down how long we spend in the idle task while executing on
+ * the simulator.
+ */
+
+extern rtems_unsigned32 CPU_SPARC_CLICKS_PER_TICK;
+
+rtems_isr_entry Old_ticker;
+
+void Clock_exit( void );
+
+/*
+ * These are set by clock driver during its init
+ */
+
+rtems_device_major_number rtems_clock_major = ~0;
+rtems_device_minor_number rtems_clock_minor;
+
+/*
+ * Clock_isr
+ *
+ * This is the clock tick interrupt handler.
+ *
+ * Input parameters:
+ * vector - vector number
+ *
+ * Output parameters: NONE
+ *
+ * Return values: NONE
+ *
+ */
+
+rtems_isr Clock_isr(
+ rtems_vector_number vector
+)
+{
+ /*
+ * If we are in "fast idle" mode, then the value for clicks per tick
+ * is lowered to decrease the amount of time spent executing the idle
+ * task while using the SPARC Instruction Simulator.
+ */
+
+#if SIMSPARC_FAST_IDLE
+ LEON_REG.Real_Time_Clock_Counter = CPU_SPARC_CLICKS_PER_TICK;
+ LEON_REG_Set_Real_Time_Clock_Timer_Control(
+ LEON_REG_TIMER_COUNTER_ENABLE_COUNTING |
+ LEON_REG_TIMER_COUNTER_LOAD_COUNTER
+ );
+#endif
+
+ /*
+ * The driver has seen another tick.
+ */
+
+ Clock_driver_ticks += 1;
+
+ /*
+ * Real Time Clock counter/timer is set to automatically reload.
+ */
+
+ rtems_clock_tick();
+}
+
+/*
+ * Install_clock
+ *
+ * This routine actually performs the hardware initialization for the clock.
+ *
+ * Input parameters:
+ * clock_isr - clock interrupt service routine entry point
+ *
+ * Output parameters: NONE
+ *
+ * Return values: NONE
+ *
+ */
+
+void Install_clock(
+ rtems_isr_entry clock_isr
+)
+{
+ int i;
+ unsigned int iobar, conf;
+
+ Clock_driver_ticks = 0;
+
+ /* Find GP Timer */
+
+ i = 0;
+ while (i < amba_conf.apbslv.devnr)
+ {
+ conf = amba_get_confword(amba_conf.apbslv, i, 0);
+ if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_GPTIMER))
+ {
+ iobar = amba_apb_get_membar(amba_conf.apbslv, i);
+ LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) amba_iobar_start(amba_conf.apbmst, iobar);
+ break;
+ }
+ i++;
+ }
+
+ clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3;
+
+ if ( BSP_Configuration.ticks_per_timeslice ) {
+ Old_ticker = (rtems_isr_entry) set_vector( clock_isr, LEON_TRAP_TYPE(clkirq), 1 );
+
+ LEON3_Timer_Regs->reload_t0 = CPU_SPARC_CLICKS_PER_TICK - 1;
+
+ LEON3_Timer_Regs->conf_t0 = LEON3_GPTIMER_EN | LEON3_GPTIMER_RL | LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN;
+
+ atexit( Clock_exit );
+ }
+
+}
+
+/*
+ * Clock_exit
+ *
+ * This routine allows the clock driver to exit by masking the interrupt and
+ * disabling the clock's counter.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values: NONE
+ *
+ */
+
+void Clock_exit( void )
+{
+ if ( BSP_Configuration.ticks_per_timeslice ) {
+ LEON_Mask_interrupt(LEON_TRAP_TYPE(clkirq));
+
+ LEON3_Timer_Regs->conf_t0 = 0;
+
+ /* do not restore old vector */
+ }
+}
+
+/*
+ * Clock_initialize
+ *
+ * This routine initializes the clock driver.
+ *
+ * Input parameters:
+ * major - clock device major number
+ * minor - clock device minor number
+ * parg - pointer to optional device driver arguments
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ * rtems_device_driver status code
+ */
+
+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;
+}
+
+/*
+ * Clock_control
+ *
+ * This routine is the clock device driver control entry point.
+ *
+ * Input parameters:
+ * major - clock device major number
+ * minor - clock device minor number
+ * parg - pointer to optional device driver arguments
+ *
+ * Output parameters: NONE
+ *
+ * Return values:
+ * rtems_device_driver status code
+ */
+
+
+
+rtems_device_driver Clock_control(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *pargp
+)
+{
+ rtems_unsigned32 isrlevel;
+ 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(LEON_TRAP_TYPE(clkirq));
+ }
+ else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
+ {
+ rtems_interrupt_disable( isrlevel );
+ (void) set_vector( args->buffer, LEON_TRAP_TYPE(clkirq), 1 );
+ rtems_interrupt_enable( isrlevel );
+ }
+
+done:
+ return RTEMS_SUCCESSFUL;
+}
diff --git a/c/src/lib/libbsp/sparc/leon3/configure.ac b/c/src/lib/libbsp/sparc/leon3/configure.ac
new file mode 100644
index 0000000000..91f0990887
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/configure.ac
@@ -0,0 +1,52 @@
+## Process this file with autoconf to produce a configure script.
+##
+## $Id$
+
+AC_PREREQ(2.57)
+AC_INIT([rtems-c-src-lib-libbsp-sparc-leon],[_RTEMS_VERSION],[rtems-bugs@rtems.com])
+AC_CONFIG_SRCDIR([bsp_specs])
+RTEMS_TOP(../../../../../..)
+
+RTEMS_CANONICAL_TARGET_CPU
+AM_INIT_AUTOMAKE([no-define foreign 1.7.2])
+RTEMS_BSP_CONFIGURE
+
+RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm])
+RTEMS_CANONICALIZE_TOOLS
+
+RTEMS_CHECK_NETWORKING
+
+AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
+
+RTEMS_CONFIG_BUILD_SUBDIRS(tools)
+
+## bsp-specific options
+RTEMS_BSPOPTS_SET([CONSOLE_USE_INTERRUPTS],[*],[0])
+RTEMS_BSPOPTS_HELP([CONSOLE_USE_INTERRUPTS],
+[The erc32 console driver can operate in either polled or interrupt mode.
+Under the simulator (especially when FAST_UART is defined), polled seems to operate
+better. It is common for a task to print a line (like the end of test message) and
+then exit. In this case, the program returns control to the simulator command line
+before the program has even queued the output to the uart. Thus sis has no chance
+of getting the data out.])
+
+RTEMS_BSPOPTS_SET([SIMSPARC_FAST_IDLE],[*],[])
+RTEMS_BSPOPTS_HELP([SIMSPARC_FAST_IDLE],
+[If defined, speed up the clock ticks while the idle task is running so
+ time spent in the idle task is minimized. This significantly reduces
+ the wall time required to execute the RTEMS test suites.])
+
+# Explicitly list all Makefiles here
+AC_CONFIG_FILES([Makefile
+amba/Makefile
+clock/Makefile
+console/Makefile
+leon_open_eth/Makefile
+leon_smc91111/Makefile
+gnatsupp/Makefile
+include/Makefile
+start/Makefile
+startup/Makefile
+timer/Makefile
+wrapup/Makefile])
+AC_OUTPUT
diff --git a/c/src/lib/libbsp/sparc/leon3/console/.cvsignore b/c/src/lib/libbsp/sparc/leon3/console/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/console/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/sparc/leon3/console/Makefile.am b/c/src/lib/libbsp/sparc/leon3/console/Makefile.am
new file mode 100644
index 0000000000..0d5e07e99e
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/console/Makefile.am
@@ -0,0 +1,31 @@
+##
+## $Id$
+##
+
+
+PGM = $(ARCH)/console.rel
+
+C_FILES = console.c consolereserveresources.c debugputs.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+OBJS = $(C_O_FILES)
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+$(PGM): $(OBJS)
+ $(make-rel)
+
+# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+
+all-local: $(ARCH) $(OBJS) $(PGM)
+
+.PRECIOUS: $(PGM)
+
+EXTRA_DIST = console.c consolereserveresources.c debugputs.c
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/console/console.c b/c/src/lib/libbsp/sparc/leon3/console/console.c
new file mode 100644
index 0000000000..41dd26c449
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/console/console.c
@@ -0,0 +1,232 @@
+/*
+ * This file contains the TTY driver for the serial ports on the LEON.
+ *
+ * This driver uses the termios pseudo driver.
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * Modified for LEON3 BSP.
+ * COPYRIGHT (c) 2004.
+ * Gaisler Research.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <bsp.h>
+#include <rtems/libio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <rtems/bspIo.h>
+
+/*
+ * Should we use a polled or interrupt drived console?
+ *
+ * NOTE: This is defined in the custom/leon.cfg file.
+ *
+ * WARNING: In sis 1.6, it did not appear that the UART interrupts
+ * worked in a desirable fashion. Immediately upon writing
+ * a character into the TX buffer, an interrupt was generated.
+ * This did not allow enough time for the program to put more
+ * characters in the buffer. So every character resulted in
+ * "priming" the transmitter. This effectively results in
+ * in a polled console with a useless interrupt per character
+ * on output. It is reasonable to assume that input does not
+ * share this problem although it was not investigated.
+ *
+ */
+
+/*
+ * console_outbyte_polled
+ *
+ * This routine transmits a character using polling.
+ */
+
+void console_outbyte_polled(
+ int port,
+ char ch
+);
+
+/* body is in debugputs.c */
+
+/*
+ * console_inbyte_nonblocking
+ *
+ * This routine polls for a character.
+ */
+
+int console_inbyte_nonblocking( int port );
+
+/* body is in debugputs.c */
+
+
+/*
+ * Console Termios Support Entry Points
+ *
+ */
+
+int console_write_support (int minor, const char *buf, int len)
+{
+ int nwrite = 0;
+
+ while (nwrite < len) {
+ console_outbyte_polled( minor, *buf++ );
+ nwrite++;
+ }
+ return nwrite;
+}
+
+
+/*
+ * Console Device Driver Entry Points
+ *
+ */
+
+volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS];
+
+rtems_device_driver console_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg
+)
+{
+ rtems_status_code status;
+ unsigned int iobar, conf;
+ int i, uarts;
+ char *console_name = "/dev/console_a";
+
+
+ rtems_termios_initialize();
+
+ /* Find UARTs */
+
+ i = 0; uarts = 0;
+ while (i < amba_conf.apbslv.devnr)
+ {
+ conf = amba_get_confword(amba_conf.apbslv, i, 0);
+ if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_APBUART))
+ {
+ iobar = amba_apb_get_membar(amba_conf.apbslv, i);
+ LEON3_Console_Uart[uarts] = (volatile LEON3_UART_Regs_Map *) amba_iobar_start(amba_conf.apbmst, iobar);
+ uarts++;
+ }
+ i++;
+ }
+
+ /* Register Device Names */
+
+ if (uarts)
+ {
+ status = rtems_io_register_name( "/dev/console", major, 0 );
+ if (status != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(status);
+
+ for (i = 1; i < uarts; i++)
+ {
+ console_name[13]++;
+ status = rtems_io_register_name( console_name, major, i);
+ }
+ }
+
+
+ /*
+ * Initialize Hardware
+ */
+
+ for (i = 0; i < uarts; i++)
+ {
+ LEON3_Console_Uart[i]->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
+ LEON3_Console_Uart[i]->status = 0;
+ }
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver console_open(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ rtems_status_code sc;
+
+ static const rtems_termios_callbacks pollCallbacks = {
+ NULL, /* firstOpen */
+ NULL, /* lastClose */
+ console_inbyte_nonblocking, /* pollRead */
+ console_write_support, /* write */
+ NULL, /* setAttributes */
+ NULL, /* stopRemoteTx */
+ NULL, /* startRemoteTx */
+ 0 /* outputUsesInterrupts */
+ };
+
+
+ assert( minor <= LEON3_APBUARTS );
+ if ( minor > LEON3_APBUARTS )
+ return RTEMS_INVALID_NUMBER;
+
+ sc = rtems_termios_open (major, minor, arg, &pollCallbacks);
+
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_device_driver console_close(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return rtems_termios_close (arg);
+}
+
+rtems_device_driver console_read(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return rtems_termios_read (arg);
+}
+
+rtems_device_driver console_write(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return rtems_termios_write (arg);
+}
+
+rtems_device_driver console_control(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void * arg
+)
+{
+ return rtems_termios_ioctl (arg);
+}
+
+/* putchar/getchar for printk */
+
+static void bsp_out_char(char c)
+{
+ console_outbyte_polled(0, c);
+}
+
+BSP_output_char_function_type BSP_output_char = bsp_out_char;
+
+static char bsp_in_char(void)
+{
+ int tmp;
+
+ while ((tmp = console_inbyte_nonblocking(0)) < 0);
+ return (char) tmp;
+}
+
+BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char;
diff --git a/c/src/lib/libbsp/sparc/leon3/console/consolereserveresources.c b/c/src/lib/libbsp/sparc/leon3/console/consolereserveresources.c
new file mode 100644
index 0000000000..7e5b155bfc
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/console/consolereserveresources.c
@@ -0,0 +1,21 @@
+/*
+ * This file contains the TTY driver for the serial ports on the LEON.
+ *
+ * This driver uses the termios pseudo driver.
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <bsp.h>
+#include <rtems/libio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+int console_reserve_resources_removed;
diff --git a/c/src/lib/libbsp/sparc/leon3/console/debugputs.c b/c/src/lib/libbsp/sparc/leon3/console/debugputs.c
new file mode 100644
index 0000000000..066a584386
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/console/debugputs.c
@@ -0,0 +1,104 @@
+/*
+ * This file contains the TTY driver for the serial ports on the LEON.
+ *
+ * This driver uses the termios pseudo driver.
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * Modified for LEON3 BSP.
+ * COPYRIGHT (c) 2004.
+ * Gaisler Research.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <bsp.h>
+#include <rtems/libio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+/*
+ * console_outbyte_polled
+ *
+ * This routine transmits a character using polling.
+ */
+
+void console_outbyte_polled(
+ int port,
+ unsigned char ch
+)
+{
+ if ((port >= 0) && (port <= CONFIGURE_NUMBER_OF_TERMIOS_PORTS))
+ {
+ while ( (LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_THE) == 0 );
+ LEON3_Console_Uart[port]->data = (unsigned int) ch;
+ }
+}
+
+/*
+ * console_inbyte_nonblocking
+ *
+ * This routine polls for a character.
+ */
+
+int console_inbyte_nonblocking( int port )
+{
+
+ if ((port >=0) && (port < CONFIGURE_NUMBER_OF_TERMIOS_PORTS))
+ {
+
+ if (LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_ERR) {
+ LEON3_Console_Uart[port]->status = ~LEON_REG_UART_STATUS_ERR;
+ }
+
+ if ((LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_DR) == 0)
+ return -1;
+ return (int) LEON3_Console_Uart[port]->data;
+ }
+
+ else
+ {
+ assert( 0 );
+ }
+
+ return -1;
+}
+
+/*
+ * DEBUG_puts
+ *
+ * This should be safe in the event of an error. It attempts to insure
+ * that no TX empty interrupts occur while it is doing polled IO. Then
+ * it restores the state of that external interrupt.
+ *
+ * Input parameters:
+ * string - pointer to debug output string
+ *
+ * Output parameters: NONE
+ *
+ * Return values: NONE
+ */
+
+void DEBUG_puts(
+ char *string
+)
+{
+ char *s;
+ /* unsigned32 old_level; */
+
+ /* LEON_Disable_interrupt( LEON_INTERRUPT_UART_1_RX_TX, old_level ); */
+ sparc_disable_interrupts();
+ LEON3_Console_Uart[0]->ctrl = LEON_REG_UART_CTRL_TE;
+ for ( s = string ; *s ; s++ )
+ console_outbyte_polled( 0, *s );
+
+ console_outbyte_polled( 0, '\r' );
+ console_outbyte_polled( 0, '\n' );
+ sparc_enable_interrupts();
+ /* LEON_Restore_interrupt( LEON_INTERRUPT_UART_1_RX_TX, old_level ); */
+}
diff --git a/c/src/lib/libbsp/sparc/leon3/gnatsupp/.cvsignore b/c/src/lib/libbsp/sparc/leon3/gnatsupp/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/gnatsupp/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/sparc/leon3/gnatsupp/Makefile.am b/c/src/lib/libbsp/sparc/leon3/gnatsupp/Makefile.am
new file mode 100644
index 0000000000..a877e1d466
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/gnatsupp/Makefile.am
@@ -0,0 +1,31 @@
+##
+## $Id$
+##
+
+
+VPATH = @srcdir@:@srcdir@/../../shared:@srcdir@/../../../shared
+
+PGM = $(ARCH)/gnatsupp.rel
+
+C_FILES = gnatsupp.c gnatcommon.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+OBJS = $(C_O_FILES)
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+$(PGM): $(OBJS)
+ $(make-rel)
+
+all-local: $(ARCH) $(OBJS) $(PGM)
+
+.PRECIOUS: $(PGM)
+
+EXTRA_DIST = gnatsupp.c
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/gnatsupp/gnatsupp.c b/c/src/lib/libbsp/sparc/leon3/gnatsupp/gnatsupp.c
new file mode 100644
index 0000000000..3836278226
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/gnatsupp/gnatsupp.c
@@ -0,0 +1,20 @@
+/*
+ *
+ * Support for gnat/rtems interrupts and exception handling.
+ * Jiri Gaisler, ESA/ESTEC, 17-02-1999.
+ *
+ * $Id$
+ */
+
+void __gnat_install_handler_common (int t1, int t2);
+
+/*
+ * Avoid trap 0x18 which is used by the clock tick, and
+ * 0x12 (UART B interrupt) which is used by the stub.
+ */
+
+void
+__gnat_install_handler ()
+{
+ __gnat_install_handler_common (0x18, 0x12);
+}
diff --git a/c/src/lib/libbsp/sparc/leon3/include/.cvsignore b/c/src/lib/libbsp/sparc/leon3/include/.cvsignore
new file mode 100644
index 0000000000..b0be3c54e6
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/include/.cvsignore
@@ -0,0 +1,6 @@
+Makefile
+Makefile.in
+bspopts.h
+bspopts.h.in
+stamp-h
+stamp-h.in
diff --git a/c/src/lib/libbsp/sparc/leon3/include/Makefile.am b/c/src/lib/libbsp/sparc/leon3/include/Makefile.am
new file mode 100644
index 0000000000..db4701af17
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/include/Makefile.am
@@ -0,0 +1,18 @@
+##
+## $Id$
+##
+
+
+include_HEADERS = amba.h bsp.h coverhd.h leon.h bspopts.h
+
+$(PROJECT_INCLUDE):
+ $(mkinstalldirs) $@
+
+$(PROJECT_INCLUDE)/%.h: %.h
+ $(INSTALL_DATA) $< $@
+
+PREINSTALL_FILES = $(PROJECT_INCLUDE) $(include_HEADERS:%=$(PROJECT_INCLUDE)/%)
+
+all-local: $(PREINSTALL_FILES)
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/include/amba.h b/c/src/lib/libbsp/sparc/leon3/include/amba.h
new file mode 100644
index 0000000000..a9d4bef59a
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/include/amba.h
@@ -0,0 +1,84 @@
+/*
+ * AMBA Plag & Play Bus Driver Macros
+ *
+ * Macros used for AMBA Plug & Play bus scanning
+ *
+ * COPYRIGHT (c) 2004.
+ * Gaisler Research
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#define LEON3_IO_AREA 0xfff00000
+#define LEON3_CONF_AREA 0xff000
+#define LEON3_AHB_SLAVE_CONF_AREA (1 << 11)
+
+#define LEON3_AHB_CONF_WORDS 8
+#define LEON3_APB_CONF_WORDS 2
+#define LEON3_AHB_MASTERS 8
+#define LEON3_AHB_SLAVES 8
+#define LEON3_APB_SLAVES 16
+#define LEON3_APBUARTS 8
+
+/* Vendor codes */
+#define VENDOR_GAISLER 1
+#define VENDOR_PENDER 2
+#define VENDOR_ESA 4
+#define VENDOR_OPENCORES 8
+
+/* Gaisler Research device id's */
+#define GAISLER_LEON3 0x03
+#define GAISLER_LEON3DSU 0x04
+#define GAISLER_ETHAHB 0x05
+#define GAISLER_APBMST 0x06
+#define GAISLER_AHBUART 0x07
+#define GAISLER_SRCTRL 0x08
+#define GAISLER_SDCTRL 0x09
+#define GAISLER_APBUART 0x0C
+#define GAISLER_IRQMP 0x0D
+#define GAISLER_AHBRAM 0x0E
+#define GAISLER_GPTIMER 0x11
+#define GAISLER_PCITRG 0x12
+#define GAISLER_PCISBRG 0x13
+#define GAISLER_PCIFBRG 0x14
+#define GAISLER_PCITRACE 0x15
+#define GAISLER_DMACTRL 0x16
+#define GAISLER_PIOPORT 0x1A
+
+/* European Space Agency device id's */
+#define ESA_LEON2 0x2
+#define ESA_MCTRL 0xF
+
+/* Opencores device id's */
+#define OPENCORES_PCIBR 0x4
+#define OPENCORES_ETHMAC 0x5
+
+
+/*
+ *
+ * Macros for manipulating Configuration registers
+ *
+ */
+
+
+#define amba_get_confword(tab, index, word) (*((tab).addr[(index)]+(word)))
+
+#define amba_vendor(x) (((x) >> 24) & 0xff)
+
+#define amba_device(x) (((x) >> 12) & 0xfff)
+
+#define amba_ahb_get_membar(tab, index, nr) (*((tab).addr[(index)]+4+(nr)))
+
+#define amba_apb_get_membar(tab, index) (*((tab).addr[(index)]+1))
+
+#define amba_membar_start(mbar) (((mbar) & 0xfff00000) & (((mbar) & 0xfff0) << 16))
+
+#define amba_iobar_start(base, iobar) ((base) | ((((iobar) & 0xfff00000)>>12) & (((iobar) & 0xfff0)<<4)) )
+
+#define amba_irq(conf) ((conf) & 0xf)
+
+
diff --git a/c/src/lib/libbsp/sparc/leon3/include/bsp.h b/c/src/lib/libbsp/sparc/leon3/include/bsp.h
new file mode 100644
index 0000000000..be77c93e23
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/include/bsp.h
@@ -0,0 +1,204 @@
+/* bsp.h
+ *
+ * This include file contains all SPARC simulator definitions.
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * Ported to ERC32 implementation of the SPARC by On-Line Applications
+ * Research Corporation (OAR) under contract to the European Space
+ * Agency (ESA).
+ *
+ * ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995.
+ * European Space Agency.
+ *
+ * $Id$
+ */
+
+#ifndef __SIS_h
+#define __SIS_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bspopts.h>
+
+#include <rtems.h>
+#include <iosupp.h>
+#include <leon.h>
+#include <clockdrv.h>
+
+#include <console.h>
+
+/*
+ * confdefs.h overrides for this BSP:
+ * - two termios serial ports
+ * - Interrupt stack space is not minimum if defined.
+ */
+
+#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 2
+#define CONFIGURE_INTERRUPT_STACK_MEMORY (16 * 1024)
+
+/*
+ * Network driver configuration
+ */
+
+struct rtems_bsdnet_ifconfig;
+extern int rtems_leon_open_eth_driver_attach(
+ struct rtems_bsdnet_ifconfig *config,
+ int attach
+);
+extern int rtems_smc91111_driver_attach_leon3(
+ struct rtems_bsdnet_ifconfig *config,
+ int attach
+);
+#define RTEMS_BSP_NETWORK_DRIVER_NAME "open_eth1"
+#define RTEMS_BSP_NETWORK_DRIVER_ATTACH_OPENETH rtems_leon_open_eth_driver_attach
+#define RTEMS_BSP_NETWORK_DRIVER_ATTACH_SMC91111 rtems_smc91111_driver_attach_leon3
+
+
+/*
+ * Define the time limits for RTEMS Test Suite test durations.
+ * Long test and short test duration limits are provided. These
+ * values are in seconds and need to be converted to ticks for the
+ * application.
+ *
+ */
+
+#define MAX_LONG_TEST_DURATION 3 /* 3 seconds */
+#define MAX_SHORT_TEST_DURATION 3 /* 3 seconds */
+
+/*
+ * Define the interrupt mechanism for Time Test 27
+ *
+ * NOTE: Since the interrupt code for the SPARC supports both synchronous
+ * and asynchronous trap handlers, support for testing with both
+ * is included.
+ */
+
+#define SIS_USE_SYNCHRONOUS_TRAP 0
+
+/*
+ * The synchronous trap is an arbitrarily chosen software trap.
+ */
+
+#if (SIS_USE_SYNCHRONOUS_TRAP == 1)
+
+#define TEST_VECTOR SPARC_SYNCHRONOUS_TRAP( 0x90 )
+
+#define MUST_WAIT_FOR_INTERRUPT 1
+
+#define Install_tm27_vector( handler ) \
+ set_vector( (handler), TEST_VECTOR, 1 );
+
+#define Cause_tm27_intr() \
+ asm volatile( "ta 0x10; nop " );
+
+#define Clear_tm27_intr()
+
+#define Lower_tm27_intr()
+
+/*
+ * The asynchronous trap is an arbitrarily chosen ERC32 interrupt source.
+ */
+
+#else /* use a regular asynchronous trap */
+
+#define TEST_INTERRUPT_SOURCE 0 /* LEON_INTERRUPT_EXTERNAL_1 */
+#define TEST_VECTOR LEON_TRAP_TYPE( TEST_INTERRUPT_SOURCE )
+#define TEST_INTERRUPT_SOURCE2 0 /* LEON_INTERRUPT_EXTERNAL_1+1 */
+#define TEST_VECTOR2 LEON_TRAP_TYPE( TEST_INTERRUPT_SOURCE2 )
+#define MUST_WAIT_FOR_INTERRUPT 1
+
+#define Install_tm27_vector( handler ) \
+ set_vector( (handler), TEST_VECTOR, 1 ); \
+ set_vector( (handler), TEST_VECTOR2, 1 );
+
+#define Cause_tm27_intr() \
+ do { \
+ LEON_Force_interrupt( TEST_INTERRUPT_SOURCE+(Interrupt_nest>>1)); \
+ nop(); \
+ nop(); \
+ nop(); \
+ } while (0)
+
+#define Clear_tm27_intr() \
+ LEON_Clear_interrupt( TEST_INTERRUPT_SOURCE )
+
+#define Lower_tm27_intr()
+
+#endif
+
+/*
+ * Simple spin delay in microsecond units for device drivers.
+ * This is very dependent on the clock speed of the target.
+ */
+
+extern void Clock_delay(rtems_unsigned32 microseconds);
+
+#define delay( microseconds ) Clock_delay(microseconds)
+
+/* Constants */
+
+/*
+ * Information placed in the linkcmds file.
+ */
+
+extern int RAM_START;
+extern int RAM_END;
+extern int RAM_SIZE;
+
+extern int PROM_START;
+extern int PROM_END;
+extern int PROM_SIZE;
+
+extern int CLOCK_SPEED;
+
+extern int end; /* last address in the program */
+
+/*
+ * Device Driver Table Entries
+ */
+
+/*
+ * NOTE: Use the standard Console driver entry
+ */
+
+/*
+ * NOTE: Use the standard Clock driver entry
+ */
+
+
+/* miscellaneous stuff assumed to exist */
+
+void bsp_cleanup( void );
+
+void bsp_start( void );
+
+rtems_isr_entry set_vector( /* returns old vector */
+ rtems_isr_entry handler, /* isr routine */
+ rtems_vector_number vector, /* vector number */
+ int type /* RTEMS or RAW intr */
+);
+
+void DEBUG_puts( char *string );
+
+void BSP_fatal_return( void );
+
+void bsp_spurious_initialize( void );
+
+extern rtems_configuration_table BSP_Configuration; /* owned by BSP */
+
+extern rtems_cpu_table Cpu_table; /* owned by BSP */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/sparc/leon3/include/coverhd.h b/c/src/lib/libbsp/sparc/leon3/include/coverhd.h
new file mode 100644
index 0000000000..eea7cc91ca
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/include/coverhd.h
@@ -0,0 +1,110 @@
+/* coverhd.h
+ *
+ * This include file has defines to represent the overhead associated
+ * with calling a particular directive from C for this target.
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * Ported to ERC32 implementation of the SPARC by On-Line Applications
+ * Research Corporation (OAR) under contract to the European Space
+ * Agency (ESA).
+ *
+ * ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995.
+ * European Space Agency.
+ *
+ * $Id$
+ */
+
+#ifndef __COVERHD_h
+#define __COVERHD_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CALLING_OVERHEAD_INITIALIZE_EXECUTIVE 0
+#define CALLING_OVERHEAD_SHUTDOWN_EXECUTIVE 0
+#define CALLING_OVERHEAD_TASK_CREATE 0
+#define CALLING_OVERHEAD_TASK_IDENT 0
+#define CALLING_OVERHEAD_TASK_START 0
+#define CALLING_OVERHEAD_TASK_RESTART 0
+#define CALLING_OVERHEAD_TASK_DELETE 0
+#define CALLING_OVERHEAD_TASK_SUSPEND 0
+#define CALLING_OVERHEAD_TASK_RESUME 0
+#define CALLING_OVERHEAD_TASK_SET_PRIORITY 0
+#define CALLING_OVERHEAD_TASK_MODE 0
+#define CALLING_OVERHEAD_TASK_GET_NOTE 0
+#define CALLING_OVERHEAD_TASK_SET_NOTE 0
+#define CALLING_OVERHEAD_TASK_WAKE_WHEN 0
+#define CALLING_OVERHEAD_TASK_WAKE_AFTER 0
+#define CALLING_OVERHEAD_INTERRUPT_CATCH 0
+#define CALLING_OVERHEAD_CLOCK_GET 0
+#define CALLING_OVERHEAD_CLOCK_SET 0
+#define CALLING_OVERHEAD_CLOCK_TICK 0
+
+#define CALLING_OVERHEAD_TIMER_CREATE 0
+#define CALLING_OVERHEAD_TIMER_IDENT 0
+#define CALLING_OVERHEAD_TIMER_DELETE 0
+#define CALLING_OVERHEAD_TIMER_FIRE_AFTER 0
+#define CALLING_OVERHEAD_TIMER_FIRE_WHEN 0
+#define CALLING_OVERHEAD_TIMER_RESET 0
+#define CALLING_OVERHEAD_TIMER_CANCEL 0
+#define CALLING_OVERHEAD_SEMAPHORE_CREATE 0
+#define CALLING_OVERHEAD_SEMAPHORE_IDENT 0
+#define CALLING_OVERHEAD_SEMAPHORE_DELETE 0
+#define CALLING_OVERHEAD_SEMAPHORE_OBTAIN 0
+#define CALLING_OVERHEAD_SEMAPHORE_RELEASE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_IDENT 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_SEND 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE 0
+#define CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH 0
+
+#define CALLING_OVERHEAD_EVENT_SEND 0
+#define CALLING_OVERHEAD_EVENT_RECEIVE 0
+#define CALLING_OVERHEAD_SIGNAL_CATCH 0
+#define CALLING_OVERHEAD_SIGNAL_SEND 0
+#define CALLING_OVERHEAD_PARTITION_CREATE 0
+#define CALLING_OVERHEAD_PARTITION_IDENT 0
+#define CALLING_OVERHEAD_PARTITION_DELETE 0
+#define CALLING_OVERHEAD_PARTITION_GET_BUFFER 0
+#define CALLING_OVERHEAD_PARTITION_RETURN_BUFFER 0
+#define CALLING_OVERHEAD_REGION_CREATE 0
+#define CALLING_OVERHEAD_REGION_IDENT 0
+#define CALLING_OVERHEAD_REGION_DELETE 0
+#define CALLING_OVERHEAD_REGION_GET_SEGMENT 0
+#define CALLING_OVERHEAD_REGION_RETURN_SEGMENT 0
+#define CALLING_OVERHEAD_PORT_CREATE 0
+#define CALLING_OVERHEAD_PORT_IDENT 0
+#define CALLING_OVERHEAD_PORT_DELETE 0
+#define CALLING_OVERHEAD_PORT_EXTERNAL_TO_INTERNAL 0
+#define CALLING_OVERHEAD_PORT_INTERNAL_TO_EXTERNAL 0
+
+#define CALLING_OVERHEAD_IO_INITIALIZE 0
+#define CALLING_OVERHEAD_IO_OPEN 0
+#define CALLING_OVERHEAD_IO_CLOSE 0
+#define CALLING_OVERHEAD_IO_READ 0
+#define CALLING_OVERHEAD_IO_WRITE 0
+#define CALLING_OVERHEAD_IO_CONTROL 0
+#define CALLING_OVERHEAD_FATAL_ERROR_OCCURRED 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CREATE 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_IDENT 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_DELETE 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_CANCEL 0
+#define CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD 0
+#define CALLING_OVERHEAD_MULTIPROCESSING_ANNOUNCE 0
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h
new file mode 100644
index 0000000000..990b359295
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h
@@ -0,0 +1,413 @@
+/* leon.h
+ *
+ * LEON3 BSP data types and macros.
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * Modified for LEON3 BSP.
+ * COPYRIGHT (c) 2004.
+ * Gaisler Research.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#ifndef _INCLUDE_LEON_h
+#define _INCLUDE_LEON_h
+
+#include <rtems/score/sparc.h>
+#include <amba.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef ASM
+/*
+ * Trap Types for on-chip peripherals
+ *
+ * Source: Table 8 - Interrupt Trap Type and Default Priority Assignments
+ *
+ * NOTE: The priority level for each source corresponds to the least
+ * significant nibble of the trap type.
+ */
+
+#define LEON_TRAP_TYPE( _source ) SPARC_ASYNCHRONOUS_TRAP((_source) + 0x10)
+
+#define LEON_TRAP_SOURCE( _trap ) ((_trap) - 0x10)
+
+#define LEON_INT_TRAP( _trap ) \
+ ( (_trap) >= 0x11 && \
+ (_trap) <= 0x1F )
+
+/*
+ * Structure for LEON memory mapped registers.
+ *
+ * Source: Section 6.1 - On-chip registers
+ *
+ * NOTE: There is only one of these structures per CPU, its base address
+ * is 0x80000000, and the variable LEON_REG is placed there by the
+ * linkcmds file.
+ */
+
+/* Leon uses dynamic register mapping using amba configuration records,
+ * LEON_Register_Map is obsolete
+ */
+/*
+ typedef struct {
+ volatile unsigned int Memory_Config_1;
+ volatile unsigned int Memory_Config_2;
+ volatile unsigned int Edac_Control;
+ volatile unsigned int Failed_Address;
+ volatile unsigned int Memory_Status;
+ volatile unsigned int Cache_Control;
+ volatile unsigned int Power_Down;
+ volatile unsigned int Write_Protection_1;
+ volatile unsigned int Write_Protection_2;
+ volatile unsigned int Leon_Configuration;
+ volatile unsigned int dummy2;
+ volatile unsigned int dummy3;
+ volatile unsigned int dummy4;
+ volatile unsigned int dummy5;
+ volatile unsigned int dummy6;
+ volatile unsigned int dummy7;
+ volatile unsigned int Timer_Counter_1;
+ volatile unsigned int Timer_Reload_1;
+ volatile unsigned int Timer_Control_1;
+ volatile unsigned int Watchdog;
+ volatile unsigned int Timer_Counter_2;
+ volatile unsigned int Timer_Reload_2;
+ volatile unsigned int Timer_Control_2;
+ volatile unsigned int dummy8;
+ volatile unsigned int Scaler_Counter;
+ volatile unsigned int Scaler_Reload;
+ volatile unsigned int dummy9;
+ volatile unsigned int dummy10;
+ volatile unsigned int UART_Channel_1;
+ volatile unsigned int UART_Status_1;
+ volatile unsigned int UART_Control_1;
+ volatile unsigned int UART_Scaler_1;
+ volatile unsigned int UART_Channel_2;
+ volatile unsigned int UART_Status_2;
+ volatile unsigned int UART_Control_2;
+ volatile unsigned int UART_Scaler_2;
+ volatile unsigned int Interrupt_Mask;
+ volatile unsigned int Interrupt_Pending;
+ volatile unsigned int Interrupt_Force;
+ volatile unsigned int Interrupt_Clear;
+ volatile unsigned int PIO_Data;
+ volatile unsigned int PIO_Direction;
+ volatile unsigned int PIO_Interrupt;
+} LEON_Register_Map;
+*/
+
+typedef struct {
+ volatile unsigned int data;
+ volatile unsigned int status;
+ volatile unsigned int ctrl;
+} LEON3_UART_Regs_Map;
+
+typedef struct {
+ volatile unsigned int ilevel;
+ volatile unsigned int ipend;
+ volatile unsigned int iforce;
+ volatile unsigned int iclear;
+ volatile unsigned int notused00;
+ volatile unsigned int notused01;
+ volatile unsigned int notused02;
+ volatile unsigned int notused03;
+ volatile unsigned int notused10;
+ volatile unsigned int notused11;
+ volatile unsigned int notused12;
+ volatile unsigned int notused13;
+ volatile unsigned int notused20;
+ volatile unsigned int notused21;
+ volatile unsigned int notused22;
+ volatile unsigned int notused23;
+ volatile unsigned int mask_p0;
+ volatile unsigned int mask_p1;
+ volatile unsigned int mask_p2;
+ volatile unsigned int mask_p3;
+ volatile unsigned int mask_p4;
+ volatile unsigned int mask_p5;
+ volatile unsigned int mask_p6;
+ volatile unsigned int mask_p7;
+ volatile unsigned int mask_p8;
+ volatile unsigned int mask_p9;
+ volatile unsigned int mask_p10;
+ volatile unsigned int mask_p11;
+ volatile unsigned int mask_p12;
+ volatile unsigned int mask_p13;
+ volatile unsigned int mask_p14;
+ volatile unsigned int mask_p15;
+} LEON3_IrqCtrl_Regs_Map;
+
+/*
+typedef struct {
+ volatile unsigned int value;
+ volatile unsigned int reload;
+ volatile unsigned int conf;
+ volatile unsigned int notused;
+} LEON3_Timer_SubType;
+*/
+
+typedef struct {
+ volatile unsigned int scaler_value; /* common timer registers */
+ volatile unsigned int scaler_reload;
+ volatile unsigned int status;
+ volatile unsigned int notused;
+ volatile unsigned int value_t0; /* timer 0 */
+ volatile unsigned int reload_t0;
+ volatile unsigned int conf_t0;
+ volatile unsigned int notused0;
+ volatile unsigned int value_t1; /* timer 1 */
+ volatile unsigned int reload_t1;
+ volatile unsigned int conf_t1;
+ volatile unsigned int notused1;
+ volatile unsigned int value_t2; /* timer 2 */
+ volatile unsigned int reload_t2;
+ volatile unsigned int conf_t2;
+ volatile unsigned int notused2;
+ volatile unsigned int value_t3; /* timer 3 */
+ volatile unsigned int reload_t3;
+ volatile unsigned int conf_t3;
+ volatile unsigned int notused3;
+ volatile unsigned int value_t4; /* timer 4 */
+ volatile unsigned int reload_t4;
+ volatile unsigned int conf_t4;
+ volatile unsigned int notused4;
+ volatile unsigned int value_t5; /* timer 5 */
+ volatile unsigned int reload_t5;
+ volatile unsigned int conf_t5;
+ volatile unsigned int notused5;
+ volatile unsigned int value_t6; /* timer 6 */
+ volatile unsigned int reload_t6;
+ volatile unsigned int conf_t6;
+} LEON3_Timer_Regs_Map;
+
+typedef struct {
+ volatile unsigned int iodata;
+ volatile unsigned int ioout;
+ volatile unsigned int iodir;
+ volatile unsigned int irqmask;
+ volatile unsigned int irqpol;
+ volatile unsigned int irqedge;
+} LEON3_IOPORT_Regs_Map;
+
+/* /\* */
+/* * This is used to manipulate the on-chip registers. */
+/* * */
+/* * The following symbol must be defined in the linkcmds file and point */
+/* * to the correct location. */
+/* *\/ */
+/* Leon uses dynamic register mapping using amba configuration records */
+/* LEON_Register_Map is obsolete */
+/* extern LEON_Register_Map LEON_REG; */
+
+#endif
+
+/*
+ * The following defines the bits in Memory Configuration Register 1.
+ */
+
+#define LEON_MEMORY_CONFIGURATION_PROM_SIZE_MASK 0x0003C000
+
+/*
+ * The following defines the bits in Memory Configuration Register 1.
+ */
+
+#define LEON_MEMORY_CONFIGURATION_RAM_SIZE_MASK 0x00001E00
+
+
+/*
+ * The following defines the bits in the Timer Control Register.
+ */
+
+#define LEON_REG_TIMER_CONTROL_EN 0x00000001 /* 1 = enable counting */
+ /* 0 = hold scalar and counter */
+#define LEON_REG_TIMER_CONTROL_RL 0x00000002 /* 1 = reload at 0 */
+ /* 0 = stop at 0 */
+#define LEON_REG_TIMER_CONTROL_LD 0x00000004 /* 1 = load counter */
+ /* 0 = no function */
+
+/*
+ * The following defines the bits in the UART Control Registers.
+ *
+ */
+
+#define LEON_REG_UART_CONTROL_RTD 0x000000FF /* RX/TX data */
+
+/*
+ * The following defines the bits in the LEON UART Status Registers.
+ */
+
+#define LEON_REG_UART_STATUS_DR 0x00000001 /* Data Ready */
+#define LEON_REG_UART_STATUS_TSE 0x00000002 /* TX Send Register Empty */
+#define LEON_REG_UART_STATUS_THE 0x00000004 /* TX Hold Register Empty */
+#define LEON_REG_UART_STATUS_BR 0x00000008 /* Break Error */
+#define LEON_REG_UART_STATUS_OE 0x00000010 /* RX Overrun Error */
+#define LEON_REG_UART_STATUS_PE 0x00000020 /* RX Parity Error */
+#define LEON_REG_UART_STATUS_FE 0x00000040 /* RX Framing Error */
+#define LEON_REG_UART_STATUS_ERR 0x00000078 /* Error Mask */
+
+
+/*
+ * The following defines the bits in the LEON UART Status Registers.
+ */
+
+#define LEON_REG_UART_CTRL_RE 0x00000001 /* Receiver enable */
+#define LEON_REG_UART_CTRL_TE 0x00000002 /* Transmitter enable */
+#define LEON_REG_UART_CTRL_RI 0x00000004 /* Receiver interrupt enable */
+#define LEON_REG_UART_CTRL_TI 0x00000008 /* Transmitter interrupt enable */
+#define LEON_REG_UART_CTRL_PS 0x00000010 /* Parity select */
+#define LEON_REG_UART_CTRL_PE 0x00000020 /* Parity enable */
+#define LEON_REG_UART_CTRL_FL 0x00000040 /* Flow control enable */
+#define LEON_REG_UART_CTRL_LB 0x00000080 /* Loop Back enable */
+
+
+/*
+ * Types and structure used for AMBA Plug & Play bus scanning
+ *
+ */
+
+typedef struct amba_device_table {
+ int devnr; /* numbrer of devices on AHB or APB bus */
+ unsigned int *addr[16]; /* addresses to the devices configuration tables */
+} amba_device_table;
+
+typedef struct amba_confarea_type {
+ amba_device_table ahbmst;
+ amba_device_table ahbslv;
+ amba_device_table apbslv;
+ unsigned int apbmst;
+} amba_confarea_type;
+
+ extern amba_confarea_type amba_conf;
+ /* extern amba_device_table amba_ahb_masters;
+extern amba_device_table amba_ahb_slaves;
+extern amba_device_table amba_apb_slaves; */
+extern unsigned int amba_apbmst_base; /* APB master base address */
+extern volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs; /* LEON3 Interrupt Controller */
+extern volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs; /* LEON3 GP Timer */
+extern volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS];
+
+/* Macros used for manipulating bits in LEON3 GP Timer Control Register */
+
+#define LEON3_GPTIMER_EN 1
+#define LEON3_GPTIMER_RL 2
+#define LEON3_GPTIMER_LD 4
+#define LEON3_GPTIMER_IRQEN 8
+
+#ifndef ASM
+
+/*
+ * Macros to manipulate the Interrupt Clear, Interrupt Force, Interrupt Mask,
+ * and the Interrupt Pending Registers.
+ *
+ * NOTE: For operations which are not atomic, this code disables interrupts
+ * to guarantee there are no intervening accesses to the same register.
+ * The operations which read the register, modify the value and then
+ * store the result back are vulnerable.
+ */
+
+#define LEON_Clear_interrupt( _source ) \
+ do { \
+ LEON3_IrqCtrl_Regs->iclear = (1 << (_source)); \
+ } while (0)
+
+#define LEON_Force_interrupt( _source ) \
+ do { \
+ LEON3_IrqCtrl_Regs->iforce = (1 << (_source)); \
+ } while (0)
+
+#define LEON_Is_interrupt_pending( _source ) \
+ (LEON3_IrqCtrl_Regs.ipend & (1 << (_source)))
+
+#define LEON_Is_interrupt_masked( _source ) \
+ (LEON3_IrqCtrl_Regs.mask_p0 & (1 << (_source)))
+
+#define LEON_Mask_interrupt( _source ) \
+ do { \
+ unsigned32 _level; \
+ \
+ _level = sparc_disable_interrupts(); \
+ LEON3_IrqCtrl_Regs->mask_p0 &= ~(1 << (_source)); \
+ sparc_enable_interrupts( _level ); \
+ } while (0)
+
+#define LEON_Unmask_interrupt( _source ) \
+ do { \
+ unsigned32 _level; \
+ \
+ _level = sparc_disable_interrupts(); \
+ LEON3_IrqCtrl_Regs->mask_p0 |= (1 << (_source)); \
+ sparc_enable_interrupts( _level ); \
+ } while (0)
+
+#define LEON_Disable_interrupt( _source, _previous ) \
+ do { \
+ unsigned32 _level; \
+ unsigned32 _mask = 1 << (_source); \
+ \
+ _level = sparc_disable_interrupts(); \
+ (_previous) = LEON3_IrqCtrl_Regs->mask_p0; \
+ LEON3_IrqCtrl_Regs->mask_p0 = _previous & ~_mask; \
+ sparc_enable_interrupts( _level ); \
+ (_previous) &= _mask; \
+ } while (0)
+
+#define LEON_Restore_interrupt( _source, _previous ) \
+ do { \
+ unsigned32 _level; \
+ unsigned32 _mask = 1 << (_source); \
+ \
+ _level = sparc_disable_interrupts(); \
+ LEON3_IrqCtrl_Regs->mask_p0 = \
+ (LEON3_IrqCtrl_Regs->mask_p0 & ~_mask) | (_previous); \
+ sparc_enable_interrupts( _level ); \
+ } while (0)
+
+/*
+ * Each timer control register is organized as follows:
+ *
+ * D0 - Enable
+ * 1 = enable counting
+ * 0 = hold scaler and counter
+ *
+ * D1 - Counter Reload
+ * 1 = reload counter at zero and restart
+ * 0 = stop counter at zero
+ *
+ * D2 - Counter Load
+ * 1 = load counter with preset value
+ * 0 = no function
+ *
+ */
+
+#define LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO 0x00000002
+#define LEON_REG_TIMER_COUNTER_STOP_AT_ZERO 0x00000000
+
+#define LEON_REG_TIMER_COUNTER_LOAD_COUNTER 0x00000004
+
+#define LEON_REG_TIMER_COUNTER_ENABLE_COUNTING 0x00000001
+#define LEON_REG_TIMER_COUNTER_DISABLE_COUNTING 0x00000000
+
+#define LEON_REG_TIMER_COUNTER_RELOAD_MASK 0x00000002
+#define LEON_REG_TIMER_COUNTER_ENABLE_MASK 0x00000001
+
+#define LEON_REG_TIMER_COUNTER_DEFINED_MASK 0x00000003
+#define LEON_REG_TIMER_COUNTER_CURRENT_MODE_MASK 0x00000003
+
+#endif /* !ASM */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_INCLUDE_LEON_h */
+/* end of include file */
+
diff --git a/c/src/lib/libbsp/sparc/leon3/leon_open_eth/.cvsignore b/c/src/lib/libbsp/sparc/leon3/leon_open_eth/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/leon_open_eth/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/sparc/leon3/leon_open_eth/Makefile.am b/c/src/lib/libbsp/sparc/leon3/leon_open_eth/Makefile.am
new file mode 100644
index 0000000000..df9a43361d
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/leon_open_eth/Makefile.am
@@ -0,0 +1,35 @@
+##
+## $Id$
+##
+
+
+PGM = $(ARCH)/leon_open_eth.rel
+
+C_FILES = leon_open_eth.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+OBJS = $(C_O_FILES)
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+AM_CPPFLAGS += -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
+
+$(PGM): $(OBJS)
+ $(make-rel)
+
+# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+
+if HAS_NETWORKING
+all-local: $(ARCH) $(OBJS) $(PGM)
+endif
+
+.PRECIOUS: $(PGM)
+
+EXTRA_DIST = leon_open_eth.c
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/leon_open_eth/leon_open_eth.c b/c/src/lib/libbsp/sparc/leon3/leon_open_eth/leon_open_eth.c
new file mode 100644
index 0000000000..c4586dd309
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/leon_open_eth/leon_open_eth.c
@@ -0,0 +1,75 @@
+/*
+ * LEON3 Opencores Ethernet MAC Configuration Information
+ *
+ * COPYRIGHT (c) 2004.
+ * Gaisler Research
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+
+#include <bsp.h>
+#include <libchip/open_eth.h>
+#if (OPEN_ETH_DEBUG & OPEN_ETH_DEBUG_PRINT_REGISTERS)
+#include <stdio.h>
+#endif
+
+/*
+ * Default sizes of transmit and receive descriptor areas
+ */
+#define RDA_COUNT 16
+#define TDA_COUNT 16
+
+open_eth_configuration_t leon_open_eth_configuration;
+
+int rtems_leon_open_eth_driver_attach(
+ struct rtems_bsdnet_ifconfig *config,
+ int attach
+)
+{
+ int device_found = 0;
+ int i;
+ unsigned int conf, iobar;
+ unsigned int base_addr = 0; /* avoid warnings */
+ unsigned int eth_irq = 0; /* avoid warnings */
+
+
+ /* Scan for MAC AHB slave interface */
+ for (i = 0; i < amba_conf.ahbslv.devnr; i++)
+ {
+ conf = amba_get_confword(amba_conf.ahbslv, i, 0);
+ if (((amba_vendor(conf) == VENDOR_OPENCORES) && (amba_device(conf) == OPENCORES_ETHMAC)) ||
+ ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_ETHAHB)))
+ {
+ iobar = amba_ahb_get_membar(amba_conf.ahbslv, i, 0);
+ base_addr = amba_iobar_start(LEON3_IO_AREA, iobar);
+ eth_irq = amba_irq(conf) + 0x10;
+ device_found = 1;
+ break;
+ }
+ }
+
+
+ if (device_found)
+ {
+ /* clear control register and reset NIC */
+ *(volatile int *) base_addr = 0;
+ *(volatile int *) base_addr = 0x800;
+ *(volatile int *) base_addr = 0;
+ leon_open_eth_configuration.base_address = base_addr;
+ leon_open_eth_configuration.vector = eth_irq;
+ leon_open_eth_configuration.txd_count = TDA_COUNT;
+ leon_open_eth_configuration.rxd_count = RDA_COUNT;
+ /* enable 100 MHz operation only if cpu frequency >= 50 MHz */
+ if (LEON3_Timer_Regs->scaler_reload >= 49) leon_open_eth_configuration.en100MHz = 1;
+ if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) {
+ LEON_Clear_interrupt(leon_open_eth_configuration.vector);
+ LEON_Unmask_interrupt(leon_open_eth_configuration.vector);
+ }
+ }
+ return 0;
+}
diff --git a/c/src/lib/libbsp/sparc/leon3/leon_smc91111/.cvsignore b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/sparc/leon3/leon_smc91111/Makefile.am b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/Makefile.am
new file mode 100644
index 0000000000..d51345a28b
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/Makefile.am
@@ -0,0 +1,35 @@
+##
+## $Id$
+##
+
+
+PGM = $(ARCH)/leon_smc91111.rel
+
+C_FILES = leon_smc91111.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+OBJS = $(C_O_FILES)
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+AM_CPPFLAGS += -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
+
+$(PGM): $(OBJS)
+ $(make-rel)
+
+# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+
+if HAS_NETWORKING
+all-local: $(ARCH) $(OBJS) $(PGM)
+endif
+
+.PRECIOUS: $(PGM)
+
+EXTRA_DIST = leon_smc91111.c
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c
new file mode 100644
index 0000000000..a0ffd52186
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c
@@ -0,0 +1,100 @@
+/*
+ * $Id$
+ */
+
+#include <bsp.h>
+#include <libchip/smc91111exp.h>
+#include <stdio.h>
+
+
+#define SMC91111_BASE_ADDR (void*)0x20000300
+#define SMC91111_BASE_IRQ 4
+#define SMC91111_BASE_PIO 4
+
+scmv91111_configuration_t leon_scmv91111_configuration = {
+ SMC91111_BASE_ADDR, /* base address */
+ LEON_TRAP_TYPE(SMC91111_BASE_IRQ), /* vector number */
+ SMC91111_BASE_PIO, /* PIO */
+ 10, /* 10b */
+ 1, /* fulldx */
+ 1 /* autoneg */
+};
+
+int _rtems_smc91111_driver_attach(
+ struct rtems_bsdnet_ifconfig *config,
+ scmv91111_configuration_t *scm_config
+);
+
+/*
+ * Attach an SMC91111 driver to the system
+ */
+int rtems_smc91111_driver_attach_leon3 (
+ struct rtems_bsdnet_ifconfig *config,
+ int attach
+)
+{
+ unsigned int iobar, conf,i;
+
+ {
+ unsigned long irq_pio, irq_mctrl, addr_pio = 0;
+ unsigned long addr_mctrl = 0, addr_timer = 0;
+
+ i = 0;
+ while (i < amba_conf.apbslv.devnr)
+ {
+ conf = amba_get_confword(amba_conf.apbslv, i, 0);
+ if ((amba_vendor(conf) == VENDOR_GAISLER) &&
+ (amba_device(conf) == GAISLER_PIOPORT))
+ {
+ irq_pio = amba_irq(conf);
+ iobar = amba_apb_get_membar(amba_conf.apbslv, i);
+ addr_pio = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar);
+ }
+ else if ((amba_vendor(conf) == VENDOR_ESA) &&
+ (amba_device(conf) == ESA_MCTRL))
+ {
+ irq_mctrl = amba_irq(conf);
+ iobar = amba_apb_get_membar(amba_conf.apbslv, i);
+ addr_mctrl = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar);
+ }
+ else if ((amba_vendor(conf) == VENDOR_GAISLER) &&
+ (amba_device(conf) == GAISLER_GPTIMER))
+ {
+ iobar = amba_apb_get_membar(amba_conf.apbslv, i);
+ addr_timer = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar);
+ }
+ i++;
+ }
+
+ if (addr_timer) {
+ LEON3_Timer_Regs_Map *timer = (LEON3_Timer_Regs_Map *)addr_timer;
+ if (timer->scaler_reload >= 49)
+ leon_scmv91111_configuration.ctl_rspeed = 100;
+ }
+
+ if (addr_pio && addr_mctrl) {
+
+ LEON3_IOPORT_Regs_Map *io = (LEON3_IOPORT_Regs_Map *) addr_pio;
+ {
+ char buf[1024];
+
+ sprintf(buf,
+ "Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n",
+ (unsigned int)addr_pio,
+ (unsigned int)addr_mctrl);
+ DEBUG_puts(buf);
+ }
+
+ *((volatile unsigned int *)addr_mctrl) |= 0x10f80000; /*mctrl ctrl 1 */
+ io->irqmask |= (1 << leon_scmv91111_configuration.pio);
+ io->irqpol |= (1 << leon_scmv91111_configuration.pio);
+ io->irqedge |= (1 << leon_scmv91111_configuration.pio);
+ io->iodir &= ~(1 << leon_scmv91111_configuration.pio);
+ } else {
+ return 0;
+ }
+ }
+
+ return _rtems_smc91111_driver_attach(config,&leon_scmv91111_configuration);
+};
+
diff --git a/c/src/lib/libbsp/sparc/leon3/start/.cvsignore b/c/src/lib/libbsp/sparc/leon3/start/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/start/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/sparc/leon3/start/Makefile.am b/c/src/lib/libbsp/sparc/leon3/start/Makefile.am
new file mode 100644
index 0000000000..4b1c8a1c00
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/start/Makefile.am
@@ -0,0 +1,34 @@
+##
+## $Id$
+##
+
+VPATH = @srcdir@:@srcdir@/../../shared
+
+S_FILES = start.S
+S_O_FILES = $(S_FILES:%.S=$(ARCH)/%.$(OBJEXT))
+
+OBJS = $(S_O_FILES)
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+install-data-local: $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).$(OBJEXT)
+ @$(mkinstalldirs) $(DESTDIR)$(bsplibdir)
+ $(INSTALL_DATA) $< $(DESTDIR)$(bsplibdir)
+
+$(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).$(OBJEXT): $(ARCH)/start.$(OBJEXT)
+ $(INSTALL_DATA) $< $@
+
+TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).$(OBJEXT)
+
+all-local: $(ARCH) $(OBJS) $(ARCH)/start.$(OBJEXT) $(TMPINSTALL_FILES)
+
+.PRECIOUS: $(ARCH)/start.$(OBJEXT)
+
+EXTRA_DIST = start.S
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/.cvsignore b/c/src/lib/libbsp/sparc/leon3/startup/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/startup/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/Makefile.am b/c/src/lib/libbsp/sparc/leon3/startup/Makefile.am
new file mode 100644
index 0000000000..26c21df649
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/startup/Makefile.am
@@ -0,0 +1,45 @@
+##
+## $Id$
+##
+
+
+VPATH = @srcdir@:@srcdir@/../../shared:@srcdir@/../../../shared
+
+PGM = $(ARCH)/startup.rel
+
+C_FILES = bspclean.c bsplibc.c bsppost.c bspstart.c main.c bootcard.c sbrk.c \
+ setvec.c spurious.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+S_FILES = ithread.S
+S_O_FILES = $(S_FILES:%.S=$(ARCH)/%.$(OBJEXT))
+
+OBJS = $(C_O_FILES) $(S_O_FILES)
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+# USE_INIT_FINI tells main.c what C++ help we need.
+AM_CPPFLAGS += -DUSE_INIT_FINI
+
+$(PGM): $(OBJS)
+ $(make-rel)
+
+bsplib_DATA = linkcmds
+
+$(PROJECT_RELEASE)/lib/linkcmds: linkcmds
+ $(INSTALL_DATA) $< $@
+
+TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/linkcmds
+
+all-local: $(ARCH) $(OBJS) $(PGM) $(TMPINSTALL_FILES)
+
+.PRECIOUS: $(PGM)
+
+EXTRA_DIST = linkcmds setvec.c spurious.c
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
new file mode 100644
index 0000000000..3ca2e4acc6
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
@@ -0,0 +1,232 @@
+/*
+ * This set of routines starts the application. It includes application,
+ * board, and monitor specific initialization and configuration.
+ * The generic CPU dependent initialization has been performed
+ * before any of these are invoked.
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * Modified for LEON3 BSP.
+ * COPYRIGHT (c) 2004.
+ * Gaisler Research.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+/* must be identical to STACK_SIZE in start.S */
+#define STACK_SIZE 16 * 1024
+
+#include <string.h>
+
+#include <bsp.h>
+#include <rtems/libio.h>
+#include <rtems/libcsupport.h>
+
+/*
+ * The original table from the application and our copy of it with
+ * some changes.
+ */
+
+extern rtems_configuration_table Configuration;
+rtems_configuration_table BSP_Configuration;
+
+rtems_cpu_table Cpu_table;
+
+/*
+ * Tells us where to put the workspace in case remote debugger is present.
+ */
+
+extern rtems_unsigned32 rdb_start;
+
+/*
+ * Amount to increment itimer by each pass
+ * It is a variable instead of a #define to allow the 'looptest'
+ * script to bump it without recompiling rtems
+ *
+ * NOTE: This is based on the PA-RISC simulator. I don't know if we
+ * can actually pull this trick on the SPARC simulator.
+ */
+
+rtems_unsigned32 CPU_SPARC_CLICKS_PER_TICK;
+
+#if SIMSPARC_FAST_IDLE
+
+/*
+ * Many of the tests are very slow on the simulator because they have
+ * have 5 second delays hardwired in.
+ *
+ * Try to speed those tests up by speeding up the clock when in the idle task.
+ *
+ * NOTE: At the current setting, 5 second delays in the tests take
+ * approximately 5 seconds of wall time.
+ */
+
+rtems_extension fast_idle_switch_hook(
+ rtems_tcb *current_task,
+ rtems_tcb *heir_task
+)
+{
+ static rtems_unsigned32 normal_clock = ~0;
+ static rtems_unsigned32 fast_clock;
+
+ /* init our params on first call */
+ if (normal_clock == ~0)
+ {
+ normal_clock = CPU_SPARC_CLICKS_PER_TICK;
+ fast_clock = CPU_SPARC_CLICKS_PER_TICK / 0x08;
+ if (fast_clock == 0) /* handle pathological case */
+ fast_clock++;
+ }
+
+ /*
+ * Run the clock faster when idle is in place.
+ */
+
+ if (heir_task == _Thread_Idle)
+ CPU_SPARC_CLICKS_PER_TICK = fast_clock;
+ else if (current_task == _Thread_Idle)
+ CPU_SPARC_CLICKS_PER_TICK = normal_clock;
+}
+
+#endif
+
+/*
+ * Use the shared implementations of the following routines
+ */
+
+void bsp_postdriver_hook(void);
+void bsp_libc_init( void *, unsigned32, int );
+extern void bsp_spurious_initialize();
+
+/*
+ * bsp_pretasking_hook
+ *
+ * BSP pretasking hook. Called just before drivers are initialized.
+ * Used to setup libc and install any BSP extensions.
+ */
+
+void bsp_pretasking_hook(void)
+{
+ extern int end;
+ rtems_unsigned32 heap_start;
+ rtems_unsigned32 heap_size;
+
+ heap_start = (rtems_unsigned32) &end;
+ if (heap_start & (CPU_ALIGNMENT-1))
+ heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
+
+ heap_size = BSP_Configuration.work_space_start - (void *)&end - STACK_SIZE;
+ heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */
+
+ bsp_libc_init((void *) heap_start, heap_size, 0);
+
+
+#if SIMSPARC_FAST_IDLE
+ /*
+ * Install the fast idle task switch extension
+ *
+ * On MP systems, might not want to do this; it confuses at least
+ * one test (mp06) on the PA-RISC simulator
+ */
+
+#if 0
+ if (BSP_Configuration.User_multiprocessing_table == 0)
+#endif
+ {
+ rtems_extensions_table fast_idle_extension;
+ rtems_id extension_id;
+ rtems_status_code rc;
+
+ memset(&fast_idle_extension, 0, sizeof(fast_idle_extension));
+
+ fast_idle_extension.thread_switch = fast_idle_switch_hook;
+
+ rc = rtems_extension_create(
+ rtems_build_name('F', 'D', 'L', 'E'),
+ &fast_idle_extension,
+ &extension_id
+ );
+ if (rc != RTEMS_SUCCESSFUL)
+ rtems_fatal_error_occurred(rc);
+ }
+#endif
+
+#ifdef RTEMS_DEBUG
+ rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
+#endif
+
+ bsp_spurious_initialize();
+}
+
+void bsp_leon3_predriver_hook(void);
+
+/*
+ * bsp_start
+ *
+ * This routine does the bulk of the system initialization.
+ */
+
+void bsp_start( void )
+{
+ unsigned char *work_space_start;
+
+ /*
+ * Set up our hooks
+ * Make sure libc_init is done before drivers initialized so that
+ * they can use atexit()
+ */
+
+ Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */
+ Cpu_table.postdriver_hook = bsp_postdriver_hook;
+ Cpu_table.predriver_hook = bsp_leon3_predriver_hook; /* scan system bus */
+
+ /*
+ * SIS does zero out memory BUT only when IT begins execution. Thus
+ * if we want to have a clean slate in the workspace each time we
+ * begin execution of OUR application, then we must zero the workspace.
+ */
+ Cpu_table.do_zero_of_workspace = TRUE;
+
+ /*
+ * This should be enough interrupt stack.
+ */
+
+ Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
+
+ work_space_start =
+ (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
+
+ if ( work_space_start <= (unsigned char *)&end ) {
+ DEBUG_puts( "bspstart: Not enough RAM!!!\n" );
+ BSP_fatal_return();
+ }
+
+ BSP_Configuration.work_space_start = work_space_start;
+
+#if SIMSPARC_FAST_IDLE
+ /*
+ * Add 1 extension for fast idle
+ */
+
+ BSP_Configuration.maximum_extensions++;
+#endif
+
+ /*
+ * Add 1 extension for MPCI_fatal
+ */
+
+ if (BSP_Configuration.User_multiprocessing_table)
+ BSP_Configuration.maximum_extensions++;
+
+ /*
+ * Set the "clicks per tick" for the simulator
+ * used by XXX/clock/clock.c to schedule interrupts
+ */
+
+ CPU_SPARC_CLICKS_PER_TICK = BSP_Configuration.microseconds_per_tick;
+}
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/ithread.S b/c/src/lib/libbsp/sparc/leon3/startup/ithread.S
new file mode 100644
index 0000000000..c3669fabf0
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/startup/ithread.S
@@ -0,0 +1,31 @@
+/*
+ * Idle Thread Body
+ *
+ * This routine puts LEON3 in power-down mode.
+ *
+ * COPYRIGHT (c) 2004.
+ * Gaisler Research.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ *
+ * $Id$
+ */
+
+
+
+#include <asm.h>
+
+/* LEON specific power-down function */
+
+ .align 4
+ PUBLIC(_CPU_Thread_Idle_body)
+SYM(_CPU_Thread_Idle_body):
+pwdloop: mov %g0, %asr19
+ ba pwdloop
+ nop
+ retl
+ nop
+
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/linkcmds b/c/src/lib/libbsp/sparc/leon3/startup/linkcmds
new file mode 100644
index 0000000000..4e4f06f2a6
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/startup/linkcmds
@@ -0,0 +1,184 @@
+/* linkcmds
+ *
+ * $Id$
+ */
+
+OUTPUT_ARCH(sparc)
+__DYNAMIC = 0;
+
+/*
+ * The memory map looks like this:
+ * +--------------------+ <- low memory
+ * | .text |
+ * | etext |
+ * | ctor list | the ctor and dtor lists are for
+ * | dtor list | C++ support
+ * | _endtext |
+ * +--------------------+
+ * | .data | initialized data goes here
+ * | _sdata |
+ * | _edata |
+ * +--------------------+
+ * | .bss |
+ * | __bss_start | start of bss, cleared by crt0
+ * | _end | start of heap, used by sbrk()
+ * +--------------------+
+ * | heap space |
+ * | _ENDHEAP |
+ * | stack space |
+ * | __stack | top of stack
+ * +--------------------+ <- high memory
+ */
+
+
+/*
+ * User modifiable values:
+ *
+ * _CLOCK_SPEED in Mhz (used to program the counter/timers)
+ *
+ * _PROM_SIZE size of PROM (permissible values are 128K, 256K,
+ * 512K, 1M, 2M, 4M, 8M and 16M)
+ * _RAM_SIZE size of RAM (permissible values are 256K, 512K,
+ * 1M, 2M, 4M, 8M, 16M, and 32M)
+ *
+ */
+
+/* Default values, can be overridden */
+
+_PROM_SIZE = 2M;
+_RAM_SIZE = 4M;
+
+_RAM_START = 0x40000000;
+_RAM_END = _RAM_START + _RAM_SIZE;
+
+_PROM_START = 0x00000000;
+_PROM_END = _PROM_START + _PROM_SIZE;
+
+/*
+ * Alternate names without leading _.
+ */
+
+PROM_START = _PROM_START;
+PROM_SIZE = _PROM_SIZE;
+PROM_END = _PROM_END;
+
+RAM_START = _RAM_START;
+RAM_SIZE = _RAM_SIZE;
+RAM_END = _RAM_END;
+
+/*
+ * Base address of the on-CPU peripherals
+ */
+
+_LEON_REG = 0x80000000;
+LEON_REG = 0x80000000;
+
+/* these are the maximum values */
+
+MEMORY
+{
+ rom : ORIGIN = 0x00000000, LENGTH = 256M
+ ram : ORIGIN = 0x40000000, LENGTH = 1024M
+}
+
+/*
+ * stick everything in ram (of course)
+ */
+SECTIONS
+{
+ .text :
+ {
+ CREATE_OBJECT_SYMBOLS
+ text_start = .;
+ _text_start = .;
+ *(.text)
+ . = ALIGN (16);
+
+ /*
+ * Special FreeBSD sysctl sections.
+ */
+ . = ALIGN (16);
+ __start_set_sysctl_set = .;
+ *(set_sysctl_*);
+ __stop_set_sysctl_set = ABSOLUTE(.);
+ *(set_domain_*);
+ *(set_pseudo_*);
+
+ *(.eh_frame)
+ . = ALIGN (16);
+
+ *(.gnu.linkonce.t*)
+
+ /*
+ * C++ constructors
+ */
+ __CTOR_LIST__ = .;
+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
+ *(.ctors)
+ LONG(0)
+ __CTOR_END__ = .;
+ __DTOR_LIST__ = .;
+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
+ *(.dtors)
+ LONG(0)
+ __DTOR_END__ = .;
+
+ _rodata_start = . ;
+ *(.rodata*)
+ *(.gnu.linkonce.r*)
+ _erodata = ALIGN( 0x10 ) ;
+
+ etext = ALIGN(0x10);
+ _etext = .;
+ *(.init)
+ *(.fini)
+ *(.lit)
+ *(.shdata)
+ . = ALIGN (16);
+ _endtext = .;
+ } > ram
+ .data :
+ {
+ data_start = .;
+ _data_start = .;
+ _sdata = . ;
+ *(.data)
+ *(.gnu.linkonce.d*)
+ *(.gcc_except_table)
+ . = ALIGN(0x10);
+ edata = .;
+ _edata = .;
+ } > ram
+ .dynamic : { *(.dynamic) } >ram
+ .jcr : { *(.jcr) } >ram
+ .got : { *(.got) } >ram
+ .plt : { *(.plt) } >ram
+ .hash : { *(.hash) } >ram
+ .dynrel : { *(.dynrel) } >ram
+ .dynsym : { *(.dynsym) } >ram
+ .dynstr : { *(.dynstr) } >ram
+ .hash : { *(.hash) } >ram
+ .shbss :
+ {
+ *(.shbss)
+ } > ram
+ .bss :
+ {
+ __bss_start = ALIGN(0x8);
+ _bss_start = .;
+ bss_start = .;
+ *(.bss)
+ *(COMMON)
+ end = .;
+ _end = ALIGN(0x8);
+ __end = ALIGN(0x8);
+ } > ram
+ .stab . (NOLOAD) :
+ {
+ [ .stab ]
+ }
+ .stabstr . (NOLOAD) :
+ {
+ [ .stabstr ]
+ }
+}
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/setvec.c b/c/src/lib/libbsp/sparc/leon3/startup/setvec.c
new file mode 100644
index 0000000000..bde2559a9a
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/startup/setvec.c
@@ -0,0 +1,64 @@
+/* set_vector
+ *
+ * This routine installs an interrupt vector on the SPARC simulator.
+ *
+ * INPUT PARAMETERS:
+ * handler - interrupt handler entry point
+ * vector - vector number
+ * type - 0 indicates raw hardware connect
+ * 1 indicates RTEMS interrupt connect
+ *
+ * OUTPUT PARAMETERS: NONE
+ *
+ * RETURNS:
+ * address of previous interrupt handler
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * Ported to LEON implementation of the SPARC by On-Line Applications
+ * Research Corporation (OAR) under contract to the European Space
+ * Agency (ESA).
+ *
+ * LEON modifications of respective RTEMS file: COPYRIGHT (c) 1995.
+ * European Space Agency.
+ *
+ * $Id$
+ */
+
+#include <bsp.h>
+
+rtems_isr_entry set_vector( /* returns old vector */
+ rtems_isr_entry handler, /* isr routine */
+ rtems_vector_number vector, /* vector number */
+ int type /* RTEMS or RAW intr */
+)
+{
+ rtems_isr_entry previous_isr;
+ unsigned32 real_trap;
+ unsigned32 source;
+
+ if ( type )
+ rtems_interrupt_catch( handler, vector, &previous_isr );
+ else
+ _CPU_ISR_install_raw_handler( vector, handler, (void *)&previous_isr );
+
+ real_trap = SPARC_REAL_TRAP_NUMBER( vector );
+
+ if ( LEON_INT_TRAP( real_trap ) ) {
+
+ source = LEON_TRAP_SOURCE( real_trap );
+
+ LEON_Clear_interrupt( source );
+ LEON_Unmask_interrupt( source );
+ }
+
+ return previous_isr;
+}
+
+
+
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/spurious.c b/c/src/lib/libbsp/sparc/leon3/startup/spurious.c
new file mode 100644
index 0000000000..2271066415
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/startup/spurious.c
@@ -0,0 +1,184 @@
+/*
+ * LEON Spurious Trap Handler
+ *
+ * This is just enough of a trap handler to let us know what
+ * the likely source of the trap was.
+ *
+ * Developed as part of the port of RTEMS to the LEON implementation
+ * of the SPARC by On-Line Applications Research Corporation (OAR)
+ * under contract to the European Space Agency (ESA).
+ *
+ * COPYRIGHT (c) 1995. European Space Agency.
+ *
+ * Modified for LEON3 BSP.
+ * COPYRIGHT (c) 2004.
+ * Gaisler Research.
+ *
+ * This terms of the RTEMS license apply to this file.
+ *
+ * $Id$
+ */
+
+#include <bsp.h>
+
+#include <string.h>
+
+static const char digits[16] = "0123456789abcdef";
+
+/* Simple integer-to-string conversion */
+
+void itos(unsigned32 u, char *s)
+{
+ int i;
+
+ for (i=0; i<8; i++) {
+ s[i] = digits[(u >> (28 - (i*4))) & 0x0f];
+ }
+}
+
+/*
+ * bsp_spurious_handler
+ *
+ * Print a message on the debug console and then die
+ */
+
+rtems_isr bsp_spurious_handler(
+ rtems_vector_number trap,
+ CPU_Interrupt_frame *isf
+)
+{
+ char line[ 80 ];
+ rtems_unsigned32 real_trap;
+
+ real_trap = SPARC_REAL_TRAP_NUMBER(trap);
+
+ strcpy(line, "Unexpected trap (0x ) at address 0x ");
+ line[ 19 ] = digits[ real_trap >> 4 ];
+ line[ 20 ] = digits[ real_trap & 0xf ];
+ itos(isf->tpc, &line[36]);
+ DEBUG_puts( line );
+
+ switch (real_trap) {
+
+ /*
+ * First the ones defined by the basic architecture
+ */
+
+ case 0x00:
+ DEBUG_puts( "reset" );
+ break;
+ case 0x01:
+ DEBUG_puts( "instruction access exception" );
+ break;
+ case 0x02:
+ DEBUG_puts( "illegal instruction" );
+ break;
+ case 0x03:
+ DEBUG_puts( "privileged instruction" );
+ break;
+ case 0x04:
+ DEBUG_puts( "fp disabled" );
+ break;
+ case 0x07:
+ DEBUG_puts( "memory address not aligned" );
+ break;
+ case 0x08:
+ DEBUG_puts( "fp exception" );
+ break;
+ case 0x09:
+ strcpy(line, "data access exception at 0x " );
+ /* itos(LEON_REG.Failed_Address, &line[27]); FIXME */
+ DEBUG_puts( line );
+ break;
+ case 0x0A:
+ DEBUG_puts( "tag overflow" );
+ break;
+
+ /*
+ * Then the ones defined by the LEON in particular
+ */
+ /* FIXME */
+
+ /*
+ case LEON_TRAP_TYPE( LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR ):
+ DEBUG_puts( "LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR" );
+ break;
+ case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_2_RX_TX ):
+ DEBUG_puts( "LEON_INTERRUPT_UART_2_RX_TX" );
+ break;
+ case LEON_TRAP_TYPE( LEON_INTERRUPT_UART_1_RX_TX ):
+ DEBUG_puts( "LEON_INTERRUPT_UART_1_RX_TX" );
+ break;
+ case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_0 ):
+ DEBUG_puts( "LEON_INTERRUPT_EXTERNAL_0" );
+ break;
+ case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_1 ):
+ DEBUG_puts( "LEON_INTERRUPT_EXTERNAL_1" );
+ break;
+ case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_2 ):
+ DEBUG_puts( "LEON_INTERRUPT_EXTERNAL_2" );
+ break;
+ case LEON_TRAP_TYPE( LEON_INTERRUPT_EXTERNAL_3 ):
+ DEBUG_puts( "LEON_INTERRUPT_EXTERNAL_3" );
+ break;
+ case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 ):
+ DEBUG_puts( "LEON_INTERRUPT_TIMER1" );
+ break;
+ case LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER2 ):
+ DEBUG_puts( "LEON_INTERRUPT_TIMER2" );
+ break;
+ */
+
+ default:
+ break;
+ }
+
+ /*
+ * What else can we do but stop ...
+ */
+
+ asm volatile( "mov 1, %g1; ta 0x0" );
+}
+
+/*
+ * bsp_spurious_initialize
+ *
+ * Install the spurious handler for most traps. Note that set_vector()
+ * will unmask the corresponding asynchronous interrupt, so the initial
+ * interrupt mask is restored after the handlers are installed.
+ */
+
+void bsp_spurious_initialize()
+{
+ rtems_unsigned32 trap;
+ unsigned32 level;
+ /* unsigned32 mask; */
+
+ level = sparc_disable_interrupts();
+ /* mask = LEON3_IrqCtrl_Regs->mask_p0; */
+
+ for ( trap=0 ; trap<256 ; trap++ ) {
+
+ /*
+ * Skip window overflow, underflow, and flush as well as software
+ * trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f
+ * which cannot happen and where some of the space is used to pass
+ * paramaters to the program.
+ */
+
+ if (( trap == 5 || trap == 6 ) ||
+ (( trap >= 0x11 ) && ( trap <= 0x1f )) ||
+ (( trap >= 0x70 ) && ( trap <= 0x83 )))
+ continue;
+
+ set_vector(
+ (rtems_isr_entry) bsp_spurious_handler,
+ SPARC_SYNCHRONOUS_TRAP( trap ),
+ 1
+ );
+ }
+
+ /* LEON3_IrqCtrl_Regs->mask_p0 = mask; */
+ sparc_enable_interrupts(level);
+
+}
diff --git a/c/src/lib/libbsp/sparc/leon3/timer/.cvsignore b/c/src/lib/libbsp/sparc/leon3/timer/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/timer/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/sparc/leon3/timer/Makefile.am b/c/src/lib/libbsp/sparc/leon3/timer/Makefile.am
new file mode 100644
index 0000000000..0e51a50a0a
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/timer/Makefile.am
@@ -0,0 +1,31 @@
+##
+## $Id$
+##
+
+
+PGM = $(ARCH)/timer.rel
+
+C_FILES = timer.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+OBJS = $(C_O_FILES)
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+$(PGM): $(OBJS)
+ $(make-rel)
+
+# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
+
+all-local: $(ARCH) $(OBJS) $(PGM)
+
+.PRECIOUS: $(PGM)
+
+EXTRA_DIST = timer.c
+
+include $(top_srcdir)/../../../../../../automake/local.am
diff --git a/c/src/lib/libbsp/sparc/leon3/timer/timer.c b/c/src/lib/libbsp/sparc/leon3/timer/timer.c
new file mode 100644
index 0000000000..805616e475
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/timer/timer.c
@@ -0,0 +1,82 @@
+/* timer.c
+ *
+ * This file implements a benchmark timer using timer 2.
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * Ported to LEON implementation of the SPARC by On-Line Applications
+ * Research Corporation (OAR) under contract to the European Space
+ * Agency (ESA).
+ *
+ * LEON modifications of respective RTEMS file: COPYRIGHT (c) 1995.
+ * European Space Agency.
+ *
+ * $Id$
+ */
+
+
+#include <bsp.h>
+
+rtems_boolean Timer_driver_Find_average_overhead;
+
+rtems_boolean Timer_driver_Is_initialized = FALSE;
+
+extern volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs;
+
+void Timer_initialize()
+{
+ /*
+ * Timer runs long and accurate enough not to require an interrupt.
+ */
+ if (LEON3_Timer_Regs) {
+ if ( Timer_driver_Is_initialized == FALSE ) {
+ /* approximately 1 us per countdown */
+ LEON3_Timer_Regs->reload_t1 = 0xffffff;
+ LEON3_Timer_Regs->value_t1 = 0xffffff;
+ } else {
+ Timer_driver_Is_initialized = TRUE;
+ }
+ LEON3_Timer_Regs->conf_t1 = LEON3_GPTIMER_EN | LEON3_GPTIMER_LD;
+ }
+}
+
+#define AVG_OVERHEAD 3 /* It typically takes 3.0 microseconds */
+ /* to start/stop the timer. */
+#define LEAST_VALID 2 /* Don't trust a value lower than this */
+
+int Read_timer()
+{
+ rtems_unsigned32 total;
+
+ if (LEON3_Timer_Regs) {
+ total = LEON3_Timer_Regs->value_t1;
+
+ total = 0xffffff - total;
+
+ if ( Timer_driver_Find_average_overhead == 1 )
+ return total; /* in one microsecond units */
+
+ if ( total < LEAST_VALID )
+ return 0; /* below timer resolution */
+
+ return total - AVG_OVERHEAD;
+ }
+ return 0;
+}
+
+rtems_status_code Empty_function( void )
+{
+ return RTEMS_SUCCESSFUL;
+}
+
+void Set_find_average_overhead(
+ rtems_boolean find_flag
+)
+{
+ Timer_driver_Find_average_overhead = find_flag;
+}
diff --git a/c/src/lib/libbsp/sparc/leon3/times b/c/src/lib/libbsp/sparc/leon3/times
new file mode 100644
index 0000000000..1b04728a25
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/times
@@ -0,0 +1,193 @@
+#
+# Timing Test Suite Results for the SPARC Instruction Simulator BSP
+#
+# NOTE: The ERC32 is derived from the Cypress 601/602 chip set.
+#
+# $Id$
+#
+
+Board: SPARC Instruction Simulator v1.8
+CPU: include coprocessor if applicable
+Clock Speed: 15 Mhz
+Memory Configuration:
+Wait States: 0
+
+Times Reported in: microseconds
+Timer Source: on-CPU General Purpose Count Down Timer
+
+Column A: 3.5.1 pre-release
+Column B: unused
+
+# DESCRIPTION A B
+== ================================================================= ==== ====
+ 1 rtems_semaphore_create 20
+ rtems_semaphore_delete 21
+ rtems_semaphore_obtain: available 15
+ rtems_semaphore_obtain: not available -- NO_WAIT 15
+ rtems_semaphore_release: no waiting tasks 16
+
+ 2 rtems_semaphore_obtain: not available -- caller blocks 62
+
+ 3 rtems_semaphore_release: task readied -- preempts caller 55
+
+ 4 rtems_task_restart: blocked task -- preempts caller 77
+ rtems_task_restart: ready task -- preempts caller 70
+ rtems_semaphore_release: task readied -- returns to caller 25
+ rtems_task_create 57
+ rtems_task_start 31
+ rtems_task_restart: suspended task -- returns to caller 36
+ rtems_task_delete: suspended task 47
+ rtems_task_restart: ready task -- returns to caller 37
+ rtems_task_restart: blocked task -- returns to caller 46
+ rtems_task_delete: blocked task 50
+
+ 5 rtems_task_suspend: calling task 51
+ rtems_task_resume: task readied -- preempts caller 49
+
+ 6 rtems_task_restart: calling task 59
+ rtems_task_suspend: returns to caller 18
+ rtems_task_resume: task readied -- returns to caller 19
+ rtems_task_delete: ready task 50
+
+ 7 rtems_task_restart: suspended task -- preempts caller 70
+
+ 8 rtems_task_set_priority: obtain current priority 12
+ rtems_task_set_priority: returns to caller 27
+ rtems_task_mode: obtain current mode 5
+ rtems_task_mode: no reschedule 5
+ rtems_task_mode: reschedule -- returns to caller 8
+ rtems_task_mode: reschedule -- preempts caller 39
+ rtems_task_set_note 13
+ rtems_task_get_note 13
+ rtems_clock_set 33
+ rtems_clock_get 3
+
+ 9 rtems_message_queue_create 110
+ rtems_message_queue_send: no waiting tasks 37
+ rtems_message_queue_urgent: no waiting tasks 37
+ rtems_message_queue_receive: available 31
+ rtems_message_queue_flush: no messages flushed 12
+ rtems_message_queue_flush: messages flushed 16
+ rtems_message_queue_delete 26
+
+10 rtems_message_queue_receive: not available -- NO_WAIT 15
+ rtems_message_queue_receive: not available -- caller blocks 62
+
+11 rtems_message_queue_send: task readied -- preempts caller 72
+
+12 rtems_message_queue_send: task readied -- returns to caller 39
+
+13 rtems_message_queue_urgent: task readied -- preempts caller 72
+
+14 rtems_message_queue_urgent: task readied -- returns to caller 39
+
+15 rtems_event_receive: obtain current events 1
+ rtems_event_receive: not available -- NO_WAIT 12
+ rtems_event_receive: not available -- caller blocks 56
+ rtems_event_send: no task readied 12
+ rtems_event_receive: available 12
+ rtems_event_send: task readied -- returns to caller 24
+
+16 rtems_event_send: task readied -- preempts caller 55
+
+17 rtems_task_set_priority: preempts caller 62
+
+18 rtems_task_delete: calling task 83
+
+19 rtems_signal_catch 9
+ rtems_signal_send: returns to caller 15
+ rtems_signal_send: signal to self 18
+ exit ASR overhead: returns to calling task 22
+ exit ASR overhead: returns to preempting task 49
+
+20 rtems_partition_create 35
+ rtems_region_create 23
+ rtems_partition_get_buffer: available 15
+ rtems_partition_get_buffer: not available 13
+ rtems_partition_return_buffer 18
+ rtems_partition_delete 16
+ rtems_region_get_segment: available 22
+ rtems_region_get_segment: not available -- NO_WAIT 21
+ rtems_region_return_segment: no waiting tasks 19
+ rtems_region_get_segment: not available -- caller blocks 64
+ rtems_region_return_segment: task readied -- preempts caller 74
+ rtems_region_return_segment: task readied -- returns to caller 44
+ rtems_region_delete 16
+ rtems_io_initialize 2
+ rtems_io_open 1
+ rtems_io_close 1
+ rtems_io_read 1
+ rtems_io_write 1
+ rtems_io_control 1
+
+21 rtems_task_ident 149
+ rtems_message_queue_ident 145
+ rtems_semaphore_ident 156
+ rtems_partition_ident 145
+ rtems_region_ident 148
+ rtems_port_ident 145
+ rtems_timer_ident 145
+ rtems_rate_monotonic_ident 145
+
+22 rtems_message_queue_broadcast: task readied -- returns to caller 42
+ rtems_message_queue_broadcast: no waiting tasks 17
+ rtems_message_queue_broadcast: task readied -- preempts caller 78
+
+23 rtems_timer_create 14
+ rtems_timer_fire_after: inactive 22
+ rtems_timer_fire_after: active 24
+ rtems_timer_cancel: active 15
+ rtems_timer_cancel: inactive 13
+ rtems_timer_reset: inactive 21
+ rtems_timer_reset: active 23
+ rtems_timer_fire_when: inactive 34
+ rtems_timer_fire_when: active 34
+ rtems_timer_delete: active 19
+ rtems_timer_delete: inactive 17
+ rtems_task_wake_when 69
+
+24 rtems_task_wake_after: yield -- returns to caller 9
+ rtems_task_wake_after: yields -- preempts caller 45
+
+25 rtems_clock_tick 4
+
+26 _ISR_Disable 0
+ _ISR_Flash 1
+ _ISR_Enable 1
+ _Thread_Disable_dispatch 0
+ _Thread_Enable_dispatch 7
+ _Thread_Set_state 11
+ _Thread_Disptach (NO FP) 31
+ context switch: no floating point contexts 21
+ context switch: self 10
+ context switch: to another task 10
+ context switch: restore 1st FP task 25
+ fp context switch: save idle, restore idle 31
+ fp context switch: save idle, restore initialized 19
+ fp context switch: save initialized, restore initialized 20
+ _Thread_Resume 7
+ _Thread_Unblock 7
+ _Thread_Ready 9
+ _Thread_Get 4
+ _Semaphore_Get 2
+ _Thread_Get: invalid id 0
+
+27 interrupt entry overhead: returns to interrupted task 6
+ interrupt exit overhead: returns to interrupted task 6
+ interrupt entry overhead: returns to nested interrupt 6
+ interrupt exit overhead: returns to nested interrupt 5
+ interrupt entry overhead: returns to preempting task 7
+ interrupt exit overhead: returns to preempting task 36
+
+28 rtems_port_create 16
+ rtems_port_external_to_internal 11
+ rtems_port_internal_to_external 11
+ rtems_port_delete 16
+
+29 rtems_rate_monotonic_create 15
+ rtems_rate_monotonic_period: initiate period -- returns to caller 21
+ rtems_rate_monotonic_period: obtain status 13
+ rtems_rate_monotonic_cancel 16
+ rtems_rate_monotonic_delete: inactive 18
+ rtems_rate_monotonic_delete: active 20
+ rtems_rate_monotonic_period: conclude periods -- caller blocks 53
diff --git a/c/src/lib/libbsp/sparc/leon3/tools/.cvsignore b/c/src/lib/libbsp/sparc/leon3/tools/.cvsignore
new file mode 100644
index 0000000000..43dd2ee260
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/tools/.cvsignore
@@ -0,0 +1,15 @@
+aclocal.m4
+autom4te*.cache
+config.cache
+config.guess
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+Makefile
+Makefile.in
+missing
+mkinstalldirs
+runtest
diff --git a/c/src/lib/libbsp/sparc/leon3/tools/ChangeLog b/c/src/lib/libbsp/sparc/leon3/tools/ChangeLog
new file mode 100644
index 0000000000..073ba2ce55
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/tools/ChangeLog
@@ -0,0 +1,52 @@
+2003-08-14 Joel Sherrill <joel@OARcorp.com>
+
+ * runtest.in: Add fileio to list of interactive tests.
+
+2003-08-11 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+ * configure.ac: Use rtems-bugs@rtems.com as bug report email address.
+
+2003-03-06 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+ * configure.ac: Remove AC_CONFIG_AUX_DIR.
+
+2003-02-11 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+ * configure.ac: AM_INIT_AUTOMAKE([1.7.2]).
+
+2003-02-11 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+ * configure.ac: AC_PREREQ(2.57).
+
+2002-10-21 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+ * .cvsignore: Reformat.
+ Add autom4te*cache.
+ Remove autom4te.cache.
+
+2002-07-26 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+ * Makefile.am: Add transform and bsptools_bindir hacks.
+ * configure.ac: Add RTEMS_ENV_RTEMSBSP.
+
+2002-03-27 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+ * configure.ac:
+ AC_INIT(package,_RTEMS_VERSION,_RTEMS_BUGS).
+ AM_INIT_AUTOMAKE([no-define foreign 1.6]).
+ * Makefile.am: Remove AUTOMAKE_OPTIONS.
+
+2001-10-11 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+ * .cvsignore: Add autom4te.cache for autoconf > 2.52.
+ * configure.in: Remove.
+ * configure.ac: New file, generated from configure.in by autoupdate.
+
+2001-09-27 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+ * Makefile.am: Use 'TMPINSTALL_FILES ='.
+
+2001-09-14 Joel Sherrill <joel@OARcorp.com>
+
+ * ChangeLog: New file.
+
diff --git a/c/src/lib/libbsp/sparc/leon3/tools/Makefile.am b/c/src/lib/libbsp/sparc/leon3/tools/Makefile.am
new file mode 100644
index 0000000000..54b520f8d5
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/tools/Makefile.am
@@ -0,0 +1,22 @@
+##
+## $Id$
+##
+
+ACLOCAL_AMFLAGS = -I ../../../../../../../aclocal
+
+transform =
+bsptools_bindir = ${exec_prefix}/@RTEMS_BSP@/tests
+bsptools_bin_SCRIPTS = runtest
+
+TMPINSTALL_FILES = $(PROJECT_ROOT)/leon/tests \
+ $(PROJECT_ROOT)/leon/tests/runtest
+
+$(PROJECT_ROOT)/leon/tests:
+ $(mkinstalldirs) $@
+
+$(PROJECT_ROOT)/leon/tests/runtest: runtest
+ $(INSTALL_SCRIPT) $< $@
+
+all-local: $(TMPINSTALL_FILES)
+
+include $(top_srcdir)/../../../../../../../automake/host.am
diff --git a/c/src/lib/libbsp/sparc/leon3/tools/configure.ac b/c/src/lib/libbsp/sparc/leon3/tools/configure.ac
new file mode 100644
index 0000000000..887c68ec5c
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/tools/configure.ac
@@ -0,0 +1,25 @@
+## Process this file with autoconf to produce a configure script.
+##
+## $Id$
+
+AC_PREREQ(2.57)
+AC_INIT([rtems-c-src-lib-libbsp-sparc-leon-tools],[_RTEMS_VERSION],[rtems-bugs@rtems.com])
+AC_CONFIG_SRCDIR([runtest.in])
+RTEMS_TOP(../../../../../../..)
+
+RTEMS_CANONICAL_TARGET_CPU
+
+AM_INIT_AUTOMAKE([no-define foreign 1.7.2])
+AM_MAINTAINER_MODE
+
+RTEMS_ENV_RTEMSBSP
+
+RTEMS_PATH_KSH
+
+RTEMS_PROJECT_ROOT
+RTEMS_TOOLPATHS
+
+# Explicitly list all Makefiles here
+AC_CONFIG_FILES([Makefile
+runtest])
+AC_OUTPUT
diff --git a/c/src/lib/libbsp/sparc/leon3/tools/runtest.in b/c/src/lib/libbsp/sparc/leon3/tools/runtest.in
new file mode 100644
index 0000000000..7a8e3ac3c0
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/tools/runtest.in
@@ -0,0 +1,312 @@
+#!@KSH@ -p
+#
+# $Id$
+#
+# Run rtems tests on the hppa simulator
+# This program generates a simulator script to run each test
+# Typically the test is then run, although it can be generated
+# and left as a file using -s
+#
+
+# progname=`basename $0`
+progname=${0##*/} # fast basename hack for ksh, bash
+
+USAGE=\
+"usage: $progname [ -opts ] test [ test ... ]
+ -o options -- specify options to be passed to simulator
+ -v -- verbose
+ -s -- generate script file (as 'test'.ss) and exit
+ -l logdir -- specify log directory (default is 'logdir')
+
+ Specify test as 'test' or 'test.exe'.
+ All multiprocessing tests *must* be specified simply as 'mp01', etc.
+"
+
+# export everything
+set -a
+
+# log an error to stderr
+prerr()
+{
+ echo "$*" >&2
+}
+
+fatal() {
+ [ "$1" ] && prerr $*
+ prerr "$USAGE"
+ exit 1
+}
+
+warn() {
+ [ "$1" ] && prerr $*
+}
+
+# print args, 1 per line
+ml_echo()
+{
+ for l
+ do
+ echo "$l"
+ done
+}
+
+# run at normal and signalled exit
+test_exit()
+{
+ exit_code=$1
+
+ rm -f ${statfile}* ${scriptfile}* ${logfile}.tmp*
+ [ "$sim_pid" ] && kill -9 $sim_pid
+
+ exit $exit_code
+}
+
+#
+# process the options
+#
+# defaults for getopt vars
+#
+# max_run_time is defaulted to 5 minutes
+#
+
+verbose=""
+extra_options=""
+script_and_exit=""
+stdio_setup="yes"
+run_to_completion="yes"
+logdir=log
+update_on_tick="no"
+max_run_time=$((5 * 60))
+using_print_buffer="yes"
+
+while getopts vhr12o:c:sl:t OPT
+do
+ case "$OPT" in
+ v)
+ verbose="yes";;
+ s)
+ script_and_exit="yes"
+ run_to_completion="no"
+ stdio_setup="no";;
+ l)
+ logdir="$OPTARG";;
+ o)
+ extra_options="$OPTARG";;
+ *)
+ fatal;;
+ esac
+done
+
+let $((shiftcount = $OPTIND - 1))
+shift $shiftcount
+
+args=$*
+
+#
+# Run the tests
+#
+
+tests="$args"
+if [ ! "$tests" ]
+then
+ set -- `echo *.exe`
+ tests="$*"
+fi
+
+[ -d $logdir ] ||
+ mkdir $logdir || fatal "could not create log directory ($logdir)"
+
+cpus=1
+
+# where the tmp files go
+statfile=/tmp/stats$$
+scriptfile=/tmp/script$$
+
+trap "test_exit" 1 2 3 13 14 15
+
+for tfile in $tests
+do
+
+ tname=`basename $tfile .exe`
+ TEST_TYPE="single"
+
+ case $tname in
+ monitor* | termios* | fileio*)
+ if [ $run_to_completion = "yes" ]
+ then
+ warn "Skipping $tname; it is interactive"
+ continue
+ fi
+ ;;
+ *-node2*)
+ fatal "MP tests not supported"
+ warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
+ continue;;
+ *-node1*)
+ warn "Running both nodes associated with $tname"
+ variant=`echo $tname | sed 's/.*-node[12]//' | sed 's/\.exe//'`
+ tname=`echo $tname | sed 's/-node.*//'`
+ TEST_TYPE="mp"
+ ;;
+ minimum*|stackchk*|spfatal*|termio*)
+ warn "Skipping $tname; it locks up or takes a VERY long time to run"
+ continue
+ ;;
+ esac
+
+ # Change the title bar to indicate which test we are running
+ # The simulator screen doesn't provide any indication
+
+ logfile=$logdir/$tname
+ infofile=$logfile.info
+
+ rm -f ${statfile}* ${scriptfile}* ${logfile}.tmp*
+
+ date=`date`
+ echo "Starting $tname at $date"
+
+ # Generate a script file to get the work done.
+ # The script file must do the following:
+ #
+ # load the program (programs if MP test)
+ # arrange for capture of output
+ # run the program
+ # produce statistics
+
+ {
+ case $TEST_TYPE in
+ "mp")
+ fatal "MP tests not supported"
+ ;;
+
+ # All other tests (single-processor)
+ *)
+ echo "load $tfile"
+ echo "go 0x02000000"
+ echo ""
+ echo "perf"
+ echo "quit"
+ ;;
+ esac
+
+ } > ${scriptfile}
+
+ if [ "$script_and_exit" = "yes" ]
+ then
+ mv ${scriptfile} $tname.ss
+ warn "script left in $tname.ss"
+ test_exit 0
+ fi
+
+ # Spin off the simulator in the background
+ sparc-rtems-sis $extra_options -c ${scriptfile} >${logfile}.tmp &
+ sim_pid=$!
+
+ # Make sure it won't run forever...
+ {
+ time_run=0
+ while [ $time_run -lt $max_run_time ]
+ do
+ # sleep 10s at a time waiting for job to finish or timer to expire
+ # if job has exited, then we exit, too.
+ sleep 10
+ if kill -0 $sim_pid 2>/dev/null
+ then
+ time_run=$((time_run + 10))
+ else
+ exit 0
+ fi
+ done
+
+ kill -2 $sim_pid 2>/dev/null
+ { sleep 5; kill -9 $sim_pid 2>/dev/null; } &
+ } &
+
+ wait $sim_pid
+ status=$?
+ if [ $status -ne 0 ]
+ then
+ ran_too_long="yes"
+ else
+ ran_too_long="no"
+ fi
+
+ sim_pid=""
+
+ # fix up the printf output from the test
+ case $TEST_TYPE in
+ mp)
+ fatal "MP not supported"
+ ;;
+ *)
+ output_it=1
+ sed -e '1,9d' \
+ -e 's/ //' -e '/^$/d' < ${logfile}.tmp |
+ while read line
+ do
+ if [ $output_it -eq 1 ] ; then
+ if [ "$line" = "sis> perf" ] ; then
+ output_it=0
+ elif [ "$line" = "sis> quit" ] ; then
+ output_it=0
+ elif [ "$line" = "sis>" ] ; then
+ output_it=0
+ else
+ echo "$line"
+ fi
+ fi
+ done > ${logfile}_1
+ ;;
+ esac
+
+ # Create the info files
+ for cpu in $cpus
+ do
+ {
+ echo "$date"
+ echo "Test run on: `uname -n` ( `uname -a` )"
+
+ output_it=0
+ sed -e 's/ //' < ${logfile}.tmp |
+ while read line
+ do
+ if [ $output_it -eq 1 ] ; then
+ if [ "$line" = "sis> quit" ] ; then
+ output_it=0
+ else
+ echo "$line"
+ fi
+ else
+ if [ "$line" = "sis> perf" ] ; then
+ output_it=1
+ fi
+ fi
+ done
+
+
+ if [ "$ran_too_long" = "yes" ]
+ then
+ echo "Test did NOT finish normally; killed after $max_run_time seconds"
+ fi
+
+ echo
+ date;
+ } > ${infofile}_$cpu
+ done
+
+ rm -f ${logfile}.tmp*
+
+ if [ "$cpus" = "1" ]
+ then
+ mv ${infofile}_1 ${infofile}
+ mv ${logfile}_1 ${logfile}
+ fi
+
+done
+
+test_exit 0
+
+# Local Variables: ***
+# mode:ksh ***
+# End: ***
+
diff --git a/c/src/lib/libbsp/sparc/leon3/wrapup/.cvsignore b/c/src/lib/libbsp/sparc/leon3/wrapup/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/wrapup/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/c/src/lib/libbsp/sparc/leon3/wrapup/Makefile.am b/c/src/lib/libbsp/sparc/leon3/wrapup/Makefile.am
new file mode 100644
index 0000000000..515a76e7cc
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/wrapup/Makefile.am
@@ -0,0 +1,31 @@
+##
+## $Id$
+##
+
+# We only build the networking device driver if HAS_NETWORKING was defined
+if HAS_NETWORKING
+NETWORKING_DRIVER = leon_open_eth leon_smc91111
+endif
+
+BSP_PIECES = startup amba console clock timer gnatsupp $(NETWORKING_DRIVER)
+# pieces to pick up out of libcpu/sparc
+CPU_PIECES = cache reg_win syscall
+
+# bummer; have to use $foreach since % pattern subst rules only replace 1x
+OBJS = $(foreach piece, $(BSP_PIECES), $(wildcard ../$(piece)/$(ARCH)/*.$(OBJEXT))) \
+ $(foreach piece, $(CPU_PIECES), ../../../../libcpu/$(RTEMS_CPU)/$(piece)/$(ARCH)/*.$(OBJEXT))
+LIB = $(ARCH)/libbsp.a
+
+include $(top_srcdir)/../../../../../../automake/compile.am
+include $(top_srcdir)/../../../../../../automake/lib.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+$(LIB): $(OBJS)
+ $(make-library)
+
+all-local: $(ARCH) $(LIB)
+
+include $(top_srcdir)/../../../../../../automake/local.am