summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc
diff options
context:
space:
mode:
authorRalf Corsepius <ralf.corsepius@rtems.org>2006-01-09 10:41:21 +0000
committerRalf Corsepius <ralf.corsepius@rtems.org>2006-01-09 10:41:21 +0000
commit41c928242335a544b17b94c6a21baebdc5d8b995 (patch)
tree62fe57379a186de08e0d08545401ed250463f6de /c/src/lib/libbsp/sparc
parent2006-01-09 Ralf Corsepius <ralf.corsepius@rtems.org> (diff)
downloadrtems-41c928242335a544b17b94c6a21baebdc5d8b995.tar.bz2
Backport from rtems-4-6-branch.
Diffstat (limited to 'c/src/lib/libbsp/sparc')
-rw-r--r--c/src/lib/libbsp/sparc/leon3/.cvsignore14
-rw-r--r--c/src/lib/libbsp/sparc/leon3/Makefile.am158
-rw-r--r--c/src/lib/libbsp/sparc/leon3/README37
-rw-r--r--c/src/lib/libbsp/sparc/leon3/amba/amba.c98
-rw-r--r--c/src/lib/libbsp/sparc/leon3/bsp_specs15
-rw-r--r--c/src/lib/libbsp/sparc/leon3/clock/ckinit.c269
-rw-r--r--c/src/lib/libbsp/sparc/leon3/configure.ac42
-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/gnatsupp.c20
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/.cvsignore4
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/amba.h84
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/bsp.h127
-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/include/tm27.h79
-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/leon_smc91111.c100
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/bspstart.c228
-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/timer.c82
-rw-r--r--c/src/lib/libbsp/sparc/leon3/times193
26 files changed, 2968 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/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am
new file mode 100644
index 0000000000..c9f65d5d74
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am
@@ -0,0 +1,158 @@
+##
+## $Id$
+##
+
+ACLOCAL_AMFLAGS = -I ../../../../aclocal
+
+include $(top_srcdir)/../../../../automake/compile.am
+include $(top_srcdir)/../../bsp.am
+
+dist_project_lib_DATA = bsp_specs
+
+include_HEADERS = include/bsp.h
+include_HEADERS += include/tm27.h
+
+nodist_include_HEADERS = include/bspopts.h
+DISTCLEANFILES = include/bspopts.h
+
+noinst_PROGRAMS =
+
+# wrapup is the one that actually builds and installs the library
+# from the individual .rel files built in other directories
+SUBDIRS = . tools
+
+include_HEADERS += include/leon.h
+include_HEADERS += include/coverhd.h
+
+EXTRA_DIST = ../../sparc/shared/start.S
+start.$(OBJEXT): ../../sparc/shared/start.S
+ $(CPPASCOMPILE) -DASM -o $@ -c $<
+
+project_lib_DATA = start.$(OBJEXT)
+
+dist_project_lib_DATA += startup/linkcmds
+
+noinst_PROGRAMS += startup.rel
+startup_rel_SOURCES = ../../sparc/shared/bspclean.c ../../shared/bsplibc.c \
+ ../../shared/bsppost.c startup/bspstart.c ../../shared/main.c \
+ ../../shared/bootcard.c ../../shared/sbrk.c startup/setvec.c \
+ startup/spurious.c startup/ithread.S
+startup_rel_CPPFLAGS = $(AM_CPPFLAGS)
+startup_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+noinst_PROGRAMS += gnatsupp.rel
+gnatsupp_rel_SOURCES = gnatsupp/gnatsupp.c ../../sparc/shared/gnatcommon.c
+gnatsupp_rel_CPPFLAGS = $(AM_CPPFLAGS)
+gnatsupp_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+include_HEADERS += include/amba.h
+
+noinst_PROGRAMS += amba.rel
+amba_rel_SOURCES = amba/amba.c
+amba_rel_CPPFLAGS = $(AM_CPPFLAGS)
+amba_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+noinst_PROGRAMS += console.rel
+console_rel_SOURCES = console/console.c console/consolereserveresources.c \
+ console/debugputs.c
+console_rel_CPPFLAGS = $(AM_CPPFLAGS)
+console_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+noinst_PROGRAMS += clock.rel
+clock_rel_SOURCES = clock/ckinit.c
+clock_rel_CPPFLAGS = $(AM_CPPFLAGS)
+clock_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+if HAS_NETWORKING
+noinst_PROGRAMS += leon_smc91111.rel
+leon_smc91111_rel_SOURCES = leon_smc91111/leon_smc91111.c
+leon_smc91111_rel_CPPFLAGS = $(AM_CPPFLAGS)
+leon_smc91111_rel_CPPFLAGS += -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
+leon_smc91111_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+endif
+
+noinst_PROGRAMS += timer.rel
+timer_rel_SOURCES = timer/timer.c
+timer_rel_CPPFLAGS = $(AM_CPPFLAGS)
+timer_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+if HAS_NETWORKING
+noinst_PROGRAMS += leon_open_eth.rel
+leon_open_eth_rel_SOURCES = leon_open_eth/leon_open_eth.c
+leon_open_eth_rel_CPPFLAGS = $(AM_CPPFLAGS)
+leon_open_eth_rel_CPPFLAGS += -D__INSIDE_RTEMS_BSD_TCPIP_STACK__
+leon_open_eth_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+endif
+
+noinst_LIBRARIES = libbsp.a
+libbsp_a_SOURCES =
+libbsp_a_LIBADD = startup.rel amba.rel console.rel clock.rel timer.rel \
+ gnatsupp.rel
+
+if HAS_NETWORKING
+libbsp_a_LIBADD += leon_open_eth.rel
+endif
+
+libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/cache.rel \
+ ../../../libcpu/@RTEMS_CPU@/reg_win.rel \
+ ../../../libcpu/@RTEMS_CPU@/syscall.rel
+
+all-local: $(PREINSTALL_FILES) $(TMPINSTALL_FILES)
+
+EXTRA_DIST += times
+
+PREINSTALL_DIRS =
+PREINSTALL_FILES =
+TMPINSTALL_FILES =
+
+$(PROJECT_INCLUDE)/$(dirstamp):
+ @$(mkdir_p) $(PROJECT_INCLUDE)
+ @: > $(PROJECT_INCLUDE)/$(dirstamp)
+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp)
+
+$(PROJECT_LIB)/$(dirstamp):
+ @$(mkdir_p) $(PROJECT_LIB)
+ @: > $(PROJECT_LIB)/$(dirstamp)
+PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp)
+
+$(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
+PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
+
+$(PROJECT_INCLUDE)/bsp.h: include/bsp.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
+
+$(PROJECT_INCLUDE)/tm27.h: include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
+
+$(PROJECT_INCLUDE)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h
+
+$(PROJECT_INCLUDE)/leon.h: include/leon.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/leon.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/leon.h
+
+$(PROJECT_INCLUDE)/coverhd.h: include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
+
+$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
+TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
+
+$(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
+PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds
+
+$(PROJECT_INCLUDE)/amba.h: include/amba.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/amba.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/amba.h
+
+CLEANFILES = $(PREINSTALL_FILES)
+DISTCLEANFILES += $(PREINSTALL_DIRS)
+CLEANFILES += $(TMPINSTALL_FILES)
+
+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/amba.c b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
new file mode 100644
index 0000000000..77a3f346eb
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
@@ -0,0 +1,98 @@
+/*
+ * 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..c7e3b5061f
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/bsp_specs
@@ -0,0 +1,15 @@
+%rename endfile old_endfile
+%rename startfile old_startfile
+%rename link old_link
+
+*endfile:
+crtend.o%s crtn.o%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/ckinit.c b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
new file mode 100644
index 0000000000..328dc3dba1
--- /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 uint32_t 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 uint32_t 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
+)
+{
+ uint32_t 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..3a192be249
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/configure.ac
@@ -0,0 +1,42 @@
+## Process this file with autoconf to produce a configure script.
+##
+## $Id$
+
+AC_PREREQ(2.59)
+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 nostdinc foreign 1.9])
+RTEMS_BSP_CONFIGURE
+
+RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm])
+RTEMS_CANONICALIZE_TOOLS
+RTEMS_PROG_CCAS
+
+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])
+AC_OUTPUT
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/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..5f1077556d
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/include/.cvsignore
@@ -0,0 +1,4 @@
+bspopts.h
+bspopts.h.in
+stamp-h
+stamp-h.in
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..2f5481a4dc
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/include/bsp.h
@@ -0,0 +1,127 @@
+/* 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 _BSP_H
+#define _BSP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bspopts.h>
+
+#include <rtems.h>
+#include <leon.h>
+#include <rtems/clockdrv.h>
+#include <rtems/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 */
+
+/*
+ * Simple spin delay in microsecond units for device drivers.
+ * This is very dependent on the clock speed of the target.
+ */
+
+extern void Clock_delay(uint32_t 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 */
+
+/* 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
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..27873d6fee
--- /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 { \
+ uint32_t _level; \
+ \
+ _level = sparc_disable_interrupts(); \
+ LEON3_IrqCtrl_Regs->mask_p0 &= ~(1 << (_source)); \
+ sparc_enable_interrupts( _level ); \
+ } while (0)
+
+#define LEON_Unmask_interrupt( _source ) \
+ do { \
+ uint32_t _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 { \
+ uint32_t _level; \
+ uint32_t _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 { \
+ uint32_t _level; \
+ uint32_t _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/include/tm27.h b/c/src/lib/libbsp/sparc/leon3/include/tm27.h
new file mode 100644
index 0000000000..db26a82b19
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/include/tm27.h
@@ -0,0 +1,79 @@
+/*
+ * tm27.h
+ *
+ * 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 _RTEMS_TMTEST27
+#error "This is an RTEMS internal file you must not include directly."
+#endif
+
+#ifndef __tm27_h
+#define __tm27_h
+
+/*
+ * 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() /* empty */
+
+#define Lower_tm27_intr() /* empty */
+
+/*
+ * The asynchronous trap is an arbitrarily chosen ERC32 interrupt source.
+ */
+
+#else /* use a regular asynchronous trap */
+
+#define TEST_INTERRUPT_SOURCE LEON_INTERRUPT_EXTERNAL_1
+#define TEST_VECTOR LEON_TRAP_TYPE( TEST_INTERRUPT_SOURCE )
+#define TEST_INTERRUPT_SOURCE2 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() /* empty */
+
+#endif
+
+#endif
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/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/startup/bspstart.c b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
new file mode 100644
index 0000000000..bdce5fa780
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
@@ -0,0 +1,228 @@
+/*
+ * 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 uint32_t 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
+ */
+
+uint32_t 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 uint32_t normal_clock = ~0;
+ static uint32_t 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 *, uint32_t, 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;
+ uint32_t heap_start;
+ uint32_t heap_size;
+
+ heap_start = (uint32_t) &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) if the simulators are running too far from real time.
+ */
+
+#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..0d2b567d02
--- /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 <rtems/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..123306c5db
--- /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;
+ uint32_t real_trap;
+ uint32_t 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..b638404eac
--- /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(uint32_t 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 ];
+ uint32_t 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()
+{
+ uint32_t trap;
+ uint32_t level;
+ /* uint32_t 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/timer.c b/c/src/lib/libbsp/sparc/leon3/timer/timer.c
new file mode 100644
index 0000000000..63a3cd2058
--- /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()
+{
+ uint32_t 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