On Wed, Aug 13, 2014 at 4:48 PM, Premysl Houdek <kom541...@gmail.com> wrote: > Included variants: > tms570ls3137_hdk_intram - place code and data into internal SRAM > tms570ls3137_hdk_sdram - place code into external SDRAM and data to SRAM > tms570ls3137_hdk - variant prepared for stand-alone RTEMS aplication > stored and running directly from flash. Not working yet. > > Chip initialization code not included in BSP. > External startup generated by TI's HalCoGen was used for > testing and debugging. > > More information about TMS570 BSP can be found at > http://www.rtems.org/wiki/index.php/Tms570 > --- > c/src/lib/libbsp/arm/tms570/Makefile.am | 148 ++++++ > c/src/lib/libbsp/arm/tms570/README | 64 +++ > c/src/lib/libbsp/arm/tms570/bsp_specs | 13 + > c/src/lib/libbsp/arm/tms570/clock/tms570-rti.c | 205 ++++++++ > c/src/lib/libbsp/arm/tms570/configure.ac | 45 ++ > .../lib/libbsp/arm/tms570/console/printk-support.c | 68 +++ > c/src/lib/libbsp/arm/tms570/console/tms570-sci.c | 546 > ++++++++++++++++++++ > c/src/lib/libbsp/arm/tms570/include/bsp.h | 101 ++++ > c/src/lib/libbsp/arm/tms570/include/irq.h | 134 +++++ > c/src/lib/libbsp/arm/tms570/include/tms570-pom.h | 101 ++++ > c/src/lib/libbsp/arm/tms570/include/tms570-rti.h | 95 ++++ > .../libbsp/arm/tms570/include/tms570-sci-driver.h | 39 ++ > c/src/lib/libbsp/arm/tms570/include/tms570-sci.h | 75 +++ > c/src/lib/libbsp/arm/tms570/include/tms570-vim.h | 74 +++ > c/src/lib/libbsp/arm/tms570/include/tms570.h | 29 ++ > c/src/lib/libbsp/arm/tms570/irq/irq.c | 182 +++++++ > .../make/custom/tms570ls3137_hdk-testsuite.tcfg | 19 + > .../arm/tms570/make/custom/tms570ls3137_hdk.cfg | 19 + > .../tms570/make/custom/tms570ls3137_hdk_intram.cfg | 20 + > .../tms570/make/custom/tms570ls3137_hdk_sdram.cfg | 19 + > c/src/lib/libbsp/arm/tms570/pom/tms570-pom.c | 100 ++++ > c/src/lib/libbsp/arm/tms570/startup/bspreset.c | 37 ++ > c/src/lib/libbsp/arm/tms570/startup/bspstart.c | 46 ++ > .../lib/libbsp/arm/tms570/startup/bspstarthooks.c | 42 ++ > .../arm/tms570/startup/linkcmds.tms570ls3137_hdk | 27 + > .../startup/linkcmds.tms570ls3137_hdk_intram | 28 + > .../tms570/startup/linkcmds.tms570ls3137_hdk_sdram | 27 + > 27 files changed, 2303 insertions(+) > create mode 100644 c/src/lib/libbsp/arm/tms570/Makefile.am > create mode 100644 c/src/lib/libbsp/arm/tms570/README > create mode 100644 c/src/lib/libbsp/arm/tms570/bsp_specs > create mode 100644 c/src/lib/libbsp/arm/tms570/clock/tms570-rti.c > create mode 100644 c/src/lib/libbsp/arm/tms570/configure.ac > create mode 100644 c/src/lib/libbsp/arm/tms570/console/printk-support.c > create mode 100644 c/src/lib/libbsp/arm/tms570/console/tms570-sci.c > create mode 100644 c/src/lib/libbsp/arm/tms570/include/bsp.h > create mode 100644 c/src/lib/libbsp/arm/tms570/include/irq.h > create mode 100644 c/src/lib/libbsp/arm/tms570/include/tms570-pom.h > create mode 100644 c/src/lib/libbsp/arm/tms570/include/tms570-rti.h > create mode 100644 c/src/lib/libbsp/arm/tms570/include/tms570-sci-driver.h > create mode 100644 c/src/lib/libbsp/arm/tms570/include/tms570-sci.h > create mode 100644 c/src/lib/libbsp/arm/tms570/include/tms570-vim.h > create mode 100644 c/src/lib/libbsp/arm/tms570/include/tms570.h > create mode 100644 c/src/lib/libbsp/arm/tms570/irq/irq.c > create mode 100644 > c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk-testsuite.tcfg > create mode 100644 > c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk.cfg > create mode 100644 > c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_intram.cfg > create mode 100644 > c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_sdram.cfg > create mode 100644 c/src/lib/libbsp/arm/tms570/network/tms570-ethernet.c > create mode 100644 c/src/lib/libbsp/arm/tms570/network/tms570-ethernet.h > create mode 100644 c/src/lib/libbsp/arm/tms570/pom/tms570-pom.c > create mode 100644 c/src/lib/libbsp/arm/tms570/startup/bspreset.c > create mode 100644 c/src/lib/libbsp/arm/tms570/startup/bspstart.c > create mode 100644 c/src/lib/libbsp/arm/tms570/startup/bspstarthooks.c > create mode 100644 > c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk > create mode 100644 > c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_intram > create mode 100644 > c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_sdram > > diff --git a/c/src/lib/libbsp/arm/tms570/Makefile.am > b/c/src/lib/libbsp/arm/tms570/Makefile.am > new file mode 100644 > index 0000000..6ded6af > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/Makefile.am > @@ -0,0 +1,148 @@ > +## > +# > +# @file makefile.am > +# > +# @brief Makefile of LibBSP for the TMS570 boards. > +# > + > +ACLOCAL_AMFLAGS = -I ../../../../aclocal > + > +include $(top_srcdir)/../../../../automake/compile.am > + > +include_bspdir = $(includedir)/bsp > + > +dist_project_lib_DATA = bsp_specs > + > + > +# ---------------------------- > +# ------ Headers > +# ---------------------------- > + > +include_HEADERS = include/bsp.h > + > +nodist_include_HEADERS = ../../shared/include/coverhd.h > +nodist_include_HEADERS += include/bspopts.h > + > +nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h > + > +include_bsp_HEADERS = > +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 += ../shared/include/start.h > +include_bsp_HEADERS += include/tms570.h > +include_bsp_HEADERS += include/tms570-sci.h > +include_bsp_HEADERS += include/irq.h > +include_bsp_HEADERS += include/tms570-rti.h > +include_bsp_HEADERS += include/tms570-vim.h > +include_bsp_HEADERS += include/tms570-pom.h > +include_bsp_HEADERS += include/tms570-sci-driver.h > + > +include_HEADERS += ../../shared/include/tm27.h > + > + > +# ---------------------------- > +# ------ Data > +# ---------------------------- > + > +noinst_LIBRARIES = libbspstart.a > + > +libbspstart_a_SOURCES = ../shared/start/start.S > + > +project_lib_DATA = start.$(OBJEXT) > +project_lib_DATA += startup/linkcmds > + > +EXTRA_DIST = > +EXTRA_DIST += startup/linkcmds.tms570ls3137_hdk > +EXTRA_DIST += startup/linkcmds.tms570ls3137_hdk_sdram > +EXTRA_DIST += startup/linkcmds.tms570ls3137_hdk_intram > + > + > +# ---------------------------- > +# ------ LibBSP > +# ---------------------------- > + > +noinst_LIBRARIES += libbsp.a > + > +libbsp_a_SOURCES = > +libbsp_a_CPPFLAGS = > +libbsp_a_LIBADD = > + > +# 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/gnatinstallhandler.c > +libbsp_a_SOURCES += ../../shared/sbrk.c > +libbsp_a_SOURCES += ../../shared/src/stackalloc.c > +libbsp_a_SOURCES += ../../shared/src/uart-output-char.c > + > +# Startup > +libbsp_a_SOURCES += ../shared/startup/bsp-start-memcpy.S > +libbsp_a_SOURCES += startup/bspreset.c > +libbsp_a_SOURCES += startup/bspstart.c > + > +# POM > +libbsp_a_SOURCES += pom/tms570-pom.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 += ../../shared/src/irq-legacy.c > +libbsp_a_SOURCES += ../../shared/src/irq-server.c > +libbsp_a_SOURCES += ../../shared/src/irq-shell.c > +libbsp_a_SOURCES += irq/irq.c > + > +# Console > +libbsp_a_SOURCES += ../../shared/console-termios.c > +libbsp_a_SOURCES += console/printk-support.c > +libbsp_a_SOURCES += console/tms570-sci.c > + > + > +# Clock > +libbsp_a_SOURCES += ../../shared/clockdrv_shell.h > +libbsp_a_SOURCES += clock/tms570-rti.c > + > +# RTC > + > +# GPIO > + > +# Timer > + > +# Benchmark Timer > + > +# Misc > + > +# Watchdog > + > +# Start hooks > +libbsp_a_SOURCES += startup/bspstarthooks.c > + > +# Network > + > +if HAS_NETWORKING > + > +noinst_PROGRAMS = network.rel > + > +network_rel_CPPFLAGS = $(AM_CPPFLAGS) -D__INSIDE_RTEMS_BSD_TCPIP_STACK__ > -D__BSD_VISIBLE > +network_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) > + > +libbsp_a_LIBADD += network.rel > + > +endif > + > +# ---------------------------- > +# ------ Special Rules > +# ---------------------------- > + > +DISTCLEANFILES = include/bspopts.h > + > +include $(srcdir)/preinstall.am > +include $(top_srcdir)/../../../../automake/local.am > diff --git a/c/src/lib/libbsp/arm/tms570/README > b/c/src/lib/libbsp/arm/tms570/README > new file mode 100644 > index 0000000..3150626 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/README > @@ -0,0 +1,64 @@ > +Development Board: TMS570LS31x Hercules Development Kit from TI > + > +http://www.ti.com/tool/tmds570ls31hdk > + > +Drivers: > + > + o Console > + o Clock > + o Ethernet - work in progress > + > +BSP variants: > + tms570ls3137_hdk_intram - place code and data into internal SRAM > + tms570ls3137_hdk_sdram - place code into external SDRAM and data to SRAM > + tms570ls3137_hdk - variant prepared for stand-alone RTEMS aplication > + stored and running directly from flash. Not working > yet. > + > +Tool-chain > + GCC 4.9.0 + Newlib 2.1.0 + Binutils 2.24 configuration: > + > + CFLAGS="-O2 -pipe" LDFLAGS=-s \ > + ../../../src/gcc-4.9/configure --target=arm-rtems4.11 --prefix=/usr \ > + --enable-languages=c,c++ \ > + --disable-libstdcxx-pch \ > + --with-gnu-ld \ > + --with-gnu-as \ > + --enable-threads \ > + --enable-target-optspace \ > + --with-system-zlib \ > + --verbose \ > + --disable-nls --without-included-gettext \ > + --disable-win32-registry \ > + --with-newlib \ > + --enable-plugin \ > + --enable-newlib-io-c99-formats \ > + --enable-version-specific-runtime-libs \ > + --enable-newlib-iconv \ > + --disable-lto \ > + > +Patches required for Cortex-R and big-endian ARM support are already > +accepted by mainline. > + > +Execution > + > + There is not used any generic bootloader. Initial complex CPU and > peripherals > + initialization and self test are not implemented and included in RTEMS BSP > + right now. For testing and debuging purposes is used simple Ti's HalCoGen > + generated application to setup board and then download RTEMS image over > + OpenOCD to internal EEC SRAM or external SDRAM. > + > + Setup application code is available there: > + https://github.com/hornmich/tms570ls3137-hdk-sdram > + > +Howto setup TMDS570LS31HDK? > + > + o Unpack board. > + o Verify that demo application runs. > + o Upload bootloader specified above > + o write BSP aplication either to sdram or intram and jump to RTEMS start > code > + > +Additional information about the board can be found at > + http://www.rtems.org/wiki/index.php/Tms570 > + > +Additional information about the CPU can be found at > + http://www.ti.com/product/tms570ls3137 > diff --git a/c/src/lib/libbsp/arm/tms570/bsp_specs > b/c/src/lib/libbsp/arm/tms570/bsp_specs > new file mode 100644 > index 0000000..1afa2ba > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/bsp_specs > @@ -0,0 +1,13 @@ > +%rename endfile old_endfile > +%rename startfile old_startfile > +%rename link old_link > + > +*startfile: > +%{!qrtems: %(old_startfile)} \ > +%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s -e _start}} > + > +*link: > +%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N -EB } > + > +*endfile: > +%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s } > diff --git a/c/src/lib/libbsp/arm/tms570/clock/tms570-rti.c > b/c/src/lib/libbsp/arm/tms570/clock/tms570-rti.c > new file mode 100644 > index 0000000..3f8278c > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/clock/tms570-rti.c > @@ -0,0 +1,205 @@ > +/** > + * @file tms570-rti.c > + * > + * @ingroup tms570 > + * > + * @brief clock functions definitions. > + */ > + > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * by embedded brains GmbH and others > + * > + * 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 <stdlib.h> > + > +#include <rtems.h> > +#include <bsp.h> > +#include <bsp/irq.h> > +#include <bsp/tms570-rti.h> > + > +void Clock_exit( void ); > +rtems_isr Clock_isr( rtems_vector_number vector ); > +void Install_clock( rtems_isr_entry ); > + > +/* > + * Clock_driver_ticks is a monotonically increasing counter of the > + * number of clock ticks since the driver was initialized. > + */ > + > +volatile uint32_t Clock_driver_ticks; > + > +/* > + * Clock_isrs is the number of clock ISRs until the next invocation of > + * the RTEMS clock tick routine. The clock tick device driver > + * gets an interrupt once a millisecond and counts down until the > + * length of time between the user configured microseconds per tick > + * has passed. > + */ > + > +uint32_t Clock_isrs; /* ISRs until next tick */ > + > +/* > + * These are set by clock driver during its init > + */ > + > +rtems_device_major_number rtems_clock_major = ~0; > +rtems_device_minor_number rtems_clock_minor; > + > +/* > + * The previous ISR on this clock tick interrupt vector. > + */ > + > +rtems_isr_entry Old_ticker; > + > +/** > + * @brief Clock isr handler > + * > + * bump the number of clock driver ticks since initialization > + * > + * determine if it is time to announce the passing of tick as configured > + * to RTEMS through the rtems_clock_tick directive > + * > + * @param[in] vector interrupt vector > + * > + * @retval Void > + */ > +rtems_isr Clock_isr( > + rtems_vector_number vector > +) > +{ > + TMS570_RTI.RTIINTFLAG = 0x00000001; > + ++Clock_driver_ticks; > + /* TMS570_RTI.RTICOMP0 += 1000; */ > + > + if ( Clock_isrs <= 1 ) { > + rtems_clock_tick(); > + Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000; > + } > + else > + Clock_isrs -= 1; > +} > + > +/** > + * @brief Installs clock handler > + * > + * determine if it is time to announce the passing of tick as configured > + * to RTEMS through the rtems_clock_tick directive * > + * > + * @retval Void > + */ > +static void tms570_clock_handler_install(rtems_isr_entry clock_isr) > +{ > + rtems_status_code sc = RTEMS_SUCCESSFUL; > + > + sc = rtems_interrupt_handler_install( > + TMS570_IRQ_TIMER_0, > + "Clock", > + RTEMS_INTERRUPT_UNIQUE, > + (rtems_interrupt_handler) Clock_isr, > + NULL > + ); > + if (sc != RTEMS_SUCCESSFUL) { > + rtems_fatal_error_occurred(0xdeadbeef); > + } > +} > + > +/** > + * @brief Installs clock > + * > + * Install a clock tick handler and reprograms the chip. This > + * is used to initially establish the clock tick. > + * > + * @retval Void > + */ > +void Install_clock( > + rtems_isr_entry clock_isr > +) > +{ > + /* > + * Initialize the clock tick device driver variables > + */ > + > + Clock_driver_ticks = 0; > + Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000; > + > + tms570_clock_handler_install(clock_isr); > + > + /* Hardware specific initialize */ > + TMS570_RTI.RTIGCTRL = 0; > + TMS570_RTI.RTICPUC0 = BSP_PLL_OUT_CLOCK /1000000 / 2; /* prescaler */ > + TMS570_RTI.RTITBCTRL = 2; > + TMS570_RTI.RTICAPCTRL = 0; > + TMS570_RTI.RTICOMPCTRL = 0; > + /* set counter to zero */ > + TMS570_RTI.RTIUC0 = 0; > + TMS570_RTI.RTIFRC0 = 0; > + /* clear interrupts*/ > + TMS570_RTI.RTICLEARINTENA = 0x00070f0f; > + TMS570_RTI.RTIINTFLAG = 0x0007000f; > + /* set timer */ > + TMS570_RTI.RTICOMP0 = TMS570_RTI.RTIFRC0 + 1000; > + TMS570_RTI.RTICOMP0CLR = TMS570_RTI.RTICOMP0 + 500; > + TMS570_RTI.RTIUDCP0 = 1000; > + /* enable interupt */ > + TMS570_RTI.RTISETINTENA = 0x1; > + /* enable timer */ > + TMS570_RTI.RTIGCTRL = 1; > + > + > + /* > + * Schedule the clock cleanup routine to execute if the application exits. > + */ > + atexit( Clock_exit ); > +} > + > +/** > + * @brief Clock exit > + * Called by aplication exit > + * Clean up before the application exits > + * > + * @retval Void > + */ > +void Clock_exit( void ) > +{ > + /* turn off the timer interrupts */ > + TMS570_RTI.RTICLEARINTENA = 0x20000; > +} > + > +/** > + * @brief Initialize the clock driver > + * > + * Device driver entry point for clock tick driver initialization. > + * Calls Install_clock > + * > + * @retval RTEMS_SUCCESSFUL > + */ > +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; > +} > diff --git a/c/src/lib/libbsp/arm/tms570/configure.ac > b/c/src/lib/libbsp/arm/tms570/configure.ac > new file mode 100644 > index 0000000..952c7a4 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/configure.ac > @@ -0,0 +1,45 @@ > +## > +# > +# @file configure.ac > +# > +# @brief Configure script of LibBSP for the TMS570 board. > +# > + > +AC_PREREQ([2.69]) > +AC_INIT([rtems-c-src-lib-libbsp-arm-tms570],[_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 1.12.2]) > +RTEMS_BSP_CONFIGURE > + > +RTEMS_PROG_CC_FOR_TARGET > +RTEMS_CANONICALIZE_TOOLS > +RTEMS_PROG_CCAS > + > +RTEMS_CHECK_NETWORKING > +AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "no") > + > +RTEMS_BSPOPTS_SET([ARM_TMS570LS3137],[*],[0]) > +RTEMS_BSPOPTS_HELP([ARM_TMS570LS3137],[target used for identify TMS570LS3137 > board]) > + > +RTEMS_BSPOPTS_SET([BSP_MINIMUM_TASK_STACK_SIZE],[*],[1024]) > +RTEMS_BSPOPTS_HELP([BSP_MINIMUM_TASK_STACK_SIZE],[Suggested minimum task > stack > + size in bytes]) > + > +RTEMS_BSPOPTS_SET([TMS570_OSCILLATOR_MAIN],[*],[12000000U]) > +RTEMS_BSPOPTS_HELP([TMS570_OSCILLATOR_MAIN],[main oscillator frequency in > Hz]) > + > +RTEMS_BSPOPTS_SET([TMS570_OSCILLATOR_RTC],[*],[32768U]) > +RTEMS_BSPOPTS_HELP([TMS570_OSCILLATOR_RTC],[RTC oscillator frequency in Hz]) > + > +RTEMS_BSPOPTS_SET([TMS570_CCLK],[*],[96000000U]) > +RTEMS_BSPOPTS_HELP([TMS570_CCLK],[CPU clock in Hz]) > + > +RTEMS_BSP_CLEANUP_OPTIONS(0, 1) > +RTEMS_BSP_LINKCMDS > + > +AC_CONFIG_FILES([Makefile]) > +AC_OUTPUT > diff --git a/c/src/lib/libbsp/arm/tms570/console/printk-support.c > b/c/src/lib/libbsp/arm/tms570/console/printk-support.c > new file mode 100644 > index 0000000..39baf04 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/console/printk-support.c > @@ -0,0 +1,68 @@ > +/** > + * @file printk-support.c > + * > + * @ingroup tms570 > + * > + * @brief definitions of serial line for debugging. > + */ > + > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * by embedded brains GmbH and others > + * > + * 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/bspIo.h> > +#include <stdint.h> > +#include <bsp/tms570-sci.h> > +#include <bsp/tms570-sci-driver.h> > + > +extern const tms570_sci_context driver_context_table[]; > + > +/** > + * @brief Puts chars into peripheral > + * > + * debug functions always use serial dev 0 peripheral > + * > + * @retval Void > + */ > +static void tms570_putc(char ch) > +{ > + rtems_interrupt_level level; > + > + rtems_interrupt_disable(level); > + while ((driver_context_table[0].regs->SCIFLR & 0x100) == 0) {
May I suggest to avoid magic numbers? > + rtems_interrupt_flash(level); > + } > + driver_context_table[0].regs->SCITD = ch; > + rtems_interrupt_enable(level); > +} > + > +/** > + * @brief debug console output > + * > + * debug functions always use serial dev 0 peripheral > + * > + * @retval Void > + */ > +static void console_output(char c) > +{ > + if (c == '\n') { > + char r = '\r'; > + tms570_putc(r); > + } > + tms570_putc(c); > +} > + > +BSP_output_char_function_type BSP_output_char = console_output; > diff --git a/c/src/lib/libbsp/arm/tms570/console/tms570-sci.c > b/c/src/lib/libbsp/arm/tms570/console/tms570-sci.c > new file mode 100644 > index 0000000..4815263 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/console/tms570-sci.c > @@ -0,0 +1,546 @@ > +/** > + * @file tms570-sci.c > + * > + * @ingroup tms570 > + * > + * @brief Serial communication interface (SCI) functions definitions. > + */ > + > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * by embedded brains GmbH and others > + * > + * 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 <bspopts.h> > + > +#include <libchip/sersupp.h> > +#include <bsp/tms570-sci.h> > +#include <bsp/tms570-sci-driver.h> > +#include <rtems/console.h> > +#include <bsp.h> > +#include <bsp/fatal.h> > +#include <bsp/irq.h> > + > +#define TMS570_SCI_BUFFER_SIZE 10 > +#define TMS570_CONTEXT_TABLE_SIZE 2 > +#define TMS570_USE_INTERRUPTS > + > +/** > + * @brief Table including all serial drivers > + * > + * Definitions of all serial drivers > + */ > +const tms570_sci_context driver_context_table[] = { > + { > + .device_name = "/dev/console", > + .regs = &TMS570_SCI, > + .irq = TMS570_IRQ_SCI_LEVEL_0, > + }, > + { > + .device_name = "/dev/ttyS1", > + .regs = &TMS570_SCI2, > + .irq = TMS570_IRQ_SCI2_LEVEL_0, > + } > +}; > + > +/** > + * @brief Serial drivers init function > + * > + * Initialize all serial drivers specified in driver_context_table > + * > + * @param[in] major > + * @param[in] minor > + * @param[in] arg > + * @retval RTEMS_SUCCESSFUL Initialization completed > + */ > +rtems_device_driver console_initialize( > + rtems_device_major_number major, > + rtems_device_minor_number minor, > + void *arg > +) > +{ > + rtems_status_code sc; > +#ifdef TMS570_USE_INTERRUPTS > + const rtems_termios_device_handler *handler = > &tms570_sci_handler_interrupt; > +#else > + const rtems_termios_device_handler *handler = &tms570_sci_handler_polled; > +#endif > + > + /* > + * Initialize the Termios infrastructure. If Termios has already > + * been initialized by another device driver, then this call will > + * have no effect. > + */ > + rtems_termios_initialize(); > + > + /* Initialize each device */ > + for ( > + minor = 0; > + minor < RTEMS_ARRAY_SIZE(driver_context_table); > + ++minor > + ) { > + tms570_sci_context *ctx = (tms570_sci_context *) > &driver_context_table[minor]; > + > + /* > + * Install this device in the file system and Termios. In order > + * to use the console (i.e. being able to do printf, scanf etc. > + * on stdin, stdout and stderr), one device must be registered as > + * "/dev/console" (CONSOLE_DEVICE_NAME). > + */ > + sc = rtems_termios_device_install( > + ctx->device_name, > + major, > + minor, > + handler, > + ctx > + ); > + if (sc != RTEMS_SUCCESSFUL) { > + bsp_fatal(BSP_FATAL_CONSOLE_NO_DEV); > + } > + } > + return RTEMS_SUCCESSFUL; > +} > + > + > +/** > + * @brief Reads chars from HW > + * > + * Reads chars from HW peripheral specified in driver context. > + * TMS570 does not have HW buffer for serial line so this function can > + * return only 0 or 1 char > + * > + * @param[in] ctx context of the driver > + * @param[out] buf read data buffer > + * @param[in] N size of buffer > + * @retval x Number of read chars from peripherals > + */ > +static int tms570_sci_read_received_chars( > + tms570_sci_context * ctx, > + char * buf, > + int N) > +{ > + if(N<1)return 0; > + if(ctx->regs->SCIRD != 0){ > + buf[0] = ctx->regs->SCIRD; > + return 1; > + } > + return 0; > +} > + > +/** > + * @brief Enables RX interrupt > + * > + * Enables RX interrupt source of SCI peripheral > + * specified in the driver context. > + * > + * @param[in] ctx context of the driver > + * @retval Void > + */ > +static void tms570_sci_enable_interrupts(tms570_sci_context * ctx){ > + ctx->regs->SCISETINT = (1<<9); > +} > + > +/** > + * @brief Disables RX interrupt > + * > + * Disables RX interrupt source of SCI peripheral specified in the driver > context. > + * > + * @param[in] ctx context of the driver > + * @retval Void > + */ > +static void tms570_sci_disable_interrupts(tms570_sci_context * ctx){ > + ctx->regs->SCICLEARINT = (1<<9); > +} > + > +/** > + * @brief Check whether driver has put char in HW > + * > + * Check whether driver has put char in HW. > + * This information is read from the driver context not from a peripheral. > + * TMS570 does not have write data buffer asociated with SCI > + * so the return can be only 0 or 1. > + * > + * @param[in] ctx context of the driver > + * @retval x > + */ > +static int tms570_sci_transmitted_chars(tms570_sci_context * ctx) > +{ > + int ret; > + ret = ctx->tx_chars_in_hw; > + if(ret == 1){ > + ctx->tx_chars_in_hw = 0; > + return 1; > + } > + return ret; > +} > + > +/** > + * @brief Set attributes of the HW peripheral > + * > + * Sets attributes of the HW peripheral (parity, baud rate, etc.) > + * TODO: untested function > + * > + * @param[in] tty rtems_termios_tty > + * @param[in] t termios driver > + * @retval true peripheral setting is changed > + */ > +static bool tms570_sci_set_attributes( > + rtems_termios_tty *tty, > + const struct termios *t > +) > +{ > + tms570_sci_context *ctx = rtems_termios_get_device_context(tty); > + rtems_interrupt_lock_context lock_context; > + > + rtems_termios_interrupt_lock_acquire(tty, &lock_context); > + > + switch (t->c_cflag & (PARENB|PARODD)) { > + case (PARENB|PARODD): > + /* Odd parity */ > + ctx->regs->SCIGCR1 &= !(1<<3); > + ctx->regs->SCIGCR1 |= (1<<2); > + break; > + > + case PARENB: > + /* Even parity */ > + ctx->regs->SCIGCR1 |= (1<<3); > + ctx->regs->SCIGCR1 |= (1<<2); > + break; > + > + default: > + case 0: > + case PARODD: > + /* No Parity */ > + ctx->regs->SCIGCR1 &= !(1<<2); > + } > + > + /* Baud rate */ > + ctx->regs->BRS |= 0xFF00001A; ditto; e.g. what other values could be used? > + > + rtems_termios_interrupt_lock_release(tty, &lock_context); > + > + return true; > +} > + > +/** > + * @brief sci interrupt handler > + * > + * Handler checks which interrupt occured and provides nessesary maintenance > + * dequeue characters in termios driver whether character is send succesfully > + * enqueue characters in termios driver whether character is recieved > + * > + * @param[in] arg rtems_termios_tty > + * @retval Void > + */ > +static void tms570_sci_interrupt_handler(void * arg){ > + rtems_termios_tty *tty = arg; > + tms570_sci_context *ctx = rtems_termios_get_device_context(tty); > + char buf[TMS570_SCI_BUFFER_SIZE]; > + size_t n; > + > + /* > + * Check if we have received something. > + */ > + if((ctx->regs->SCIFLR & (1<<9)) == (1<<9)){ > + n = tms570_sci_read_received_chars(ctx, buf, TMS570_SCI_BUFFER_SIZE); > + if (n > 0) { > + /* Hand the data over to the Termios infrastructure */ > + rtems_termios_enqueue_raw_characters(tty, buf, n); > + } > + } > + /* > + * Check if we have something transmitted. > + */ > + if((ctx->regs->SCIFLR & (1<<8)) == (1<<8)){ > + n = tms570_sci_transmitted_chars(ctx); > + if (n > 0) { > + /* > + * Notify Termios that we have transmitted some characters. It > + * will call now the interrupt write function if more characters > + * are ready for transmission. > + */ > + rtems_termios_dequeue_characters(tty, n); > + } > + } > +} > + > +/** > + * @brief sci write function called from interrupt > + * > + * Nonblocking write function. Writes characters to HW peripheral > + * TMS570 does not have write data buffer asociated with SCI > + * so only one character can be written. > + * > + * @param[in] tty rtems_termios_tty > + * @param[in] buf buffer of characters pending to send > + * @param[in] len size of the buffer > + * @retval Void > + */ > +static void tms570_sci_interrupt_write( > + rtems_termios_tty *tty, > + const char *buf, > + size_t len > +) > +{ > + tms570_sci_context *ctx = rtems_termios_get_device_context(tty); > + > + if (len > 0) { > + /* start UART TX, this will result in an interrupt when done */ > + ctx->regs->SCITD = *buf; > + /* character written - raise count*/ > + ctx->tx_chars_in_hw = 1; > + /* Enable TX interrupt (interrupt is edge-triggered) */ > + ctx->regs->SCISETINT = (1<<8); > + > + } else { > + /* No more to send, disable TX interrupts */ > + ctx->regs->SCICLEARINT = (1<<8); > + /* Tell close that we sent everything */ > + } > +} > + > +/** > + * @brief sci write function > + * > + * Blocking write function. Waits until HW peripheral is ready and then > writes > + * character to HW peripheral. Writes all characters in the buffer. > + * > + * @param[in] tty rtems_termios_tty > + * @param[in] buf buffer of characters pending to send > + * @param[in] len size of the buffer > + * @retval Void > + */ > +static void tms570_sci_poll_write( > + rtems_termios_tty *tty, > + const char *buf, > + size_t n > +) > +{ > + tms570_sci_context *ctx = rtems_termios_get_device_context(tty); > + size_t i; > + > + /* Write */ > + > + for (i = 0; i < n; ++i) { > + while ((ctx->regs->SCIFLR & (1<<11)) == 0) { > + ; > + } > + ctx->regs->SCITD = buf[i]; > + } > +} > + > +/** > + * @brief See if there is recieved charakter to read > + * > + * read the RX flag from peripheral specified in context > + * > + * @param[in] ctx context of the driver > + * @retval 0 No character to read > + * @retval x Character ready to read > + */ > +static int TMS570_sci_can_read_char( > + tms570_sci_context * ctx > +) > +{ > + return ctx->regs->SCIFLR & (1<<9); > +} > + > +/** > + * @brief reads character from peripheral > + * > + * reads the recieved character from peripheral specified in context > + * > + * @param[in] ctx context of the driver > + * @retval x Character > + */ > +static char TMS570_sci_read_char( > + tms570_sci_context * ctx > +) > +{ > + return ctx->regs->SCIRD; > +} > + > +/** > + * @brief sci read function > + * > + * check if there is recieved character to be read and reads it. > + * > + * @param[in] tty rtems_termios_tty (context of the driver) > + * @retval -1 No character to be read > + * @retval x Read character > + */ > +static int tms570_sci_poll_read(rtems_termios_tty *tty) > +{ > + tms570_sci_context *ctx = rtems_termios_get_device_context(tty); > + > + /* Check if a character is available */ > + if (TMS570_sci_can_read_char(ctx)) { > + return TMS570_sci_read_char(ctx); > + } else { > + return -1; > + } > +} > + > +/** > + * @brief inicialization of the driver > + * > + * inicialization of the HW peripheral specified in contex of the driver. > + * This function is called only once when opening the driver. > + * > + * @param[in] tty context of the driver > + * @param[in] args > + * @retval false Error occured during inicialization > + * @retval true Driver is open and ready > + */ > +static bool tms570_sci_poll_first_open( > + rtems_termios_tty *tty, > + rtems_libio_open_close_args_t *args > +) > +{ > + bool ok; > + /* TODO: test peripheral startup code below > + tms570_sci_context *ctx = rtems_termios_get_device_context(tty); > + ctx->regs->SCIGCR1 |= (1<<25) | (1<<24) | (1<<4); > + ctx->regs->SCIFORMAT |= 0x7; > + ctx->regs->SCIPIO0 |= (1<<1) | (1<<2); > + ctx->regs->SCISETINTLVL = 0; > + ok = tms570_sci_set_attributes(tty, rtems_termios_get_termios(tty)); > + */ > + ok = true; > + if (!ok) { > + return false; > + } > + return true; > +} > + > +/** > + * @brief inicialization of the interrupt driven driver > + * > + * calls tms570_sci_poll_first_open function. > + * install and enables interrupts. > + * > + * @param[in] tty context of the driver > + * @param[in] args > + * @retval false Error occured during inicialization > + * @retval true Driver is open and ready > + */ > +static bool tms570_sci_interrupt_first_open( > + rtems_termios_tty *tty, > + rtems_libio_open_close_args_t *args > +){ > + tms570_sci_context *ctx = rtems_termios_get_device_context(tty); > + rtems_status_code sc; > + bool ret; > + ret = tms570_sci_poll_first_open(tty,args); > + if (ret == false) > + return false; > + /* Register Interrupt handler */ > + sc = rtems_interrupt_handler_install(ctx->irq, > + ctx->device_name, > + RTEMS_INTERRUPT_SHARED, > + tms570_sci_interrupt_handler, > + tty); > + if (sc != RTEMS_SUCCESSFUL) > + return false; > + tms570_sci_enable_interrupts(rtems_termios_get_device_context(tty)); > + return true; > +} > + > +/** > + * @brief deinicializes sci peripheral > + * > + * @param[in] tty context of the driver > + * @param[in] args > + * @retval false Error occured during inicialization > + * @retval true Driver is open and ready > + */ > +static void tms570_sci_poll_last_close( > + rtems_termios_tty *tty, > + rtems_libio_open_close_args_t *args > +) > +{ > + /*tms570_sci_context *ctx = rtems_termios_get_device_context(tty);*/ > + > + /* TODO: Here shall be peripheral HW reset, someday */ > + > +} > + > +/** > + * @brief deinicializes sci peripheral of interrupt driven driver > + * > + * calls tms570_sci_poll_last_close and disables interrupts > + * > + * @param[in] tty context of the driver > + * @param[in] args > + * @retval false Error occured during inicialization > + * @retval true Driver is open and ready > + */ > +static void tms570_sci_interrupt_last_close( > + rtems_termios_tty *tty, > + rtems_libio_open_close_args_t *args > +) > +{ > + tms570_sci_context *ctx = rtems_termios_get_device_context(tty); > + rtems_interrupt_lock_context lock_context; > + > + /* Turn off RX interrupts */ > + rtems_termios_interrupt_lock_acquire(tty, &lock_context); > + tms570_sci_disable_interrupts(ctx); > + rtems_termios_interrupt_lock_release(tty, &lock_context); > + > + /* Flush device */ > + while ((ctx->regs->SCIFLR & (1<<11)) > 0) { > + ;/* Wait until all data has been sent */ > + } > + > + /* uninstall ISR */ > + rtems_interrupt_handler_remove(ctx->irq, tms570_sci_interrupt_handler, > tty); > + > + tms570_sci_poll_last_close(tty,args); > +} > + > +/** > + * @brief Struct containing definitions of polled driver functions. > + * > + * Encapsulates polled driver functions. > + * Use of this table is determited by not defining TMS570_USE_INTERRUPTS > + */ > +const rtems_termios_device_handler tms570_sci_handler_polled = { > + .first_open = tms570_sci_poll_first_open, > + .last_close = tms570_sci_poll_last_close, > + .poll_read = tms570_sci_poll_read, > + .write = tms570_sci_poll_write, > + .set_attributes = tms570_sci_set_attributes, > + .stop_remote_tx = NULL, > + .start_remote_tx = NULL, > + .mode = TERMIOS_POLLED > +}; > + > +/** > + * @brief Struct containing definitions of interrupt driven driver functions. > + * > + * Encapsulates interrupt driven driver functions. > + * Use of this table is determited by defining TMS570_USE_INTERRUPTS > + */ > +const rtems_termios_device_handler tms570_sci_handler_interrupt = { > + .first_open = tms570_sci_interrupt_first_open, > + .last_close = tms570_sci_interrupt_last_close, > + .poll_read = NULL, > + .write = tms570_sci_interrupt_write, > + .set_attributes = tms570_sci_set_attributes, > + .stop_remote_tx = NULL, > + .start_remote_tx = NULL, > + .mode = TERMIOS_IRQ_DRIVEN > +}; > diff --git a/c/src/lib/libbsp/arm/tms570/include/bsp.h > b/c/src/lib/libbsp/arm/tms570/include/bsp.h > new file mode 100644 > index 0000000..450ca68 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/include/bsp.h > @@ -0,0 +1,101 @@ > +/** > + * @file bsp.h > + * > + * @ingroup tms570 > + * > + * @brief Global BSP definitions. > + */ > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * > + * 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_ARM_TMS570_BSP_H > +#define LIBBSP_ARM_TMS570_BSP_H > + > +#include <bspopts.h> > + > +#define TMS570_PCLK ( TMS570_CCLK / TMS570_PCLKDIV ) > +#define TMS570_MPU_REGION_COUNT 8u > + > +#define BSP_FEATURE_IRQ_EXTENSION > + > +#ifndef ASM > + > +#include <rtems.h> > +#include <rtems/console.h> > +#include <rtems/clockdrv.h> > +#include <bsp/default-initial-extension.h> > + > +#define BSP_OSCILATOR_CLOCK 8000000 > +#define BSP_PLL_OUT_CLOCK 160000000 > + > +/** Define operation count for Tests */ > +#define OPERATION_COUNT 4 > + > +#ifdef __cplusplus > +extern "C" { > +#endif /* __cplusplus */ > + > +struct rtems_bsdnet_ifconfig; > + > +/** > + * @defgroup tms570 TMS570 Support > + * > + * @ingroup bsp_arm > + * > + * @brief TMS570 support package. > + * > + * @{ > + */ > + > +/** > + * @brief Optimized idle task. > + * > + * This idle task sets the power mode to idle. This causes the processor > + * clock to be stopped, while on-chip peripherals remain active. > + * Any enabled interrupt from a peripheral or an external interrupt source > + * will cause the processor to resume execution. > + * > + * To enable the idle task use the following in the system configuration: > + * > + * @code > + * #include <bsp.h> > + * > + * #define CONFIGURE_INIT > + * > + * #define CONFIGURE_IDLE_TASK_BODY bsp_idle_thread > + * > + * #include <confdefs.h> > + * @endcode > + */ > +void*bsp_idle_thread( uintptr_t ignored ); > + > +#define BSP_CONSOLE_UART_BASE 0x4000C000U > + > +/** > + * @brief Restarts the bsp with "addr" address > + * @param addr Address used to restart the bsp > + */ > +void bsp_restart( const void *addr ); > + > +/** @} */ > + > +#ifdef __cplusplus > +} > +#endif /* __cplusplus */ > + > +#endif /* ASM */ > + > +#endif /* LIBBSP_ARM_TMS570_BSP_H */ > diff --git a/c/src/lib/libbsp/arm/tms570/include/irq.h > b/c/src/lib/libbsp/arm/tms570/include/irq.h > new file mode 100644 > index 0000000..718abad > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/include/irq.h > @@ -0,0 +1,134 @@ > +/** > + * @file irq.h > + * > + * @ingroup tms570 > + * > + * @brief TMS570 interrupt definitions. > + */ > + > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * by embedded brains GmbH and others > + * > + * 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_ARM_TMS570_IRQ_H > +#define LIBBSP_ARM_TMS570_IRQ_H > + > +#ifndef ASM > +#include <rtems.h> > +#include <rtems/irq.h> > +#include <rtems/irq-extension.h> > +#endif > + > +#define BSP_INTERRUPT_VECTOR_MIN 0U > +#define TMS570_IRQ_ESM_HIGH 0 > +#define TMS570_IRQ_RESERVED 1 > +#define TMS570_IRQ_TIMER_0 2 > +#define TMS570_IRQ_TIMER_1 3 > +#define TMS570_IRQ_TIMER_2 4 > +#define TMS570_IRQ_TIMER_3 5 > +#define TMS570_IRQ_RTI_OVERFLOW_0 6 > +#define TMS570_IRQ_RTI_OVERFLOW_1 7 > +#define TMS570_IRQ_RTI_TIMEBASE 8 > +#define TMS570_IRQ_GIO_HIGH 9 > +#define TMS570_IRQ_HET_HIGH 10 > +#define TMS570_IRQ_HET_TU_HIGH 11 > +#define TMS570_IRQ_MIBSPI1_HIGH 12 > +#define TMS570_IRQ_SCI_LEVEL_0 13 > +#define TMS570_IRQ_ADC1_EVENT 14 > +#define TMS570_IRQ_ADC1_GROUP_1 15 > +#define TMS570_IRQ_CAN1_HIGH 16 > +#define TMS570_IRQ_RESERVED 17 > +#define TMS570_IRQ_FLEXRAY_HIGH 18 > +#define TMS570_IRQ_CRC_1 19 > +#define TMS570_IRQ_ESM_LOW 20 > +#define TMS570_IRQ_SSI 21 > +#define TMS570_IRQ_PMU 22 > +#define TMS570_IRQ_GIO_LOW 23 > +#define TMS570_IRQ_HET_LOW 24 > +#define TMS570_IRQ_HET_TU_LOW 25 > +#define TMS570_IRQ_MIBSPI1_LOW 26 > +#define TMS570_IRQ_SCI_LEVEL_1 27 > +#define TMS570_IRQ_ADC1_GROUP_2 28 > +#define TMS570_IRQ_CAN1_LOW 29 > +#define TMS570_IRQ_RESERVED > +#define TMS570_IRQ_ADC1_MAG 31 > +#define TMS570_IRQ_FLEXRAY_LOW 32 > +#define TMS570_IRQ_DMA_FTCA 33 > +#define TMS570_IRQ_DMA_LFSA 34 > +#define TMS570_IRQ_CAN2_HIGH 35 > +#define TMS570_IRQ_DMM_HIGH 36 > +#define TMS570_IRQ_MIBSPI3_HIGH 37 > +#define TMS570_IRQ_MIBSPI3_LOW 38 > +#define TMS570_IRQ_DMA_HBCA 39 > +#define TMS570_IRQ_DMA_BTCA 40 > +#define TMS570_IRQ_DMA_BERA 41 > +#define TMS570_IRQ_CAN2_LOW 42 > +#define TMS570_IRQ_DMM_LOW 43 > +#define TMS570_IRQ_CAN1_IF3 44 > +#define TMS570_IRQ_CAN3_HIGH 45 > +#define TMS570_IRQ_CAN2_IF3 46 > +#define TMS570_IRQ_FPU 47 > +#define TMS570_IRQ_FLEXRAY_TU 48 > +#define TMS570_IRQ_SPI4_HIGH 49 > +#define TMS570_IRQ_ADC2_EVENT 50 > +#define TMS570_IRQ_ADC2_GROUP_1 51 > +#define TMS570_IRQ_FLEXRAY_T0C 52 > +#define TMS570_IRQ_MIBSPIP5_HIGH 53 > +#define TMS570_IRQ_SPI4_LOW 54 > +#define TMS570_IRQ_CAN3_LOW 55 > +#define TMS570_IRQ_MIBSPIP5_LOW 56 > +#define TMS570_IRQ_ADC2_GROUP_2 57 > +#define TMS570_IRQ_FLEXRAY_TU_ERROR 58 > +#define TMS570_IRQ_ADC2_MAG 59 > +#define TMS570_IRQ_CAN3_IF3 60 > +#define TMS570_IRQ_FSM_DONE 61 > +#define TMS570_IRQ_FLEXRAY_T1C 62 > +#define TMS570_IRQ_HET2_LEVEL_0 63 > +#define TMS570_IRQ_SCI2_LEVEL_0 64 > +#define TMS570_IRQ_HET_TU2_LEVEL_0 65 > +#define TMS570_IRQ_IC2_INTERRUPT 66 > +#define TMS570_IRQ_HET2_LEVEL_1 73 > +#define TMS570_IRQ_SCI2_LEVEL_1 74 > +#define TMS570_IRQ_HET_TU2_LEVEL_1 75 > +#define TMS570_IRQ_HWA_INT_REQ_H 80 > +#define TMS570_IRQ_HWA_INT_REQ_H 81 > +#define TMS570_IRQ_DCC_DONE_INTERRUPT 82 > +#define TMS570_IRQ_DCC2_DONE_INTERRUPT 83 > +#define TMS570_IRQ_HWAG1_INT_REQ_L 88 > +#define TMS570_IRQ_HWAG2_INT_REQ_L 89 > +#define BSP_INTERRUPT_VECTOR_MAX 94 > + > +#define TMS570_IRQ_PRIORITY_VALUE_MIN 0U > +#define TMS570_IRQ_PRIORITY_VALUE_MAX 0U > + > +#define TMS570_IRQ_PRIORITY_COUNT ( TMS570_IRQ_PRIORITY_VALUE_MAX + 1U ) > +#define TMS570_IRQ_PRIORITY_HIGHEST TMS570_IRQ_PRIORITY_VALUE_MIN > +#define TMS570_IRQ_PRIORITY_LOWEST TMS570_IRQ_PRIORITY_VALUE_MAX > + > +#ifndef ASM > + > +void tms570_irq_set_priority( > + rtems_vector_number vector, > + unsigned priority > +); > + > +unsigned tms570_irq_get_priority( rtems_vector_number vector ); > + > +#endif /* ASM */ > + > +/** @} */ > + > +#endif /* LIBBSP_ARM_TMS570_IRQ_H */ > diff --git a/c/src/lib/libbsp/arm/tms570/include/tms570-pom.h > b/c/src/lib/libbsp/arm/tms570/include/tms570-pom.h > new file mode 100644 > index 0000000..810c5c8 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/include/tms570-pom.h > @@ -0,0 +1,101 @@ > +/** > + * @file tms570-pom.h > + * @ingroup tms570 > + * @brief Parameter Overlay Module (POM) header file > + */ > + > +/* > + * Copyright (c) 2014 Pavel Pisa <p...@cmp.felk.cvut.cz> > + * > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * 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_ARM_TMS570_POM_H > +#define LIBBSP_ARM_TMS570_POM_H > + > +#include <stdint.h> > + > +#ifdef __cplusplus > +extern "C" { > +#endif /* __cplusplus */ > + > +#define TMS570_POM_REGIONS 32 > +#define TMS570_POM_GLBCTRL_ENABLE 0x000000a0a > + > +#define TMS570_POM_REGSIZE_DISABLED 0 > +#define TMS570_POM_REGSIZE_64B 1 > +#define TMS570_POM_REGSIZE_128B 2 > +#define TMS570_POM_REGSIZE_256B 3 > +#define TMS570_POM_REGSIZE_5120B 4 > +#define TMS570_POM_REGSIZE_1KB 5 > +#define TMS570_POM_REGSIZE_2KB 6 > +#define TMS570_POM_REGSIZE_4KB 7 > +#define TMS570_POM_REGSIZE_8KB 8 > +#define TMS570_POM_REGSIZE_16KB 9 > +#define TMS570_POM_REGSIZE_32KB 0xa > +#define TMS570_POM_REGSIZE_64KB 0xb > +#define TMS570_POM_REGSIZE_128KB 0xc > +#define TMS570_POM_REGSIZE_256KB 0xd > + > +#define TMS570_POM_REGADDRMASK ((1<<23)-1) > + > +typedef struct tms570_pom_region_t { > + uint32_t PROGSTART; > + uint32_t OVLSTART; > + uint32_t REGSIZE; > + uint32_t res0; > +} tms570_pom_region_t; > + > +typedef struct tms570_pom_t { > + uint32_t GLBCTRL; /* 000h Global Control Register */ > + uint32_t REV; /* 004h Revision ID */ > + uint32_t CLKCTRL; /* 008h Clock Gate Control Register */ > + uint32_t FLG; /* 00Ch Status Register */ > + uint32_t res0[0x1f0/4]; > + tms570_pom_region_t REG[TMS570_POM_REGIONS]; /* 200h Program Regions */ > + uint32_t res1[0xb00/4]; > + uint32_t ITCTRL; /* F00h Integration Control Register */ > + uint32_t res2[0x09c/4]; > + uint32_t CLAIMSET; /* FA0h Claim Set Register */ > + uint32_t CLAIMCLR; /* FA4h Claim Clear Register */ > + uint32_t res3[0x008/4]; > + uint32_t LOCKACCESS; /* FB0h Lock Access Register */ > + uint32_t LOCKSTATUS; /* FB4h Lock Status Register */ > + uint32_t AUTHSTATUS; /* FB8h Authentication Status Register */ > + uint32_t res4[0x00c/4]; > + uint32_t DEVID; /* FC8h Device ID Register */ > + uint32_t DEVTYPE; /* FCCh Device Type Register */ > + uint32_t PERIPHERALID4; /* FD0h Peripheral ID 4 Register */ > + uint32_t PERIPHERALID5; /* FD4h Peripheral ID 5 Register */ > + uint32_t PERIPHERALID6; /* FD8h Peripheral ID 6 Register */ > + uint32_t PERIPHERALID7; /* FDCh Peripheral ID 7 Register */ > + uint32_t PERIPHERALID0; /* FE0h Peripheral ID 0 Register */ > + uint32_t PERIPHERALID1; /* FE4h Peripheral ID 1 Register */ > + uint32_t PERIPHERALID2; /* FE8h Peripheral ID 2 Register */ > + uint32_t PERIPHERALID3; /* FECh Peripheral ID 3 Register */ > + uint32_t COMPONENTID0; /* FF0h Component ID 0 Register */ > + uint32_t COMPONENTID1; /* FF4h Component ID 1 Register */ > + uint32_t COMPONENTID2; /* FF8h Component ID 2 Register */ > + uint32_t COMPONENTID3; /* FFCh Component ID 3 Register */ > +} tms570_pom_t; > + > +#define TMS570_POM (*(volatile tms570_pom_t*)0xffa04000) > + > +int mem_dump(void *buf, unsigned long start, unsigned long len, int blen); > +void tms570_pom_remap(void); > + > +/** @} */ > + > +#ifdef __cplusplus > +} > +#endif /* __cplusplus */ > + > +#endif /* LIBBSP_ARM_TMS570_POM_H */ > diff --git a/c/src/lib/libbsp/arm/tms570/include/tms570-rti.h > b/c/src/lib/libbsp/arm/tms570/include/tms570-rti.h > new file mode 100644 > index 0000000..379d4e1 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/include/tms570-rti.h > @@ -0,0 +1,95 @@ > +/** > + * @file tms570-rti.h > + * > + * @ingroup tms570 > + * > + * @brief Real Time Interrupt module (RTI) header file. > + */ > + > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * by embedded brains GmbH and others > + * > + * 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_ARM_TMS570_RTI_H > +#define LIBBSP_ARM_TMS570_RTI_H > + > +#ifndef ASM > + > +#include <stdint.h> > + > +#ifdef __cplusplus > +extern "C" { > +#endif /* __cplusplus */ > + > + typedef struct { > + uint32_t RTIGCTRL; //RTIGlobalControlRegister > + uint32_t RTITBCTRL; //RTITimebaseControlRegister > + uint32_t RTICAPCTRL; //RTICaptureControlRegister > + uint32_t RTICOMPCTRL; //RTICompareControlRegister > + uint32_t RTIFRC0; //RTIFreeRunningCounter0Register > + uint32_t RTIUC0; //RTIUpCounter0Register > + uint32_t RTICPUC0; //RTICompareUpCounter0Register > + uint32_t reserved1 [0x4/4]; > + uint32_t RTICAFRC0; //RTICaptureFreeRunningCounter0Register > + uint32_t RTICAUC0; //RTICaptureUpCounter0Register > + uint32_t reserved2 [0x8/4]; > + uint32_t RTIFRC1; //RTIFreeRunningCounter1Register > + uint32_t RTIUC1; //RTIUpCounter1Register > + uint32_t RTICPUC1; //RTICompareUpCounter1Register > + uint32_t reserved3 [0x4/4]; > + uint32_t RTICAFRC1; //RTICaptureFreeRunningCounter1Register > + uint32_t RTICAUC1; //RTICaptureUpCounter1Register > + uint32_t reserved4 [0x8/4]; > + uint32_t RTICOMP0; //RTICompare0Register > + uint32_t RTIUDCP0; //RTIUpdateCompare0Register > + uint32_t RTICOMP1; //RTICompare1Register > + uint32_t RTIUDCP1; //RTIUpdateCompare1Register > + uint32_t RTICOMP2; //RTICompare2Register > + uint32_t RTIUDCP2; //RTIUpdateCompare2Register > + uint32_t RTICOMP3; //RTICompare3Register > + uint32_t RTIUDCP3; //RTIUpdateCompare3Register > + uint32_t RTITBLCOMP; //RTITimebaseLowCompareRegister > + uint32_t RTITBHCOMP; //RTITimebaseHighCompareRegister > + uint32_t reserved5 [0x8/4]; > + uint32_t RTISETINTENA; //RTISetInterruptEnableRegister > + uint32_t RTICLEARINTENA; //RTIClearInterruptEnableRegister > + uint32_t RTIINTFLAG; //RTIInterruptFlagRegister > + uint32_t reserved6 [0x4/4]; > + uint32_t RTIDWDCTRL; //DigitalWatchdogControlRegister > + uint32_t RTIDWDPRLD; //DigitalWatchdogPreloadRegister > + uint32_t RTIWDSTATUS; //WatchdogStatusRegister > + uint32_t RTIWDKEY; //RTIWatchdogKeyRegister > + uint32_t RTIDWDCNTR; //RTIDigitalWatchdogDownCounterRegister > + uint32_t RTIWWDRXNCTRL; //DigitalWindowedWatchdogReactionControlRegister > + uint32_t RTIWWDSIZECTRL; > //DigitalWindowedWatchdogWindowSizeControlRegister > + uint32_t RTIINTCLRENABLE; //RTICompareInterruptClearEnableRegister > + uint32_t RTICOMP0CLR; //RTICompare0ClearRegister > + uint32_t RTICOMP1CLR; //RTICompare1ClearRegister > + uint32_t RTICOMP2CLR; //RTICompare2ClearRegister > + uint32_t RTICOMP3CLR; //RTICompare3ClearRegister > +}tms570_rti_t; > + > +#define TMS570_RTI (*(volatile tms570_rti_t*)0xFFFFFC00) > + > +/** @} */ > + > +#ifdef __cplusplus > +} > +#endif /* __cplusplus */ > + > +#endif /* ASM */ > + > +#endif /* LIBBSP_ARM_TMS570_IRQ_H */ > diff --git a/c/src/lib/libbsp/arm/tms570/include/tms570-sci-driver.h > b/c/src/lib/libbsp/arm/tms570/include/tms570-sci-driver.h > new file mode 100644 > index 0000000..37ea8ce > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/include/tms570-sci-driver.h > @@ -0,0 +1,39 @@ > +/** > + * @file tms570-sci-driver.h > + * > + * @ingroup tms570 > + * > + * @brief Declaration of serial's driver inner structure. > + */ > +#ifndef TMS570_SCI_DRIVER > +#define TMS570_SCI_DRIVER > + > +#include <rtems/termiostypes.h> > +#include <rtems/irq.h> > +#include <bsp/tms570-sci.h> > + > +#ifdef __cplusplus > +extern "C" { > +#endif /* __cplusplus */ > + > +/* Low-level driver specific data structure */ > +typedef struct { > + const char *device_name; > + volatile tms570_sci_t *regs; > + int tx_chars_in_hw; > + rtems_vector_number irq; > +} tms570_sci_context; > + > +extern const rtems_termios_device_handler tms570_sci_handler_polled; > + > +extern const rtems_termios_device_handler tms570_sci_handler_interrupt; > + > +extern const tms570_sci_context driver_context_table[]; > + > +/** @} */ > + > +#ifdef __cplusplus > +} > +#endif /* __cplusplus */ > + > +#endif /* TMS570_SCI_DRIVER */ > diff --git a/c/src/lib/libbsp/arm/tms570/include/tms570-sci.h > b/c/src/lib/libbsp/arm/tms570/include/tms570-sci.h > new file mode 100644 > index 0000000..da37c4d > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/include/tms570-sci.h > @@ -0,0 +1,75 @@ > +/** > + * @file tms570-sci.h > + * > + * @ingroup tms570 > + * > + * @brief Serial Communication Interface (SCI) header file. > + */ > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * by embedded brains GmbH and others > + * > + * 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_ARM_TMS570_SCI_H > +#define LIBBSP_ARM_TMS570_SCI_H > + > +#include <libchip/serial.h> > + > +#include <rtems.h> > +#include <stdint.h> > + > +#ifdef __cplusplus > +extern "C" { > +#endif /* __cplusplus */ > + > +typedef struct { > + uint32_t SCIGCR0; /*SCIGlobalControlRegister0*/ > + uint32_t SCIGCR1; /*SCIGlobalControlRegister1*/ > + uint32_t reserved1 [0x4/4]; > + uint32_t SCISETINT; /*SCISetInterruptRegister*/ > + uint32_t SCICLEARINT; /*SCIClearInterruptRegister*/ > + uint32_t SCISETINTLVL; /*SCISetInterruptLevelRegister*/ > + uint32_t SCICLEARINTLVL; /*SCIClearInterruptLevelRegister*/ > + uint32_t SCIFLR; /*SCIFlagsRegister*/ > + uint32_t SCIINTVECT0; /*SCIInterruptVectorOffset0*/ > + uint32_t SCIINTVECT1; /*SCIInterruptVectorOffset1*/ > + uint32_t SCIFORMAT; /*SCIFormatControlRegister*/ > + uint32_t BRS; /*BaudRateSelectionRegister*/ > + uint32_t SCIED; /*ReceiverEmulationDataBuffer*/ > + uint32_t SCIRD; /*ReceiverDataBuffer*/ > + uint32_t SCITD; /*TransmitDataBuffer*/ > + uint32_t SCIPIO0; /*SCIPinI/OControlRegister0*/ > + uint32_t SCIPIO1; /*SCIPinI/OControlRegister1*/ > + uint32_t SCIPIO2; /*SCIPinI/OControlRegister2*/ > + uint32_t SCIPIO3; /*SCIPinI/OControlRegister3*/ > + uint32_t SCIPIO4; /*SCIPinI/OControlRegister4*/ > + uint32_t SCIPIO5; /*SCIPinI/OControlRegister5*/ > + uint32_t SCIPIO6; /*SCIPinI/OControlRegister6*/ > + uint32_t SCIPIO7; /*SCIPinI/OControlRegister7*/ > + uint32_t SCIPIO8; /*SCIPinI/OControlRegister8*/ > + uint32_t reserved2 [0x30/4]; > + uint32_t IODFTCTRL; /*Input/OutputErrorEnableRegister*/ > +}tms570_sci_t; > + > +#define TMS570_SCI (*(volatile tms570_sci_t*)0xFFF7E400U) > +#define TMS570_SCI2 (*(volatile tms570_sci_t*)0xFFF7E500U) > + > +/** @} */ > + > +#ifdef __cplusplus > +} > +#endif /* __cplusplus */ > + > +#endif > diff --git a/c/src/lib/libbsp/arm/tms570/include/tms570-vim.h > b/c/src/lib/libbsp/arm/tms570/include/tms570-vim.h > new file mode 100644 > index 0000000..6d3bb54 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/include/tms570-vim.h > @@ -0,0 +1,74 @@ > +/** > + * @file tms570-vim.h > + * > + * @ingroup tms570 > + * > + * @brief Vectored Interrupt Module (VIM) header file. > + */ > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * by embedded brains GmbH and others > + * > + * 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_ARM_TMS570_VIM_H > +#define LIBBSP_ARM_TMS570_VIM_H > + > +#ifndef ASM > +#include <rtems.h> > +#include <stdint.h> > + > +#ifdef __cplusplus > +extern "C" { > +#endif /* __cplusplus */ > + > +typedef struct{ > + uint32_t PARFLG; /* InterruptVectorTableParityFlagRegister */ > + uint32_t PARCTL; /* InterruptVectorTableParityControlRegister */ > + uint32_t ADDERR; /* AddressParityErrorRegister */ > + uint32_t FBPARERR; /* Fall-BackAddressParityErrorRegister */ > + uint32_t reserved1 [0x4/4]; > + uint32_t IRQINDEX; /* IRQIndexOffsetVectorRegister */ > + uint32_t FIQINDEX; /* FIQIndexOffsetVectorRegister */ > + uint32_t reserved2 [0x8/4]; > + uint32_t FIRQPR[3]; /* FIQ/IRQProgramControlRegister0 */ > + uint32_t reserved3 [0x4/4]; > + uint32_t INTREQ[3]; /* PendingInterruptReadLocationRegister0 */ > + uint32_t reserved4 [0x4/4]; > + uint32_t REQENASET[3]; /* InterruptEnableSetRegister0 */ > + uint32_t reserved5 [0x4/4]; > + uint32_t REQENACLR[3]; /* InterruptEnableClearRegister0 */ > + uint32_t reserved6 [0x4/4]; > + uint32_t WAKEENASET[3]; /* Wake-upEnableSetRegister0 */ > + uint32_t reserved7 [0x4/4]; > + uint32_t WAKEENACLR[3]; /* Wake-upEnableClearRegister0 */ > + uint32_t reserved8 [0x4/4]; > + uint32_t IRQVECREG; /* IRQInterruptVectorRegister */ > + uint32_t FIQVECREG; /* FIQInterruptVectorRegister */ > + uint32_t CAPEVT; /* CaptureEventRegister */ > + uint32_t reserved9 [0x4/4]; > + uint32_t CHANCTRL [0x5c/4]; /* VIM Interrupt Control Register (PARSER > ERROR) */ > +}tms570_vim_t; > + > +#define TMS570_VIM (*(volatile tms570_vim_t*)0xFFFFFDEC) > + > +#endif > + > +/** @} */ > + > +#ifdef __cplusplus > +} > +#endif /* __cplusplus */ > + > +#endif /* LIBBSP_ARM_TMS570_IRQ_H */ > diff --git a/c/src/lib/libbsp/arm/tms570/include/tms570.h > b/c/src/lib/libbsp/arm/tms570/include/tms570.h > new file mode 100644 > index 0000000..e7f43f2 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/include/tms570.h > @@ -0,0 +1,29 @@ > +/** > + * @file tms570.h > + * > + * @ingroup tms570 > + * > + * @brief Specific register definitions according to tms570 family boards. > + */ > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * > + * 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_ARM_TMS570_H > +#define LIBBSP_ARM_TMS570_H > + > + > + > +#endif /* LIBBSP_ARM_TMS570_H */ > diff --git a/c/src/lib/libbsp/arm/tms570/irq/irq.c > b/c/src/lib/libbsp/arm/tms570/irq/irq.c > new file mode 100644 > index 0000000..5f72356 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/irq/irq.c > @@ -0,0 +1,182 @@ > +/** > + * @file irq.c > + * > + * @ingroup tms570 > + * > + * @brief TMS570 interrupt support functions definitions. > + */ > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * > + * 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/score/armv4.h> > + > +#include <bsp.h> > +#include <bsp/irq-generic.h> > +#include <bsp/tms570-vim.h> > +#include <bsp/irq.h> > +#include <rtems/score/armv4.h> > + > +/** > + * @brief Check if isr vector is valid > + * > + * Check if isr vector is valid by using BSP_INTERRUPT_VECTOR_MAX and > + * BSP_INTERRUPT_VECTOR_MIN defined in irq.h > + * > + * @param[in] vector interrupt vector to be checked. > + * @retval TRUE vector is valid. > + * @retval FALSE vector is invalid > + */ > +static inline bool tms570_irq_is_valid(rtems_vector_number vector) > +{ > + return (vector <= BSP_INTERRUPT_VECTOR_MAX) && > + (vector > BSP_INTERRUPT_VECTOR_MIN); > +} > + > +unsigned int priorityTable[BSP_INTERRUPT_VECTOR_MAX+1]; > + > +/** > + * @brief Set priority of the interrupt vector. > + * > + * This function is here because of compability. It should set > + * priority of the interrupt vector. > + * !!!WARNING!!! > + * It does not set any priority at HW layer. It is nearly imposible to set > + * priority of the interrupt on TMS570 in the nice way. > + * > + * @param[in] vector vector of isr > + * @param[in] priority new priority assigned to the vector > + * @return Void > + */ > +void tms570_irq_set_priority(rtems_vector_number vector, unsigned priority){ > + if (tms570_irq_is_valid(vector)) { > + priorityTable[vector] = priority; > + } > +} > + > +/** > + * @brief Gets priority of the interrupt vector. > + * > + * This function is here because of compability. It returns priority > + * of the isr vector last set by tms570_irq_set_priority function. > + * !!!WARNING!!! > + * It does not return any priority of the HW layer. > + * > + * @param[in] vector vector of isr > + * @retval 0 vector is invalid. > + * @retval priority priority of the interrupt > + */ > +unsigned tms570_irq_get_priority(rtems_vector_number vector){ > + if (tms570_irq_is_valid(vector)) { > + return priorityTable[vector]; > + } > + return 0; > +} > + > +/** > + * @brief Interrupt dispatch > + * > + * Called by OS to determine which interrupt occured. > + * Function passes control to interrupt handler. > + * > + * @return Void > + */ > +void bsp_interrupt_dispatch(void) > +{ > + > + rtems_vector_number vector = TMS570_VIM.IRQINDEX-1; > + > + bsp_interrupt_handler_dispatch(vector); > +} > + > +/** > + * @brief enables interrupt vector in the HW > + * > + * Enables HW interrupt for specified vector > + * > + * @param[in] vector vector of the isr which needs to be enabled. > + * @retval RTEMS_INVALID_ID vector is invalid. > + * @retval RTEMS_SUCCESSFUL interrupt source enabled. > + */ > +rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector) > +{ > + if(!tms570_irq_is_valid(vector)) > + return RTEMS_INVALID_ID; > + > + TMS570_VIM.REQENASET[vector >> 5] = 1 << (vector & 0x1f); > + > + return RTEMS_SUCCESSFUL; > +} > + > +/** > + * @brief disables interrupt vector in the HW > + * > + * Disables HW interrupt for specified vector > + * > + * @param[in] vector vector of the isr which needs to be disabled. > + * @retval RTEMS_INVALID_ID vector is invalid. > + * @retval RTEMS_SUCCESSFUL interrupt source disabled. > + */ > +rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector) > +{ > + if(!tms570_irq_is_valid(vector)) > + return RTEMS_INVALID_ID; > + > + TMS570_VIM.REQENACLR[vector >> 5] = 1 << (vector & 0x1f); > + > + return RTEMS_SUCCESSFUL; > +} > + > +/** > + * @brief Init function of interrupt module > + * > + * Resets vectored interrupt interface to default state. > + * Disables all interrupts. > + * Set all sources as IRQ (not FIR). > + * > + * @retval RTEMS_SUCCESSFUL All is set > + */ > +rtems_status_code bsp_interrupt_facility_initialize(void) > +{ > + void (**vim_vec)(void) = (void (**)(void)) 0xFFF82000; > + unsigned int value = 0x00010203; > + unsigned int i = 0; > + uint32_t sctlr; > + > + /* Disable interrupts */ > + for(i = 0; i < 3; i++) > + TMS570_VIM.REQENACLR[i] = 0xffffffff; > + /* Map default events on interrupt vectors */ > + for(i=0;i<24;i+=1,value += 0x04040404) > + TMS570_VIM.CHANCTRL[i] = value; > + /* Set all vectors as IRQ (not FIR) */ > + TMS570_VIM.FIRQPR[0] = 3; > + TMS570_VIM.FIRQPR[1] = 0; > + TMS570_VIM.FIRQPR[2] = 0; > + > + /*_CPU_ISR_install_vector(ARM_EXCEPTION_IRQ, _ARMV4_Exception_interrupt, > NULL);*/ > + for(i = 0; i <= 94; i++) > + vim_vec[i] = _ARMV4_Exception_interrupt; > + > + /* Clear bit VE in SCTLR register to not use VIM IRQ exception bypass*/ > + asm volatile ("mrc p15, 0, %0, c1, c0, 0\n": "=r" (sctlr)); > + sctlr &= ~(1 << 24); > + asm volatile ("mcr p15, 0, %0, c1, c0, 0\n": : "r" (sctlr)); > + > + return RTEMS_SUCCESSFUL; > +} > + > + > + > diff --git > a/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk-testsuite.tcfg > b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk-testsuite.tcfg > new file mode 100644 > index 0000000..6f722bc > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk-testsuite.tcfg > @@ -0,0 +1,19 @@ > +# > +# tms570ls3137 mbed RTEMS Test Database. > +# > +# Format is one line per test that is _NOT_ built. > +# > + > +flashdisk01 > +utf8proc01 > +spstkalloc02 > +fsdosfsname01 > +jffs2_fserror > +jffs2_fslink > +jffs2_fspatheval > +jffs2_fspermission > +jffs2_fsrdwr > +jffs2_fssymlink > +jffs2_fstime > +pppd > +mghttpd01 > diff --git a/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk.cfg > b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk.cfg > new file mode 100644 > index 0000000..ed43811 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk.cfg > @@ -0,0 +1,19 @@ > +# > +# Config file for mbed TMS570LS3137 board. > +# > + > +include $(RTEMS_ROOT)/make/custom/default.cfg > + > +RTEMS_CPU = arm > + > +CPU_CFLAGS = -march=armv7-r -mthumb -mbig-endian > + > +CFLAGS_OPTIMIZE_V = -O2 -ggdb3 -DNDEBUG > +BINEXT?=.bin > +# This defines the operations performed on the linked executable. > +# is currently required. > +define bsp-post-link > + $(OBJCOPY) -O binary --strip-all \ > + $(basename $@)$(EXEEXT) $(basename $@)$(BINEXT) > + $(SIZE) $(basename $@)$(EXEEXT) > +endef > diff --git > a/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_intram.cfg > b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_intram.cfg > new file mode 100644 > index 0000000..d4a7b44 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_intram.cfg > @@ -0,0 +1,20 @@ > +# > +# Config file for mbed TMS570LS3137 board. > +# > + > +include $(RTEMS_ROOT)/make/custom/default.cfg > + > +RTEMS_CPU = arm > + > +CPU_CFLAGS = -march=armv7-r -mthumb -mbig-endian > + > +#CFLAGS_OPTIMIZE_V = -O2 -ggdb3 -DNDEBUG > +CFLAGS_OPTIMIZE_V = -O0 -ggdb3 > +BINEXT?=.bin > +# This defines the operations performed on the linked executable. > +# is currently required. > +define bsp-post-link > + $(OBJCOPY) -O binary --strip-all \ > + $(basename $@)$(EXEEXT) $(basename $@)$(BINEXT) > + $(SIZE) $(basename $@)$(EXEEXT) > +endef > diff --git > a/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_sdram.cfg > b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_sdram.cfg > new file mode 100644 > index 0000000..ed43811 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_sdram.cfg > @@ -0,0 +1,19 @@ > +# > +# Config file for mbed TMS570LS3137 board. > +# > + > +include $(RTEMS_ROOT)/make/custom/default.cfg > + > +RTEMS_CPU = arm > + > +CPU_CFLAGS = -march=armv7-r -mthumb -mbig-endian > + > +CFLAGS_OPTIMIZE_V = -O2 -ggdb3 -DNDEBUG > +BINEXT?=.bin > +# This defines the operations performed on the linked executable. > +# is currently required. > +define bsp-post-link > + $(OBJCOPY) -O binary --strip-all \ > + $(basename $@)$(EXEEXT) $(basename $@)$(BINEXT) > + $(SIZE) $(basename $@)$(EXEEXT) > +endef > diff --git a/c/src/lib/libbsp/arm/tms570/network/tms570-ethernet.c > b/c/src/lib/libbsp/arm/tms570/network/tms570-ethernet.c > new file mode 100644 > index 0000000..e69de29 > diff --git a/c/src/lib/libbsp/arm/tms570/network/tms570-ethernet.h > b/c/src/lib/libbsp/arm/tms570/network/tms570-ethernet.h > new file mode 100644 > index 0000000..e69de29 > diff --git a/c/src/lib/libbsp/arm/tms570/pom/tms570-pom.c > b/c/src/lib/libbsp/arm/tms570/pom/tms570-pom.c > new file mode 100644 > index 0000000..0b7ff79 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/pom/tms570-pom.c > @@ -0,0 +1,100 @@ > +/** > + * @file tms570-pom.c > + * > + * @ingroup tms570 > + * > + * @brief TMS570 Parameter Overlay Module functions definitions. > + */ > + > + /* > + * Copyright (c) 2014 Pavel Pisa <p...@cmp.felk.cvut.cz> > + * > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * 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 <stdint.h> > +#include <bsp/tms570-pom.h> > +#include <bsp/linker-symbols.h> > +#include <bsp.h> > + > +/** > + * @brief Prints part of the memory > + * > + * debug function > + * > + * @retval 0 > + */ > +int mem_dump(void *buf, unsigned long start, unsigned long len, int blen) > +{ > + unsigned long addr=start; > + volatile unsigned char *p=buf; > + int i; > + > + while(len){ > + printk("%08lX:",addr); > + i=len>16?16:len; > + addr+=i; > + len-=i; > + while(i>0){ > + i -= blen; > + switch(blen){ > + case 4: > + printk("%08lX%c",(unsigned long)*(volatile uint32_t*)p,i>0?' > ':'\n'); > + break; > + case 2: > + printk("%04X%c",*(volatile uint16_t*)p,i>0?' ':'\n'); > + break; > + default: > + printk("%02X%c",*(volatile uint8_t*)(p),i>0?' ':'\n'); > + break; > + } > + p += blen; > + } > + } > + return 0; > +} > + > +/** > + * @brief remaps vector table > + * > + * transfer the rtems start vector table to address 0x0 > + * > + * @retval Void > + */ > +void tms570_pom_remap(void) > +{ > + > + int i; > + uint32_t vec_overlay_start = 0x08000000; > + > + memcpy((void*)vec_overlay_start, bsp_start_vector_table_begin, 64); > + > + TMS570_POM.GLBCTRL = 0; > + > + for (i = 0; i < TMS570_POM_REGIONS; i++) > + TMS570_POM.REG[i].REGSIZE = TMS570_POM_REGSIZE_DISABLED; > + > + TMS570_POM.REG[0].PROGSTART = 0x0 & TMS570_POM_REGADDRMASK; > + TMS570_POM.REG[0].OVLSTART = vec_overlay_start & TMS570_POM_REGADDRMASK; > + TMS570_POM.REG[0].REGSIZE = TMS570_POM_REGSIZE_64B; > + > + TMS570_POM.GLBCTRL = TMS570_POM_GLBCTRL_ENABLE | > + (vec_overlay_start & ~TMS570_POM_REGADDRMASK); > + > + #ifdef POM_REMAP_TEST > + p32[1] = 0xe12fff1e; > + > + mem_dump((uint8_t *)0x00000000, 0x00000000, 256, 1); > + > + printk("Probing call to address 0x00000004\n"); > + ((void(*)(void))4)(); > + printk("POM call really returned\n"); > + #endif /*POM_REMAP_TEST*/ > +} > diff --git a/c/src/lib/libbsp/arm/tms570/startup/bspreset.c > b/c/src/lib/libbsp/arm/tms570/startup/bspreset.c > new file mode 100644 > index 0000000..6a043f5 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/startup/bspreset.c > @@ -0,0 +1,37 @@ > +/** > + * @file bspreset.c > + * > + * @ingroup tms570 > + * > + * @brief Reset code. > + */ > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * > + * 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/bootcard.h> > +#include <bsp/tms570.h> > +#include <bsp/start.h> > + > +BSP_START_TEXT_SECTION __attribute__( ( flatten ) ) void bsp_reset( void ) > +{ > + > + while ( true ) { > + /* Do nothing */ > + } > +} > diff --git a/c/src/lib/libbsp/arm/tms570/startup/bspstart.c > b/c/src/lib/libbsp/arm/tms570/startup/bspstart.c > new file mode 100644 > index 0000000..9a7e434 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/startup/bspstart.c > @@ -0,0 +1,46 @@ > +/** > + * @file bspstart.c > + * > + * @ingroup tms570 > + * > + * @brief Startup code. > + */ > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * > + * 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/tms570-pom.h> > +#include <bsp/irq-generic.h> > +#include <bsp/start.h> > +#include <bsp/bootcard.h> > + > +void bsp_pretasking_hook( void ) > +{ > + > +} > + > +void bsp_start( void ) > +{ > + > + /* set the cpu mode to supervisor and big endian */ > + arm_cpu_mode = 0x213; > + > + tms570_pom_remap(); > + > + /* Interrupts */ > + bsp_interrupt_initialize(); > + > +} > diff --git a/c/src/lib/libbsp/arm/tms570/startup/bspstarthooks.c > b/c/src/lib/libbsp/arm/tms570/startup/bspstarthooks.c > new file mode 100644 > index 0000000..45a6903 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/startup/bspstarthooks.c > @@ -0,0 +1,42 @@ > +/** > + * @file bspstarthooks.c > + * > + * @ingroup tms570 > + * > + * @brief First configurations and initializations to the correct > + * functionality of the board. > + */ > + > +/* > + * Copyright (c) 2014 Premysl Houdek <kom541...@gmail.com> > + * > + * Google Summer of Code 2014 at > + * Czech Technical University in Prague > + * Zikova 1903/4 > + * 166 36 Praha 6 > + * Czech Republic > + * > + * Based on LPC24xx and LPC1768 BSP > + * by embedded brains GmbH and others > + * > + * 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/start.h> > + > + > +BSP_START_TEXT_SECTION void bsp_start_hook_0( void ) > +{ > + > +} > + > +BSP_START_TEXT_SECTION void bsp_start_hook_1( void ) > +{ > + bsp_start_copy_sections(); > + bsp_start_clear_bss(); > + > + /* At this point we can use objects outside the .start section */ > +} > diff --git a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk > b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk > new file mode 100644 > index 0000000..e02dcd6 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk > @@ -0,0 +1,27 @@ > + > +MEMORY { > + ROM_INT (RX) : ORIGIN = 0x00000000, LENGTH = 3M > + RAM_INT (AIW) : ORIGIN = 0x08000000, LENGTH = 256k > + RAM_EXT (AIWX) : ORIGIN = 0x80000000, LENGTH = 8M > +} > + > +REGION_ALIAS ("REGION_START", ROM_INT); > +REGION_ALIAS ("REGION_VECTOR", RAM_INT); > +REGION_ALIAS ("REGION_TEXT", ROM_INT); > +REGION_ALIAS ("REGION_TEXT_LOAD", ROM_INT); > +REGION_ALIAS ("REGION_RODATA", ROM_INT); > +REGION_ALIAS ("REGION_RODATA_LOAD", ROM_INT); > +REGION_ALIAS ("REGION_DATA", RAM_INT); > +REGION_ALIAS ("REGION_DATA_LOAD", ROM_INT); > +REGION_ALIAS ("REGION_FAST_TEXT", RAM_INT); > +REGION_ALIAS ("REGION_FAST_TEXT_LOAD", ROM_INT); > +REGION_ALIAS ("REGION_FAST_DATA", RAM_INT); > +REGION_ALIAS ("REGION_FAST_DATA_LOAD", ROM_INT); > +REGION_ALIAS ("REGION_BSS", RAM_INT); > +REGION_ALIAS ("REGION_WORK", RAM_INT); > +REGION_ALIAS ("REGION_STACK", RAM_INT); > + > +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); > + > +INCLUDE linkcmds.armv4 > diff --git > a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_intram > b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_intram > new file mode 100644 > index 0000000..19bb7b2 > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_intram > @@ -0,0 +1,28 @@ > + > +MEMORY { > + ROM_INT (RX) : ORIGIN = 0x00000000, LENGTH = 3M > + RAM_INT_VEC : ORIGIN = 0x08000000, LENGTH = 1k > + RAM_INT (AIWX) : ORIGIN = 0x08000400, LENGTH = 256k - 1k > + RAM_EXT (AIW) : ORIGIN = 0x80000000, LENGTH = 8M > +} > + > +REGION_ALIAS ("REGION_START", RAM_INT); > +REGION_ALIAS ("REGION_VECTOR", RAM_INT); > +REGION_ALIAS ("REGION_TEXT", RAM_INT); > +REGION_ALIAS ("REGION_TEXT_LOAD", RAM_INT); > +REGION_ALIAS ("REGION_RODATA", RAM_INT); > +REGION_ALIAS ("REGION_RODATA_LOAD", RAM_INT); > +REGION_ALIAS ("REGION_DATA", RAM_INT); > +REGION_ALIAS ("REGION_DATA_LOAD", RAM_INT); > +REGION_ALIAS ("REGION_FAST_TEXT", RAM_INT); > +REGION_ALIAS ("REGION_FAST_TEXT_LOAD", RAM_INT); > +REGION_ALIAS ("REGION_FAST_DATA", RAM_INT); > +REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM_INT); > +REGION_ALIAS ("REGION_BSS", RAM_INT); > +REGION_ALIAS ("REGION_WORK", RAM_INT); > +REGION_ALIAS ("REGION_STACK", RAM_INT); > + > +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); > + > +INCLUDE linkcmds.armv4 > diff --git > a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_sdram > b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_sdram > new file mode 100644 > index 0000000..110179f > --- /dev/null > +++ b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_sdram > @@ -0,0 +1,27 @@ > + > +MEMORY { > + ROM_INT (RX) : ORIGIN = 0x00000000, LENGTH = 3M > + RAM_INT (AIW) : ORIGIN = 0x08000000, LENGTH = 256k > + RAM_EXT (AIWX) : ORIGIN = 0x80000000, LENGTH = 8M > +} > + > +REGION_ALIAS ("REGION_START", RAM_EXT); > +REGION_ALIAS ("REGION_VECTOR", RAM_EXT); > +REGION_ALIAS ("REGION_TEXT", RAM_EXT); > +REGION_ALIAS ("REGION_TEXT_LOAD", RAM_EXT); > +REGION_ALIAS ("REGION_RODATA", RAM_EXT); > +REGION_ALIAS ("REGION_RODATA_LOAD", RAM_EXT); > +REGION_ALIAS ("REGION_DATA", RAM_EXT); > +REGION_ALIAS ("REGION_DATA_LOAD", RAM_EXT); > +REGION_ALIAS ("REGION_FAST_TEXT", RAM_EXT); > +REGION_ALIAS ("REGION_FAST_TEXT_LOAD", RAM_EXT); > +REGION_ALIAS ("REGION_FAST_DATA", RAM_EXT); > +REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM_EXT); > +REGION_ALIAS ("REGION_BSS", RAM_EXT); > +REGION_ALIAS ("REGION_WORK", RAM_EXT); > +REGION_ALIAS ("REGION_STACK", RAM_EXT); > + > +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); > + > +INCLUDE linkcmds.armv4 > -- > 1.7.10.4 > > _______________________________________________ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel -- Daniel F. Gutson Chief Engineering Officer, SPD San Lorenzo 47, 3rd Floor, Office 5 Córdoba, Argentina Phone: +54 351 4217888 / +54 351 4218211 Skype: dgutson _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel