From b21b0ab3e77d91fc32e4324d3dfaf57ce24096ab Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 13 Nov 2000 22:40:29 +0000 Subject: 2000-11-13 Jiri Gaisler * .cvsignore, ChangeLog, Makefile.am, README, bsp_specs, configure.in, times, 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/bsp.h, include/coverhd.h, include/leon.h, start/.cvsignore, start/Makefile.am, startup/.cvsignore, startup/Makefile.am, startup/boardinit.S, startup/linkcmds, startup/setvec.c, startup/spurious.c, timer/.cvsignore, timer/Makefile.am, timer/timer.c, tools/.cvsignore, tools/Makefile.am, tools/configure.in, tools/runtest.in, wrapup/.cvsignore, wrapup/Makefile.am: New file. --- c/src/lib/libbsp/sparc/leon/.cvsignore | 13 + c/src/lib/libbsp/sparc/leon/ChangeLog | 16 + c/src/lib/libbsp/sparc/leon/Makefile.am | 17 + c/src/lib/libbsp/sparc/leon/README | 80 ++++ c/src/lib/libbsp/sparc/leon/bsp_specs | 26 ++ c/src/lib/libbsp/sparc/leon/clock/.cvsignore | 2 + c/src/lib/libbsp/sparc/leon/clock/Makefile.am | 33 ++ c/src/lib/libbsp/sparc/leon/clock/ckinit.c | 250 ++++++++++++ c/src/lib/libbsp/sparc/leon/configure.in | 41 ++ c/src/lib/libbsp/sparc/leon/console/.cvsignore | 2 + c/src/lib/libbsp/sparc/leon/console/Makefile.am | 33 ++ c/src/lib/libbsp/sparc/leon/console/console.c | 439 +++++++++++++++++++++ .../sparc/leon/console/consolereserveresources.c | 21 + c/src/lib/libbsp/sparc/leon/console/debugputs.c | 109 +++++ c/src/lib/libbsp/sparc/leon/gnatsupp/.cvsignore | 2 + c/src/lib/libbsp/sparc/leon/gnatsupp/Makefile.am | 33 ++ c/src/lib/libbsp/sparc/leon/gnatsupp/gnatsupp.c | 17 + c/src/lib/libbsp/sparc/leon/include/.cvsignore | 2 + c/src/lib/libbsp/sparc/leon/include/Makefile.am | 22 ++ c/src/lib/libbsp/sparc/leon/include/bsp.h | 184 +++++++++ c/src/lib/libbsp/sparc/leon/include/coverhd.h | 110 ++++++ c/src/lib/libbsp/sparc/leon/include/leon.h | 380 ++++++++++++++++++ c/src/lib/libbsp/sparc/leon/start/.cvsignore | 2 + c/src/lib/libbsp/sparc/leon/start/Makefile.am | 35 ++ c/src/lib/libbsp/sparc/leon/startup/.cvsignore | 2 + c/src/lib/libbsp/sparc/leon/startup/Makefile.am | 45 +++ c/src/lib/libbsp/sparc/leon/startup/boardinit.S | 64 +++ c/src/lib/libbsp/sparc/leon/startup/linkcmds | 173 ++++++++ c/src/lib/libbsp/sparc/leon/startup/setvec.c | 72 ++++ c/src/lib/libbsp/sparc/leon/startup/spurious.c | 173 ++++++++ c/src/lib/libbsp/sparc/leon/timer/.cvsignore | 2 + c/src/lib/libbsp/sparc/leon/timer/Makefile.am | 33 ++ c/src/lib/libbsp/sparc/leon/timer/timer.c | 84 ++++ c/src/lib/libbsp/sparc/leon/times | 193 +++++++++ c/src/lib/libbsp/sparc/leon/tools/.cvsignore | 14 + c/src/lib/libbsp/sparc/leon/tools/Makefile.am | 21 + c/src/lib/libbsp/sparc/leon/tools/configure.in | 22 ++ c/src/lib/libbsp/sparc/leon/tools/runtest.in | 312 +++++++++++++++ c/src/lib/libbsp/sparc/leon/wrapup/.cvsignore | 2 + c/src/lib/libbsp/sparc/leon/wrapup/Makefile.am | 40 ++ 40 files changed, 3121 insertions(+) create mode 100644 c/src/lib/libbsp/sparc/leon/.cvsignore create mode 100644 c/src/lib/libbsp/sparc/leon/ChangeLog create mode 100644 c/src/lib/libbsp/sparc/leon/Makefile.am create mode 100644 c/src/lib/libbsp/sparc/leon/README create mode 100644 c/src/lib/libbsp/sparc/leon/bsp_specs create mode 100644 c/src/lib/libbsp/sparc/leon/clock/.cvsignore create mode 100644 c/src/lib/libbsp/sparc/leon/clock/Makefile.am create mode 100644 c/src/lib/libbsp/sparc/leon/clock/ckinit.c create mode 100644 c/src/lib/libbsp/sparc/leon/configure.in create mode 100644 c/src/lib/libbsp/sparc/leon/console/.cvsignore create mode 100644 c/src/lib/libbsp/sparc/leon/console/Makefile.am create mode 100644 c/src/lib/libbsp/sparc/leon/console/console.c create mode 100644 c/src/lib/libbsp/sparc/leon/console/consolereserveresources.c create mode 100644 c/src/lib/libbsp/sparc/leon/console/debugputs.c create mode 100644 c/src/lib/libbsp/sparc/leon/gnatsupp/.cvsignore create mode 100644 c/src/lib/libbsp/sparc/leon/gnatsupp/Makefile.am create mode 100644 c/src/lib/libbsp/sparc/leon/gnatsupp/gnatsupp.c create mode 100644 c/src/lib/libbsp/sparc/leon/include/.cvsignore create mode 100644 c/src/lib/libbsp/sparc/leon/include/Makefile.am create mode 100644 c/src/lib/libbsp/sparc/leon/include/bsp.h create mode 100644 c/src/lib/libbsp/sparc/leon/include/coverhd.h create mode 100644 c/src/lib/libbsp/sparc/leon/include/leon.h create mode 100644 c/src/lib/libbsp/sparc/leon/start/.cvsignore create mode 100644 c/src/lib/libbsp/sparc/leon/start/Makefile.am create mode 100644 c/src/lib/libbsp/sparc/leon/startup/.cvsignore create mode 100644 c/src/lib/libbsp/sparc/leon/startup/Makefile.am create mode 100644 c/src/lib/libbsp/sparc/leon/startup/boardinit.S create mode 100644 c/src/lib/libbsp/sparc/leon/startup/linkcmds create mode 100644 c/src/lib/libbsp/sparc/leon/startup/setvec.c create mode 100644 c/src/lib/libbsp/sparc/leon/startup/spurious.c create mode 100644 c/src/lib/libbsp/sparc/leon/timer/.cvsignore create mode 100644 c/src/lib/libbsp/sparc/leon/timer/Makefile.am create mode 100644 c/src/lib/libbsp/sparc/leon/timer/timer.c create mode 100644 c/src/lib/libbsp/sparc/leon/times create mode 100644 c/src/lib/libbsp/sparc/leon/tools/.cvsignore create mode 100644 c/src/lib/libbsp/sparc/leon/tools/Makefile.am create mode 100644 c/src/lib/libbsp/sparc/leon/tools/configure.in create mode 100644 c/src/lib/libbsp/sparc/leon/tools/runtest.in create mode 100644 c/src/lib/libbsp/sparc/leon/wrapup/.cvsignore create mode 100644 c/src/lib/libbsp/sparc/leon/wrapup/Makefile.am (limited to 'c/src/lib/libbsp/sparc/leon') diff --git a/c/src/lib/libbsp/sparc/leon/.cvsignore b/c/src/lib/libbsp/sparc/leon/.cvsignore new file mode 100644 index 0000000000..525275c115 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/.cvsignore @@ -0,0 +1,13 @@ +Makefile +Makefile.in +aclocal.m4 +config.cache +config.guess +config.log +config.status +config.sub +configure +depcomp +install-sh +missing +mkinstalldirs diff --git a/c/src/lib/libbsp/sparc/leon/ChangeLog b/c/src/lib/libbsp/sparc/leon/ChangeLog new file mode 100644 index 0000000000..8f7bbd2dad --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/ChangeLog @@ -0,0 +1,16 @@ +2000-11-13 Jiri Gaisler + + * .cvsignore, ChangeLog, Makefile.am, README, bsp_specs, + configure.in, times, 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/bsp.h, + include/coverhd.h, include/leon.h, start/.cvsignore, + start/Makefile.am, startup/.cvsignore, startup/Makefile.am, + startup/boardinit.S, startup/linkcmds, startup/setvec.c, + startup/spurious.c, timer/.cvsignore, timer/Makefile.am, + timer/timer.c, tools/.cvsignore, tools/Makefile.am, + tools/configure.in, tools/runtest.in, wrapup/.cvsignore, + wrapup/Makefile.am: New file. diff --git a/c/src/lib/libbsp/sparc/leon/Makefile.am b/c/src/lib/libbsp/sparc/leon/Makefile.am new file mode 100644 index 0000000000..0e9ca9b05b --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/Makefile.am @@ -0,0 +1,17 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 +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 console clock timer 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/leon/README b/c/src/lib/libbsp/sparc/leon/README new file mode 100644 index 0000000000..93f19bb383 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/README @@ -0,0 +1,80 @@ +# +# Description of SIS as related to this BSP +# +# $Id$ +# + +BSP NAME: sis +BOARD: any based on the European Space Agency's ERC32 +BUS: N/A +CPU FAMILY: sparc +CPU: ERC32 (SPARC V7 + on-CPU peripherals) + based on Cypress 601/602 +COPROCESSORS: on-chip 602 compatible FPU +MODE: 32 bit mode + +DEBUG MONITOR: none + +PERIPHERALS +=========== +TIMERS: + NAME: General Purpose Timer + RESOLUTION: 50 nanoseconds - 12.8 microseconds + NAME: Real Time Clock Timer + RESOLUTION: 50 nanoseconds - 3.2768 milliseconds + NAME: Watchdog Timer + RESOLUTION: XXX +SERIAL PORTS: 2 using on-chip UART +REAL-TIME CLOCK: none +DMA: on-chip +VIDEO: none +SCSI: none +NETWORKING: none + +DRIVER INFORMATION +================== +CLOCK DRIVER: ERC32 internal Real Time Clock Timer +IOSUPP DRIVER: N/A +SHMSUPP: N/A +TIMER DRIVER: ERC32 internal General Purpose Timer +CONSOLE DRIVER: ERC32 internal UART + +STDIO +===== +PORT: Channel A +ELECTRICAL: na since using simulator +BAUD: na +BITS PER CHARACTER: na +PARITY: na +STOP BITS: na + +Notes +===== + +ERC32 BSP only supports single processor operations. + +A nice feature of this BSP is that the RAM and PROM size are set in the +linkcmds file and the startup code programs the Memory Configuration +Register based on those sizes. + +The Watchdog Timer is disabled. + +This code was developed and tested entirely using the SPARC Instruction +Simulator (SIS) for the ERC32. All tests were known to run correctly +against sis v1.7. + + +Memory Map +========== + +0x00000000 - 0x00000000 + _PROM_SIZE code and initialized data +0x01f80000 on chip peripherals +0x00000000 - 0x02000000 + _RAM_SIZE destination for initialized data + BSS (i.e. unitialized data) + C Heap (i.e. malloc area) + RTEMS Workspace + +The C heap is assigned all memory between the end of the BSS and the +RTEMS Workspace. The size of the RTEMS Workspace is based on that +specified in the application's configuration table. + diff --git a/c/src/lib/libbsp/sparc/leon/bsp_specs b/c/src/lib/libbsp/sparc/leon/bsp_specs new file mode 100644 index 0000000000..b4b9989da4 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/bsp_specs @@ -0,0 +1,26 @@ +%rename cpp old_cpp +%rename lib old_lib +%rename endfile old_endfile +%rename startfile old_startfile +%rename link old_link + +*cpp: +%(old_cpp) %{qrtems: -D__embedded__} -Asystem(embedded) + +*endfile: +crtend.o%s crtn.o%s + +*lib: +%{!qrtems: %(old_lib)} %{qrtems: --start-group \ +%{!qrtems_debug: -lrtemsall} %{qrtems_debug: -lrtemsall_g} \ +-lc -lgcc --end-group \ +%{!qnolinkcmds: -T linkcmds%s}} + +*startfile: +%{!qrtems: %(old_startfile)} %{qrtems: \ +%{!qrtems_debug: start.o%s 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/leon/clock/.cvsignore b/c/src/lib/libbsp/sparc/leon/clock/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/clock/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sparc/leon/clock/Makefile.am b/c/src/lib/libbsp/sparc/leon/clock/Makefile.am new file mode 100644 index 0000000000..bb7f99ff8d --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/clock/Makefile.am @@ -0,0 +1,33 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +PGM = $(ARCH)/clock.rel + +C_FILES = ckinit.c +C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) + +OBJS = $(C_O_FILES) + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +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/leon/clock/ckinit.c b/c/src/lib/libbsp/sparc/leon/clock/ckinit.c new file mode 100644 index 0000000000..ed8c4d033c --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/clock/ckinit.c @@ -0,0 +1,250 @@ +/* + * 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). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * 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 + +#include +#include + +/* + * 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; + +/* + * 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 +) +{ + Clock_driver_ticks = 0; + + if ( BSP_Configuration.ticks_per_timeslice ) { + Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 ); + + LEON_REG.Timer_Reload_1 = CPU_SPARC_CLICKS_PER_TICK - 1; + + LEON_REG.Timer_Control_1 = ( + LEON_REG_TIMER_COUNTER_ENABLE_COUNTING | + LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO | + LEON_REG_TIMER_COUNTER_LOAD_COUNTER + ); + + 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_INTERRUPT_TIMER1 ); + + LEON_REG.Timer_Control_1 = 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(CLOCK_VECTOR); + } + else if (args->command == rtems_build_name('N', 'E', 'W', ' ')) + { + rtems_interrupt_disable( isrlevel ); + (void) set_vector( args->buffer, CLOCK_VECTOR, 1 ); + rtems_interrupt_enable( isrlevel ); + } + +done: + return RTEMS_SUCCESSFUL; +} diff --git a/c/src/lib/libbsp/sparc/leon/configure.in b/c/src/lib/libbsp/sparc/leon/configure.in new file mode 100644 index 0000000000..429b68b168 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/configure.in @@ -0,0 +1,41 @@ +dnl Process this file with autoconf to produce a configure script. +dnl +dnl $Id$ + +AC_PREREQ(2.13) +AC_INIT(bsp_specs) +RTEMS_TOP(../../../../../..) +AC_CONFIG_AUX_DIR(../../../../../..) + +RTEMS_CANONICAL_TARGET_CPU +AM_INIT_AUTOMAKE(rtems-c-src-lib-libbsp-sparc-leon,$RTEMS_VERSION,no) +AM_MAINTAINER_MODE + +RTEMS_PROG_CC_FOR_TARGET +RTEMS_CANONICALIZE_TOOLS + +RTEMS_ENV_RTEMSBSP +RTEMS_CHECK_CUSTOM_BSP(RTEMS_BSP) +RTEMS_CHECK_BSP_CACHE(RTEMS_BSP) +RTEMS_CHECK_NETWORKING +RTEMS_CANONICAL_HOST + +dnl AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes") + +RTEMS_CONFIG_BUILD_SUBDIRS(tools) + +RTEMS_PROJECT_ROOT + +# Explicitly list all Makefiles here +AC_OUTPUT( +Makefile +clock/Makefile +console/Makefile +gnatsupp/Makefile +include/Makefile +start/Makefile +startup/Makefile +timer/Makefile +wrapup/Makefile) + +RTEMS_OUTPUT_BUILD_SUBDIRS(RTEMS_BUILD_SUBDIRS) diff --git a/c/src/lib/libbsp/sparc/leon/console/.cvsignore b/c/src/lib/libbsp/sparc/leon/console/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/console/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sparc/leon/console/Makefile.am b/c/src/lib/libbsp/sparc/leon/console/Makefile.am new file mode 100644 index 0000000000..dfce241bab --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/console/Makefile.am @@ -0,0 +1,33 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +PGM = $(ARCH)/console.rel + +C_FILES = console.c consolereserveresources.c debugputs.c +C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) + +OBJS = $(C_O_FILES) + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +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/leon/console/console.c b/c/src/lib/libbsp/sparc/leon/console/console.c new file mode 100644 index 0000000000..00730f5718 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/console/console.c @@ -0,0 +1,439 @@ +/* + * 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). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include +#include +#include +#include + +/* + * 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 */ + +/* + * Interrupt driven console IO + */ + +#if (CONSOLE_USE_INTERRUPTS) + +/* + * Buffers between task and ISRs + */ + +#include + +Ring_buffer_t TX_Buffer[ 2 ]; +boolean Is_TX_active[ 2 ]; + +void *console_termios_data[ 2 ]; + +/* + * console_isr_a + * + * This routine is the console interrupt handler for Channel 1. + * + * Input parameters: + * vector - vector number + * + * Output parameters: NONE + * + * Return values: NONE + */ + +rtems_isr console_isr_a( + rtems_vector_number vector +) +{ + char ch; + int UStat; + + if ( (UStat = LEON_REG.UART_Status_1) & LEON_REG_UART_STATUS_DR ) { + if (UStat & LEON_REG_UART_STATUS_ERR) { + LEON_REG.UART_Status_1 = LEON_REG_UART_STATUS_CLR; + } + ch = LEON_REG.UART_Channel_1; + + rtems_termios_enqueue_raw_characters( console_termios_data[ 0 ], &ch, 1 ); + } + + if ( LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE ) { + if ( !Ring_buffer_Is_empty( &TX_Buffer[ 0 ] ) ) { + Ring_buffer_Remove_character( &TX_Buffer[ 0 ], ch ); + LEON_REG.UART_Channel_1 = (unsigned32) ch; + } else + Is_TX_active[ 0 ] = FALSE; + } + + LEON_Clear_interrupt( LEON_INTERRUPT_UART_1_RX_TX ); +} + +/* + * console_isr_b + * + * This routine is the console interrupt handler for Channel 2. + * + * Input parameters: + * vector - vector number + * + * Output parameters: NONE + * + * Return values: NONE + */ + +rtems_isr console_isr_b( + rtems_vector_number vector +) +{ + char ch; + int UStat; + + if ( (UStat = LEON_REG.UART_Status_2) & LEON_REG_UART_STATUS_DR ) { + if (UStat & LEON_REG_UART_STATUS_ERR) { + LEON_REG.UART_Status_2 = LEON_REG_UART_STATUS_CLR; + } + ch = LEON_REG.UART_Channel_2; + rtems_termios_enqueue_raw_characters( console_termios_data[ 1 ], &ch, 1 ); + + } + + if ( LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE ) { + if ( !Ring_buffer_Is_empty( &TX_Buffer[ 1 ] ) ) { + Ring_buffer_Remove_character( &TX_Buffer[ 1 ], ch ); + LEON_REG.UART_Channel_2 = (unsigned32) ch; + } else + Is_TX_active[ 1 ] = FALSE; + } + + LEON_Clear_interrupt( LEON_INTERRUPT_UART_2_RX_TX ); +} + +/* + * console_exit + * + * This routine allows the console to exit by masking its associated interrupt + * vectors. + * + * Input parameters: NONE + * + * Output parameters: NONE + * + * Return values: NONE + */ + +void console_exit() +{ + rtems_unsigned32 port; + rtems_unsigned32 ch; + + /* + * Although the interrupts for the UART are unmasked, the PIL is set to + * disable all external interrupts. So we might as well do this first. + */ + + LEON_Mask_interrupt( LEON_INTERRUPT_UART_1_RX_TX ); + LEON_Mask_interrupt( LEON_INTERRUPT_UART_2_RX_TX ); + + for ( port=0 ; port <= 1 ; port++ ) { + while ( !Ring_buffer_Is_empty( &TX_Buffer[ port ] ) ) { + Ring_buffer_Remove_character( &TX_Buffer[ port ], ch ); + console_outbyte_polled( port, ch ); + } + } + + /* + * Now wait for all the data to actually get out ... the send register + * should be empty. + */ + + while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) != + LEON_REG_UART_STATUS_THE ); + + while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) != + LEON_REG_UART_STATUS_THE ); + + LEON_REG.UART_Control_1 = 0; + LEON_REG.UART_Control_2 = 0; + LEON_REG.UART_Status_1 = 0; + LEON_REG.UART_Status_2 = 0; + + +} + +#define CONSOLE_UART_1_TRAP LEON_TRAP_TYPE( LEON_INTERRUPT_UART_1_RX_TX ) +#define CONSOLE_UART_2_TRAP LEON_TRAP_TYPE( LEON_INTERRUPT_UART_2_RX_TX ) + +/* + * console_initialize_interrupts + * + * This routine initializes the console's receive and transmit + * ring buffers and loads the appropriate vectors to handle the interrupts. + * + * Input parameters: NONE + * + * Output parameters: NONE + * + * Return values: NONE + */ + +#ifdef RDB_BREAK_IN + extern unsigned32 trap_table[]; +#endif + +void console_initialize_interrupts( void ) +{ + Ring_buffer_Initialize( &TX_Buffer[ 0 ] ); + Ring_buffer_Initialize( &TX_Buffer[ 1 ] ); + + Is_TX_active[ 0 ] = FALSE; + Is_TX_active[ 1 ] = FALSE; + + atexit( console_exit ); + + LEON_REG.UART_Control_1 |= LEON_REG_UART_CTRL_RI | LEON_REG_UART_CTRL_TI; + LEON_REG.UART_Control_2 |= LEON_REG_UART_CTRL_RI | LEON_REG_UART_CTRL_TI; + + set_vector( console_isr_a, CONSOLE_UART_1_TRAP, 1 ); +#ifdef RDB_BREAK_IN + if (trap_table[0x150/4] == 0x91d02000) +#endif + set_vector( console_isr_b, CONSOLE_UART_2_TRAP, 1 ); +} + +/* + * console_outbyte_interrupt + * + * This routine transmits a character out. + * + * Input parameters: + * port - port to transmit character to + * ch - character to be transmitted + * + * Output parameters: NONE + * + * Return values: NONE + */ + +void console_outbyte_interrupt( + int port, + char ch +) +{ + /* + * If this is the first character then we need to prime the pump + */ + + if ( Is_TX_active[ port ] == FALSE ) { + Is_TX_active[ port ] = TRUE; + console_outbyte_polled( port, ch ); + return; + } + + while ( Ring_buffer_Is_full( &TX_Buffer[ port ] ) ); + + Ring_buffer_Add_character( &TX_Buffer[ port ], ch ); +} + +#endif /* CONSOLE_USE_INTERRUPTS */ + +/* + * Console Termios Support Entry Points + * + */ + +int console_write_support (int minor, const char *buf, int len) +{ + int nwrite = 0; + + while (nwrite < len) { +#if (CONSOLE_USE_INTERRUPTS) + console_outbyte_interrupt( minor, *buf++ ); +#else + console_outbyte_polled( minor, *buf++ ); +#endif + nwrite++; + } + return nwrite; +} + +void console_reserve_resources( + rtems_configuration_table *configuration +) +{ + rtems_termios_reserve_resources( configuration, 2 ); +} + +/* + * Console Device Driver Entry Points + * + */ + +rtems_device_driver console_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +) +{ + rtems_status_code status; + + rtems_termios_initialize(); + + /* + * Register Device Names + */ + + status = rtems_io_register_name( "/dev/console", major, 0 ); + if (status != RTEMS_SUCCESSFUL) + rtems_fatal_error_occurred(status); + + status = rtems_io_register_name( "/dev/console_b", major, 1 ); + if (status != RTEMS_SUCCESSFUL) + rtems_fatal_error_occurred(status); + + /* + * Initialize Hardware + */ + + LEON_REG.UART_Control_1 = LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE; + LEON_REG.UART_Control_2 = LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE | + LEON_REG_UART_CTRL_RI; /* rx irq default enable for remote debugger */ + LEON_REG.UART_Status_1 = 0; + LEON_REG.UART_Status_2 = 0; +#if (CONSOLE_USE_INTERRUPTS) + console_initialize_interrupts(); +#endif + + return RTEMS_SUCCESSFUL; +} + +rtems_device_driver console_open( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg +) +{ + rtems_status_code sc; +#if (CONSOLE_USE_INTERRUPTS) + rtems_libio_open_close_args_t *args = arg; + static const rtems_termios_callbacks intrCallbacks = { + NULL, /* firstOpen */ + NULL, /* lastClose */ + NULL, /* pollRead */ + console_write_support, /* write */ + NULL, /* setAttributes */ + NULL, /* stopRemoteTx */ + NULL, /* startRemoteTx */ + 0 /* outputUsesInterrupts */ + }; +#else + 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 */ + }; +#endif + + assert( minor <= 1 ); + if ( minor > 2 ) + return RTEMS_INVALID_NUMBER; + +#if (CONSOLE_USE_INTERRUPTS) + sc = rtems_termios_open (major, minor, arg, &intrCallbacks); + + console_termios_data[ minor ] = args->iop->data1; +#else + sc = rtems_termios_open (major, minor, arg, &pollCallbacks); +#endif + + 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); +} + diff --git a/c/src/lib/libbsp/sparc/leon/console/consolereserveresources.c b/c/src/lib/libbsp/sparc/leon/console/consolereserveresources.c new file mode 100644 index 0000000000..b5df942a8e --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/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.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include +#include +#include +#include + +int console_reserve_resources_removed; diff --git a/c/src/lib/libbsp/sparc/leon/console/debugputs.c b/c/src/lib/libbsp/sparc/leon/console/debugputs.c new file mode 100644 index 0000000000..71b5c8debf --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/console/debugputs.c @@ -0,0 +1,109 @@ +/* + * 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.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include +#include +#include +#include + +/* + * console_outbyte_polled + * + * This routine transmits a character using polling. + */ + +void console_outbyte_polled( + int port, + char ch +) +{ + if ( port == 0 ) { + while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) == 0 ); + LEON_REG.UART_Channel_1 = (int) ch; + return; + } + + while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) == 0 ); + LEON_REG.UART_Channel_2 = (int) ch; +} + +/* + * console_inbyte_nonblocking + * + * This routine polls for a character. + */ + +int console_inbyte_nonblocking( int port ) +{ + + switch (port) { + + case 0: + if (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_ERR) { + LEON_REG.UART_Status_1 = ~LEON_REG_UART_STATUS_ERR; + } + + if ((LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_DR) == 0) + return -1; + return (int) LEON_REG.UART_Channel_1; + return 1; + + case 1: + if (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_ERR) { + LEON_REG.UART_Status_2 = ~LEON_REG_UART_STATUS_ERR; + } + + if ((LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_DR) == 0) + return -1; + return (int) LEON_REG.UART_Channel_2; + + default: + 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 ); + LEON_REG.UART_Control_1 = 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' ); + LEON_Restore_interrupt( LEON_INTERRUPT_UART_1_RX_TX, old_level ); +} diff --git a/c/src/lib/libbsp/sparc/leon/gnatsupp/.cvsignore b/c/src/lib/libbsp/sparc/leon/gnatsupp/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/gnatsupp/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sparc/leon/gnatsupp/Makefile.am b/c/src/lib/libbsp/sparc/leon/gnatsupp/Makefile.am new file mode 100644 index 0000000000..f061171fa9 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/gnatsupp/Makefile.am @@ -0,0 +1,33 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +VPATH = @srcdir@:@srcdir@/../../shared:@srcdir@/../../../shared + +PGM = $(ARCH)/gnatsupp.rel + +C_FILES = gnatsupp.c gnatcommon.c +C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) + +OBJS = $(C_O_FILES) + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +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/leon/gnatsupp/gnatsupp.c b/c/src/lib/libbsp/sparc/leon/gnatsupp/gnatsupp.c new file mode 100644 index 0000000000..347435d950 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/gnatsupp/gnatsupp.c @@ -0,0 +1,17 @@ +/* + * + * Support for gnat/rtems interrupts and exception handling. + * Jiri Gaisler, ESA/ESTEC, 17-02-1999. + * + */ + +/* + * 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/leon/include/.cvsignore b/c/src/lib/libbsp/sparc/leon/include/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/include/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sparc/leon/include/Makefile.am b/c/src/lib/libbsp/sparc/leon/include/Makefile.am new file mode 100644 index 0000000000..1ceb66f5d0 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/include/Makefile.am @@ -0,0 +1,22 @@ +include $(top_srcdir)/../../../../../../automake/compile.am +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +H_FILES = bsp.h coverhd.h leon.h + +$(PROJECT_INCLUDE): + $(mkinstalldirs) $@ + +$(PROJECT_INCLUDE)/%.h: %.h + $(INSTALL_DATA) $< $@ + +PREINSTALL_FILES += $(PROJECT_INCLUDE) $(H_FILES:%.h=$(PROJECT_INCLUDE)/%.h) + +all-local: $(PREINSTALL_FILES) + +EXTRA_DIST = bsp.h coverhd.h + +include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/sparc/leon/include/bsp.h b/c/src/lib/libbsp/sparc/leon/include/bsp.h new file mode 100644 index 0000000000..4bf594111c --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/include/bsp.h @@ -0,0 +1,184 @@ +/* bsp.h + * + * This include file contains all SPARC simulator definitions. + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * 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 +#include +#include +#include + +#include + +/* + * 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) + + +/* + * 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 LEON_INTERRUPT_EXTERNAL_1 +#define TEST_VECTOR LEON_TRAP_TYPE( TEST_INTERRUPT_SOURCE ) + +#define MUST_WAIT_FOR_INTERRUPT 1 + +#define Install_tm27_vector( handler ) \ + set_vector( (handler), TEST_VECTOR, 1 ); + +#define Cause_tm27_intr() \ + do { \ + LEON_Force_interrupt( TEST_INTERRUPT_SOURCE ); \ + 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/leon/include/coverhd.h b/c/src/lib/libbsp/sparc/leon/include/coverhd.h new file mode 100644 index 0000000000..77fac56517 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/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.OARcorp.com/rtems/license.html. + * + * 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/leon/include/leon.h b/c/src/lib/libbsp/sparc/leon/include/leon.h new file mode 100644 index 0000000000..5c5163f80f --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/include/leon.h @@ -0,0 +1,380 @@ +/* erc32.h + * + * This include file contains information pertaining to the LEON-1. + * The LEON-1 is a custom SPARC V7 implementation. + * This CPU has a number of on-board peripherals and + * was developed by the European Space Agency to target space applications. + * + * NOTE: Other than where absolutely required, this version currently + * supports only the peripherals and bits used by the basic board + * support package. This includes at least significant pieces of + * the following items: + * + * + UART Channels A and B + * + Real Time Clock + * + Memory Control Register + * + Interrupt Control + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * 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$ + */ + +#ifndef _INCLUDE_LEON_h +#define _INCLUDE_LEON_h + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Interrupt Sources + * + * The interrupt source numbers directly map to the trap type and to + * the bits used in the Interrupt Clear, Interrupt Force, Interrupt Mask, + * and the Interrupt Pending Registers. + */ + +#define LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR 1 +#define LEON_INTERRUPT_UART_2_RX_TX 2 +#define LEON_INTERRUPT_UART_1_RX_TX 3 +#define LEON_INTERRUPT_EXTERNAL_0 4 +#define LEON_INTERRUPT_EXTERNAL_1 5 +#define LEON_INTERRUPT_EXTERNAL_2 6 +#define LEON_INTERRUPT_EXTERNAL_3 7 +#define LEON_INTERRUPT_TIMER1 8 +#define LEON_INTERRUPT_TIMER2 9 +#define LEON_INTERRUPT_EMPTY1 10 +#define LEON_INTERRUPT_EMPTY2 11 +#define LEON_INTERRUPT_EMPTY3 12 +#define LEON_INTERRUPT_EMPTY4 13 +#define LEON_INTERRUPT_EMPTY5 14 +#define LEON_INTERRUPT_EMPTY6 15 + +#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) >= LEON_TRAP_TYPE( LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR ) && \ + (_trap) <= LEON_TRAP_TYPE( LEON_INTERRUPT_EMPTY6 ) ) + +/* + * 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. + */ + +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; + +#endif + +/* + * The following constants are intended to be used ONLY in assembly + * language files. + * + * NOTE: The intended style of usage is to load the address of LEON REGS + * into a register and then use these as displacements from + * that register. + */ + +#ifdef ASM + +#define LEON_REG_MEMCFG1_OFFSET 0x00 +#define LEON_REG_MEMCFG2_OFFSET 0x04 +#define LEON_REG_EDACCTRL_OFFSET 0x08 +#define LEON_REG_FAILADDR_OFFSET 0x0C +#define LEON_REG_MEMSTATUS_OFFSET 0x10 +#define LEON_REG_CACHECTRL_OFFSET 0x14 +#define LEON_REG_POWERDOWN_OFFSET 0x18 +#define LEON_REG_WRITEPROT1_OFFSET 0x1C +#define LEON_REG_WRITEPROT2_OFFSET 0x20 +#define LEON_REG_LEONCONF_OFFSET 0x24 +#define LEON_REG_UNIMPLEMENTED_2_OFFSET 0x28 +#define LEON_REG_UNIMPLEMENTED_3_OFFSET 0x2C +#define LEON_REG_UNIMPLEMENTED_4_OFFSET 0x30 +#define LEON_REG_UNIMPLEMENTED_5_OFFSET 0x34 +#define LEON_REG_UNIMPLEMENTED_6_OFFSET 0x38 +#define LEON_REG_UNIMPLEMENTED_7_OFFSET 0x3C +#define LEON_REG_TIMERCNT1_OFFSET 0x40 +#define LEON_REG_TIMERLOAD1_OFFSET 0x44 +#define LEON_REG_TIMERCTRL1_OFFSET 0x48 +#define LEON_REG_WDOG_OFFSET 0x4C +#define LEON_REG_TIMERCNT2_OFFSET 0x50 +#define LEON_REG_TIMERLOAD2_OFFSET 0x54 +#define LEON_REG_TIMERCTRL2_OFFSET 0x58 +#define LEON_REG_UNIMPLEMENTED_8_OFFSET 0x5C +#define LEON_REG_SCALERCNT_OFFSET 0x60 +#define LEON_REG_SCALER_LOAD_OFFSET 0x64 +#define LEON_REG_UNIMPLEMENTED_9_OFFSET 0x68 +#define LEON_REG_UNIMPLEMENTED_10_OFFSET 0x6C +#define LEON_REG_UARTDATA1_OFFSET 0x70 +#define LEON_REG_UARTSTATUS1_OFFSET 0x74 +#define LEON_REG_UARTCTRL1_OFFSET 0x78 +#define LEON_REG_UARTSCALER1_OFFSET 0x7C +#define LEON_REG_UARTDATA2_OFFSET 0x80 +#define LEON_REG_UARTSTATUS2_OFFSET 0x84 +#define LEON_REG_UARTCTRL2_OFFSET 0x88 +#define LEON_REG_UARTSCALER2_OFFSET 0x8C +#define LEON_REG_IRQMASK_OFFSET 0x90 +#define LEON_REG_IRQPEND_OFFSET 0x94 +#define LEON_REG_IRQFORCE_OFFSET 0x98 +#define LEON_REG_IRQCLEAR_OFFSET 0x9C +#define LEON_REG_PIODATA_OFFSET 0xA0 +#define LEON_REG_PIODIR_OFFSET 0xA4 +#define LEON_REG_PIOIRQ_OFFSET 0xA8 +#define LEON_REG_SIM_RAM_SIZE_OFFSET 0xF4 +#define LEON_REG_SIM_ROM_SIZE_OFFSET 0xF8 + +#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 */ + +#ifndef ASM + +/* + * 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. + */ + +extern LEON_Register_Map LEON_REG; + +/* + * 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 { \ + LEON_REG.Interrupt_Clear = (1 << (_source)); \ + } while (0) + +#define LEON_Force_interrupt( _source ) \ + do { \ + LEON_REG.Interrupt_Force = (1 << (_source)); \ + } while (0) + +#define LEON_Is_interrupt_pending( _source ) \ + (LEON_REG.Interrupt_Pending & (1 << (_source))) + +#define LEON_Is_interrupt_masked( _source ) \ + (LEON_REG.Interrupt_Masked & (1 << (_source))) + +#define LEON_Mask_interrupt( _source ) \ + do { \ + unsigned32 _level; \ + \ + _level = sparc_disable_interrupts(); \ + LEON_REG.Interrupt_Mask &= ~(1 << (_source)); \ + sparc_enable_interrupts( _level ); \ + } while (0) + +#define LEON_Unmask_interrupt( _source ) \ + do { \ + unsigned32 _level; \ + \ + _level = sparc_disable_interrupts(); \ + LEON_REG.Interrupt_Mask |= (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) = LEON_REG.Interrupt_Mask; \ + LEON_REG.Interrupt_Mask = _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(); \ + LEON_REG.Interrupt_Mask = \ + (LEON_REG.Interrupt_Mask & ~_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/leon/start/.cvsignore b/c/src/lib/libbsp/sparc/leon/start/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/start/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sparc/leon/start/Makefile.am b/c/src/lib/libbsp/sparc/leon/start/Makefile.am new file mode 100644 index 0000000000..ec9d9e7175 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/start/Makefile.am @@ -0,0 +1,35 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +VPATH = @srcdir@:@srcdir@/../../shared + +PGM = $(ARCH)/start.o + +S_FILES = start.S +S_O_FILES = $(S_FILES:%.S=$(ARCH)/%.o) + +OBJS = $(S_O_FILES) + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../../../../../../automake/compile.am +include $(top_srcdir)/../../../../../../automake/lib.am + +# +# (OPTIONAL) Add local stuff here using += +# + +$(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).o: $(PGM) + $(INSTALL_DATA) $< $@ + +TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).o + +all-local: $(ARCH) $(OBJS) $(PGM) $(TMPINSTALL_FILES) + +.PRECIOUS: $(PGM) + +EXTRA_DIST = start.S + +include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/sparc/leon/startup/.cvsignore b/c/src/lib/libbsp/sparc/leon/startup/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/startup/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sparc/leon/startup/Makefile.am b/c/src/lib/libbsp/sparc/leon/startup/Makefile.am new file mode 100644 index 0000000000..b9784d9030 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/startup/Makefile.am @@ -0,0 +1,45 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +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)/%.o) + +S_FILES = boardinit.S +S_O_FILES = $(S_FILES:%.S=$(ARCH)/%.o) + +OBJS = $(C_O_FILES) $(S_O_FILES) + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +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) + +$(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 boardinit.S + +include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/sparc/leon/startup/boardinit.S b/c/src/lib/libbsp/sparc/leon/startup/boardinit.S new file mode 100644 index 0000000000..54fa6f576b --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/startup/boardinit.S @@ -0,0 +1,64 @@ +/* + * boardinit.s + * + * Start code for the LEON. + * + * $Id$ + */ + +#include +#include + + .global __bsp_board_init + +__bsp_board_init: + +/* Check if LEON is initialised. If not, this means that we are + running on the simulator. Initiate some of the parameters + that are done by the boot-prom otherwise. +*/ + + set SYM(LEON_REG), %l0 ! %l0 = base address of peripherals + ld [%l0+LEON_REG_CACHECTRL_OFFSET], %l1 ! Check if LEON has been initialised + andcc %l1, 3, %g0 + bne 2f + nop + + + flush + set 0x1000f, %l1 + st %l1, [%l0 + LEON_REG_CACHECTRL_OFFSET] ! enable caches + ld [%l0 + LEON_REG_SIM_ROM_SIZE_OFFSET], %g1 ! load simulator rom size + clr %l2 + srl %g1, 13, %g1 ! calculate appropriate rom size +1: + srl %g1, 1, %g1 + tst %g1 + bne,a 1b + inc %l2 + sll %l2, 14, %l2 + st %l2, [%l0 + LEON_REG_MEMCFG1_OFFSET] ! set prom size in memcfg1 + + set 0, %l2 + ld [%l0 + LEON_REG_SIM_RAM_SIZE_OFFSET], %g2 ! load simulator ram size + srl %g2, 13, %g1 ! calculate appropriate ram size +1: + srl %g1, 1, %g1 + tst %g1 + bne,a 1b + inc %l2 + sll %l2, 9, %l2 + st %l2, [%l0 + LEON_REG_MEMCFG2_OFFSET] ! set ram size in memcfg2 + + set SYM(RAM_START), %l1 ! Cannot use RAM_END due to bug in linker + set SYM(RAM_SIZE), %l2 + add %l1, %l2, %sp + set 49, %l2 + st %l2, [%l0 + LEON_REG_SCALER_LOAD_OFFSET] ! scaler reload register + st %l2, [%l0 + LEON_REG_SCALERCNT_OFFSET] ! scaler counter register + +2: + retl + nop + +/* end of file */ diff --git a/c/src/lib/libbsp/sparc/leon/startup/linkcmds b/c/src/lib/libbsp/sparc/leon/startup/linkcmds new file mode 100644 index 0000000000..02e3cb48f5 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/startup/linkcmds @@ -0,0 +1,173 @@ +/* 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); + + *(.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 + .dynamic : { *(.dynamic) } >ram + .got : { *(.got) } >ram + .plt : { *(.plt) } >ram + .hash : { *(.hash) } >ram + .dynrel : { *(.dynrel) } >ram + .dynsym : { *(.dynsym) } >ram + .dynstr : { *(.dynstr) } >ram + .hash : { *(.hash) } >ram + .data : + { + data_start = .; + _data_start = .; + _sdata = . ; + *(.data) + *(.gnu.linkonce.d*) + *(.gcc_except_table) + . = ALIGN(0x10); + edata = .; + _edata = .; + } > 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/leon/startup/setvec.c b/c/src/lib/libbsp/sparc/leon/startup/setvec.c new file mode 100644 index 0000000000..27adfa7b4b --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/startup/setvec.c @@ -0,0 +1,72 @@ +/* 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). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * 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 + +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; +} + +/* LEON specific power-down function */ + +void _CPU_Thread_Idle_body( void ) +{ + while (1) { + LEON_REG.Power_Down = 0; /* value is irrelevant */ + } +} + diff --git a/c/src/lib/libbsp/sparc/leon/startup/spurious.c b/c/src/lib/libbsp/sparc/leon/startup/spurious.c new file mode 100644 index 0000000000..9e8f796bf5 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/startup/spurious.c @@ -0,0 +1,173 @@ +/* + * 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. + * + * This terms of the RTEMS license apply to this file. + * + * $Id$ + */ + +#include + +#include + +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]); + DEBUG_puts( line ); + break; + case 0x0A: + DEBUG_puts( "tag overflow" ); + break; + + /* + * Then the ones defined by the LEON in particular + */ + + 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 = LEON_REG.Interrupt_Mask; + + 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( bsp_spurious_handler, SPARC_SYNCHRONOUS_TRAP( trap ), 1 ); + } + + LEON_REG.Interrupt_Mask = mask; + sparc_enable_interrupts(level); + +} diff --git a/c/src/lib/libbsp/sparc/leon/timer/.cvsignore b/c/src/lib/libbsp/sparc/leon/timer/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/timer/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sparc/leon/timer/Makefile.am b/c/src/lib/libbsp/sparc/leon/timer/Makefile.am new file mode 100644 index 0000000000..53b53ebc99 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/timer/Makefile.am @@ -0,0 +1,33 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +PGM = $(ARCH)/timer.rel + +C_FILES = timer.c +C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) + +OBJS = $(C_O_FILES) + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +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/leon/timer/timer.c b/c/src/lib/libbsp/sparc/leon/timer/timer.c new file mode 100644 index 0000000000..190d4dd313 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/timer/timer.c @@ -0,0 +1,84 @@ +/* timer.c + * + * This file implements a benchmark timer using timer 2. + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * 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 + +rtems_boolean Timer_driver_Find_average_overhead; + +rtems_boolean Timer_driver_Is_initialized = FALSE; + +void Timer_initialize() +{ + /* + * Timer runs long and accurate enough not to require an interrupt. + */ + + if ( Timer_driver_Is_initialized == FALSE ) { + + /* approximately 1 us per countdown */ + LEON_REG.Timer_Counter_2 = 0xffffff; + LEON_REG.Timer_Reload_2 = 0xffffff; + + } else { + Timer_driver_Is_initialized = TRUE; + } + + LEON_REG.Timer_Control_2 = ( + LEON_REG_TIMER_COUNTER_ENABLE_COUNTING | + LEON_REG_TIMER_COUNTER_LOAD_COUNTER + ); + +} + +#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; + + total = LEON_REG.Timer_Counter_2; + + 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; +} + +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/leon/times b/c/src/lib/libbsp/sparc/leon/times new file mode 100644 index 0000000000..1b04728a25 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/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/leon/tools/.cvsignore b/c/src/lib/libbsp/sparc/leon/tools/.cvsignore new file mode 100644 index 0000000000..a15eeb5dc5 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/tools/.cvsignore @@ -0,0 +1,14 @@ +Makefile +Makefile.in +aclocal.m4 +config.cache +config.guess +config.log +config.status +config.sub +configure +depcomp +install-sh +missing +mkinstalldirs +runtest diff --git a/c/src/lib/libbsp/sparc/leon/tools/Makefile.am b/c/src/lib/libbsp/sparc/leon/tools/Makefile.am new file mode 100644 index 0000000000..778c9994ce --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/tools/Makefile.am @@ -0,0 +1,21 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 +ACLOCAL_AMFLAGS = -I ../../../../../../../aclocal + +noinst_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/leon/tools/configure.in b/c/src/lib/libbsp/sparc/leon/tools/configure.in new file mode 100644 index 0000000000..14010bddb7 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/tools/configure.in @@ -0,0 +1,22 @@ +dnl Process this file with autoconf to produce a configure script. +dnl +dnl $Id$ + +AC_INIT(runtest.in) +RTEMS_TOP(../../../../../../..) +AC_CONFIG_AUX_DIR(../../../../../../..) + +RTEMS_CANONICAL_TARGET_CPU + +AM_INIT_AUTOMAKE(rtems-c-src-lib-libbsp-sparc-leon-tools,$RTEMS_VERSION,no) +AM_MAINTAINER_MODE + +RTEMS_PATH_KSH + +RTEMS_PROJECT_ROOT +RTEMS_TOOLPATHS + +# Explicitly list all Makefiles here +AC_OUTPUT( +Makefile +runtest) diff --git a/c/src/lib/libbsp/sparc/leon/tools/runtest.in b/c/src/lib/libbsp/sparc/leon/tools/runtest.in new file mode 100644 index 0000000000..b7c6f723c2 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/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) + 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/leon/wrapup/.cvsignore b/c/src/lib/libbsp/sparc/leon/wrapup/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/wrapup/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sparc/leon/wrapup/Makefile.am b/c/src/lib/libbsp/sparc/leon/wrapup/Makefile.am new file mode 100644 index 0000000000..56ffe742f3 --- /dev/null +++ b/c/src/lib/libbsp/sparc/leon/wrapup/Makefile.am @@ -0,0 +1,40 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +#if HAS_NETWORKING +#NETWORKING_DRIVER = network +#endif + +BSP_PIECES = startup console clock timer gnatsupp $(NETWORK) +# pieces to pick up out of libcpu/sparc +CPU_PIECES = reg_win syscall + +# bummer; have to use $foreach since % pattern subst rules only replace 1x +OBJS = $(foreach piece, $(BSP_PIECES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \ + $(foreach piece, $(CPU_PIECES), ../../../../libcpu/$(RTEMS_CPU)/$(piece)/$(ARCH)/$(piece).rel) +LIB = $(ARCH)/libbsp.a + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../../../../../../automake/compile.am +include $(top_srcdir)/../../../../../../automake/lib.am + +# +# (OPTIONAL) Add local stuff here using += +# + +$(LIB): $(OBJS) + $(make-library) + +$(PROJECT_RELEASE)/lib/libbsp$(LIB_VARIANT).a: $(LIB) + $(INSTALL_DATA) $< $@ + +TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/libbsp$(LIB_VARIANT).a + +all-local: $(ARCH) $(OBJS) $(LIB) $(TMPINSTALL_FILES) + +.PRECIOUS: $(LIB) + +include $(top_srcdir)/../../../../../../automake/local.am -- cgit v1.2.3