[PATCH 2/2] Epiphany: Add the first epiphany_sim BSP.

Gedare Bloom gedare at rtems.org
Fri May 8 15:56:47 UTC 2015


On Thu, May 7, 2015 at 10:12 PM, Hesham ALMatary
<heshamelmatary at gmail.com> wrote:
> This BSP in intended to run on the simulator that should be built
> from RSB. When building RTEMS for Epiphany --disable-networking must
> be provided part of the configure command.
> ---
>  c/src/aclocal/rtems-cpu-subdirs.m4                 |   1 +
>  c/src/lib/libbsp/epiphany/Makefile.am              |   8 +
>  c/src/lib/libbsp/epiphany/acinclude.m4             |  10 +
>  c/src/lib/libbsp/epiphany/configure.ac             |  20 ++
>  c/src/lib/libbsp/epiphany/epiphany_sim/Makefile.am |  95 ++++++
>  c/src/lib/libbsp/epiphany/epiphany_sim/README      |   6 +
>  c/src/lib/libbsp/epiphany/epiphany_sim/bsp_specs   |  11 +
>  .../lib/libbsp/epiphany/epiphany_sim/configure.ac  |  37 +++
>  .../epiphany/epiphany_sim/console/console-io.c     |  87 +++++
>  .../lib/libbsp/epiphany/epiphany_sim/include/bsp.h |  40 +++
>  .../libbsp/epiphany/epiphany_sim/include/bspopts.h |  53 ++++
>  .../lib/libbsp/epiphany/epiphany_sim/include/irq.h |  31 ++
>  .../libbsp/epiphany/epiphany_sim/include/tm27.h    |  38 +++
>  c/src/lib/libbsp/epiphany/epiphany_sim/irq/irq.c   |  43 +++
>  .../epiphany_sim/make/custom/epiphany_sim.cfg      |   7 +
>  .../lib/libbsp/epiphany/epiphany_sim/preinstall.am | 104 ++++++
>  .../lib/libbsp/epiphany/epiphany_sim/start/start.S | 152 +++++++++
>  .../libbsp/epiphany/epiphany_sim/startup/linkcmds  | 351 +++++++++++++++++++++
>  .../lib/libbsp/epiphany/epiphany_sim/timer/timer.c | 111 +++++++
>  c/src/lib/libbsp/epiphany/preinstall.am            |   7 +
>  .../epiphany/shared/include/linker-symbols.h       |  81 +++++
>  21 files changed, 1293 insertions(+)
>  create mode 100644 c/src/lib/libbsp/epiphany/Makefile.am
>  create mode 100644 c/src/lib/libbsp/epiphany/acinclude.m4
>  create mode 100644 c/src/lib/libbsp/epiphany/configure.ac
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/Makefile.am
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/README
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/bsp_specs
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/configure.ac
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/console/console-io.c
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/include/bsp.h
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/include/bspopts.h
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/include/irq.h
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/include/tm27.h
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/irq/irq.c
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/make/custom/epiphany_sim.cfg
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/preinstall.am
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/start/start.S
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/startup/linkcmds
>  create mode 100644 c/src/lib/libbsp/epiphany/epiphany_sim/timer/timer.c
>  create mode 100644 c/src/lib/libbsp/epiphany/preinstall.am
>  create mode 100644 c/src/lib/libbsp/epiphany/shared/include/linker-symbols.h
>
> diff --git a/c/src/aclocal/rtems-cpu-subdirs.m4 b/c/src/aclocal/rtems-cpu-subdirs.m4
> index 9593d34..524edac 100644
> --- a/c/src/aclocal/rtems-cpu-subdirs.m4
> +++ b/c/src/aclocal/rtems-cpu-subdirs.m4
> @@ -12,6 +12,7 @@ AC_DEFUN([RTEMS_CPU_SUBDIRS],
>  case $RTEMS_CPU in
>  _RTEMS_CPU_SUBDIR([arm],[$1]);;
>  _RTEMS_CPU_SUBDIR([bfin],[$1]);;
> +_RTEMS_CPU_SUBDIR([epiphany],[$1]);;
>  _RTEMS_CPU_SUBDIR([avr],[$1]);;
>  _RTEMS_CPU_SUBDIR([h8300],[$1]);;
>  _RTEMS_CPU_SUBDIR([i386],[$1]);;
> diff --git a/c/src/lib/libbsp/epiphany/Makefile.am b/c/src/lib/libbsp/epiphany/Makefile.am
> new file mode 100644
> index 0000000..cdcc3fb
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/Makefile.am
> @@ -0,0 +1,8 @@
> +ACLOCAL_AMFLAGS = -I ../../../aclocal
> +## Descend into the @RTEMS_BSP_FAMILY@ directory
> +## Currently, the shared directory is not explicitly
> +## added but it is present in the source tree.
> +SUBDIRS = @RTEMS_BSP_FAMILY@
> +include $(srcdir)/preinstall.am
> +include $(top_srcdir)/../../../automake/subdirs.am
> +include $(top_srcdir)/../../../automake/local.am
> diff --git a/c/src/lib/libbsp/epiphany/acinclude.m4 b/c/src/lib/libbsp/epiphany/acinclude.m4
> new file mode 100644
> index 0000000..0fe1e2e
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/acinclude.m4
> @@ -0,0 +1,10 @@
> +# RTEMS_CHECK_BSPDIR(RTEMS_BSP_FAMILY)
> +AC_DEFUN([RTEMS_CHECK_BSPDIR],
> +[
> +  case "$1" in
> +  epiphany_sim )
> +    AC_CONFIG_SUBDIRS([epiphany_sim]);;
> +  *)
> +    AC_MSG_ERROR([Invalid BSP]);;
> +  esac
> +])
> diff --git a/c/src/lib/libbsp/epiphany/configure.ac b/c/src/lib/libbsp/epiphany/configure.ac
> new file mode 100644
> index 0000000..899d4d7
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/configure.ac
> @@ -0,0 +1,19 @@
> +# Process this file with autoconf to produce a configure script.
> +
> +AC_PREREQ([2.69])
> +AC_INIT([rtems-c-src-lib-libbsp-epiphany],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
> +AC_CONFIG_SRCDIR([epiphany_sim])
> +RTEMS_TOP(../../../../..)
> +
> +RTEMS_CANONICAL_TARGET_CPU
> +AM_INIT_AUTOMAKE([no-define foreign subdir-objects 1.12.2])
> +AM_MAINTAINER_MODE
> +
> +RTEMS_ENV_RTEMSBSP
> +RTEMS_PROJECT_ROOT
> +
> +RTEMS_CHECK_BSPDIR([$RTEMS_BSP_FAMILY])
> +
> +# Explicitly list all Makefiles here
> +AC_CONFIG_FILES([Makefile])
> +AC_OUTPUT
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/Makefile.am b/c/src/lib/libbsp/epiphany/epiphany_sim/Makefile.am
> new file mode 100644
> index 0000000..0b84843
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/Makefile.am
> @@ -0,0 +1,95 @@
> +##
> +#
> +# @brief Makefile of LibBSP for the Epiphany simulator.
> +#
> +#
> +ACLOCAL_AMFLAGS = -I ../../../../aclocal
> +
> +include $(top_srcdir)/../../../../automake/compile.am
> +
> +include_bspdir = $(includedir)/bsp
> +include_libcpudir = $(includedir)/libcpu
> +
> +dist_project_lib_DATA = bsp_specs
> +
> +###############################################################################
> +#                  Header                                                     #
> +###############################################################################
> +
> +include_HEADERS = include/bsp.h
> +include_HEADERS += include/tm27.h
> +include_HEADERS += ../../shared/include/coverhd.h
> +
> +nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
> +include_bsp_HEADERS = ../shared/include/linker-symbols.h
> +
> +include_bsp_HEADERS += ../../../libbsp/shared/include/mm.h
> +include_bsp_HEADERS += ../../shared/include/utility.h
> +include_bsp_HEADERS += ../../shared/include/irq-generic.h
> +include_bsp_HEADERS += ../../shared/include/irq-info.h
> +include_bsp_HEADERS += ../../shared/include/stackalloc.h
> +include_bsp_HEADERS += ../../shared/include/console-polled.h
> +include_bsp_HEADERS += include/irq.h
> +
> +nodist_include_HEADERS = include/bspopts.h
> +
> +###############################################################################
> +#                  Data                                                       #
> +###############################################################################
> +noinst_LIBRARIES = libbspstart.a
> +
> +libbspstart_a_SOURCES = start/start.S
> +
> +project_lib_DATA = start/start.$(OBJEXT)
> +
> +project_lib_DATA += startup/linkcmds
> +
> +###############################################################################
> +#                  LibBSP                                                     #
> +###############################################################################
> +
> +noinst_LIBRARIES += libbsp.a
> +
> +# Startup
> +libbsp_a_SOURCES = ../../shared/bspreset.c
> +libbsp_a_SOURCES += ../../shared/bspstart.c
> +
> +# Shared
> +libbsp_a_SOURCES += ../../shared/bootcard.c
> +libbsp_a_SOURCES += ../../shared/bspclean.c
> +libbsp_a_SOURCES += ../../shared/bsplibc.c
> +libbsp_a_SOURCES += ../../shared/bsppost.c
> +libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
> +libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
> +libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
> +libbsp_a_SOURCES += ../../shared/sbrk.c
> +libbsp_a_SOURCES += ../../shared/src/stackalloc.c
> +libbsp_a_SOURCES += ../../shared/bspgetworkarea.c
> +
> +# clock
> +libbsp_a_SOURCES += ../../shared/clock_driver_simidle.c
> +
> +# Timer
> +libbsp_a_SOURCES += timer/timer.c
> +
> +# console
> +libbsp_a_SOURCES += ../../shared/console-polled.c
> +
> +# IRQ
> +libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c
> +libbsp_a_SOURCES += ../../shared/src/irq-generic.c
> +libbsp_a_SOURCES += ../../shared/src/irq-info.c
> +libbsp_a_SOURCES += irq/irq.c
> +
> +# Cache
> +libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
> +libbsp_a_SOURCES += ../../shared/include/cache_.h
> +libbsp_a_CPPFLAGS = -I$(srcdir)/../../shared/include
> +
> +# debugio
> +libbsp_a_SOURCES += console/console-io.c
> +
> +DISTCLEANFILES = include/bspopts.h
> +
> +include $(srcdir)/preinstall.am
> +include $(top_srcdir)/../../../../automake/local.am
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/README b/c/src/lib/libbsp/epiphany/epiphany_sim/README
> new file mode 100644
> index 0000000..7127d91
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/README
> @@ -0,0 +1,6 @@
> +This BSP is intended to run on epiphany-*-run simulator.
> +
> +From command line type:
> +
> +$ epiphany-rtems4.11-run -e=on --memory-region 0x8e000000,0x2000000 \
> +  $PATH_TO_RTEMS_EXE
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/bsp_specs b/c/src/lib/libbsp/epiphany/epiphany_sim/bsp_specs
> new file mode 100644
> index 0000000..0fcd2dc
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/bsp_specs
> @@ -0,0 +1,11 @@
> +%rename endfile old_endfile
> +%rename startfile old_startfile
> +%rename link old_link
> +
> +*startfile:
> +%{!qrtems: %(old_startfile)} %{!nostdlib: %{qrtems: \
> +%{!qrtems_debug: start.o%s} \
> +%{qrtems_debug: start_g.o%s}}}
> +
> +*link:
> +%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N -e _start}
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/configure.ac b/c/src/lib/libbsp/epiphany/epiphany_sim/configure.ac
> new file mode 100644
> index 0000000..c3bed0d
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/configure.ac
> @@ -0,0 +1,36 @@
> +##
> +#
> +# @file
> +#
> +# @brief Configure script of LibBSP for epiphany_sim BSP.
> +#
> +
> +AC_PREREQ(2.69)
> +AC_INIT([rtems-c-src-lib-libbsp-epiphany-sim],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
> +AC_CONFIG_SRCDIR([bsp_specs])
> +RTEMS_TOP(../../../../../..)
> +
> +RTEMS_CANONICAL_TARGET_CPU
> +AM_INIT_AUTOMAKE([no-define nostdinc foreign subdir-objects 1.12.2])
> +RTEMS_BSP_CONFIGURE
> +
> +RTEMS_BSPOPTS_SET([BSP_START_RESET_VECTOR],[*],[])
> +RTEMS_BSPOPTS_HELP([BSP_START_RESET_VECTOR],[reset vector address for BSP
> +start])
> +
> +RTEMS_BSPOPTS_SET([BSP_EPIPHANY_PERIPHCLK],[*],[100000000U])
> +RTEMS_BSPOPTS_HELP([BSP_EPIPHANY_PERIPHCLK],[epiphany PERIPHCLK clock
> +frequency in Hz])
> +
> +RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm])
> +RTEMS_CANONICALIZE_TOOLS
> +RTEMS_PROG_CCAS
> +
> +RTEMS_CHECK_SMP
> +AM_CONDITIONAL(HAS_SMP,[test "$rtems_cv_HAS_SMP" = "yes"])
> +
> +RTEMS_BSP_CLEANUP_OPTIONS(0, 1)
> +RTEMS_BSP_LINKCMDS
> +
> +AC_CONFIG_FILES([Makefile])
> +AC_OUTPUT
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/console/console-io.c b/c/src/lib/libbsp/epiphany/epiphany_sim/console/console-io.c
> new file mode 100644
> index 0000000..35b2ab9
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/console/console-io.c
> @@ -0,0 +1,87 @@
> +/*
> + *  COPYRIGHT (c) 2015 University of York.
> + *  Hesham ALMatary <hmka501 at york.ac.uk>
> + *
> + *  The license and distribution terms for this file may be
> + *  found in the file LICENSE in this distribution or at
> + *  http://www.rtems.org/license/LICENSE
> + */
> +
> +#include <bsp.h>
> +#include <bsp/console-polled.h>
> +#include <rtems/libio.h>
> +#include <stdlib.h>
> +#include <assert.h>
> +#include <stdio.h>
> +
> +static void outbyte_console( char );
> +static char inbyte_console( void );
> +
> +void console_initialize_hardware(void)
> +{
> +  /* Do nothing */
> +}
> +
> +/* Epiphany simulator would handle this system call */
> +static void outbyte_console(char c)
> +{
> +  register int chan asm("r0") = STDOUT_FILENO;
> +  register void* addr asm("r1") = &c;
> +  register int len asm("r2") = 1;
> +
> +  /* Invoke write system call to be handled by Epiphany simulator */
> +  asm volatile ("trap 0" : : "r" (chan), "r" (addr), "r" (len));
__asm__

> +}
> +
> +static char inbyte_console(void)
> +{
> +  char c;
> +  register int chan asm("r0") = STDIN_FILENO;
> +  register void* addr asm("r1") = &c;
> +  register int len asm("r2") = 1;
> +
> +  /* Invoke read system call to be handled by Epiphany simulator */
> + asm ("trap 1" :: "r" (chan), "r" (addr), "r" (len));
Missing a whitespace for indent

> +  return c;
> +}
> +
> +/*
> + *  console_outbyte_polled
> + *
> + *  This routine transmits a character using polling.
> + */
> +void console_outbyte_polled(
> +  int  port,
> +  char ch
> +)
> +{
> +  outbyte_console( ch );
> +}
> +
> +/*
> + *  console_inbyte_nonblocking
> + *
> + *  This routine polls for a character.
> + */
> +
> +int console_inbyte_nonblocking(int port)
> +{
> +  char c;
> +
> +  c = inbyte_console();
> +  if (!c)
> +    return -1;
> +  return (int) c;
> +}
> +
> +/*
> + *  To support printk
> + */
> +
> +#include <rtems/bspIo.h>
> +
> +static void Epiphany_output_char(char c) { console_outbyte_polled( 0, c ); }
> +
> +BSP_output_char_function_type BSP_output_char = Epiphany_output_char;
> +BSP_polling_getchar_function_type BSP_poll_char =
> +  (void *)console_inbyte_nonblocking;
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/include/bsp.h b/c/src/lib/libbsp/epiphany/epiphany_sim/include/bsp.h
> new file mode 100644
> index 0000000..b9549ac
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/include/bsp.h
> @@ -0,0 +1,40 @@
> +/*
> + *  Epiphany CPU Dependent Source
> + *
> + *  COPYRIGHT (c) 2015 University of York.
> + *  Hesham ALMatary <hmka501 at york.ac.uk>
> + *
> + *  COPYRIGHT (c) 1989-1999.
> + *  On-Line Applications Research Corporation (OAR).
> + *
> + *  The license and distribution terms for this file may be
> + *  found in the file LICENSE in this distribution or at
> + *  http://www.rtems.com/license/LICENSE.
> + *
> + */
> +
> +#ifndef LIBBSP_EPIPHANY_PARALLELLA_H
> +#define LIBBSP_EPIPHANY_PARALLELLA_H
Typo: PARALLELA. Also, not sure why you use that here and not SIM.

> +
> +#include <rtems.h>
> +#include <rtems/clockdrv.h>
> +#include <rtems/console.h>
> +
> +#include <bspopts.h>
> +#include <bsp/default-initial-extension.h>
> +
> +#include <rtems/devnull.h>
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/* Constants */
> +Thread clock_driver_sim_idle_body(uintptr_t);
> +#define BSP_IDLE_TASK_BODY clock_driver_sim_idle_body
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* LIBBSP_EPIPHANY_PARALLELLA_H */
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/include/bspopts.h b/c/src/lib/libbsp/epiphany/epiphany_sim/include/bspopts.h
> new file mode 100644
> index 0000000..cdba6d2
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/include/bspopts.h
> @@ -0,0 +1,53 @@
> +/*
> + *  Epiphany CPU Dependent Source
> + *
> + *  COPYRIGHT (c) 2015 University of York.
> + *  Hesham ALMatary <hmka501 at york.ac.uk>
> + *
> + *  COPYRIGHT (c) 1989-1999.
> + *  On-Line Applications Research Corporation (OAR).
> + *
> + *  The license and distribution terms for this file may be
> + *  found in the file LICENSE in this distribution or at
> + *  http://www.rtems.com/license/LICENSE.
> + *
> + */
> +
> +/* include/bspopts.h.in.  Generated from configure.ac by autoheader.  */
> +
> +/* If defined, then the BSP Framework will put a non-zero pattern into the
> +   RTEMS Workspace and C program heap. This should assist in finding code that
> +   assumes memory starts set to zero. */
> +#undef BSP_DIRTY_MEMORY
> +
> +/* If defined, print a message and wait until pressed before resetting board
> +   when application exits. */
> +#undef BSP_PRESS_KEY_FOR_RESET
> +
> +/* If defined, prints the exception context when an unexpected exception
> +   occurs. */
> +#undef BSP_PRINT_EXCEPTION_CONTEXT
> +
> +/* If defined, reset the board when the application exits. */
> +#undef BSP_RESET_BOARD_AT_EXIT
> +
> +/* reset vector address for BSP start */
> +#undef BSP_START_RESET_VECTOR
> +
> +/* Define to the address where bug reports for this package should be sent. */
> +#undef PACKAGE_BUGREPORT
> +
> +/* Define to the full name of this package. */
> +#undef PACKAGE_NAME
> +
> +/* Define to the full name and version of this package. */
> +#undef PACKAGE_STRING
> +
> +/* Define to the one symbol short name of this package. */
> +#undef PACKAGE_TARNAME
> +
> +/* Define to the home page for this package. */
> +#undef PACKAGE_URL
> +
> +/* Define to the version of this package. */
> +#undef PACKAGE_VERSION
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/include/irq.h b/c/src/lib/libbsp/epiphany/epiphany_sim/include/irq.h
> new file mode 100644
> index 0000000..e7d01c3
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/include/irq.h
> @@ -0,0 +1,31 @@
> +/**
> + * @file
> + *
> + * @ingroup Epiphany_IRQ
> + *
> + * @brief Interrupt definitions.
> + */
> +
> +/**
> + * COPYRIGHT (c) 2015 University of York.
> + * Hesham ALMatary <hmka501 at york.ac.uk>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.org/license/LICENSE
> + */
> +
> +#ifndef LIBBSP_GENERIC_EPIPHANY_IRQ_H
> +#define LIBBSP_GENERIC_EPIPHANY_IRQ_H
> +
> +#ifndef ASM
> +
> +#include <rtems.h>
> +#include <rtems/irq.h>
> +#include <rtems/irq-extension.h>
> +
> +#define BSP_INTERRUPT_VECTOR_MIN  0x0
> +#define BSP_INTERRUPT_VECTOR_MAX  0x24
> +
> +#endif /* ASM */
> +#endif /* LIBBSP_GENEIRC_OR1K_IRQ_H */
Fix comment. Probably the typo in GENERIC caused find/replace to fail.
May want to fix the typo in the associated or1k file.


> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/include/tm27.h b/c/src/lib/libbsp/epiphany/epiphany_sim/include/tm27.h
> new file mode 100644
> index 0000000..181cca0
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/include/tm27.h
> @@ -0,0 +1,38 @@
> +/*
> + *  Epiphany CPU Dependent Source
> + *
> + *  COPYRIGHT (c) 2015 University of York.
> + *  Hesham ALMatary <hmka501 at york.ac.uk>
> + *
> + *  COPYRIGHT (c) 1989-1999.
> + *  On-Line Applications Research Corporation (OAR).
> + *
> + *  The license and distribution terms for this file may be
> + *  found in the file LICENSE in this distribution or at
> + *  http://www.rtems.com/license/LICENSE.
> + *
> + */
> +
> +#ifndef _RTEMS_TMTEST27
> +#error "This is an RTEMS internal file you must not include directly."
> +#endif
> +
> +#ifndef __tm27_h
> +#define __tm27_h
> +
> +/**
> + * @name Interrupt mechanisms for Time Test 27
> + * @{
> + */
> +
> +#define MUST_WAIT_FOR_INTERRUPT 0
> +
> +#define Install_tm27_vector( handler ) /* empty */
> +
> +#define Cause_tm27_intr() /* empty */
> +
> +#define Clear_tm27_intr() /* empty */
> +
> +#define Lower_tm27_intr() /* empty */
> +
> +#endif
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/irq/irq.c b/c/src/lib/libbsp/epiphany/epiphany_sim/irq/irq.c
> new file mode 100644
> index 0000000..2be8df0
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/irq/irq.c
> @@ -0,0 +1,43 @@
> +/**
> + * @file
> + *
> + * @ingroup epiphany_interrupt
> + *
> + * @brief Interrupt support.
> + */
> +
> +/*
> + *  COPYRIGHT (c) 2015 University of York.
> + *  Hesham ALMatary <hmka501 at york.ac.uk>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.org/license/LICENSE.
> + */
> +
> +#include <bsp/irq.h>
> +#include <bsp/irq-generic.h>
> +
> +/* Almost all of the jobs that the following functions should
> + * do are implemented in cpukit
> + */
> +
> +void bsp_interrupt_handler_default(rtems_vector_number vector)
> +{
> +    printk("spurious interrupt: %u\n", vector);
> +}
> +
> +rtems_status_code bsp_interrupt_facility_initialize()
> +{
> +  return 0;
> +}
> +
> +rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
> +{
> +  return 0;
> +}
> +
> +rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
> +{
> +  return 0;
> +}
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/make/custom/epiphany_sim.cfg b/c/src/lib/libbsp/epiphany/epiphany_sim/make/custom/epiphany_sim.cfg
> new file mode 100644
> index 0000000..9eea2a0
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/make/custom/epiphany_sim.cfg
> @@ -0,0 +1,7 @@
> +include $(RTEMS_ROOT)/make/custom/default.cfg
> +
> +RTEMS_CPU = epiphany
> +
> +CPU_CFLAGS =
> +
> +CFLAGS_OPTIMIZE_V ?= -O0 -g
No optimizing?

> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/preinstall.am b/c/src/lib/libbsp/epiphany/epiphany_sim/preinstall.am
> new file mode 100644
> index 0000000..e53b646
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/preinstall.am
> @@ -0,0 +1,103 @@
> +## Automatically generated by ampolish3 - Do not edit
> +
> +if AMPOLISH3
> +$(srcdir)/preinstall.am: Makefile.am
> +       $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
> +endif
> +
> +PREINSTALL_DIRS =
> +DISTCLEANFILES += $(PREINSTALL_DIRS)
> +
> +all-am: $(PREINSTALL_FILES)
> +
> +PREINSTALL_FILES =
> +CLEANFILES = $(PREINSTALL_FILES)
> +
> +all-local: $(TMPINSTALL_FILES)
> +
> +TMPINSTALL_FILES =
> +CLEANFILES += $(TMPINSTALL_FILES)
> +
> +$(PROJECT_LIB)/$(dirstamp):
> +       @$(MKDIR_P) $(PROJECT_LIB)
> +       @: > $(PROJECT_LIB)/$(dirstamp)
> +PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp)
> +
> +$(PROJECT_INCLUDE)/$(dirstamp):
> +       @$(MKDIR_P) $(PROJECT_INCLUDE)
> +       @: > $(PROJECT_INCLUDE)/$(dirstamp)
> +PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp)
> +
> +$(PROJECT_INCLUDE)/bsp/$(dirstamp):
> +       @$(MKDIR_P) $(PROJECT_INCLUDE)/bsp
> +       @: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +
> +$(PROJECT_INCLUDE)/libcpu/$(dirstamp):
> +       @$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu
> +       @: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
> +PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
> +
> +$(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
> +PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
> +
> +$(PROJECT_INCLUDE)/bsp.h: include/bsp.h $(PROJECT_INCLUDE)/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
> +
> +$(PROJECT_INCLUDE)/tm27.h: include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
> +
> +$(PROJECT_INCLUDE)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
> +
> +$(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
> +
> +$(PROJECT_INCLUDE)/bsp/linker-symbols.h: ../shared/include/linker-symbols.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/linker-symbols.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/linker-symbols.h
> +
> +$(PROJECT_INCLUDE)/bsp/mm.h: ../../../libbsp/shared/include/mm.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mm.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mm.h
> +
> +$(PROJECT_INCLUDE)/bsp/utility.h: ../../shared/include/utility.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/utility.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/utility.h
> +
> +$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
> +
> +$(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h
> +
> +$(PROJECT_INCLUDE)/bsp/stackalloc.h: ../../shared/include/stackalloc.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/stackalloc.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/stackalloc.h
> +
> +$(PROJECT_INCLUDE)/bsp/console-polled.h: ../../shared/include/console-polled.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/console-polled.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/console-polled.h
> +
> +$(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
> +
> +$(PROJECT_INCLUDE)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h
> +
> +$(PROJECT_LIB)/start.$(OBJEXT): start/start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
> +TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
> +
> +$(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
> +       $(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
> +TMPINSTALL_FILES += $(PROJECT_LIB)/linkcmds
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/start/start.S b/c/src/lib/libbsp/epiphany/epiphany_sim/start/start.S
> new file mode 100644
> index 0000000..3c4b24f
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/start/start.S
> @@ -0,0 +1,152 @@
> +/*
> + *  COPYRIGHT (c) 2015 University of York.
> + *  Hesham ALMatary <hmka501 at york.ac.uk>
> + *
> + *  The license and distribution terms for this file may be
> + *  found in the file LICENSE in this distribution or at
> + *  http://www.rtems.org/license/LICENSE
> + */
> +#include <bsp/linker-symbols.h>
> +
> +.extern bsp_section_bss_begin
> +.extern bsp_section_bss_end
> +.extern _ISR_Handler
> +.extern  bsp_start_vector_table_end
> +.extern  bsp_start_vector_table_size
> +.extern  bsp_vector_table_size
> +.extern  bsp_section_stack_begin
> +
> +.global  _EPIPHANY_Exception_default;
> +.global  _bsp_start_vector_table_begin

Use the macros like EXTERN and GLOBAL?

> +
> +.section .vector, "ax";
Probably need "wax" to support installing exception handlers at run-time?

> +.global _start;
> +.type   _start, %function;
> +_start:
> +  .balign 4 ;
> +    b .normal_start
> +
> +  .balign 4 ; 0x4
Is the b instruction != 32 bits wide? If it is 32-bits, don't need to
keep aligning?

> +    b .sw_exception
> +
> +  .balign 4 ; 0x8
> +    b .normal_start
> +
> +  .balign 4 ; 0xc
> +    b .clock_isr
> +
> +  .balign 4 ; 0x10
> +    b .timer1_isr
> +
> +  .balign 4 ; 0x14
> +    b _EPIPHANY_Exception_default
> +
> +  .balign 4 ; 0x18
> +    b _EPIPHANY_Exception_default
> +
> +  .balign 4 ; 0x1c
> +    b _EPIPHANY_Exception_default
> +
> +  .balign 4 ; 0x20
> +    b _EPIPHANY_Exception_default
> +
> +  .balign 4 ; 0x24
> +    b _EPIPHANY_Exception_default
> +
> +_bsp_start_vector_table_begin:
> +
> +  .balign 4 ;
> +    .word .normal_start /* Reset */
> +  .balign 4 ;
Almost certainly you shouldn't need to keep aligning here, right?
.word should give you 4 bytes I would guess.

> +    .word _EPIPHANY_Exception_default /* SW exception */
> +  .balign 4 ;
> +    .word _EPIPHANY_Exception_default /* Data Page Fault */
> +  .balign 4 ;
> +    .word _EPIPHANY_Exception_default /* Timer 0 */
> +  .balign 4 ;
> +    .word _EPIPHANY_Exception_default /* Timer 1 */
> +  .balign 4 ;
> +   .word _EPIPHANY_Exception_default /* Message int */
> +  .balign 4 ;
> +   .word _EPIPHANY_Exception_default /* DMA0 int */
> +  .balign 4 ;
> +   .word _EPIPHANY_Exception_default /* DMA1 int */
> +  .balign 4 ;
> +   .word _EPIPHANY_Exception_default /* WAND */
> +  .balign 4 ;
> +   .word _EPIPHANY_Exception_default /* User interrupt */
> +
> +_bsp_start_vector_table_end:
> +
> +.size  _start, .-_start
> +
> +.section .start,"ax"
> +.align  4
> +.type   _external_start, %function
> +.normal_start:
> +  /* Initialize the stack and frame pointers */
> +  mov  sp, %low(bsp_section_stack_begin)
> +  movt sp, %high(bsp_section_stack_begin)
> +  mov  fp, sp
> +
> +cpu0:
> +  /* Zero .bss section */
> +  mov  r0, %low(bsp_section_bss_begin)
> +  movt r0, %high(bsp_section_bss_begin)
> +  mov  r1, sp
> +  mov  r2,#0
> +  mov  r3,#0
> +
> +_bss_clear_loop:
> +  strd  r2, [r0], +#1
> +  sub   r5, r1, r0
> +  bne   _bss_clear_loop
> +
> +  /* Clear the reset interrupt flag */
> +  mov   r0, %low(_jump_to_c)
> +  movt  r0, %high(_jump_to_c)
> +  movts iret, r0
> +  rti
> +
> +_jump_to_c:
> +  /* Jump to bootcard */
> +  mov  r3, %low(_boot_card)
> +  movt r3, %high(_boot_card)
> +  jalr r3
> +
> + /* Should never reach here */
> + idle
> +
> +.size  .normal_start, .-.normal_start
> +
> +.balign 4
> +.type   .sw_exception, %function
> +.sw_exception:
> +  idle
> +
> +.balign 4
> +.type   .clock_isr, %function
> +.clock_isr:
> +  add  sp, sp, #-8;
> +  str  r62, [sp, #4];
> +  str  r63, [sp, #8];
What's going on here? And why isn't this code part of the clock driver?

> +  mov  r62, 3;
> +  mov  r63, %low(_ISR_Handler);
> +  movt r63, %high(_ISR_Handler);
> +  jr   r63
> +
> +.balign 4
> +.type   .timer1_isr, %function
> +.timer1_isr:
> +  add  sp, sp, #-8;
> +  str  r62, [sp, #4];
> +  str  r63, [sp, #8];
> +  mov  r62, 4;
> +  mov  r63, %low(_ISR_Handler);
> +  movt r63, %high(_ISR_Handler);
> +  jr  r63
> +
> +.balign 4
> +.type   _EPIPHANY_Exception_default, %function
> +_EPIPHANY_Exception_default:
> +  idle
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/startup/linkcmds b/c/src/lib/libbsp/epiphany/epiphany_sim/startup/linkcmds
> new file mode 100644
> index 0000000..2f59982
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/startup/linkcmds
> @@ -0,0 +1,351 @@
> +/**
> + * @file
> + *
> + * @ingroup bsp_linker
> + *
> + * @brief Memory map
> + */
> +
> +/*
> + *  COPYRIGHT (c) 2015 University of York.
> + *  Hesham ALMatary <hmka501 at york.ac.uk>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.org/license/LICENSE
> + */
> +
> +OUTPUT_FORMAT("elf32-epiphany", "elf32-epiphany", "elf32-epiphany")
> +OUTPUT_ARCH (epiphany)
> +
> +ENTRY (_start)
> +
> +MEMORY
> +{
> +  VECTOR_RAM  (AIW) : ORIGIN = 0x00000000, LENGTH = 0xB0
> +  LOCAL_MEM   (AIW) : ORIGIN = 0x000000B0, LENGTH = 0x00007FC0 /* 32KiB Local memory */
> +  RAM               : ORIGIN = 0x8E000000, LENGTH = 0x01000000 /* 16MiB external RAM */
> +}
> +
> +REGION_ALIAS ("REGION_START", LOCAL_MEM);
> +REGION_ALIAS ("REGION_VECTOR", VECTOR_RAM);
> +REGION_ALIAS ("REGION_TEXT", RAM);
> +REGION_ALIAS ("REGION_TEXT_LOAD", RAM);
> +REGION_ALIAS ("REGION_RODATA", RAM);
> +REGION_ALIAS ("REGION_RODATA_LOAD", RAM);
> +REGION_ALIAS ("REGION_DATA", RAM);
> +REGION_ALIAS ("REGION_DATA_LOAD", RAM);
> +REGION_ALIAS ("REGION_FAST_DATA", RAM);
> +REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM);
> +REGION_ALIAS ("REGION_BSS", RAM);
> +REGION_ALIAS ("REGION_WORK", RAM);
> +REGION_ALIAS ("REGION_STACK", RAM);
> +
> +/* The following address is used for text output */
> +bsp_section_outbut_buffer = 0x8F800000;
> +bsp_section_vector_begin  = 0x00000000;
> +
> +/*
> + * Global symbols that may be defined externally
> + */
> +bsp_vector_table_size = DEFINED (bsp_vector_table_size) ? bsp_vector_table_size : 64;
> +
> +bsp_section_xbarrier_align  = DEFINED (bsp_section_xbarrier_align) ? bsp_section_xbarrier_align : 1;
> +bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1;
> +bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1;
> +
> +bsp_stack_align = DEFINED (bsp_stack_align) ? bsp_stack_align : 8;
> +
> +bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 1024;
> +bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
> +
> +_bsp_processor_count = DEFINED (_bsp_processor_count) ? _bsp_processor_count : 1;
> +
> +SECTIONS {
> +
> +  .vector :
> +  {
> +    *(.vector)
> +    . = ALIGN(bsp_vector_table_size);
> +    bsp_section_vector_end = .;
> +  } > REGION_VECTOR AT > REGION_VECTOR
> +  bsp_section_vector_size = bsp_section_vector_end - bsp_section_vector_begin;
> +  bsp_vector_table_begin = bsp_section_vector_begin;
> +  bsp_vector_table_end = bsp_vector_table_begin + bsp_vector_table_size;
> +
> +  .start :
> +  {
> +    . = ALIGN(8);
> +    bsp_section_start_begin = .;
> +    KEEP (*(.bsp_start_text))
> +    KEEP (*(.bsp_start_data))
> +    bsp_section_start_end = .;
> +  } > REGION_START AT > REGION_START
> +  bsp_section_start_size = bsp_section_start_end - bsp_section_start_begin;
> +
> +.xbarrier :   {
> +    . = ALIGN (bsp_section_xbarrier_align);
> +  } > REGION_VECTOR AT > REGION_VECTOR
> +
> +.text :   {
> +    . = ALIGN(8);
> +    bsp_section_text_begin = .;
> +    *(.text.unlikely .text.*_unlikely)
> +    *(.text .stub .text.* .gnu.linkonce.t.*)
> +    /* .gnu.warning sections are handled specially by elf32.em.  */
> +    *(.gnu.warning)
> +    *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
> +  } > REGION_TEXT AT > REGION_TEXT_LOAD
> +  .init :   {
> +    KEEP (*(.init))
> +  } > REGION_TEXT AT > REGION_TEXT_LOAD
> +  .fini :   {
> +    KEEP (*(.fini))
> +    . = ALIGN(8);
> +    bsp_section_text_end = .;
> +  } > REGION_TEXT AT > REGION_TEXT_LOAD
> +  bsp_section_text_size = bsp_section_text_end - bsp_section_text_begin;
> +  bsp_section_text_load_begin = LOADADDR (.text);
> +  bsp_section_text_load_end = bsp_section_text_load_begin + bsp_section_text_size;
> +
> +.robarrier :   {
> +    . = ALIGN (bsp_section_robarrier_align);
> +  } > REGION_RODATA AT > REGION_RODATA
> +
> +.rodata :   {
> +    . = ALIGN(8);
> +    bsp_section_rodata_begin = .;
> +    *(.rodata .rodata.* .gnu.linkonce.r.*)
> +  } > REGION_RODATA AT > REGION_RODATA_LOAD
> +.eh_frame :   {
> +               KEEP (*(.eh_frame))
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .gcc_except_table :   {
> +               *(.gcc_except_table .gcc_except_table.*)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .tdata :   {
> +               __TLS_Data_begin = .;
> +               *(.tdata .tdata.* .gnu.linkonce.td.*)
> +               __TLS_Data_end = .;
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .tbss :   {
> +               __TLS_BSS_begin = .;
> +               *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
> +               __TLS_BSS_end = .;
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       __TLS_Data_size = __TLS_Data_end - __TLS_Data_begin;
> +       __TLS_Data_begin = __TLS_Data_size != 0 ? __TLS_Data_begin : __TLS_BSS_begin;
> +       __TLS_Data_end = __TLS_Data_size != 0 ? __TLS_Data_end : __TLS_BSS_begin;
> +       __TLS_BSS_size = __TLS_BSS_end - __TLS_BSS_begin;
> +       __TLS_Size = __TLS_BSS_end - __TLS_Data_begin;
> +       __TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));
> +       .preinit_array :   {
> +               PROVIDE_HIDDEN (__preinit_array_start = .);
> +               KEEP (*(.preinit_array))
> +               PROVIDE_HIDDEN (__preinit_array_end = .);
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .init_array :   {
> +               PROVIDE_HIDDEN (__init_array_start = .);
> +               KEEP (*(SORT(.init_array.*)))
> +               KEEP (*(.init_array))
> +               PROVIDE_HIDDEN (__init_array_end = .);
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .fini_array :   {
> +               PROVIDE_HIDDEN (__fini_array_start = .);
> +               KEEP (*(.fini_array))
> +               KEEP (*(SORT(.fini_array.*)))
> +               PROVIDE_HIDDEN (__fini_array_end = .);
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .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))
> +               KEEP (*crtbegin?.o(.ctors))
> +               /* We don't want to include the .ctor section 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 *crtend?.o ) .ctors))
> +               KEEP (*(SORT(.ctors.*)))
> +               KEEP (*(.ctors))
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .dtors :   {
> +               KEEP (*crtbegin.o(.dtors))
> +               KEEP (*crtbegin?.o(.dtors))
> +               KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
> +               KEEP (*(SORT(.dtors.*)))
> +               KEEP (*(.dtors))
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .data.rel.ro :   {
> +               *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*)
> +               *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .jcr :   {
> +               KEEP (*(.jcr))
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .interp :   {
> +               *(.interp)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .note.gnu.build-id :   {
> +               *(.note.gnu.build-id)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .hash :   {
> +               *(.hash)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .gnu.hash :   {
> +               *(.gnu.hash)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .dynsym :   {
> +               *(.dynsym)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .dynstr :   {
> +               *(.dynstr)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .gnu.version :   {
> +               *(.gnu.version)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .gnu.version_d :   {
> +               *(.gnu.version_d)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .gnu.version_r :   {
> +               *(.gnu.version_r)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .rel.dyn :   {
> +               *(.rel.init)
> +               *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
> +               *(.rel.fini)
> +               *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
> +               *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
> +               *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
> +               *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
> +               *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
> +               *(.rel.ctors)
> +               *(.rel.dtors)
> +               *(.rel.got)
> +               *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
> +               PROVIDE_HIDDEN (__rel_iplt_start = .);
> +               *(.rel.iplt)
> +               PROVIDE_HIDDEN (__rel_iplt_end = .);
> +               PROVIDE_HIDDEN (__rela_iplt_start = .);
> +               PROVIDE_HIDDEN (__rela_iplt_end = .);
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .rela.dyn :   {
> +               *(.rela.init)
> +               *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
> +               *(.rela.fini)
> +               *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
> +               *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
> +               *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
> +               *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
> +               *(.rela.ctors)
> +               *(.rela.dtors)
> +               *(.rela.got)
> +               *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
> +               PROVIDE_HIDDEN (__rel_iplt_start = .);
> +               PROVIDE_HIDDEN (__rel_iplt_end = .);
> +               PROVIDE_HIDDEN (__rela_iplt_start = .);
> +               *(.rela.iplt)
> +               PROVIDE_HIDDEN (__rela_iplt_end = .);
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .rel.plt :   {
> +               *(.rel.plt)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .rela.plt :   {
> +               *(.rela.plt)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .plt :   {
> +               *(.plt)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .iplt :   {
> +               *(.iplt)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .dynamic :   {
> +               *(.dynamic)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .got :   {
> +               *(.got.plt) *(.igot.plt) *(.got) *(.igot)
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +       .rtemsroset :   {
> +               /* Special FreeBSD linker set sections */
> +               __start_set_sysctl_set = .;
> +               *(set_sysctl_*);
> +               __stop_set_sysctl_set = .;
> +               *(set_domain_*);
> +               *(set_pseudo_*);
> +
> +               KEEP (*(SORT(.rtemsroset.*)))
> +               . = ALIGN(8);
> +               bsp_section_rodata_end = .;
> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
> +  bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin;
> +  bsp_section_rodata_load_begin = LOADADDR (.rodata);
> +  bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size;
> +
> +.rwbarrier :   {
> +    . = ALIGN(8);
> +    . = ALIGN (bsp_section_rwbarrier_align);
> +  } > REGION_DATA AT > REGION_DATA
> +
> +.data :   {
> +    . = ALIGN(8);
> +    bsp_section_data_begin = .;
> +    *(.data .data.* .gnu.linkonce.d.*)
> +    SORT(CONSTRUCTORS)
> +  } > REGION_DATA AT > REGION_DATA_LOAD
> +  .data1 :   {
> +    *(.data1)
> +  } > REGION_DATA AT > REGION_DATA_LOAD
> +  .rtemsrwset :   {
> +    KEEP (*(SORT(.rtemsrwset.*)))
> +    . = ALIGN(8);
> +    bsp_section_data_end = .;
> +  } > REGION_DATA AT > REGION_DATA_LOAD
> +  bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin;
> +  bsp_section_data_load_begin = LOADADDR (.data);
> +  bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size;
> +
> +  .bss :   {
> +    . = ALIGN(8);
> +    bsp_section_bss_begin = .;
> +    *(.dynbss)
> +    *(.bss .bss.* .gnu.linkonce.b.*)
> +    *(COMMON)
> +    . = ALIGN(8);
> +    bsp_section_bss_end = .;
> +  } > REGION_BSS AT > REGION_BSS
> +  bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin;
> +
> +.work :   {
> +    /*
> +     * The work section will occupy the remaining REGION_WORK region and
> +     * contains the RTEMS work space and heap.
> +     */
> +    . = ALIGN(8);
> +    bsp_section_work_begin = .;
> +    . += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.);
> +    . = ALIGN(8);
> +    bsp_section_work_end = .;
> +  } > REGION_WORK AT > REGION_WORK
> +  bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin;
> +
> +  .stack :   {
> +    . = ALIGN(8);
> +    bsp_section_stack_begin = .;
> +    . += ORIGIN (REGION_STACK) + LENGTH (REGION_STACK) - ABSOLUTE (.);
> +    . = ALIGN(8);
> +    bsp_section_stack_end = .;
> +  } > REGION_STACK AT > REGION_STACK
> +  bsp_section_stack_size = bsp_section_stack_begin - bsp_section_stack_end;
> +
> +  _RamBase = ORIGIN (REGION_WORK);
> +  _RamSize = LENGTH (REGION_WORK);
> +  _WorkAreaBase = bsp_section_work_begin;
> +  _HeapSize = 0;
> +}
> diff --git a/c/src/lib/libbsp/epiphany/epiphany_sim/timer/timer.c b/c/src/lib/libbsp/epiphany/epiphany_sim/timer/timer.c
> new file mode 100644
> index 0000000..7644939
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/epiphany_sim/timer/timer.c
> @@ -0,0 +1,111 @@
> +/*
> + *  COPYRIGHT (c) 2015 University of York.
> + *  Hesham ALMatary <hmka501 at york.ac.uk>
> + *
> + *  The license and distribution terms for this file may be
> + *  found in the file LICENSE in this distribution or at
> + *  http://www.rtems.org/license/LICENSE
> + */
> +
> +#include <rtems.h>
> +#include <bsp.h>
> +#include <rtems/btimer.h>
> +#include <rtems/score/epiphany-utility.h>
> +
> +extern char bsp_start_vector_table_begin[];
> +
> +bool benchmark_timer_find_average_overhead;
> +
> +static benchmark_timer1_interrupt_handler(void)
> +{
> +  unsigned int val = 0xFFFFFFFF;
> +  unsigned int event_type = 0x1;
> +
> +  /* Embed assembly code for setting timer1 */
> +  asm volatile ("movts ctimer1, %[val] \t \n" :: [val] "r" (val));
> +
> +  asm volatile ("movfs r16, config; \t \n"
> +                "mov   r17, %%low(0xfffff0ff);\t \n"
> +                "movt  r17, %%high(0xffff0ff);\t \n"
> +                "lsl   r18, %[event_type], 0x8; \t \n"
> +                "and   r16, r16, r17; \t \n"
> +                "movts config, r16; \t \n"
> +                "orr   r16, r16, r18; \t \n"
> +                "movts config, r16; \t \n"
So you need to write to config twice? Or should it just be the second
one? (ditto below)

> +                :: [event_type] "r" (event_type));
> +}
> +
> +/* Start eCore tiemr 1 usef for profiling and timing analysis */
> +void benchmark_timer_initialize( void )
> +{
> +  unsigned int val = 0xFFFFFFFF;
> +  unsigned int event_type = 0x1;
> +
> +
> +  /* Install interrupt handler for timer 1 */
> +
> +  proc_ptr *table =
> +    (proc_ptr *) bsp_start_vector_table_begin;
> +
> +  table[TIMER1] = benchmark_timer1_interrupt_handler;
> +
> +  asm volatile ("mov r0, 0x0; \n \t"
> +                "movts config, r0; \t \n"::);
Consider adding some macros in epiphany.h for reading/writing the
special registers.

> +
> +  /* Embed assembly code for setting timer1 */
> +  asm volatile ("movts ctimer1, %[val] \t \n" :: [val] "r" (val));
> +
> +  asm volatile ("movfs r16, config; \t \n"
> +                "mov   r17, %%low(0xfffff0ff);\t \n"
> +                "movt  r17, %%high(0xffff0ff);\t \n"
> +                "lsl   r18, %[event_type], 0x8; \t \n"
> +                "and   r16, r16, r17; \t \n"
> +                "movts config, r16; \t \n"
> +                "orr   r16, r16, r18; \t \n"
> +                "movts config, r16; \t \n"
> +                :: [event_type] "r" (event_type));
> +}
Reduce copy-paste between initialize and the interrupt handler.

> +
> +/*
> + *  The following controls the behavior of benchmark_timer_read().
> + *
> + *  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 X.X 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 */
> +
> +benchmark_timer_t benchmark_timer_read( void )
> +{
> +  uint32_t timer_val = 0;
> +  uint32_t total;
> +
> +  asm volatile ("movfs %[timer_val], ctimer1 \t \n"
> +  :[timer_val] "=r" (timer_val):);
Fix indentation (nest second line) or better yet create a macro in
epiphany.h to read this reg.
> +
> +  total = (0xFFFFFFFF - timer_val); /* Convert to uS */
I don't know why this subtraction happens.

> +
> +  if ( benchmark_timer_find_average_overhead == true )
> +    return total;
> +  else {
> +    if ( total < LEAST_VALID )
> +      return 0;            /* below timer resolution */
> +  /*
> +   *  Somehow convert total into microseconds
> +   */
> +      return (total - AVG_OVERHEAD);
> +    }
> +}
> +
> +void benchmark_timer_disable_subtracting_average_overhead(
> +  bool find_flag
> +)
> +{
> +  benchmark_timer_find_average_overhead = find_flag;
> +}
> diff --git a/c/src/lib/libbsp/epiphany/preinstall.am b/c/src/lib/libbsp/epiphany/preinstall.am
> new file mode 100644
> index 0000000..dba6cc4
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/preinstall.am
> @@ -0,0 +1,6 @@
> +## Automatically generated by ampolish3 - Do not edit
> +
> +if AMPOLISH3
> +$(srcdir)/preinstall.am: Makefile.am
> +       $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
> +endif
> diff --git a/c/src/lib/libbsp/epiphany/shared/include/linker-symbols.h b/c/src/lib/libbsp/epiphany/shared/include/linker-symbols.h
> new file mode 100644
> index 0000000..c218b7f
> --- /dev/null
> +++ b/c/src/lib/libbsp/epiphany/shared/include/linker-symbols.h
> @@ -0,0 +1,81 @@
> +#ifndef LIBBSP_EPIPHANY_SHARED_LINKER_SYMBOLS_H
> +#define LIBBSP_EPIPHANY_SHARED_LINKER_SYMBOLS_H
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif /* __cplusplus */
> +
> +/**
> + * @defgroup epiphany_linker Linker Support
> + *
> + * @ingroup epiphany_shared
> + *
> + * @brief Linker support.
> + *
> + * @{
> + */
> +
> +#ifndef ASM
> +  #define LINKER_SYMBOL(sym) extern char sym [];
> +#else
> +  #define LINKER_SYMBOL(sym) .extern sym
> +#endif
> +
> +LINKER_SYMBOL(bsp_section_start_begin)
> +LINKER_SYMBOL(bsp_section_start_end)
> +LINKER_SYMBOL(bsp_section_start_size)
> +
> +LINKER_SYMBOL(bsp_section_vector_begin)
> +LINKER_SYMBOL(bsp_section_vector_end)
> +LINKER_SYMBOL(bsp_section_vector_size)
> +
> +LINKER_SYMBOL(bsp_section_text_begin)
> +LINKER_SYMBOL(bsp_section_text_end)
> +LINKER_SYMBOL(bsp_section_text_size)
> +LINKER_SYMBOL(bsp_section_text_load_begin)
> +LINKER_SYMBOL(bsp_section_text_load_end)
> +
> +LINKER_SYMBOL(bsp_section_rodata_begin)
> +LINKER_SYMBOL(bsp_section_rodata_end)
> +LINKER_SYMBOL(bsp_section_rodata_size)
> +LINKER_SYMBOL(bsp_section_rodata_load_begin)
> +LINKER_SYMBOL(bsp_section_rodata_load_end)
> +
> +LINKER_SYMBOL(bsp_section_data_begin)
> +LINKER_SYMBOL(bsp_section_data_end)
> +LINKER_SYMBOL(bsp_section_data_size)
> +LINKER_SYMBOL(bsp_section_data_load_begin)
> +LINKER_SYMBOL(bsp_section_data_load_end)
> +
> +LINKER_SYMBOL(bsp_section_bss_begin)
> +LINKER_SYMBOL(bsp_section_bss_end)
> +LINKER_SYMBOL(bsp_section_bss_size)
> +
> +LINKER_SYMBOL(bsp_section_work_begin)
> +LINKER_SYMBOL(bsp_section_work_end)
> +LINKER_SYMBOL(bsp_section_work_size)
> +
> +LINKER_SYMBOL(bsp_section_stack_begin)
> +LINKER_SYMBOL(bsp_section_stack_end)
> +LINKER_SYMBOL(bsp_section_stack_size)
> +
> +LINKER_SYMBOL(bsp_vector_table_begin)
> +LINKER_SYMBOL(bsp_vector_table_end)
> +LINKER_SYMBOL(bsp_vector_table_size)
> +
> +LINKER_SYMBOL(bsp_start_vector_table_begin)
> +LINKER_SYMBOL(bsp_start_vector_table_end)
> +LINKER_SYMBOL(bsp_start_vector_table_size)
> +
> +LINKER_SYMBOL(bsp_translation_table_base)
> +LINKER_SYMBOL(bsp_translation_table_end)
> +
> +LINKER_SYMBOL(_bsp_processor_count)
> +
> +/** @} */
> +
> +#ifdef __cplusplus
> +}
> +#endif /* __cplusplus */
> +
> +#endif /* LIBBSP_EPIPHANY_SHARED_LINKER_SYMBOLS_H */
> --
> 2.1.0
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel



More information about the devel mailing list