From cd67dcaf009326c46d67951976f87a6559ed7928 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 11 Oct 2001 21:04:35 +0000 Subject: 2001-10-11 Alexandra Kossovsky * clock/Makefile.am, clock/ckinit.c, clock/.cvsignore, Makefile.am, README, bsp_specs, console/Makefile.am, console/console.c, console/.cvsignore, include/Makefile.am, include/bsp.h, include/coverhd.h, include/syscall.h, include/ramdisk.h, include/.cvsignore, start/Makefile.am, start/start.S, start/.cvsignore, startup/Makefile.am, startup/bspstart.c, startup/hw_init.c, startup/linkcmds, startup/linkcmds-le, startup/linkcmds-le.coff, startup/.cvsignore, timer/Makefile.am, timer/timer.c, timer/.cvsignore, wrapup/Makefile.am, wrapup/.cvsignore, configure.ac, .cvsignore, ChangeLog: New files. Reviewed and updated to latest automake and autoconf standards by Ralf Corsepius . --- c/src/lib/libbsp/sh/simsh4/.cvsignore | 14 + c/src/lib/libbsp/sh/simsh4/ChangeLog | 15 + c/src/lib/libbsp/sh/simsh4/Makefile.am | 20 + c/src/lib/libbsp/sh/simsh4/README | 47 +++ c/src/lib/libbsp/sh/simsh4/bsp_specs | 22 ++ c/src/lib/libbsp/sh/simsh4/clock/.cvsignore | 2 + c/src/lib/libbsp/sh/simsh4/clock/Makefile.am | 33 ++ c/src/lib/libbsp/sh/simsh4/clock/ckinit.c | 189 +++++++++ c/src/lib/libbsp/sh/simsh4/configure.ac | 35 ++ c/src/lib/libbsp/sh/simsh4/console/.cvsignore | 2 + c/src/lib/libbsp/sh/simsh4/console/Makefile.am | 34 ++ c/src/lib/libbsp/sh/simsh4/console/console.c | 429 +++++++++++++++++++++ c/src/lib/libbsp/sh/simsh4/include/.cvsignore | 2 + c/src/lib/libbsp/sh/simsh4/include/Makefile.am | 16 + c/src/lib/libbsp/sh/simsh4/include/bsp.h | 154 ++++++++ c/src/lib/libbsp/sh/simsh4/include/coverhd.h | 121 ++++++ c/src/lib/libbsp/sh/simsh4/include/ramdisk.h | 55 +++ c/src/lib/libbsp/sh/simsh4/include/syscall.h | 31 ++ c/src/lib/libbsp/sh/simsh4/start/.cvsignore | 2 + c/src/lib/libbsp/sh/simsh4/start/Makefile.am | 31 ++ c/src/lib/libbsp/sh/simsh4/start/start.S | 171 ++++++++ c/src/lib/libbsp/sh/simsh4/startup/.cvsignore | 2 + c/src/lib/libbsp/sh/simsh4/startup/Makefile.am | 43 +++ c/src/lib/libbsp/sh/simsh4/startup/bspstart.c | 141 +++++++ c/src/lib/libbsp/sh/simsh4/startup/hw_init.c | 57 +++ c/src/lib/libbsp/sh/simsh4/startup/linkcmds | 185 +++++++++ c/src/lib/libbsp/sh/simsh4/startup/linkcmds-le | 249 ++++++++++++ .../lib/libbsp/sh/simsh4/startup/linkcmds-le.coff | 186 +++++++++ c/src/lib/libbsp/sh/simsh4/timer/.cvsignore | 2 + c/src/lib/libbsp/sh/simsh4/timer/Makefile.am | 35 ++ c/src/lib/libbsp/sh/simsh4/timer/timer.c | 111 ++++++ c/src/lib/libbsp/sh/simsh4/wrapup/.cvsignore | 2 + c/src/lib/libbsp/sh/simsh4/wrapup/Makefile.am | 40 ++ 33 files changed, 2478 insertions(+) create mode 100644 c/src/lib/libbsp/sh/simsh4/.cvsignore create mode 100644 c/src/lib/libbsp/sh/simsh4/ChangeLog create mode 100644 c/src/lib/libbsp/sh/simsh4/Makefile.am create mode 100644 c/src/lib/libbsp/sh/simsh4/README create mode 100644 c/src/lib/libbsp/sh/simsh4/bsp_specs create mode 100644 c/src/lib/libbsp/sh/simsh4/clock/.cvsignore create mode 100644 c/src/lib/libbsp/sh/simsh4/clock/Makefile.am create mode 100644 c/src/lib/libbsp/sh/simsh4/clock/ckinit.c create mode 100644 c/src/lib/libbsp/sh/simsh4/configure.ac create mode 100644 c/src/lib/libbsp/sh/simsh4/console/.cvsignore create mode 100644 c/src/lib/libbsp/sh/simsh4/console/Makefile.am create mode 100644 c/src/lib/libbsp/sh/simsh4/console/console.c create mode 100644 c/src/lib/libbsp/sh/simsh4/include/.cvsignore create mode 100644 c/src/lib/libbsp/sh/simsh4/include/Makefile.am create mode 100644 c/src/lib/libbsp/sh/simsh4/include/bsp.h create mode 100644 c/src/lib/libbsp/sh/simsh4/include/coverhd.h create mode 100644 c/src/lib/libbsp/sh/simsh4/include/ramdisk.h create mode 100644 c/src/lib/libbsp/sh/simsh4/include/syscall.h create mode 100644 c/src/lib/libbsp/sh/simsh4/start/.cvsignore create mode 100644 c/src/lib/libbsp/sh/simsh4/start/Makefile.am create mode 100644 c/src/lib/libbsp/sh/simsh4/start/start.S create mode 100644 c/src/lib/libbsp/sh/simsh4/startup/.cvsignore create mode 100644 c/src/lib/libbsp/sh/simsh4/startup/Makefile.am create mode 100644 c/src/lib/libbsp/sh/simsh4/startup/bspstart.c create mode 100644 c/src/lib/libbsp/sh/simsh4/startup/hw_init.c create mode 100644 c/src/lib/libbsp/sh/simsh4/startup/linkcmds create mode 100644 c/src/lib/libbsp/sh/simsh4/startup/linkcmds-le create mode 100644 c/src/lib/libbsp/sh/simsh4/startup/linkcmds-le.coff create mode 100644 c/src/lib/libbsp/sh/simsh4/timer/.cvsignore create mode 100644 c/src/lib/libbsp/sh/simsh4/timer/Makefile.am create mode 100644 c/src/lib/libbsp/sh/simsh4/timer/timer.c create mode 100644 c/src/lib/libbsp/sh/simsh4/wrapup/.cvsignore create mode 100644 c/src/lib/libbsp/sh/simsh4/wrapup/Makefile.am (limited to 'c/src/lib/libbsp') diff --git a/c/src/lib/libbsp/sh/simsh4/.cvsignore b/c/src/lib/libbsp/sh/simsh4/.cvsignore new file mode 100644 index 0000000000..d29e5050f5 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/.cvsignore @@ -0,0 +1,14 @@ +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +config.cache +config.guess +config.log +config.status +config.sub +configure +depcomp +install-sh +missing +mkinstalldirs diff --git a/c/src/lib/libbsp/sh/simsh4/ChangeLog b/c/src/lib/libbsp/sh/simsh4/ChangeLog new file mode 100644 index 0000000000..a1eb630cec --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/ChangeLog @@ -0,0 +1,15 @@ +2001-10-11 Alexandra Kossovsky + + * clock/Makefile.am, clock/ckinit.c, clock/.cvsignore, Makefile.am, + README, bsp_specs, console/Makefile.am, console/console.c, + console/.cvsignore, include/Makefile.am, include/bsp.h, + include/coverhd.h, include/syscall.h, include/ramdisk.h, + include/.cvsignore, start/Makefile.am, start/start.S, + start/.cvsignore, startup/Makefile.am, startup/bspstart.c, + startup/hw_init.c, startup/linkcmds, startup/linkcmds-le, + startup/linkcmds-le.coff, startup/.cvsignore, timer/Makefile.am, + timer/timer.c, timer/.cvsignore, wrapup/Makefile.am, wrapup/.cvsignore, + configure.ac, .cvsignore, ChangeLog: New files. + Reviewed and updated to latest automake and autoconf standards + by Ralf Corsepius . + diff --git a/c/src/lib/libbsp/sh/simsh4/Makefile.am b/c/src/lib/libbsp/sh/simsh4/Makefile.am new file mode 100644 index 0000000000..d176fc7a96 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/Makefile.am @@ -0,0 +1,20 @@ +## +## $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 console clock timer wrapup + +# FIXME: This directory is missing +# ramdisk + +include $(top_srcdir)/../../bsp.am + +EXTRA_DIST = bsp_specs + +include $(top_srcdir)/../../../../../../automake/subdirs.am +include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/sh/simsh4/README b/c/src/lib/libbsp/sh/simsh4/README new file mode 100644 index 0000000000..cafb35a700 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/README @@ -0,0 +1,47 @@ +# +# $Id$ +# +# Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia +# Author: Victor V. Vengerov +# + +BSP NAME: simsh4 (SH4 BSP working together with gdb simulator) +BOARD: n/a +BUS: n/a +CPU FAMILY: Hitachi SH +CPU: SH4 +COPROCESSORS: none +MODE: n/a + +DEBUG MONITOR: gdb + +PERIPHERALS +=========== +TIMERS: not supported now +SERIAL PORTS: implemented using simulator 'trap 34' hook (stdio redir). +REAL-TIME CLOCK: none +DMA: not used +VIDEO: none +SCSI: none +NETWORKING: none + +DRIVER INFORMATION +================== +CLOCK DRIVER: not supported now +IOSUPP DRIVER: default +SHMSUPP: default +TIMER DRIVER: not supported now +TTY DRIVER: /dev/console + +STDIO +===== +PORT: n/a +ELECTRICAL: n/a +BAUD: n/a +BITS PER CHARACTER: n/a +PARITY: n/a +STOP BITS: n/a + +NOTES +===== + diff --git a/c/src/lib/libbsp/sh/simsh4/bsp_specs b/c/src/lib/libbsp/sh/simsh4/bsp_specs new file mode 100644 index 0000000000..7951c5ff32 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/bsp_specs @@ -0,0 +1,22 @@ +%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) + +*lib: +%{!qrtems: %(old_lib)} \ +%{qrtems: --start-group %{!qrtems_debug: -lrtemsall } %{qrtems_debug: -lrtemsall_g} \ + -lc -lgcc --end-group \ + %{!qnolinkcmds: %{ml: -T linkcmds-le%s} %{!ml: -T linkcmds%s}}} + +*startfile: +%{!qrtems: %(old_startfile)} \ +%{qrtems: %{qrtems_debug: start_g.o%s} %{!qrtems_debug: start.o%s}} + +*link: +%(old_link) %{qrtems: -dc -dp -N -e _start} + diff --git a/c/src/lib/libbsp/sh/simsh4/clock/.cvsignore b/c/src/lib/libbsp/sh/simsh4/clock/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/clock/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sh/simsh4/clock/Makefile.am b/c/src/lib/libbsp/sh/simsh4/clock/Makefile.am new file mode 100644 index 0000000000..4a34199830 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/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: $(ARCH) $(OBJS) $(PGM) + +.PRECIOUS: $(PGM) + +EXTRA_DIST = ckinit.c + +include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/sh/simsh4/clock/ckinit.c b/c/src/lib/libbsp/sh/simsh4/clock/ckinit.c new file mode 100644 index 0000000000..4e07f09c49 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/clock/ckinit.c @@ -0,0 +1,189 @@ +/* + * Clock Driver for SH4 simulator (timer interrupt not supported now). + * + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + * + * COPYRIGHT (c) 1989-2001. + * 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 + +/* + * Clock_driver_ticks is a monotonically increasing counter of the + * number of clock ticks since the driver was initialized. + */ +volatile rtems_unsigned32 Clock_driver_ticks; + + +/* + * These are set by clock driver during its init + */ + +rtems_device_major_number rtems_clock_major = ~0; +rtems_device_minor_number rtems_clock_minor; + +rtems_isr (*rtems_clock_hook)(rtems_vector_number) = NULL; + +static void +set_clock_period(rtems_unsigned32 period) +{ + asm volatile ("\tmov %0,r0\n" + "\ttrapa\t#4\n" + : + : "r" (period) + : "r0" ); +} + +/* Clock_isr -- + * This handles the timer interrupt by clearing the timer's interrupt + * flag and announcing the clock tick to the system. + * + * PARAMETERS: + * vector - timer interrupt vector number + * + * RETURNS: + * none + */ +rtems_isr +Clock_isr (rtems_vector_number vector) +{ + /* Announce the clock tick */ + Clock_driver_ticks++; + rtems_clock_tick(); +} + + +/* Clock_exit -- + * This shuts down the timer if it was enabled and removes it + * from the interrupt mask. + * + * PARAMETERS: + * none + * + * RETURNS: + * none + */ +void +Clock_exit(void) +{ + if (BSP_Configuration.ticks_per_timeslice) + { + /* disable all timer1 interrupts */ + set_clock_period(0); + } +} + + +/* Install_clock -- + * This initialises timer1 with the BSP timeslice config value + * as a reference and sets up the interrupt handler for clock ticks. + * + * PARAMETERS: + * clock_isr - clock interrupt handler routine + * + * RETURNS: + * none. + */ +static void +Install_clock(rtems_isr_entry clock_isr) +{ + rtems_unsigned32 period; + Clock_driver_ticks = 0; + if (BSP_Configuration.ticks_per_timeslice) + { + void *old_isr; + period = Cpu_table.clicks_per_second / + BSP_Configuration.ticks_per_timeslice; + + /* Configure timer interrupts */ + set_clock_period(period); + + /* Register the interrupt handler */ + rtems_interrupt_catch(clock_isr, CLOCK_VECTOR, &old_isr); + + /* Register the driver exit procedure so we can shutdown */ + atexit(Clock_exit); + } +} + + +/* Clock_initialize -- + * This is called to setup the clock driver. It calls the hardware + * setup function and make the driver major/minor values available + * for other. + * + * PARAMETERS: + * major - clock device major number + * minor - clock device minor number + * pargp - device driver initialization argument (not used) + * + * RETURNS: + * RTEMS 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 -- + * I/O control (IOCTL) function for Clock driver. At this moment this + * just runs the interrupt handler or re-registers the interrupt handler + * on request. + * + * PARAMETERS: + * major - clock major device number + * minor - clock minor device number + * pargp - pointer to IOCTL arguments + * + * RETURNS: + * RTEMS 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) + { + void *old_isr; + /* + * 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 ); + rtems_interrupt_catch(Clock_isr, CLOCK_VECTOR, &old_isr); + rtems_interrupt_enable( isrlevel ); + } + } + return RTEMS_SUCCESSFUL; +} diff --git a/c/src/lib/libbsp/sh/simsh4/configure.ac b/c/src/lib/libbsp/sh/simsh4/configure.ac new file mode 100644 index 0000000000..5b473fa079 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/configure.ac @@ -0,0 +1,35 @@ +dnl Process this file with autoconf to produce a configure script. +dnl +dnl $Id$ + +AC_PREREQ(2.52) +AC_INIT +AC_CONFIG_SRCDIR([bsp_specs]) +RTEMS_TOP(../../../../../..) +AC_CONFIG_AUX_DIR(../../../../../..) + +RTEMS_CANONICAL_TARGET_CPU +AM_INIT_AUTOMAKE(rtems-c-src-lib-libbsp-sh-simsh4,$RTEMS_VERSION,no) +AM_MAINTAINER_MODE + +RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm]) +RTEMS_CANONICALIZE_TOOLS + +RTEMS_ENV_RTEMSBSP +RTEMS_CHECK_CUSTOM_BSP(RTEMS_BSP) +RTEMS_CHECK_BSP_CACHE(RTEMS_BSP) +RTEMS_CANONICAL_HOST + +RTEMS_PROJECT_ROOT + +# Explicitly list all Makefiles here +AC_CONFIG_FILES([Makefile +console/Makefile +include/Makefile +start/Makefile +startup/Makefile +clock/Makefile +timer/Makefile +wrapup/Makefile +]) +AC_OUTPUT diff --git a/c/src/lib/libbsp/sh/simsh4/console/.cvsignore b/c/src/lib/libbsp/sh/simsh4/console/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/console/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sh/simsh4/console/Makefile.am b/c/src/lib/libbsp/sh/simsh4/console/Makefile.am new file mode 100644 index 0000000000..d759853180 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/console/Makefile.am @@ -0,0 +1,34 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +VPATH = @srcdir@ + +PGM = $(ARCH)/console.rel + +C_FILES = console.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) + +include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/sh/simsh4/console/console.c b/c/src/lib/libbsp/sh/simsh4/console/console.c new file mode 100644 index 0000000000..08a0c04db7 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/console/console.c @@ -0,0 +1,429 @@ +/* + * Raw Console Driver for SH4 simulator + * + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + * + * COPYRIGHT (c) 1989-2001. + * 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 operations mode: + * 0 - raw (non-termios) polled input/output + * 1 - termios-based polled input/output + * 2 - termios-based interrupt-driven input/output + */ +#define CONSOLE_MODE_RAW (0) +#define CONSOLE_MODE_POLL (1) +#define CONSOLE_MODE_INT (2) + +int console_mode = CONSOLE_MODE_RAW; + + +/* console_poll_read -- + * poll read operation for simulator console through trap 34 mechanism. + * + * PARAMETERS: + * minor - minor device number + * + * RETURNS: + * character code red from UART, or -1 if there is no characters + * available + */ +static int +console_poll_read(int minor) +{ + unsigned char buf; + int rc; + rc = __trap34(SYS_read, 0, &buf, sizeof(buf)); + if (rc != -1) + return buf; + else + return -1; +} + +/* console_interrupt_write -- + * interrupt write operation for simulator console: not supported. + * + * PARAMETERS: + * minor - minor device number + * buf - output buffer + * len - output buffer length + * + * RETURNS: + * result code + */ +static int +console_interrupt_write(int minor, const char *buf, int len) +{ + return -1; +} + +/* console_poll_write -- + * wrapper for polling mode write function + * + * PARAMETERS: + * minor - minor device number + * buf - output buffer + * len - output buffer length + * + * RETURNS: + * result code (0) + */ +static int +console_poll_write(int minor, const char *buf, int len) +{ + int rc; + if (minor == 0) + { + rc = __trap34(SYS_write, 1, (char *)buf, len); + return 0; + } +} + +/* console_set_attributes -- + * wrapper for hardware-dependent termios attributes setting. + * Null implementation for simulator BSP. + * + * PARAMETERS: + * minor - minor device number + * t - pointer to the termios structure + * + * RETURNS: + * RTEMS_SUCCESSFUL + */ +static int +console_set_attributes(int minor, const struct termios *t) +{ + return RTEMS_SUCCESSFUL; +} + +/* console_stop_remote_tx -- + * wrapper for stopping data flow from remote party. + * + * PARAMETERS: + * minor - minor device number + * + * RETURNS: + * result code + */ +static int +console_stop_remote_tx(int minor) +{ + if (minor == 0) + return RTEMS_SUCCESSFUL; + else + return RTEMS_INVALID_NUMBER; +} + +/* console_start_remote_tx -- + * wrapper for resuming data flow from remote party. + * + * PARAMETERS: + * minor - minor device number + * + */ +static int +console_start_remote_tx(int minor) +{ + if (minor == 0) + return RTEMS_SUCCESSFUL; + else + return RTEMS_INVALID_NUMBER; +} + +/* console_first_open -- + * wrapper for UART controller initialization functions + * + * PARAMETERS: + * major - major device number + * minor - minor device number + * arg - libio device open argument + * + * RETURNS: + * error code + */ +static int +console_first_open(int major, int minor, void *arg) +{ + rtems_libio_open_close_args_t *args = arg; + rtems_status_code sc; + + if (minor != 0) + { + return RTEMS_INVALID_NUMBER; /* Single console supported */ + } + + return RTEMS_SUCCESSFUL; +} + +/* console_last_close -- + * wrapper for UART controller close function + * + * PARAMETERS: + * major - major device number + * minor - minor device number + * arg - libio device close argument + * + * RETURNS: + * error code + */ +static int +console_last_close(int major, int minor, void *arg) +{ + return RTEMS_SUCCESSFUL; +} + +/* console_reserve_resources -- + * reserve termios resources for 2 UART channels + * + * PARAMETERS: + * configuration -- pointer to the RTEMS configuration table + * + * RETURNS: + * none + */ +void +console_reserve_resources(rtems_configuration_table *configuration) +{ + if (console_mode != CONSOLE_MODE_RAW) + rtems_termios_reserve_resources (configuration, 1); +} + +/* console_initialize -- + * This routine initializes the console IO drivers and register devices + * in RTEMS I/O system. + * + * PARAMETERS: + * major - major console device number + * minor - minor console device number (not used) + * arg - device initialize argument + * + * RETURNS: + * RTEMS error code (RTEMS_SUCCESSFUL if device initialized successfuly) + */ +rtems_device_driver +console_initialize(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg) +{ + rtems_status_code status; + + /* + * Set up TERMIOS + */ + if (console_mode != CONSOLE_MODE_RAW) + rtems_termios_initialize (); + + /* + * Register the devices + */ + status = rtems_io_register_name ("/dev/console", major, 0); + if (status != RTEMS_SUCCESSFUL) + rtems_fatal_error_occurred (status); + status = rtems_io_register_name ("/dev/aux", major, 1); + if (status != RTEMS_SUCCESSFUL) + rtems_fatal_error_occurred (status); + + return RTEMS_SUCCESSFUL; +} + +/* console_open -- + * Open console device driver. Pass appropriate termios callback + * functions to termios library. + * + * PARAMETERS: + * major - major device number for console devices + * minor - minor device number for console + * arg - device opening argument + * + * RETURNS: + * RTEMS error code + */ +rtems_device_driver +console_open(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg) +{ + static const rtems_termios_callbacks intr_callbacks = { + console_first_open, /* firstOpen */ + console_last_close, /* lastClose */ + NULL, /* pollRead */ + console_interrupt_write, /* write */ + console_set_attributes, /* setAttributes */ + console_stop_remote_tx, /* stopRemoteTx */ + console_start_remote_tx, /* startRemoteTx */ + 1 /* outputUsesInterrupts */ + }; + static const rtems_termios_callbacks poll_callbacks = { + console_first_open, /* firstOpen */ + console_last_close, /* lastClose */ + console_poll_read, /* pollRead */ + console_poll_write, /* write */ + console_set_attributes, /* setAttributes */ + console_stop_remote_tx, /* stopRemoteTx */ + console_start_remote_tx, /* startRemoteTx */ + 0 /* outputUsesInterrupts */ + }; + + switch (console_mode) + { + case CONSOLE_MODE_RAW: + return RTEMS_SUCCESSFUL; + + case CONSOLE_MODE_INT: + return rtems_termios_open(major, minor, arg, &intr_callbacks); + + case CONSOLE_MODE_POLL: + return rtems_termios_open(major, minor, arg, &poll_callbacks); + + default: + rtems_fatal_error_occurred(0xC07A1310); + } + return RTEMS_INTERNAL_ERROR; +} + +/* console_close -- + * Close console device. + * + * PARAMETERS: + * major - major device number for console devices + * minor - minor device number for console + * arg - device close argument + * + * RETURNS: + * RTEMS error code + */ +rtems_device_driver +console_close(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg) +{ + if (console_mode != CONSOLE_MODE_RAW) + return rtems_termios_close (arg); + else + return RTEMS_SUCCESSFUL; +} + +/* console_read -- + * Read from the console device + * + * PARAMETERS: + * major - major device number for console devices + * minor - minor device number for console + * arg - device read argument + * + * RETURNS: + * RTEMS error code + */ +rtems_device_driver +console_read(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg) +{ + if (console_mode != CONSOLE_MODE_RAW) + { + return rtems_termios_read (arg); + } + else + { + rtems_libio_rw_args_t *argp = arg; + char *buf = argp->buffer; + int count = argp->count; + int n = 0; + int c; + while (n < count) + { + do { + c = console_poll_read(minor); + } while (c == -1); + if (c == '\r') + c = '\n'; + *(buf++) = c; + n++; + if (c == '\n') + break; + } + argp->bytes_moved = n; + return RTEMS_SUCCESSFUL; + } +} + +/* console_write -- + * Write to the console device + * + * PARAMETERS: + * major - major device number for console devices + * minor - minor device number for console + * arg - device write argument + * + * RETURNS: + * RTEMS error code + */ +rtems_device_driver +console_write(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +) +{ + if (console_mode != CONSOLE_MODE_RAW) + { + return rtems_termios_write (arg); + } + else + { + rtems_libio_rw_args_t *argp = arg; + char cr = '\r'; + char *buf = argp->buffer; + int count = argp->count; + int i; + for (i = 0; i < count; i++) + { + if (*buf == '\n') + console_poll_write(minor, &cr, 1); + console_poll_write(minor, buf, 1); + buf++; + } + argp->bytes_moved = count; + return RTEMS_SUCCESSFUL; + } +} + +/* console_control -- + * Handle console device I/O control (IOCTL) + * + * PARAMETERS: + * major - major device number for console devices + * minor - minor device number for console + * arg - device ioctl argument + * + * RETURNS: + * RTEMS error code + */ +rtems_device_driver +console_control(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg) +{ + if (console_mode != CONSOLE_MODE_RAW) + { + return rtems_termios_ioctl (arg); + } + else + { + return RTEMS_SUCCESSFUL; + } +} diff --git a/c/src/lib/libbsp/sh/simsh4/include/.cvsignore b/c/src/lib/libbsp/sh/simsh4/include/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/include/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sh/simsh4/include/Makefile.am b/c/src/lib/libbsp/sh/simsh4/include/Makefile.am new file mode 100644 index 0000000000..e2a0c00be6 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/include/Makefile.am @@ -0,0 +1,16 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +include_HEADERS = bsp.h coverhd.h syscall.h ramdisk.h + +$(PROJECT_INCLUDE)/%.h: %.h + $(INSTALL_DATA) $< $@ + +PREINSTALL_FILES = $(include_HEADERS:%.h=$(PROJECT_INCLUDE)/%.h) + +all-local: $(PREINSTALL_FILES) + +include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/sh/simsh4/include/bsp.h b/c/src/lib/libbsp/sh/simsh4/include/bsp.h new file mode 100644 index 0000000000..1f9972b252 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/include/bsp.h @@ -0,0 +1,154 @@ +/* + * This include file contains all board IO definitions. + * + * sh4 simulator bsp + * + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + * Alexandra Kossovsky + * + * Based on work: + * Author: Ralf Corsepius (corsepiu@faw.uni-ulm.de) + * + * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * + * COPYRIGHT (c) 1998-2001. + * 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. + * + * Minor adaptations for sh2 by: + * John M. Mills (jmills@tga.com) + * TGA Technologies, Inc. + * 100 Pinnacle Way, Suite 140 + * Norcross, GA 30071 U.S.A. + * + * This modified file may be copied and distributed in accordance + * the above-referenced license. It is provided for critique and + * developmental purposes without any warranty nor representation + * by the authors or by TGA Technologies. + * + * $Id$ + */ + +#ifndef __simsh4_h +#define __simsh4_h + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +/* + * confdefs.h overrides for this BSP: + * - number of termios serial ports (defaults to 1) + * - Interrupt stack space is not minimum if defined. + */ + +#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 1 +#define CONFIGURE_INTERRUPT_STACK_MEMORY (4 * 1024) + +/* !!! Should be defined in accordance to simulator considerations.*/ +#define CLOCK_VECTOR 32 + +/* + * 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 300 /* 5 minutes = 300 seconds */ +#define MAX_SHORT_TEST_DURATION 3 /* 3 seconds */ + +/* + * Stuff for Time Test 27 + */ + +#define MUST_WAIT_FOR_INTERRUPT 0 + +#define Install_tm27_vector( handler ) \ +{ \ + rtems_isr_entry ignored ; \ + rtems_interrupt_catch( (handler), 0, &ignored ) ; \ +} + +#define Cause_tm27_intr() + +#define Clear_tm27_intr() + +#define Lower_tm27_intr() + +/* Constants */ + +/* + * Simple spin delay in microsecond units for device drivers. + * This is very dependent on the clock speed of the target. + */ + +#define delay( microseconds ) CPU_delay(microseconds) +#define sh_delay( microseconds ) CPU_delay( microseconds ) + + +/* + * Defined in the linker script 'linkcmds' + */ + +extern unsigned32 HeapStart ; +extern unsigned32 HeapEnd ; +extern unsigned32 WorkSpaceStart ; +extern unsigned32 WorkSpaceEnd ; + +extern void *CPU_Interrupt_stack_low ; +extern void *CPU_Interrupt_stack_high ; + + +/* miscellaneous stuff assumed to exist */ + +extern rtems_configuration_table BSP_Configuration; + +extern rtems_cpu_table Cpu_table; + +extern void bsp_cleanup( void ); + +/* + * Device Driver Table Entries + */ + +#undef CONSOLE_DRIVER_TABLE_ENTRY +#define CONSOLE_DRIVER_TABLE_ENTRY \ + { console_initialize, console_open, console_close, \ + console_read, console_write, console_control } + +#define RAMDISK_DRIVER_TABLE_ENTRY \ + { ramdisk_initialize, ramdisk_open, ramdisk_close, \ + ramdisk_read, ramdisk_write, ramdisk_control } + + +/* + * NOTE: Use the standard Clock driver entry + */ + +/* + * Trap interface with simulator + */ +int __trap34(); + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/c/src/lib/libbsp/sh/simsh4/include/coverhd.h b/c/src/lib/libbsp/sh/simsh4/include/coverhd.h new file mode 100644 index 0000000000..ef8afb04b4 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/include/coverhd.h @@ -0,0 +1,121 @@ +/* coverhd.h + * + * This include file has defines to represent the overhead associated + * with calling a particular directive from C. These are used in the + * Timing Test Suite to ignore the overhead required to pass arguments + * to directives. On some CPUs and/or target boards, this overhead + * is significant and makes it difficult to distinguish internal + * RTEMS execution time from that used to call the directive. + * This file should be updated after running the C overhead timing + * test. Once this update has been performed, the RTEMS Time Test + * Suite should be rebuilt to account for these overhead times in the + * timing results. + * + * NOTE: If these are all zero, then the times reported include all + * all calling overhead including passing of arguments. + * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * 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. + * + * This file may be copied and distributed in accordance + * the above-referenced license. It is provided for critique and + * developmental purposes without any warranty nor representation + * by the authors or by TGA Technologies. + * + * $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/sh/simsh4/include/ramdisk.h b/c/src/lib/libbsp/sh/simsh4/include/ramdisk.h new file mode 100644 index 0000000000..af0019df7c --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/include/ramdisk.h @@ -0,0 +1,55 @@ +/* ramdisk.h + * + * + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Eugeny S. Mints + * + * + * COPYRIGHT (c) 1989-2001. + * 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$ + */ + +#ifndef _RAMDISK_DRIVER_h +#define _RAMDISK_DRIVER_h + +#ifdef __cplusplus +extern "C" { +#endif + + +rtems_device_driver ramdisk_initialize(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +rtems_device_driver ramdisk_open(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +rtems_device_driver ramdisk_close(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +rtems_device_driver ramdisk_read(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +rtems_device_driver ramdisk_write(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +rtems_device_driver ramdisk_control(rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/c/src/lib/libbsp/sh/simsh4/include/syscall.h b/c/src/lib/libbsp/sh/simsh4/include/syscall.h new file mode 100644 index 0000000000..f141df764c --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/include/syscall.h @@ -0,0 +1,31 @@ +#define SYS_exit 1 +#define SYS_fork 2 + +#define SYS_read 3 +#define SYS_write 4 +#define SYS_open 5 +#define SYS_close 6 +#define SYS_wait4 7 +#define SYS_creat 8 +#define SYS_link 9 +#define SYS_unlink 10 +#define SYS_execv 11 +#define SYS_chdir 12 +#define SYS_mknod 14 +#define SYS_chmod 15 +#define SYS_chown 16 +#define SYS_lseek 19 +#define SYS_getpid 20 +#define SYS_isatty 21 +#define SYS_fstat 22 +#define SYS_time 23 + + +#define SYS_ARG 24 +#define SYS_stat 38 + +#define SYS_pipe 42 +#define SYS_execve 59 + +#define SYS_utime 201 /* not really a system call */ +#define SYS_wait 202 /* nor is this */ diff --git a/c/src/lib/libbsp/sh/simsh4/start/.cvsignore b/c/src/lib/libbsp/sh/simsh4/start/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/start/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sh/simsh4/start/Makefile.am b/c/src/lib/libbsp/sh/simsh4/start/Makefile.am new file mode 100644 index 0000000000..2590c71e24 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/start/Makefile.am @@ -0,0 +1,31 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +PGMS = $(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: $(PGMS) + $(INSTALL_DATA) $< $@ + +TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).o + +all-local: $(ARCH) $(OBJS) $(TMPINSTALL_FILES) + +EXTRA_DIST = start.S trap.S + +include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/sh/simsh4/start/start.S b/c/src/lib/libbsp/sh/simsh4/start/start.S new file mode 100644 index 0000000000..3618cad537 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/start/start.S @@ -0,0 +1,171 @@ +/* + * start.S -- Initialization code for SH4 simulator BSP + * + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + * + * Based on work: + * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and + * Bernd Becker (becker@faw.uni-ulm.de) + * + * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Modified to reflect Hitachi EDK SH7045F: + * John M. Mills (jmills@tga.com) + * TGA Technologies, Inc. + * 100 Pinnacle Way, Suite 140 + * Norcross, GA 30071 U.S.A. + * + * + * This modified file may be copied and distributed in accordance + * the above-referenced license. It is provided for critique and + * developmental purposes without any warranty nor representation + * by the authors or by TGA Technologies. + * + * COPYRIGHT (c) 1999-2001. + * 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 "asm.h" +#include "rtems/score/sh4_regs.h" + + BEGIN_CODE + PUBLIC(start) + +SYM (start): + ! install the stack pointer + mov.l stack_k,r15 + + mov.l initial_sr_k,r0 + ldc r0,ssr + ldc r0,sr + + ! Set up VBR register + mov.l _vbr_base_k,r0 + ldc r0,vbr + + +#ifdef START_HW_INIT /* from $RTEMS_BSP.cfg */ + ! Initialize minimal hardware + mov.l hw_init_k, r0 + jsr @r0 + nop !dead slot +#endif /* START_HW_INIT */ + + ! zero out bss + mov.l edata_k,r0 + mov.l end_k,r1 + mov #0,r2 +0: + mov.l r2,@r0 + add #4,r0 + cmp/ge r0,r1 + bt 0b + + ! initialise fpscr for gcc + mov.l set_fpscr_k, r1 + jsr @r1 + nop + + ! Set FPSCR register + mov.l initial_fpscr_k,r0 + lds r0,fpscr + + ! call the mainline + mov #0,r4 ! argc + mov.l main_k,r0 + jsr @r0 + mov #0,r5 ! argv - can place in dead slot + + ! call exit + mov r0,r4 + mov.l exit_k,r0 + jsr @r0 + or r0,r0 + + ! stop the simulator + trapa #2 + nop + + .global ___trap34 +___trap34: + trapa #34 +! tst r1,r1 ! r1 is errno +! bt ret +! mov.l perrno,r2 +! mov.l r1,@r2 +!ret: + rts + nop + +! .align 2 +!perrno: +! .long _errno + + + END_CODE + + .align 2 +set_fpscr_k: + .long ___set_fpscr +_vbr_base_k: + .long SYM(_vbr_base) + +stack_k: + .long SYM(stack) +edata_k: + .long SYM(edata) +end_k: + .long SYM(end) +main_k: + .long SYM(boot_card) +exit_k: + .long SYM(exit) + +#ifdef START_HW_INIT /* from $RTEMS_BSP.cfg */ +hw_init_k: + .long SYM(early_hw_init) +#endif /* START_HW_INIT */ + +vects_k: + .long SYM(vectab) +vects_size: + .word 255 + + .align 2 +initial_sr_k: + .long SH4_SR_MD | SH4_SR_RB | SH4_SR_IMASK +initial_fpscr_k: +#ifdef __SH4__ + .long SH4_FPSCR_DN | SH4_FPSCR_PR | SH4_FPSCR_RM +#else + .long SH4_FPSCR_DN | SH4_FPSCR_RM +#endif + +#ifdef __ELF__ + .section .stack,"aw" +#else + .section .stack +#endif +SYM(stack): + .long 0xdeaddead + +#ifdef __ELF__ + .section .bss,"aw" +#else + .section .bss +#endif + + .global __sh4sim_dummy_register +__sh4sim_dummy_register: + .long 0 diff --git a/c/src/lib/libbsp/sh/simsh4/startup/.cvsignore b/c/src/lib/libbsp/sh/simsh4/startup/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/startup/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sh/simsh4/startup/Makefile.am b/c/src/lib/libbsp/sh/simsh4/startup/Makefile.am new file mode 100644 index 0000000000..d3aa81dadd --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/startup/Makefile.am @@ -0,0 +1,43 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +VPATH = @srcdir@:@srcdir@/../../shared:@srcdir@/../../../shared + +PGM = $(ARCH)/startup.rel + +C_FILES = hw_init.c bsplibc.c bsppost.c bspstart.c bspclean.c sbrk.c \ + bootcard.c main.c gnatinstallhandler.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 += +# + +$(PROJECT_RELEASE)/lib/linkcmds: linkcmds + $(INSTALL_DATA) $< $@ + +$(PROJECT_RELEASE)/lib/linkcmds-le: linkcmds-le + $(INSTALL_DATA) $< $@ + +$(PGM): $(OBJS) + $(make-rel) + +TMPINSTALL_FILES += $(PROJECT_RELEASE)/lib/linkcmds \ + $(PROJECT_RELEASE)/lib/linkcmds-le + +all-local: $(ARCH) $(TMPINSTALL_FILES) $(OBJS) $(PGM) + +.PRECIOUS: $(PGM) + +EXTRA_DIST = bspclean.c bspstart.c hw_init.c linkcmds linkcmds-le + +include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/sh/simsh4/startup/bspstart.c b/c/src/lib/libbsp/sh/simsh4/startup/bspstart.c new file mode 100644 index 0000000000..9282574d2e --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/startup/bspstart.c @@ -0,0 +1,141 @@ +/* + * This routine starts the application. It includes application, + * board, and monitor specific initialization and configuration. + * The generic CPU dependent initialization has been performed + * before this routine is invoked. + * + * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and + * Bernd Becker (becker@faw.uni-ulm.de) + * + * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * + * COPYRIGHT (c) 1998-2001. + * 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 + +/* + * The original table from the application and our copy of it with + * some changes. + */ + +extern void bsp_hw_init(void); + +extern rtems_configuration_table Configuration; + +rtems_configuration_table BSP_Configuration; + +rtems_cpu_table Cpu_table; + +char *rtems_progname; + +/* + * Use the shared implementations of the following routines + */ + +void bsp_postdriver_hook(void); +void bsp_libc_init( void *, unsigned32, int ); + +/* + * Function: bsp_pretasking_hook + * + * Description: + * BSP pretasking hook. Called just before drivers are initialized. + * Used to setup libc and install any BSP extensions. + * + * NOTES: + * Must not use libc (to do io) from here, since drivers are + * not yet initialized. + * + */ + +void bsp_pretasking_hook(void) +{ + bsp_libc_init(&HeapStart, ((char *)&HeapEnd - (char *)&HeapStart), 0); + +#ifdef RTEMS_DEBUG + rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); +#endif +} + +/* + * bsp_start + * + * This routine does the bulk of the system initialization. + */ + +void bsp_start(void) +{ + /* + For real boards you need to setup the hardware + and need to copy the vector table from rom to ram. + + Depending on the board this can ether be done from inside the rom + startup code, rtems startup code or here. + */ + +#ifndef START_HW_INIT + /* board hardware setup here, or from 'start.S' */ + bsp_hw_init(); +#endif + + /* + * Allocate the memory for the RTEMS Work Space. This can come from + * a variety of places: hard coded address, malloc'ed from outside + * RTEMS world (e.g. simulator or primitive memory manager), or (as + * typically done by stock BSPs) by subtracting the required amount + * of work space from the last physical address on the CPU board. + */ + + /* + * Need to "allocate" the memory for the RTEMS Workspace and + * tell the RTEMS configuration where it is. This memory is + * not malloc'ed. It is just "pulled from the air". + */ + + BSP_Configuration.work_space_start = (void *) &WorkSpaceStart ; + BSP_Configuration.work_space_size = + (unsigned32) &WorkSpaceEnd - + (unsigned32) &WorkSpaceStart ; + + /* + * initialize the CPU table for this BSP + */ + +#if ( CPU_ALLOCATE_INTERRUPT_STACK == FALSE ) + _CPU_Interrupt_stack_low = &CPU_Interrupt_stack_low ; + _CPU_Interrupt_stack_high = &CPU_Interrupt_stack_high ; + + /* This isn't used anywhere */ + Cpu_table.interrupt_stack_size = + (unsigned32) (&CPU_Interrupt_stack_high) - + (unsigned32) (&CPU_Interrupt_stack_low) ; +#endif + + + Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ + Cpu_table.postdriver_hook = bsp_postdriver_hook; + +#if ( CPU_ALLOCATE_INTERRUPT_STACK == TRUE ) + Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; +#endif + + Cpu_table.clicks_per_second = HZ ; +} diff --git a/c/src/lib/libbsp/sh/simsh4/startup/hw_init.c b/c/src/lib/libbsp/sh/simsh4/startup/hw_init.c new file mode 100644 index 0000000000..2d1b747ad9 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/startup/hw_init.c @@ -0,0 +1,57 @@ +/* + * hw_init.c - initialize hardware resources for simulator. + * Currently there are no models of hardware resources which should be + * initialized here; it is just a stub. + * + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * + * 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 + +/* exported entries */ +extern void bsp_hw_init (void); +extern void early_hw_init (void); + +/* early_hw_init -- + * Hardware initialization called from 'start.S' on "#ifdef START_HW_INIT" + * + * ARGUMENTS: + * none + * + * RETURNS: + * none + */ +void +early_hw_init (void) +{ +}; + +/* bsp_hw_init -- + * Part of hardware initialization called from bspstart.c + * + * ARGUMENTS: + * none + * + * RETURNS: + * none + */ +void bsp_hw_init (void) +{ +} diff --git a/c/src/lib/libbsp/sh/simsh4/startup/linkcmds b/c/src/lib/libbsp/sh/simsh4/startup/linkcmds new file mode 100644 index 0000000000..2aea30b1d2 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/startup/linkcmds @@ -0,0 +1,185 @@ +/* + * Memory layout for SH4 GNU simulator. + * + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * + * COPYRIGHT (c) 1998-2001. + * 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$ + */ + +OUTPUT_FORMAT("coff-sh") +OUTPUT_ARCH(sh) +ENTRY(_start) + +_HeapSize = DEFINED(_HeapSize) ? _HeapSize : (512 * 1024); +_WorkspaceSize = DEFINED(_WorkspaceSize) ? _WorkspaceSize : (1024 * 1024); + +/* These assignments load code into SH7045F EVB SRAM for monitor debugging */ + +MEMORY +{ + ram : o = 0x00000000, l = 0x01000000 +} + +/* Sections are defined for RAM loading and monitor debugging */ +SECTIONS +{ + + /* Read-only sections, merged into text segment: */ + + . = 0x00004000 ; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.text : + { *(.rel.text) *(.rel.gnu.linkonce.t*) } + .rela.text : + { *(.rela.text) *(.rela.gnu.linkonce.t*) } + .rel.data : + { *(.rel.data) *(.rel.gnu.linkonce.d*) } + .rela.data : + { *(.rela.data) *(.rela.gnu.linkonce.d*) } + .rel.rodata : + { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } + .rela.rodata : + { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : { *(.init) } =0 + .plt : { *(.plt) } + .text . : + { + *(.text) + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } > ram + _etext = .; + PROVIDE (etext = .); + .fini . : { *(.fini) } =0 + .rodata . : { *(.rodata) *(.gnu.linkonce.r*) } + .rodata1 . : { *(.rodata1) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN(128) + (. & (128 - 1)); + .data . : + { + *(.data) + *(.gnu.linkonce.d*) + CONSTRUCTORS + } > ram + .data1 . : { *(.data1) } + .ctors . : + { + ___ctors = .; + *(.ctors) + ___ctors_end = .; + } + .dtors . : + { + ___dtors = .; + *(.dtors) + ___dtors_end = .; + } + .got . : { *(.got.plt) *(.got) } + .dynamic . : { *(.dynamic) } + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata . : { *(.sdata) } + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + .sbss . : { *(.sbss) *(.scommon) } + .bss . : + { + *(.dynbss) + *(.bss) + *(COMMON) + } > ram + _end = . ; + PROVIDE (end = .); + + . = ALIGN(16); + _HeapStart = . ; + . = . + _HeapSize ; + PROVIDE( _HeapEnd = . ); + + . = ALIGN(16); + _WorkSpaceStart = . ; + . = . + _WorkspaceSize ; + PROVIDE(_WorkSpaceEnd = .); + + . = ALIGN(16); + .stack . : { + . = . + 4096; + } + + . = ALIGN(16); + _CPU_Interrupt_stack_low = . ; + _CPU_Interrupt_stack_high = _CPU_Interrupt_stack_low + 4096 ; + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + +} diff --git a/c/src/lib/libbsp/sh/simsh4/startup/linkcmds-le b/c/src/lib/libbsp/sh/simsh4/startup/linkcmds-le new file mode 100644 index 0000000000..b2fd3094b2 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/startup/linkcmds-le @@ -0,0 +1,249 @@ +OUTPUT_FORMAT("elf32-shl", "elf32-shl", + "elf32-shl") +OUTPUT_ARCH(sh) +ENTRY(_start) +/* Do we need any of these for elf? + __DYNAMIC = 0; */ + +_HeapSize = DEFINED(_HeapSize) ? _HeapSize : (512 * 1024); +_WorkspaceSize = DEFINED(_WorkspaceSize) ? _WorkspaceSize : (1024 * 1024); + +MEMORY +{ + ram : o = 0x00000000, l = 0x01000000 +} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + /* . = 0x1000; */ + . = 0x00004000 ; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.text : + { + *(.rel.text) + *(.rel.text.*) + *(.rel.gnu.linkonce.t*) + } + .rela.text : + { + *(.rela.text) + *(.rela.text.*) + *(.rela.gnu.linkonce.t*) + } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.rodata : + { + *(.rel.rodata) + *(.rel.rodata.*) + *(.rel.gnu.linkonce.r*) + } + .rela.rodata : + { + *(.rela.rodata) + *(.rela.rodata.*) + *(.rela.gnu.linkonce.r*) + } + .rel.data : + { + *(.rel.data) + *(.rel.data.*) + *(.rel.gnu.linkonce.d*) + } + .rela.data : + { + *(.rela.data) + *(.rela.data.*) + *(.rela.gnu.linkonce.d*) + } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.sdata : + { + *(.rel.sdata) + *(.rel.sdata.*) + *(.rel.gnu.linkonce.s*) + } + .rela.sdata : + { + *(.rela.sdata) + *(.rela.sdata.*) + *(.rela.gnu.linkonce.s*) + } + .rel.sbss : { *(.rel.sbss) } + .rela.sbss : { *(.rela.sbss) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : + { + KEEP (*(.init)) + } =0 + .plt : { *(.plt) } + .text : + { + . = . + 16; + *(.text) + *(.text.*) + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } > ram + _etext = .; + PROVIDE (etext = .); + .fini : + { + KEEP (*(.fini)) + } > ram + .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*) } > ram + .rodata1 : { *(.rodata1) } > ram + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN(128) + (. & (128 - 1)); + .data : + { + *(.data) + *(.data.*) + *(.gnu.linkonce.d*) + SORT(CONSTRUCTORS) + } > ram + .data1 : { *(.data1) } > ram + .eh_frame : { *(.eh_frame) } > ram + .gcc_except_table : { *(.gcc_except_table) } > ram + .ctors : + { + ___ctors = .; + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ___ctors_end = .; + } > ram + .dtors : + { + ___dtors = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ___dtors_end = .; + } > ram + .got : { *(.got.plt) *(.got) } + .dynamic : { *(.dynamic) } + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata : + { + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + } > ram + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + .sbss : + { + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.scommon) + } > ram + .bss : + { + *(.dynbss) + *(.bss) + *(.bss.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(32 / 8); + } > ram + . = ALIGN(32 / 8); + _end = .; + PROVIDE (end = .); + + . = ALIGN(16); + _HeapStart = . ; + . = . + _HeapSize ; + PROVIDE( _HeapEnd = . ); + + . = ALIGN(16); + _WorkSpaceStart = . ; + . = . + _WorkspaceSize ; + PROVIDE(_WorkSpaceEnd = .); + + . = ALIGN(16); + .stack . : { + . = . + 4096; + } + + . = ALIGN(16); + _CPU_Interrupt_stack_low = . ; + _CPU_Interrupt_stack_high = _CPU_Interrupt_stack_low + 4096 ; + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + .stack 0x30000 : { _stack = .; *(.stack) } + /* These must appear regardless of . */ +} diff --git a/c/src/lib/libbsp/sh/simsh4/startup/linkcmds-le.coff b/c/src/lib/libbsp/sh/simsh4/startup/linkcmds-le.coff new file mode 100644 index 0000000000..4f07cd6217 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/startup/linkcmds-le.coff @@ -0,0 +1,186 @@ +/* + * Memory layout for SH4 GNU simulator. + * + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * + * COPYRIGHT (c) 1998-2001. + * 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$ + */ + +/* OUTPUT_FORMAT("coff-shl") */ +OUTPUT_FORMAT("elf32-shl") +OUTPUT_ARCH(sh) +ENTRY(_start) + +_HeapSize = DEFINED(_HeapSize) ? _HeapSize : (512 * 1024); +_WorkspaceSize = DEFINED(_WorkspaceSize) ? _WorkspaceSize : (1024 * 1024); + +/* These assignments load code into SH7045F EVB SRAM for monitor debugging */ + +MEMORY +{ + ram : o = 0x00000000, l = 0x01000000 +} + +/* Sections are defined for RAM loading and monitor debugging */ +SECTIONS +{ + + /* Read-only sections, merged into text segment: */ + + . = 0x00004000 ; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.text : + { *(.rel.text) *(.rel.gnu.linkonce.t*) } + .rela.text : + { *(.rela.text) *(.rela.gnu.linkonce.t*) } + .rel.data : + { *(.rel.data) *(.rel.gnu.linkonce.d*) } + .rela.data : + { *(.rela.data) *(.rela.gnu.linkonce.d*) } + .rel.rodata : + { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } + .rela.rodata : + { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : { *(.init) } =0 + .plt : { *(.plt) } + .text . : + { + *(.text) + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } > ram + _etext = .; + PROVIDE (etext = .); + .fini . : { *(.fini) } =0 + .rodata . : { *(.rodata) *(.gnu.linkonce.r*) } + .rodata1 . : { *(.rodata1) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN(128) + (. & (128 - 1)); + .data . : + { + *(.data) + *(.gnu.linkonce.d*) + CONSTRUCTORS + } > ram + .data1 . : { *(.data1) } + .ctors . : + { + ___ctors = .; + *(.ctors) + ___ctors_end = .; + } + .dtors . : + { + ___dtors = .; + *(.dtors) + ___dtors_end = .; + } + .got . : { *(.got.plt) *(.got) } + .dynamic . : { *(.dynamic) } + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata . : { *(.sdata) } + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + .sbss . : { *(.sbss) *(.scommon) } + .bss . : + { + *(.dynbss) + *(.bss) + *(COMMON) + } > ram + _end = . ; + PROVIDE (end = .); + + . = ALIGN(16); + _HeapStart = . ; + . = . + _HeapSize ; + PROVIDE( _HeapEnd = . ); + + . = ALIGN(16); + _WorkSpaceStart = . ; + . = . + _WorkspaceSize ; + PROVIDE(_WorkSpaceEnd = .); + + . = ALIGN(16); + .stack . : { + . = . + 4096; + } + + . = ALIGN(16); + _CPU_Interrupt_stack_low = . ; + _CPU_Interrupt_stack_high = _CPU_Interrupt_stack_low + 4096 ; + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + +} diff --git a/c/src/lib/libbsp/sh/simsh4/timer/.cvsignore b/c/src/lib/libbsp/sh/simsh4/timer/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/timer/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sh/simsh4/timer/Makefile.am b/c/src/lib/libbsp/sh/simsh4/timer/Makefile.am new file mode 100644 index 0000000000..d81ff87872 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/timer/Makefile.am @@ -0,0 +1,35 @@ +## +## $Id$ +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +PGM = $(ARCH)/timer.rel + +C_FILES = timer.c +C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) +S_FILES = +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 += +# + +$(PGM): $(OBJS) + $(make-rel) + +# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile + +all: $(ARCH) $(OBJS) $(PGM) + +.PRECIOUS: $(PGM) + +EXTRA_DIST = timer.c timerisr.S + +include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/sh/simsh4/timer/timer.c b/c/src/lib/libbsp/sh/simsh4/timer/timer.c new file mode 100644 index 0000000000..d8feb88e0a --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/timer/timer.c @@ -0,0 +1,111 @@ +/* + * Timer Init + * + * This module implements benchmark stub for simulator. + * + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + * + * COPYRIGHT (c) 1989-1998-2001. + * 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 + +rtems_unsigned32 Timer_interrupts; + +rtems_boolean Timer_driver_Find_average_overhead; + +/* External assembler interrupt handler routine */ +extern rtems_isr timerisr(rtems_vector_number vector); + + +/* Timer_initialize -- + * Initialize timer 2 for accurate time measurement. + * + * PARAMETERS: + * none + * + * RETURNS: + * none + */ +void +Timer_initialize(void) +{ + return; +} + +/* + * The following controls the behavior of Read_timer(). + * + * FIND_AVG_OVERHEAD * instructs the routine to return the "raw" count. + * + * AVG_OVEREHAD is the overhead for starting and stopping the timer. It + * is usually deducted from the number returned. + * + * LEAST_VALID is the lowest number this routine should trust. Numbers + * below this are "noise" and zero is returned. + */ + +#define AVG_OVERHEAD 0 /* It typically takes 2.0 microseconds */ + /* (Y countdowns) to start/stop the timer. */ + /* This value is in microseconds. */ +#define LEAST_VALID 1 /* Don't trust a clicks value lower than this */ + +/* Read_timer -- + * Read timer value in microsecond units since timer start. + * + * PARAMETERS: + * none + * + * RETURNS: + * number of microseconds since timer has been started + */ +int +Read_timer( void ) +{ + return 0; +} + + +/* Empty_function -- + * Empty function call used in loops to measure basic cost of looping + * in Timing Test Suite. + * + * PARAMETERS: + * none + * + * RETURNS: + * RTEMS_SUCCESSFUL + */ +rtems_status_code +Empty_function(void) +{ + return RTEMS_SUCCESSFUL; +} + +/* Set_find_average_overhead -- + * This routine is invoked by the "Check Timer" (tmck) test in the + * RTEMS Timing Test Suite. It makes the Read_timer routine not + * subtract the overhead required to initialize and read the benchmark + * timer. + * + * PARAMETERS: + * find_flag - boolean flag, TRUE if overhead must not be subtracted. + * + * RETURNS: + * none + */ +void +Set_find_average_overhead(rtems_boolean find_flag) +{ + Timer_driver_Find_average_overhead = find_flag; +} diff --git a/c/src/lib/libbsp/sh/simsh4/wrapup/.cvsignore b/c/src/lib/libbsp/sh/simsh4/wrapup/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/wrapup/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/lib/libbsp/sh/simsh4/wrapup/Makefile.am b/c/src/lib/libbsp/sh/simsh4/wrapup/Makefile.am new file mode 100644 index 0000000000..b30445beb9 --- /dev/null +++ b/c/src/lib/libbsp/sh/simsh4/wrapup/Makefile.am @@ -0,0 +1,40 @@ +## +## $Id$ +## +## build and install libbsp +## + +AUTOMAKE_OPTIONS = foreign 1.4 + +BSP_PIECES = startup console clock ramdisk timer + +# pieces to pick up out of libcpu/sh +CPU_PIECES = score + +# bummer; have to use $foreach since % pattern subst rules only replace 1x +OBJS = $(foreach piece, $(BSP_PIECES), ../$(piece)/$(ARCH)/$(piece).rel) \ + $(foreach piece, $(CPU_PIECES), ../../../../libcpu/$(RTEMS_CPU)/simsh4/$(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