Add BSP for multiprocessing on Patmos hardware

This commit is contained in:
afpr
2014-07-03 19:15:38 +01:00
parent f80ce31aef
commit 17e51eada9
9 changed files with 547 additions and 0 deletions

View File

@@ -6,6 +6,8 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
AC_CONFIG_SUBDIRS([pasim]);;
tcrest )
AC_CONFIG_SUBDIRS([tcrest]);;
tcrestmp )
AC_CONFIG_SUBDIRS([tcrestmp]);;
*)
AC_MSG_ERROR([Invalid BSP]);;
esac

View File

@@ -0,0 +1,56 @@
##
## $Id: Makefile.am,v 1.00 2014/03/27 15:17:12 Andre Rocha $
##
ACLOCAL_AMFLAGS = -I ../../../../aclocal
include $(top_srcdir)/../../../../automake/compile.am
include_bspdir = $(includedir)/bsp
dist_project_lib_DATA = bsp_specs
include_HEADERS = include/bsp.h
include_HEADERS += ../../shared/include/tm27.h
nodist_include_HEADERS = include/bspopts.h
nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
DISTCLEANFILES = include/bspopts.h
noinst_PROGRAMS =
include_HEADERS += include/tcrestmp.h
include_HEADERS += ../../shared/include/coverhd.h
include_HEADERS += ../shared/noc/noc.h
noinst_LIBRARIES = libbspstart.a
libbspstart_a_SOURCES = ../../patmos/shared/startup/start.S
project_lib_DATA = start.$(OBJEXT)
dist_project_lib_DATA += startup/linkcmds
dist_project_lib_DATA += ../shared/libsyms.ll
noinst_LIBRARIES += libbsp.a
libbsp_a_SOURCES =
# startup
libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \
../../shared/bsppost.c ../../shared/bootcard.c ../shared/startup/bspstart.c \
../../shared/bsppretaskinghook.c ../../shared/bsppredriverhook.c \
../shared/bspgetworkarea.c ../../shared/sbrk.c
# console
libbsp_a_SOURCES += ../shared/console/console.c
# debugio
libbsp_a_SOURCES += ../shared/console/debugputs.c
# clock
libbsp_a_SOURCES += ../shared/clock/ckinit.c ../../../shared/clockdrv_shell.h
# noc
libbsp_a_SOURCES += ../shared/noc/noc.c
# timer
libbsp_a_SOURCES += ../shared/timer/timer.c
libbsp_a_LIBADD = ../../../libcpu/@RTEMS_CPU@/cache.rel \
../../../libcpu/@RTEMS_CPU@/exceptions.rel
include $(srcdir)/preinstall.am
include $(top_srcdir)/../../../../automake/local.am

View File

@@ -0,0 +1,13 @@
%rename endfile old_endfile
%rename startfile old_startfile
%rename link old_link
*endfile:
crtend.o%s crtn.o%s
*startfile:
%{!qrtems: %(old_startfile)} \
%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s}}
*link:
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}

View File

@@ -0,0 +1,22 @@
## Process this file with autoconf to produce a configure script.
##
## $Id: configure.ac,v 1.00 2013/06/14 15:17:12 Andre Rocha $
AC_PREREQ([2.68])
AC_INIT([rtems-c-src-lib-libbsp-patmos-tcrestmp],[_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.11.1])
RTEMS_BSP_CONFIGURE
RTEMS_PROG_CC_FOR_TARGET
RTEMS_CANONICALIZE_TOOLS
RTEMS_PROG_CCAS
RTEMS_BSP_CLEANUP_OPTIONS(0, 0)
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@@ -0,0 +1,76 @@
/* bsp.h
*
* This include file contains all Patmos hardware (multi-core) definitions.
*
* Project: T-CREST - Time-Predictable Multi-Core Architecture for Embedded Systems
*
* Copyright (C) GMVIS Skysoft S.A., 2014
* @author Andre Rocha
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
*/
#ifndef _BSP_H
#define _BSP_H
#ifdef __cplusplus
extern "C" {
#endif
/* Patmos CPU variant: TCRESTMP */
#define TCRESTMP 3
/* Flag for hard_reset */
#define PATMOS_MULTICORE
/* Constants */
/*
* Information placed in the linkcmds file.
*/
#define RAM_START 0x400
#define RAM_SIZE 1M
#define RAM_END RAM_START + RAM_SIZE
#define PROM_START 0x00000000
#define PROM_SIZE 0K
#define PROM_END PROM_START + PROM_SIZE
#ifndef ASM
#include <bspopts.h>
#include <rtems.h>
#include <rtems/clockdrv.h>
#include <rtems/console.h>
extern int CLOCK_SPEED;
extern int end; /* last address in the program */
/* miscellaneous stuff assumed to exist */
rtems_isr_entry set_vector( /* returns old vector */
rtems_isr_entry handler, /* isr routine */
rtems_vector_number vector, /* vector number */
int type /* RTEMS or RAW intr */
);
void BSP_fatal_return( void );
void bsp_spurious_initialize( void );
#endif /* !ASM */
#ifdef __cplusplus
}
#endif
#include <tcrestmp.h>
#endif

