[PATCH] Add new (first) OpenRISC BSP called or1ksim.

Hesham Moustafa heshamelmatary at gmail.com
Wed Aug 20 10:19:57 UTC 2014


Hi Joel,

On Tue, Aug 19, 2014 at 8:09 PM, Joel Sherrill
<joel.sherrill at oarcorp.com> wrote:
>
> On 8/19/2014 1:00 PM, Hesham ALMatary wrote:
>> This BSP is intended to run on or1ksim (the main OpenRISC emulator).
>> ---
>>  c/src/aclocal/rtems-cpu-subdirs.m4                 |   1 +
>>  c/src/lib/libbsp/or1k/Makefile.am                  |  10 +
>>  c/src/lib/libbsp/or1k/acinclude.m4                 |  10 +
>>  c/src/lib/libbsp/or1k/configure.ac                 |  19 ++
>>  c/src/lib/libbsp/or1k/or1ksim/Makefile.am          | 109 +++++++
>>  c/src/lib/libbsp/or1k/or1ksim/README               |  17 ++
>>  c/src/lib/libbsp/or1k/or1ksim/bsp_specs            |  12 +
>>  c/src/lib/libbsp/or1k/or1ksim/clock/clockdrv.c     | 104 +++++++
>>  c/src/lib/libbsp/or1k/or1ksim/configure.ac         |  31 ++
>>  .../libbsp/or1k/or1ksim/console/console-config.c   |  58 ++++
>>  c/src/lib/libbsp/or1k/or1ksim/console/uart.c       | 144 ++++++++++
>>  c/src/lib/libbsp/or1k/or1ksim/include/bsp.h        |  47 +++
>>  c/src/lib/libbsp/or1k/or1ksim/include/irq.h        |  45 +++
>>  c/src/lib/libbsp/or1k/or1ksim/include/or1ksim.h    | 118 ++++++++
>>  c/src/lib/libbsp/or1k/or1ksim/include/tm27.h       |  16 ++
>>  c/src/lib/libbsp/or1k/or1ksim/include/uart.h       |  42 +++
>>  c/src/lib/libbsp/or1k/or1ksim/irq/irq.c            |  42 +++
>>  .../or1k/or1ksim/make/custom/or1k_or1ksim.cfg      |   7 +
>>  c/src/lib/libbsp/or1k/or1ksim/preinstall.am        | 111 +++++++
>>  c/src/lib/libbsp/or1k/or1ksim/start/start.S        | 182 ++++++++++++
>>  c/src/lib/libbsp/or1k/or1ksim/startup/bspreset.c   |  14 +
>>  c/src/lib/libbsp/or1k/or1ksim/startup/bspstart.c   |  15 +
>>  c/src/lib/libbsp/or1k/or1ksim/startup/linkcmds     | 320 +++++++++++++++++++++
>>  c/src/lib/libbsp/or1k/or1ksim/timer/timer.c        |  63 ++++
>>  c/src/lib/libbsp/or1k/preinstall.am                |   7 +
>>  .../libbsp/or1k/shared/include/linker-symbols.h    |  79 +++++
>>  26 files changed, 1623 insertions(+)
>>  create mode 100644 c/src/lib/libbsp/or1k/Makefile.am
>>  create mode 100644 c/src/lib/libbsp/or1k/acinclude.m4
>>  create mode 100644 c/src/lib/libbsp/or1k/configure.ac
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/Makefile.am
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/README
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/bsp_specs
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/clock/clockdrv.c
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/configure.ac
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/console/console-config.c
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/console/uart.c
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/include/bsp.h
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/include/irq.h
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/include/or1ksim.h
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/include/tm27.h
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/include/uart.h
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/irq/irq.c
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/make/custom/or1k_or1ksim.cfg
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/preinstall.am
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/start/start.S
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/startup/bspreset.c
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/startup/bspstart.c
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/startup/linkcmds
>>  create mode 100644 c/src/lib/libbsp/or1k/or1ksim/timer/timer.c
>>  create mode 100644 c/src/lib/libbsp/or1k/preinstall.am
>>  create mode 100644 c/src/lib/libbsp/or1k/shared/include/linker-symbols.h
>>
>> diff --git a/c/src/aclocal/rtems-cpu-subdirs.m4 b/c/src/aclocal/rtems-cpu-subdirs.m4
>> index c5a4a19..9593d34 100644
>> --- a/c/src/aclocal/rtems-cpu-subdirs.m4
>> +++ b/c/src/aclocal/rtems-cpu-subdirs.m4
>> @@ -23,6 +23,7 @@ _RTEMS_CPU_SUBDIR([mips],[$1]);;
>>  _RTEMS_CPU_SUBDIR([moxie],[$1]);;
>>  _RTEMS_CPU_SUBDIR([nios2],[$1]);;
>>  _RTEMS_CPU_SUBDIR([no_cpu],[$1]);;
>> +_RTEMS_CPU_SUBDIR([or1k],[$1]);;
>>  _RTEMS_CPU_SUBDIR([powerpc],[$1]);;
>>  _RTEMS_CPU_SUBDIR([sh],[$1]);;
>>  _RTEMS_CPU_SUBDIR([sparc],[$1]);;
>> diff --git a/c/src/lib/libbsp/or1k/Makefile.am b/c/src/lib/libbsp/or1k/Makefile.am
>> new file mode 100644
>> index 0000000..0ce20e6
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/Makefile.am
>> @@ -0,0 +1,10 @@
>> +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/or1k/acinclude.m4 b/c/src/lib/libbsp/or1k/acinclude.m4
>> new file mode 100644
>> index 0000000..c593670
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/acinclude.m4
>> @@ -0,0 +1,10 @@
>> +# RTEMS_CHECK_BSPDIR(RTEMS_BSP_FAMILY)
>> +AC_DEFUN([RTEMS_CHECK_BSPDIR],
>> +[
>> +  case "$1" in
>> +  or1ksim )
>> +    AC_CONFIG_SUBDIRS([or1ksim]);;
>> +  *)
>> +    AC_MSG_ERROR([Invalid BSP]);;
>> +  esac
>> +])
>> diff --git a/c/src/lib/libbsp/or1k/configure.ac b/c/src/lib/libbsp/or1k/configure.ac
>> new file mode 100644
>> index 0000000..96bba16
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/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-or1k],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
>> +AC_CONFIG_SRCDIR([or1ksim])
>> +RTEMS_TOP(../../../../..)
>> +
>> +RTEMS_CANONICAL_TARGET_CPU
>> +AM_INIT_AUTOMAKE([no-define foreign 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/or1k/or1ksim/Makefile.am b/c/src/lib/libbsp/or1k/or1ksim/Makefile.am
>> new file mode 100644
>> index 0000000..a0efc9e
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/or1ksim/Makefile.am
>> @@ -0,0 +1,109 @@
>> +##
> I don't see the point of the above line. There are other files with "##" as
> the first line and those seem to be pointless as well.
I copied these headers templates from other BSPs (raspberry pi) should
I delete this line?

>> +#
>> +# @file
>> +#
>> +# @brief Makefile of LibBSP for the or1ksim BSP.
>> +#
>> +
>> +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_bsp_HEADERS =
>> +include_HEADERS = include/bsp.h
>> +include_HEADERS += include/tm27.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/uart-output-char.h
>> +include_bsp_HEADERS += ../../shared/tod.h
>> +include_bsp_HEADERS += include/irq.h
>> +include_bsp_HEADERS += include/uart.h
>> +include_bsp_HEADERS += include/or1ksim.h
>> +
>> +nodist_include_HEADERS = ../../shared/include/coverhd.h \
>> +  include/bspopts.h
>> +
>> +###############################################################################
>> +#                  Data                                                       #
>> +###############################################################################
>> +
>> +noinst_LIBRARIES = libbspstart.a
>> +
>> +libbspstart_a_SOURCES = start/start.S
>> +
>> +project_lib_DATA = start.$(OBJEXT)
>> +
>> +project_lib_DATA += startup/linkcmds
>> +
>> +###############################################################################
>> +#                  LibBSP                                                     #
>> +###############################################################################
>> +
>> +noinst_LIBRARIES += libbsp.a
>> +
>> +libbsp_a_SOURCES =
>> +libbsp_a_CPPFLAGS =
>> +libbsp_a_LIBADD =
>> +
>> +# Startup
>> +#libbsp_a_SOURCES += startup/bspreset.c
>> +libbsp_a_SOURCES += startup/bspstart.c
>> +
>> +# Shared
>> +libbsp_a_SOURCES += ../../shared/bootcard.c
>> +libbsp_a_SOURCES += ../../shared/bspclean.c
>> +libbsp_a_SOURCES += ../../shared/bspgetworkarea.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/cpucounterread.c
>> +libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
>> +libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
>> +libbsp_a_SOURCES += ../../shared/sbrk.c
>> +libbsp_a_SOURCES += ../../shared/src/stackalloc.c
>> +
>> +# Console
>> +libbsp_a_SOURCES += ../../shared/console.c
>> +libbsp_a_SOURCES += ../../shared/console_control.c
>> +libbsp_a_SOURCES += ../../shared/console_read.c
>> +libbsp_a_SOURCES += ../../shared/console_select.c
>> +libbsp_a_SOURCES += ../../shared/console_write.c
>> +libbsp_a_SOURCES += console/console-config.c
>> +libbsp_a_SOURCES += console/uart.c
>> +
>> +# Timer
>> +libbsp_a_SOURCES += timer/timer.c
>> +
>> +# clock
>> +libbsp_a_SOURCES += clock/clockdrv.c ../../../shared/clockdrv_shell.h
>> +
>> +# 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
>> +###############################################################################
>> +#                  Special Rules                                              #
>> +###############################################################################
>> +
>> +DISTCLEANFILES = include/bspopts.h
>> +
>> +include $(srcdir)/preinstall.am
>> +include $(top_srcdir)/../../../../automake/local.am
>> diff --git a/c/src/lib/libbsp/or1k/or1ksim/README b/c/src/lib/libbsp/or1k/or1ksim/README
>> new file mode 100644
>> index 0000000..99d1edf
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/or1ksim/README
>> @@ -0,0 +1,17 @@
>> +This BSP should run only on or1ksim: the main simulator for or1k architecture.
>> +or1ksim should be used for testing purposes.
>> +
>> +svn co http://opencores.org/ocsvn/openrisc/openrisc/trunk/or1ksim
>> +cd or1ksim
>> +mkdir builddir_or1ksim
>> +cd builddir_or1ksim
>> +../configure --target=or32-elf --prefix=/opt/or1ksim
>> +make all
>> +make install
>> +export PATH=/opt/or1ksim/bin:$PATH
>> +
>> +Configuration file "sim.cfg" should be provided for complex board
>> +configurations at the current directory (which you run or1ksim from) or at
>> +~/.or1k/
>> +
>> +sim -f sim.cfg hello.exe
>
> Is the sim.cfg file you are using provided?
No, where should I provide it?
>>
>> diff --git a/c/src/lib/libbsp/or1k/or1ksim/include/tm27.h b/c/src/lib/libbsp/or1k/or1ksim/include/tm27.h
>> new file mode 100644
>> index 0000000..0bda31d
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/or1ksim/include/tm27.h
>> @@ -0,0 +1,16 @@
>> +/*
>> + * COPYRIGHT (c) 2014 Hesham ALMatary <heshamelmatary at gmail.com>
>> + *
>> + * 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 _RTEMS_TMTEST27
>> +#error "This is an RTEMS internal file you must not include directly."
>> +#endif
>> +
>> +#ifndef __tm27_h
>> +#define __tm27_h
>> +
>> +#endif
> Since this is a stub use the one in shared that provides a dummy
> implementation.
>> diff --git a/c/src/lib/libbsp/or1k/or1ksim/make/custom/or1k_or1ksim.cfg b/c/src/lib/libbsp/or1k/or1ksim/make/custom/or1k_or1ksim.cfg
>> new file mode 100644
>> index 0000000..fff00ae
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/or1ksim/make/custom/or1k_or1ksim.cfg
>> @@ -0,0 +1,7 @@
>> +include $(RTEMS_ROOT)/make/custom/default.cfg
>> +
>> +RTEMS_CPU = or1k
>> +
>> +CPU_CFLAGS = -O2
>> +
>> +CFLAGS_OPTIMIZE_V ?= -O0 -g
> I don't think you should be setting this.  Just change CPU_CFLAGS.
>> diff --git a/c/src/lib/libbsp/or1k/or1ksim/startup/bspreset.c b/c/src/lib/libbsp/or1k/or1ksim/startup/bspreset.c
>> new file mode 100644
>> index 0000000..2f4fec6
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/or1ksim/startup/bspreset.c
>> @@ -0,0 +1,14 @@
>> +/*
>> + * COPYRIGHT (c) 2014 Hesham ALMatary <heshamelmatary at gmail.com>
>> + *
>> + * 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/bootcard.h>
>> +
>> +void bsp_reset(void)
>> +{
>> +
>> +}
> There should be a stub version of this to use in libbsp/shared.
>> diff --git a/c/src/lib/libbsp/or1k/or1ksim/startup/bspstart.c b/c/src/lib/libbsp/or1k/or1ksim/startup/bspstart.c
>> new file mode 100644
>> index 0000000..3a160fb
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/or1ksim/startup/bspstart.c
>> @@ -0,0 +1,15 @@
>> +/*
>> + * COPYRIGHT (c) 2014 Hesham ALMatary <heshamelmatary at gmail.com>
>> + *
>> + * 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/bootcard.h>
>> +
>> +void bsp_start(void)
>> +{
>> +
>> +}
> Ditto for stub version from shared.
>> diff --git a/c/src/lib/libbsp/or1k/or1ksim/startup/linkcmds b/c/src/lib/libbsp/or1k/or1ksim/startup/linkcmds
>> new file mode 100644
>> index 0000000..aaa6bb3
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/or1ksim/startup/linkcmds
>> @@ -0,0 +1,320 @@
>> +OUTPUT_ARCH (or1k)
>> +
>> +ENTRY (_start)
>> +
>> +/*
>> + * Global symbols that may be defined externally
>> + */
>> +
>> +bsp_start_vector_table_begin = 0x1F00;
>> +bsp_vector_table_size = DEFINED (bsp_vector_table_size) ? bsp_vector_table_size
>> +: 8260;
>> +/* 8192 for raw vector table, and 17 * 4 for handlers vector. */
>> +
>> +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 : 0;
>> +bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
>> +
>> +bsp_processor_count = DEFINED (bsp_processor_count) ? bsp_processor_count : 1;
>> +
>> +MEMORY
>> +  {
>> +      VECTOR_RAM     (AIW) : ORIGIN = 0x0       , LENGTH = 8260
>> +      RAM   : org = 0x00002048, l = 0x1FFDFB8
>> +      UNEXPECTED_SECTIONS : ORIGIN = 0xffffffff, LENGTH = 0
>> +  }
>> +
>> +REGION_ALIAS ("REGION_START", RAM);
>> +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);
>> +
>> +
>> +    bsp_section_vector_begin = 0;
>> +
>
> If I am reading this correctly, the above is BSP specific and the part below
> should be in a shared file that any or1k BSP can use.
>> +SECTIONS {
>> +
>> +  .vector : ALIGN_WITH_INPUT {
>> +    *(.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_WITH_INPUT {
>> +    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_WITH_INPUT {
>> +    . = ALIGN (bsp_section_xbarrier_align);
>> +  } > REGION_VECTOR AT > REGION_VECTOR
>> +
>> +.text : ALIGN_WITH_INPUT {
>> +    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 : ALIGN_WITH_INPUT {
>> +    KEEP (*(.init))
>> +  } > REGION_TEXT AT > REGION_TEXT_LOAD
>> +  .fini : ALIGN_WITH_INPUT {
>> +    KEEP (*(.fini))
>> +    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_WITH_INPUT {
>> +    . = ALIGN (bsp_section_robarrier_align);
>> +  } > REGION_RODATA AT > REGION_RODATA
>> +
>> +.rodata : ALIGN_WITH_INPUT {
>> +    bsp_section_rodata_begin = .;
>> +    *(.rodata .rodata.* .gnu.linkonce.r.*)
>> +  } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +.eh_frame : ALIGN_WITH_INPUT {
>> +               KEEP (*(.eh_frame))
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .gcc_except_table : ALIGN_WITH_INPUT {
>> +               *(.gcc_except_table .gcc_except_table.*)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .tdata : ALIGN_WITH_INPUT {
>> +               _TLS_Data_begin = .;
>> +               *(.tdata .tdata.* .gnu.linkonce.td.*)
>> +               _TLS_Data_end = .;
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .tbss : ALIGN_WITH_INPUT {
>> +               _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 : ALIGN_WITH_INPUT {
>> +               PROVIDE_HIDDEN (__preinit_array_start = .);
>> +               KEEP (*(.preinit_array))
>> +               PROVIDE_HIDDEN (__preinit_array_end = .);
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .init_array : ALIGN_WITH_INPUT {
>> +               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 : ALIGN_WITH_INPUT {
>> +               PROVIDE_HIDDEN (__fini_array_start = .);
>> +               KEEP (*(.fini_array))
>> +               KEEP (*(SORT(.fini_array.*)))
>> +               PROVIDE_HIDDEN (__fini_array_end = .);
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .ctors : ALIGN_WITH_INPUT {
>> +               /* 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 : ALIGN_WITH_INPUT {
>> +               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 : ALIGN_WITH_INPUT {
>> +               *(.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 : ALIGN_WITH_INPUT {
>> +               KEEP (*(.jcr))
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .interp : ALIGN_WITH_INPUT {
>> +               *(.interp)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .note.gnu.build-id : ALIGN_WITH_INPUT {
>> +               *(.note.gnu.build-id)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .hash : ALIGN_WITH_INPUT {
>> +               *(.hash)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .gnu.hash : ALIGN_WITH_INPUT {
>> +               *(.gnu.hash)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .dynsym : ALIGN_WITH_INPUT {
>> +               *(.dynsym)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .dynstr : ALIGN_WITH_INPUT {
>> +               *(.dynstr)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .gnu.version : ALIGN_WITH_INPUT {
>> +               *(.gnu.version)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .gnu.version_d : ALIGN_WITH_INPUT {
>> +               *(.gnu.version_d)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .gnu.version_r : ALIGN_WITH_INPUT {
>> +               *(.gnu.version_r)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .rel.dyn : ALIGN_WITH_INPUT {
>> +               *(.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 : ALIGN_WITH_INPUT {
>> +               *(.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 : ALIGN_WITH_INPUT {
>> +               *(.rel.plt)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .rela.plt : ALIGN_WITH_INPUT {
>> +               *(.rela.plt)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .plt : ALIGN_WITH_INPUT {
>> +               *(.plt)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .iplt : ALIGN_WITH_INPUT {
>> +               *(.iplt)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .dynamic : ALIGN_WITH_INPUT {
>> +               *(.dynamic)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .got : ALIGN_WITH_INPUT {
>> +               *(.got.plt) *(.igot.plt) *(.got) *(.igot)
>> +       } > REGION_RODATA AT > REGION_RODATA_LOAD
>> +       .rtemsroset : ALIGN_WITH_INPUT {
>> +               /* Special FreeBSD linker set sections */
>> +               __start_set_sysctl_set = .;
>> +               *(set_sysctl_*);
>> +               __stop_set_sysctl_set = .;
>> +               *(set_domain_*);
>> +               *(set_pseudo_*);
>> +
>> +               KEEP (*(SORT(.rtemsroset.*)))
>> +               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_WITH_INPUT {
>> +    . = ALIGN (bsp_section_rwbarrier_align);
>> +  } > REGION_DATA AT > REGION_DATA
>> +
>> +.data : ALIGN_WITH_INPUT {
>> +    bsp_section_data_begin = .;
>> +    *(.data .data.* .gnu.linkonce.d.*)
>> +    SORT(CONSTRUCTORS)
>> +  } > REGION_DATA AT > REGION_DATA_LOAD
>> +  .data1 : ALIGN_WITH_INPUT {
>> +    *(.data1)
>> +  } > REGION_DATA AT > REGION_DATA_LOAD
>> +  .rtemsrwset : ALIGN_WITH_INPUT {
>> +    KEEP (*(SORT(.rtemsrwset.*)))
>> +    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_WITH_INPUT {
>> +    bsp_section_bss_begin = .;
>> +    *(.dynbss)
>> +    *(.bss .bss.* .gnu.linkonce.b.*)
>> +    *(COMMON)
>> +    bsp_section_bss_end = .;
>> +  } > REGION_BSS AT > REGION_BSS
>> +  bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin;
>> +
>> +.work : ALIGN_WITH_INPUT {
>> +    /*
>> +     * The work section will occupy the remaining REGION_WORK region and
>> +     * contains the RTEMS work space and heap.
>> +     */
>> +    bsp_section_work_begin = .;
>> +    . += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.);
>> +    bsp_section_work_end = .;
>> +  } > REGION_WORK AT > REGION_WORK
>> +  bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin;
>> +
>> +  .stack : ALIGN_WITH_INPUT {
>> +    bsp_section_stack_end = .;
>> +  } > REGION_STACK AT > REGION_STACK
>> +  bsp_section_stack_begin = 0x1FFDFB8;
>> +  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/or1k/or1ksim/timer/timer.c b/c/src/lib/libbsp/or1k/or1ksim/timer/timer.c
>> new file mode 100644
>> index 0000000..73ee112
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/or1k/or1ksim/timer/timer.c
>> @@ -0,0 +1,63 @@
>> +/**
>> + * @file
>> + *
>> + * @ingroup or1ksim
>> + *
>> + * @brief Benchmark timer support.
>> + */
>> +
>> +/*
>> + * Copyright (c) 2014 by Hesham ALMatary
>> + *
>> + *  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 <rtems/btimer.h>
>> +#include <bsp/or1ksim.h>
>> +#include <rtems/score/or1k-utility.h>
>> +
>> +static bool benchmark_timer_find_average_overhead = false;
>> +static uint32_t tick_time;
>> +static uint64_t benchmark_timer_base;
>> +
>> +void benchmark_timer_initialize(void)
>> +{
>> +  benchmark_timer_base = _OR1K_mfspr(CPU_OR1K_SPR_TTCR);
>> +}
>> +
>> +#define AVG_OVERHEAD  0
>> +#define LEAST_VALID   1
>> +
>> +uint32_t benchmark_timer_read( void )
>> +{
>> +  uint64_t         clicks;
>> +  uint64_t         total;
>> +  uint64_t         delta;
>> +
>> +  /*
>> +   *  Read the timer and see how many clicks it has been since we started.
>> +   */
>> +  clicks = _OR1K_mfspr(CPU_OR1K_SPR_TTCR);
>> +
>> +  delta = clicks - benchmark_timer_base;
>> +
>> +  /* total in microseconds */
>> +  total = tick_time * (delta);
>> +
>> +  if ( benchmark_timer_find_average_overhead == true )
>> +    return total;          /* in nanoseconds microsecond units */
>> +  else {
>> +    if ( total < LEAST_VALID )
>> +      return 0;            /* below timer resolution */
>> +
>> +      return (total - AVG_OVERHEAD);
>> +  }
>> +}
>> +
> Trailing blank line and what units are these really in? The comments in the
> benchmark_timer_read() are very confusing.
>> +void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
>> +{
>> +  benchmark_timer_find_average_overhead = find_flag;
>> +}
>>
>> --
>> 1.9.3
>>
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
>
> --
> Joel Sherrill, Ph.D.             Director of Research & Development
> joel.sherrill at OARcorp.com        On-Line Applications Research
> Ask me about RTEMS: a free RTOS  Huntsville AL 35805
> Support Available                (256) 722-9985
>



More information about the devel mailing list