View File

@@ -0,0 +1,225 @@
/* tcrestmp.h
*
* TCRESTMP BSP data types and macros.
*
* Project: T-CREST - Time-Predictable Multi-Core Architecture for Embedded Systems
*
* Copyright (C) GMVIS Skysoft S.A., 2014
* @author Andre Rocha
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
*/
#ifndef _INCLUDE_TCRESTMP_h
#define _INCLUDE_TCRESTMP_h
#include <rtems/score/patmos.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* TODO: replace these by linker symbols
*/
#define _shadow_stack_base 0x00100000
#define _stack_cache_base 0x000f0000
#ifndef ASM
#define _IODEV __attribute__((address_space(1)))
typedef _IODEV unsigned int volatile * const _iodev_ptr_t;
/*
* Attribute for pointers into the scratchpad memory. Use as
*
* _SPM int *p = (_SPM int *) 0x1234;
*
*/
#define _SPM __attribute__((address_space(1)))
/*
* Attribute for pointers into main memory using cache bypass. Use as
*
* _UNCACHED int *p = (_UNCACHED int *) &mydata;
*/
#define _UNCACHED __attribute__((address_space(3)))
typedef volatile int (*entrypoint_t)(void);
/*
* CPU Info Management
*/
extern char _cpuinfo_base; /* linker symbol giving the address of the CPU info */
/* Address to access the CPU id */
#define __PATMOS_CPU_ID_ADDR (&_cpuinfo_base + 0x00)
/* Address to access the CPU frequency */
#define __PATMOS_CPU_FREQ_ADDR (&_cpuinfo_base + 0x04)
/* Macro to read the CPU id */
#define __PATMOS_CPU_RD_ID(res) res = *((_iodev_ptr_t)__PATMOS_CPU_ID_ADDR);
/* Macro to read the CPU frequency */
#define __PATMOS_CPU_RD_FREQ(res) res = *((_iodev_ptr_t)__PATMOS_CPU_FREQ_ADDR);
/*
* End of CPU Info Management
*/
/*
* UART Management
*/
extern char _iomap_base; /* linker symbol giving the base address of the IO map address range */
extern char _uart_base; /* linker symbol giving the address of the UART */
/*
* The following defines the bits in the TCREST UART Status Registers.
*/
#define __PATMOS_UART_TRE 1 /* Bit mask for the transmit-ready bit (TRE) */
#define __PATMOS_UART_DAV 2 /* Bit mask for the data-available bit (DAV) */
#define __PATMOS_UART_PAE 4 /* Bit mask for the parity-error bit (PAE) */
#define __PATMOS_UART_TFL 8 /* Bit mask for the transmit-flush bit (TFL) */
/*
* Address to access the status register of the UART coming with Patmos
*/
#define __PATMOS_UART_STATUS_ADDR (&_uart_base + 0x00)
/*
* Address to access the data register of the UART coming with Patmos
*/
#define __PATMOS_UART_DATA_ADDR (&_uart_base + 0x04)
/*
* Macros to handle read and write to the UART's status, control and data registers
*/
/* Macro to read the UART's status register */
#define __PATMOS_UART_STATUS(res) res = *((_iodev_ptr_t)__PATMOS_UART_STATUS_ADDR);
/* Macro to read the UART's data register */
#define __PATMOS_UART_RD_DATA(res) res = *((_iodev_ptr_t)__PATMOS_UART_DATA_ADDR);
/* Macro to write the UART's control register */
#define __PATMOS_UART_WR_CTRL(data) *((_iodev_ptr_t)__PATMOS_UART_STATUS_ADDR) = data;
/* Macro to write the UART's data register */
#define __PATMOS_UART_WR_DATA(data) *((_iodev_ptr_t)__PATMOS_UART_DATA_ADDR) = data;
/*
* End of UART Management
*/
/*
* RTC Management
*/
extern char _timer_base; /* linker symbol giving the address of the RTC */
extern uint64_t get_cpu_usecs (void);
/* Address to access the cycle counter low register of the RTC */
#define __PATMOS_RTC_CYCLE_LOW_ADDR (&_timer_base + 0x04)
/* Address to access the cycle counter up register of the RTC */
#define __PATMOS_RTC_CYCLE_UP_ADDR (&_timer_base + 0x00)
/* Address to access the time in microseconds low register of the RTC */
#define __PATMOS_RTC_TIME_LOW_ADDR (&_timer_base + 0x0C)
/* Address to access the time in microseconds up register of the RTC */
#define __PATMOS_RTC_TIME_UP_ADDR (&_timer_base + 0x08)
/* Address to access the ISR address register of the RTC cycle timer */
#define __PATMOS_RTC_ISR_ADDR (&_excunit_base + 0xc0)
/* Macro to read the RTC's cycle counter low register of the RTC */
#define __PATMOS_RTC_RD_CYCLE_LOW(res) res = *((_iodev_ptr_t)__PATMOS_RTC_CYCLE_LOW_ADDR);
/* Macro to read the RTC's cycle counter up register of the RTC */
#define __PATMOS_RTC_RD_CYCLE_UP(res) res = *((_iodev_ptr_t)__PATMOS_RTC_CYCLE_UP_ADDR);
/* Macro to read the RTC's time in microseconds low register of the RTC */
#define __PATMOS_RTC_RD_TIME_LOW(res) res = *((_iodev_ptr_t)__PATMOS_RTC_TIME_LOW_ADDR);
/* Macro to read the RTC's time in microseconds up register of the RTC */
#define __PATMOS_RTC_RD_TIME_UP(res) res = *((_iodev_ptr_t)__PATMOS_RTC_TIME_UP_ADDR);
/* Macro to write the RTC's cycle counter low register */
#define __PATMOS_RTC_WR_CYCLE_LOW(val) *((_iodev_ptr_t)__PATMOS_RTC_CYCLE_LOW_ADDR) = val;
/* Macro to write the RTC's cycle counter up register */
#define __PATMOS_RTC_WR_CYCLE_UP(val) *((_iodev_ptr_t)__PATMOS_RTC_CYCLE_UP_ADDR) = val;
/* Macro to write the RTC's ISR address register */
#define __PATMOS_RTC_WR_ISR(address) *((_iodev_ptr_t)__PATMOS_RTC_ISR_ADDR) = address;
/*
* End of RTC Management
*/
/*
* Exception Management
*/
extern char _excunit_base; /* linker symbol giving the base address of the exception handling unit */
/* The status register of the exception unit */
#define EXC_STATUS (*((_iodev_ptr_t)(&_excunit_base+0x00)))
/* The interrupt mask register */
#define EXC_MASK (*((_iodev_ptr_t)(&_excunit_base+0x04)))
/* The pending interrupts register */
#define EXC_PEND (*((_iodev_ptr_t)(&_excunit_base+0x08)))
/* The exception source register */
#define EXC_SOURCE (*((_iodev_ptr_t)(&_excunit_base+0x0c)))
/*
* End of Exception Management
*/
/*
* NOC Management
*
* TODO: replace these by linker symbols
*/
/* The base address for DMA entries */
#define NOC_DMA_BASE ((volatile int _IODEV *)0xE0000000)
/* The base address for DMA routing information */
#define NOC_DMA_P_BASE ((volatile int _IODEV *)0xE1000000)
/* The base address for the slot table */
#define NOC_ST_BASE ((volatile int _IODEV *)0xE2000000)
/* The base address of the communication SPM */
#define NOC_SPM_BASE ((volatile int _SPM *)0xE8000000)
/*
* End of NOC Management
*/
#endif /* !ASM */
#ifdef __cplusplus
}
#endif
#endif /* !_INCLUDE_TCRESTMP_h */
/* end of include file */

View File

@@ -0,0 +1,29 @@
#
# Config file for the TCREST PATMOS processor.
#
# $Id: tcrestmp.cfg,v 1.00 2014/03/27 15:17:12 Andre Rocha $
#
include $(RTEMS_ROOT)/make/custom/default.cfg
RTEMS_CPU=patmos
RTEMS_CPU_MODEL=tcrestmp
# This contains the compiler options necessary to select the CPU model
# and (hopefully) optimize for it.
CPU_CFLAGS = -msoft-float
# optimize flag: typically -O2
CFLAGS_OPTIMIZE_V = -O2 -g
# debug flags: disable optimizations
# We need the optimized register allocator here, the fast register allocator at -O0 wants to introduce spill code in naked functions.
CFLAGS_DEBUG_V = -O0 -Xllc -optimize-regalloc
# linker script
LINKER_SCRIPT = $(PROJECT_RELEASE)/lib/linkcmds
LINK_LIBS += $(PROJECT_RELEASE)/lib/start.o $(PROJECT_RELEASE)/lib/libsyms.ll -l=c -l=rtemscpu -l=rtemsbsp -nostartfiles \
-Xgold --script=$(LINKER_SCRIPT) -mpatmos-disable-vliw \
-mpatmos-method-cache-size=0x800 -mpatmos-preferred-subfunction-size=0 -mpatmos-stack-base=0x0f0000 \
-mpatmos-shadow-stack-base=0x100000 -Xgold -n -Xgold -entry=hard_reset

View File

@@ -0,0 +1,79 @@
## Automatically generated by ampolish3 - Do not edit
if AMPOLISH3
$(srcdir)/preinstall.am: Makefile.am
$(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
endif
PREINSTALL_DIRS =
DISTCLEANFILES += $(PREINSTALL_DIRS)
all-local: $(TMPINSTALL_FILES)
TMPINSTALL_FILES =
CLEANFILES = $(TMPINSTALL_FILES)
all-am: $(PREINSTALL_FILES)
PREINSTALL_FILES =
CLEANFILES += $(PREINSTALL_FILES)
$(PROJECT_LIB)/$(dirstamp):
@$(MKDIR_P) $(PROJECT_LIB)
@: > $(PROJECT_LIB)/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp)
$(PROJECT_INCLUDE)/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)
@: > $(PROJECT_INCLUDE)/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp)
$(PROJECT_INCLUDE)/bsp/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/bsp
@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
$(PROJECT_INCLUDE)/bsp.h: include/bsp.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
$(PROJECT_INCLUDE)/tm27.h: ../../shared/include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
$(PROJECT_INCLUDE)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h
$(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
$(PROJECT_INCLUDE)/tcrestmp.h: include/tcrestmp.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tcrestmp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/tcrestmp.h
$(PROJECT_INCLUDE)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
$(PROJECT_INCLUDE)/noc.h: ../shared/noc/noc.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/noc.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/noc.h
$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
$(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds
$(PROJECT_LIB)/libsyms.ll: ../shared/libsyms.ll $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/libsyms.ll
PREINSTALL_FILES += $(PROJECT_LIB)/libsyms.ll

View File

@@ -0,0 +1,45 @@
# A simple linker script to put code and data into the external memory
/* these are the maximum values */
RamBase = 0x400;
RamSize = 1M;
OUTPUT_ARCH(patmos)
SECTIONS
{
. = SEGMENT_START(".rodata", 0x400);
.init_array : { *(SORT(.init_array.*) .init_array) }
.fini_array : { *(SORT(.fini_array.*) .fini_array) }
.data : {
data_start = . ;
_data_start = . ;
*(.data)
_edata = ALIGN( 0x10 ) ;
}
.bss : {
bss_start = . ;
_bss_start = . ;
*(.bss)
*(COMMON)
WorkAreaBase = . ;
bss_end = . ;
_bss_end = . ;
__bss_end = . ;
}
. = SEGMENT_START(".text", 0x80000);
.text : {
text_start = . ;
_text_start = . ;
*(.text)
. = ALIGN (0x10);
}
. = ALIGN(8);
_end = .; PROVIDE (end = .);
}