* 0001-Fixed-interrupt-handling-for-ARMv7M.patch,
	0002-Fixed-system-handler-priority-register-access.patch,
	0003-Disable-priority_mask-unused-for-NVIC.patch, 0004-Typo.patch,
	0005-Evil-hack-for-BASEPRI-BASEPRI_MAX.patch,
	0006-Evil-hack-to-increase-the-RAM-size.patch, bsp_specs, ChangeLog,
	clock/clock-config.c, configure.ac, console/console-config.c,
	console/uart.c, .cvsignore, include/bsp.h, include/.cvsignore,
	include/irq.h, include/lm3s69xx.h, include/uart.h, irq/irq.c,
	make/custom/lm3s6965.cfg, make/custom/lm3s69xx.inc, Makefile.am,
	README, start/start.S, startup/bspreset.c, startup/bspstart.c,
	startup/bspstarthook.c, startup/linkcmds.lm3s6965, timer/timer.c: New
	files.
This commit is contained in:
Sebastian Huber
2011-09-24 13:23:42 +00:00
parent c5ed14844e
commit e263c1607a
29 changed files with 1343 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
aclocal.m4
autom4te*.cache
config.cache
config.log
config.status
configure
Makefile
Makefile.in

View File

@@ -0,0 +1,28 @@
From 917f2491c1dc2525b24c635afe4459e55700149c Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Sun, 5 Jun 2011 14:57:17 +0200
Subject: [PATCH 1/6] Fixed interrupt handling for ARMv7M.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
cpu-exec.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index 6ddd8dd..d1e9816 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -470,8 +470,8 @@ int cpu_exec(CPUState *env1)
We avoid this by disabling interrupts when
pc contains a magic address. */
if (interrupt_request & CPU_INTERRUPT_HARD
- && ((IS_M(env) && env->regs[15] < 0xfffffff0)
- || !(env->uncached_cpsr & CPSR_I))) {
+ && !(env->uncached_cpsr & CPSR_I)
+ && (!IS_M(env) || env->regs[15] < 0xfffffff0)) {
env->exception_index = EXCP_IRQ;
do_interrupt(env);
next_tb = 0;
--
1.7.1

View File

@@ -0,0 +1,102 @@
From 403b4e0718a815b425a964cfbf7f4117a9278d88 Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Sun, 19 Jun 2011 15:33:17 +0200
Subject: [PATCH 2/6] Fixed system handler priority register access.
According to "ARMv7-M Architecture Reference Manual" issue D section
"B3.2.10 System Handler Prioriy Register 1, SHPR1", "B3.2.11 System
Handler Prioriy Register 2, SHPR2", and "B3.2.12 System Handler Prioriy
Register 3, SHPR3".
---
hw/arm_gic.c | 16 ++++++++++++++--
hw/armv7m_nvic.c | 19 -------------------
2 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/hw/arm_gic.c b/hw/arm_gic.c
index 0e934ec..9f75fcc 100644
--- a/hw/arm_gic.c
+++ b/hw/arm_gic.c
@@ -341,6 +341,11 @@ static uint32_t gic_dist_readb(void *opaque, target_phys_addr_t offset)
if (GIC_TEST_TRIGGER(irq + i))
res |= (2 << (i * 2));
}
+#else
+ } else if (0xd18 <= offset && offset < 0xd24) {
+ /* System Handler Priority. */
+ irq = offset - 0xd14;
+ res = GIC_GET_PRIORITY(irq, cpu);
#endif
} else if (offset < 0xfe0) {
goto bad_reg;
@@ -372,7 +377,8 @@ static uint32_t gic_dist_readl(void *opaque, target_phys_addr_t offset)
gic_state *s = (gic_state *)opaque;
uint32_t addr;
addr = offset;
- if (addr < 0x100 || addr > 0xd00)
+ if (addr < 0x100 || (addr > 0xd00 && addr != 0xd18 && addr != 0xd1c
+ && addr != 0xd20)) {
return nvic_readl(s, addr);
#endif
val = gic_dist_readw(opaque, offset);
@@ -507,6 +513,11 @@ static void gic_dist_writeb(void *opaque, target_phys_addr_t offset,
GIC_CLEAR_TRIGGER(irq + i);
}
}
+#else
+ } else if (0xd18 <= offset && offset < 0xd24) {
+ /* System Handler Priority. */
+ irq = offset - 0xd14;
+ s->priority1[irq][0] = value & 0xff;
#endif
} else {
/* 0xf00 is only handled for 32-bit writes. */
@@ -532,7 +543,8 @@ static void gic_dist_writel(void *opaque, target_phys_addr_t offset,
#ifdef NVIC
uint32_t addr;
addr = offset;
- if (addr < 0x100 || (addr > 0xd00 && addr != 0xf00)) {
+ if (addr < 0x100 || (addr > 0xd00 && addr != 0xd18 && addr != 0xd1c
+ && addr != 0xd20 && addr != 0xf00)) {
nvic_writel(s, addr, value);
return;
}
diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c
index d06eec9..a2d1404 100644
--- a/hw/armv7m_nvic.c
+++ b/hw/armv7m_nvic.c
@@ -194,14 +194,6 @@ static uint32_t nvic_readl(void *opaque, uint32_t offset)
case 0xd14: /* Configuration Control. */
/* TODO: Implement Configuration Control bits. */
return 0;
- case 0xd18: case 0xd1c: case 0xd20: /* System Handler Priority. */
- irq = offset - 0xd14;
- val = 0;
- val |= s->gic.priority1[irq++][0];
- val |= s->gic.priority1[irq++][0] << 8;
- val |= s->gic.priority1[irq++][0] << 16;
- val |= s->gic.priority1[irq][0] << 24;
- return val;
case 0xd24: /* System Handler Status. */
val = 0;
if (s->gic.irq_state[ARMV7M_EXCP_MEM].active) val |= (1 << 0);
@@ -334,17 +326,6 @@ static void nvic_writel(void *opaque, uint32_t offset, uint32_t value)
case 0xd14: /* Configuration Control. */
/* TODO: Implement control registers. */
goto bad_reg;
- case 0xd18: case 0xd1c: case 0xd20: /* System Handler Priority. */
- {
- int irq;
- irq = offset - 0xd14;
- s->gic.priority1[irq++][0] = value & 0xff;
- s->gic.priority1[irq++][0] = (value >> 8) & 0xff;
- s->gic.priority1[irq++][0] = (value >> 16) & 0xff;
- s->gic.priority1[irq][0] = (value >> 24) & 0xff;
- gic_update(&s->gic);
- }
- break;
case 0xd24: /* System Handler Control. */
/* TODO: Real hardware allows you to set/clear the active bits
under some circumstances. We don't implement this. */
--
1.7.1

View File

@@ -0,0 +1,28 @@
From 00cf49e35ff83ca3d90caf98339591452b1100e5 Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Sun, 17 Jul 2011 15:13:42 +0200
Subject: [PATCH 3/6] Disable priority_mask (unused for NVIC).
---
hw/arm_gic.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/hw/arm_gic.c b/hw/arm_gic.c
index 9f75fcc..a97a318 100644
--- a/hw/arm_gic.c
+++ b/hw/arm_gic.c
@@ -642,7 +642,11 @@ static void gic_reset(gic_state *s)
int i;
memset(s->irq_state, 0, GIC_NIRQ * sizeof(gic_irq_state));
for (i = 0 ; i < NUM_CPU(s); i++) {
+#ifdef NVIC
+ s->priority_mask[i] = 0x100;
+#else
s->priority_mask[i] = 0xf0;
+#endif
s->current_pending[i] = 1023;
s->running_irq[i] = 1023;
s->running_priority[i] = 0x100;
--
1.7.1

View File

@@ -0,0 +1,25 @@
From 9c977927e545943996981c86c7ec71f0b44921ba Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Sun, 17 Jul 2011 15:14:40 +0200
Subject: [PATCH 4/6] Typo.
---
hw/arm_gic.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/hw/arm_gic.c b/hw/arm_gic.c
index a97a318..237f13f 100644
--- a/hw/arm_gic.c
+++ b/hw/arm_gic.c
@@ -378,7 +378,7 @@ static uint32_t gic_dist_readl(void *opaque, target_phys_addr_t offset)
uint32_t addr;
addr = offset;
if (addr < 0x100 || (addr > 0xd00 && addr != 0xd18 && addr != 0xd1c
- && addr != 0xd20)) {
+ && addr != 0xd20))
return nvic_readl(s, addr);
#endif
val = gic_dist_readw(opaque, offset);
--
1.7.1

View File

@@ -0,0 +1,49 @@
From ee20f52f56b076e71f617e4e3cfe413bea73b824 Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Fri, 16 Sep 2011 21:28:21 +0200
Subject: [PATCH 5/6] Evil hack for BASEPRI/BASEPRI_MAX.
---
target-arm/helper.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 2fd45c4..d5fc9d3 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -1997,7 +1997,11 @@ uint32_t HELPER(v7m_mrs)(CPUState *env, uint32_t reg)
return (env->uncached_cpsr & CPSR_I) != 0;
case 17: /* BASEPRI */
case 18: /* BASEPRI_MAX */
+ /* FIXME */
+ return (env->uncached_cpsr & CPSR_I) != 0;
+#if 0
return env->v7m.basepri;
+#endif
case 19: /* FAULTMASK */
return (env->uncached_cpsr & CPSR_F) != 0;
case 20: /* CONTROL */
@@ -2052,6 +2056,12 @@ void HELPER(v7m_msr)(CPUState *env, uint32_t reg, uint32_t val)
env->uncached_cpsr &= ~CPSR_I;
break;
case 17: /* BASEPRI */
+ case 18: /* BASEPRI_MAX */
+ if (val)
+ env->uncached_cpsr |= CPSR_I;
+ else
+ env->uncached_cpsr &= ~CPSR_I;
+#if 0
env->v7m.basepri = val & 0xff;
break;
case 18: /* BASEPRI_MAX */
@@ -2059,6 +2069,7 @@ void HELPER(v7m_msr)(CPUState *env, uint32_t reg, uint32_t val)
if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0))
env->v7m.basepri = val;
break;
+#endif
case 19: /* FAULTMASK */
if (val & 1)
env->uncached_cpsr |= CPSR_F;
--
1.7.1

View File

@@ -0,0 +1,26 @@
From 187cd2844ffb0e197231dbf7a844e531c1146e09 Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Sat, 24 Sep 2011 15:21:41 +0200
Subject: [PATCH 6/6] Evil hack to increase the RAM size.
---
hw/stellaris.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/hw/stellaris.c b/hw/stellaris.c
index ac9fcc1..c00b2fa 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -1177,7 +1177,8 @@ static stellaris_board_info stellaris_boards[] = {
{ "LM3S6965EVB",
0x10010002,
0x1073402e,
- 0x00ff007f, /* dc0 */
+ /* FIXME */
+ 0xffffffff, /* dc0 */
0x001133ff,
0x030f5317,
0x0f0f87ff,
--
1.7.1

View File

@@ -0,0 +1,14 @@
2011-09-24 Sebastian Huber <sebastian.huber@embedded-brains.de>
* 0001-Fixed-interrupt-handling-for-ARMv7M.patch,
0002-Fixed-system-handler-priority-register-access.patch,
0003-Disable-priority_mask-unused-for-NVIC.patch, 0004-Typo.patch,
0005-Evil-hack-for-BASEPRI-BASEPRI_MAX.patch,
0006-Evil-hack-to-increase-the-RAM-size.patch, bsp_specs, ChangeLog,
clock/clock-config.c, configure.ac, console/console-config.c,
console/uart.c, .cvsignore, include/bsp.h, include/.cvsignore,
include/irq.h, include/lm3s69xx.h, include/uart.h, irq/irq.c,
make/custom/lm3s6965.cfg, make/custom/lm3s69xx.inc, Makefile.am,
README, start/start.S, startup/bspreset.c, startup/bspstart.c,
startup/bspstarthook.c, startup/linkcmds.lm3s6965, timer/timer.c: New
files.

View File

@@ -0,0 +1,114 @@
##
#
# @file
#
# @brief Makefile of LibBSP for the LM3S69XX boards.
#
# $Id$
ACLOCAL_AMFLAGS = -I ../../../../aclocal
include $(top_srcdir)/../../../../automake/compile.am
include_bspdir = $(includedir)/bsp
dist_project_lib_DATA = bsp_specs
###############################################################################
# Header #
###############################################################################
include_HEADERS = include/bsp.h
nodist_include_HEADERS = ../../shared/include/coverhd.h \
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/tod.h
include_bsp_HEADERS += ../shared/include/start.h
include_bsp_HEADERS += include/irq.h
include_bsp_HEADERS += include/uart.h
include_bsp_HEADERS += include/lm3s69xx.h
include_HEADERS += ../../shared/include/tm27.h
###############################################################################
# Data #
###############################################################################
noinst_LIBRARIES = libbspstart.a
libbspstart_a_SOURCES = start/start.S
project_lib_DATA = start.$(OBJEXT)
project_lib_DATA += startup/linkcmds
EXTRA_DIST = startup/linkcmds.lm3s6965
###############################################################################
# LibBSP #
###############################################################################
noinst_LIBRARIES += libbsp.a
libbsp_a_SOURCES =
libbsp_a_CPPFLAGS =
libbsp_a_LIBADD =
# Shared
libbsp_a_SOURCES += ../../shared/bootcard.c \
../../shared/bspclean.c \
../../shared/bspgetworkarea.c \
../../shared/bsplibc.c \
../../shared/bsppost.c \
../../shared/bsppredriverhook.c \
../../shared/bsppretaskinghook.c \
../../shared/gnatinstallhandler.c \
../../shared/sbrk.c \
../../shared/src/stackalloc.c
# Startup
libbsp_a_SOURCES += startup/bspstart.c \
startup/bspstarthook.c \
startup/bspreset.c
# IRQ
libbsp_a_SOURCES += ../../shared/src/irq-generic.c \
../../shared/src/irq-legacy.c \
../../shared/src/irq-info.c \
../../shared/src/irq-shell.c \
../../shared/src/irq-server.c \
irq/irq.c
# Console
libbsp_a_SOURCES += ../../shared/console.c \
console/console-config.c \
console/uart.c
# Clock
libbsp_a_SOURCES += clock/clock-config.c \
../../../shared/clockdrv_shell.h
# Timer
libbsp_a_SOURCES += timer/timer.c
# Cache
libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c \
../../../libcpu/arm/shared/cache/cache_.h
libbsp_a_CPPFLAGS += -I$(srcdir)/../../../libcpu/arm/shared/include
###############################################################################
# Special Rules #
###############################################################################
DISTCLEANFILES = include/bspopts.h
include $(srcdir)/preinstall.am
include $(top_srcdir)/../../../../automake/local.am

View File

@@ -0,0 +1,15 @@
Tested only on Qemu simulator with git (git://git.qemu.org/qemu.git) version
f9188227a455446b5c10a8f5114f266001c1c801 (Tue May 17 17:08:43 2011).
You have to apply the patches:
0001-Fixed-interrupt-handling-for-ARMv7M.patch
0002-Fixed-system-handler-priority-register-access.patch
0003-Disable-priority_mask-unused-for-NVIC.patch
0004-Typo.patch
0005-Evil-hack-for-BASEPRI-BASEPRI_MAX.patch
0006-Evil-hack-to-increase-the-RAM-size.patch
Command line:
qemu-system-arm -S -s -net none -nographic -M lm3s6965evb -kernel hello.bin

View File

@@ -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}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* 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.
*
* $Id$
*/
#include <rtems.h>
#include <rtems/score/armv7m.h>
/* This is defined in ../../../shared/clockdrv_shell.h */
rtems_isr Clock_isr(rtems_vector_number vector);
static uint64_t _ARMV7M_Systick_factor;
static void _ARMV7M_Systick_at_tick(void)
{
volatile ARMV7M_Systick *systick = _ARMV7M_Systick;
/* Clear COUNTFLAG */
systick->csr;
}
static void _ARMV7M_Systick_handler(void)
{
_ARMV7M_Interrupt_service_enter();
Clock_isr(ARMV7M_VECTOR_SYSTICK);
_ARMV7M_Interrupt_service_leave();
}
static void _ARMV7M_Systick_handler_install(void)
{
_ARMV7M_Set_exception_handler(
ARMV7M_VECTOR_SYSTICK,
_ARMV7M_Systick_handler
);
}
static void _ARMV7M_Systick_initialize(void)
{
volatile ARMV7M_Systick *systick = _ARMV7M_Systick;
uint64_t frequency = ARMV7M_SYSTICK_CALIB_TENMS(systick->calib) * 100ULL;
uint64_t us_per_tick = rtems_configuration_get_microseconds_per_tick();
uint64_t interval = (frequency * us_per_tick) / 1000000ULL;
_ARMV7M_Systick_factor = (1000000000ULL << 32) / frequency;
systick->rvr = (uint32_t) interval;
systick->cvr = 0;
systick->csr = ARMV7M_SYSTICK_CSR_TICKINT | ARMV7M_SYSTICK_CSR_ENABLE;
}
static void _ARMV7M_Systick_cleanup(void)
{
volatile ARMV7M_Systick *systick = _ARMV7M_Systick;
systick->csr = 0;
}
static uint32_t _ARMV7M_Systick_nanoseconds_since_last_tick(void)
{
volatile ARMV7M_Systick *systick = _ARMV7M_Systick;
volatile ARMV7M_SCB *scb = _ARMV7M_SCB;
uint32_t rvr = systick->rvr;
uint32_t c = rvr - systick->cvr;
if ((scb->icsr & ARMV7M_SCB_ICSR_PENDSTSET) != 0) {
c = rvr - systick->cvr + rvr;
}
return (uint32_t) ((c * _ARMV7M_Systick_factor) >> 32);
}
#define Clock_driver_support_at_tick() \
_ARMV7M_Systick_at_tick()
#define Clock_driver_support_initialize_hardware() \
_ARMV7M_Systick_initialize()
#define Clock_driver_support_install_isr(isr, old_isr) \
do { \
_ARMV7M_Systick_handler_install(); \
old_isr = NULL; \
} while (0)
#define Clock_driver_support_shutdown_hardware() \
_ARMV7M_Systick_cleanup()
#define Clock_driver_nanoseconds_since_last_tick \
_ARMV7M_Systick_nanoseconds_since_last_tick
/* Include shared source clock driver code */
#include "../../../shared/clockdrv_shell.h"

View File

@@ -0,0 +1,46 @@
##
#
# @file
#
# @brief Configure script of LibBSP for the LM3S39XX boards.
#
AC_PREREQ([2.68])
AC_INIT([rtems-c-src-lib-libbsp-arm-lm3s69xx],[_RTEMS_VERSION],[rtems-bugs@rtems.com])
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_CHECK_NETWORKING
AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
RTEMS_BSPOPTS_SET([BSP_SMALL_MEMORY],[*],[])
RTEMS_BSPOPTS_HELP([BSP_SMALL_MEMORY],[disable testsuite samples with high memory demands])
RTEMS_BSPOPTS_SET([LM3S69XX_SYSTEM_CLOCK],[*],[50000000])
RTEMS_BSPOPTS_HELP([LM3S69XX_SYSTEM_CLOCK],[system clock in Hz])
RTEMS_BSPOPTS_SET([LM3S69XX_UART_BAUD],[*],[115200])
RTEMS_BSPOPTS_HELP([LM3S69XX_UART_BAUD],[baud for UARTs])
RTEMS_BSPOPTS_SET([LM3S69XX_ENABLE_UART_0],[*],[1])
RTEMS_BSPOPTS_HELP([LM3S69XX_ENABLE_UART_0],[enable UART 0])
RTEMS_BSPOPTS_SET([LM3S69XX_ENABLE_UART_1],[*],[])
RTEMS_BSPOPTS_HELP([LM3S69XX_ENABLE_UART_1],[enable UART 1])
RTEMS_BSPOPTS_SET([LM3S69XX_ENABLE_UART_2],[*],[])
RTEMS_BSPOPTS_HELP([LM3S69XX_ENABLE_UART_2],[enable UART 2])
RTEMS_BSP_CLEANUP_OPTIONS(0, 0)
RTEMS_BSP_LINKCMDS
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* 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.
*
* $Id$
*/
#include <rtems/bspIo.h>
#include <libchip/serial.h>
#include <bspopts.h>
#include <bsp/irq.h>
#include <bsp/uart.h>
#include <bsp/lm3s69xx.h>
console_tbl Console_Port_Tbl [] = {
#ifdef LM3S69XX_ENABLE_UART_0
{
.sDeviceName = "/dev/ttyS0",
.deviceType = SERIAL_CUSTOM,
.pDeviceFns = &lm3s69xx_uart_fns,
.ulCtrlPort1 = LM3S69XX_UART_0_BASE,
.ulClock = LM3S69XX_UART_BAUD,
.ulIntVector = LM3S69XX_IRQ_UART_0
},
#endif
#ifdef LM3S69XX_ENABLE_UART_1
{
.sDeviceName = "/dev/ttyS1",
.deviceType = SERIAL_CUSTOM,
.pDeviceFns = &lm3s69xx_uart_fns,
.ulCtrlPort1 = LM3S69XX_UART_1_BASE,
.ulClock = LM3S69XX_UART_BAUD,
.ulIntVector = LM3S69XX_IRQ_UART_1
}
#endif
#ifdef LM3S69XX_ENABLE_UART_2
{
.sDeviceName = "/dev/ttyS2",
.deviceType = SERIAL_CUSTOM,
.pDeviceFns = &lm3s69xx_uart_fns,
.ulCtrlPort1 = LM3S69XX_UART_2_BASE,
.ulClock = LM3S69XX_UART_BAUD,
.ulIntVector = LM3S69XX_IRQ_UART_2
}
#endif
};
#define PORT_COUNT (sizeof(Console_Port_Tbl) / sizeof(Console_Port_Tbl [0]))
unsigned long Console_Port_Count = PORT_COUNT;
rtems_device_minor_number Console_Port_Minor;
console_data Console_Port_Data [PORT_COUNT];
static void output_char(char c)
{
const console_fns *con = Console_Port_Tbl [Console_Port_Minor].pDeviceFns;
if (c == '\n') {
con->deviceWritePolled((int) Console_Port_Minor, '\r');
}
con->deviceWritePolled((int) Console_Port_Minor, c);
}
BSP_output_char_function_type BSP_output_char = output_char;
BSP_polling_getchar_function_type BSP_poll_char = NULL;

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* 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.
*
* $Id$
*/
#include <bspopts.h>
#include <bsp/uart.h>
#include <libchip/sersupp.h>
static volatile lm3s69xx_uart *get_uart_regs(int minor)
{
console_tbl *ct = &Console_Port_Tbl [minor];
return (lm3s69xx_uart *) ct->ulCtrlPort1;
}
static void initialize(int minor)
{
volatile lm3s69xx_uart *uart = get_uart_regs(minor);
uart->ctl = 0;
uart->lcrh = UARTLCRH_WLEN(0x3) | UARTLCRH_FEN;
uart->ctl = UARTCTL_RXE | UARTCTL_TXE | UARTCTL_UARTEN;
}
static int first_open(int major, int minor, void *arg)
{
rtems_libio_open_close_args_t *oc = (rtems_libio_open_close_args_t *) arg;
struct rtems_termios_tty *tty = (struct rtems_termios_tty *) oc->iop->data1;
console_tbl *ct = &Console_Port_Tbl [minor];
console_data *cd = &Console_Port_Data [minor];
cd->termios_data = tty;
rtems_termios_set_initial_baud(tty, LM3S69XX_UART_BAUD);
return 0;
}
static int last_close(int major, int minor, void *arg)
{
return 0;
}
static int read_polled(int minor)
{
volatile lm3s69xx_uart *uart = get_uart_regs(minor);
if ((uart->fr & UARTFR_RXFE) != 0) {
return -1;
} else {
return UARTDR_DATA(uart->dr);
}
}
static void write_polled(int minor, char c)
{
volatile lm3s69xx_uart *uart = get_uart_regs(minor);
while ((uart->fr & UARTFR_TXFF) != 0) {
/* Wait */
}
uart->dr = UARTDR_DATA(c);
}
static ssize_t write_support_polled(
int minor,
const char *s,
size_t n
)
{
ssize_t i = 0;
for (i = 0; i < n; ++i) {
write_polled(minor, s [i]);
}
return n;
}
static int set_attribues(int minor, const struct termios *term)
{
return -1;
}
console_fns lm3s69xx_uart_fns = {
.deviceProbe = libchip_serial_default_probe,
.deviceFirstOpen = first_open,
.deviceLastClose = last_close,
.deviceRead = read_polled,
.deviceWrite = write_support_polled,
.deviceInitialize = initialize,
.deviceWritePolled = write_polled,
.deviceSetAttributes = set_attribues,
.deviceOutputUsesInterrupts = false
};

View File

@@ -0,0 +1,4 @@
stamp-h
stamp-h.in
bspopts.h
bspopts.h.in

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#ifndef LIBBSP_ARM_LM3S69XX_BSP_H
#define LIBBSP_ARM_LM3S69XX_BSP_H
#include <bspopts.h>
#include <rtems.h>
#include <rtems/console.h>
#include <rtems/clockdrv.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define BSP_FEATURE_IRQ_EXTENSION
#ifndef ASM
#endif /* ASM */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LIBBSP_ARM_LM3S69XX_BSP_H */

View File

@@ -0,0 +1,81 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#ifndef LIBBSP_ARM_LM3S69XX_IRQ_H
#define LIBBSP_ARM_LM3S69XX_IRQ_H
#ifndef ASM
#include <rtems.h>
#include <rtems/irq.h>
#include <rtems/irq-extension.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ASM */
#define LM3S69XX_IRQ_GPIO_PORT_A 16
#define LM3S69XX_IRQ_GPIO_PORT_B 17
#define LM3S69XX_IRQ_GPIO_PORT_C 18
#define LM3S69XX_IRQ_GPIO_PORT_D 19
#define LM3S69XX_IRQ_GPIO_PORT_E 20
#define LM3S69XX_IRQ_UART_0 21
#define LM3S69XX_IRQ_UART_1 22
#define LM3S69XX_IRQ_SSI_0 23
#define LM3S69XX_IRQ_I2C_0 24
#define LM3S69XX_IRQ_PWM_GENERATOR_0 26
#define LM3S69XX_IRQ_PWM_GENERATOR_1 27
#define LM3S69XX_IRQ_PWM_GENERATOR_2 28
#define LM3S69XX_IRQ_QEI_0 29
#define LM3S69XX_IRQ_ADC0_SEQUENCE_0 30
#define LM3S69XX_IRQ_ADC0_SEQUENCE_1 31
#define LM3S69XX_IRQ_ADC0_SEQUENCE_2 32
#define LM3S69XX_IRQ_ADC0_SEQUENCE_3 33
#define LM3S69XX_IRQ_WATCHDOG_TIMER_0 34
#define LM3S69XX_IRQ_TIMER_0_A 35
#define LM3S69XX_IRQ_TIMER_0_B 36
#define LM3S69XX_IRQ_TIMER_1_A 37
#define LM3S69XX_IRQ_TIMER_1_B 38
#define LM3S69XX_IRQ_TIMER_2_A 39
#define LM3S69XX_IRQ_TIMER_2_B 40
#define LM3S69XX_IRQ_ANALOG_COMPARATOR_0 41
#define LM3S69XX_IRQ_ANALOG_COMPARATOR_1 42
#define LM3S69XX_IRQ_SYSTEM_CONTROL 44
#define LM3S69XX_IRQ_FLASH_MEMORY_CONTROL 45
#define LM3S69XX_IRQ_GPIO_PORT_F 46
#define LM3S69XX_IRQ_GPIO PORT_G 47
#define LM3S69XX_IRQ_UART_2 49
#define LM3S69XX_IRQ_TIMER_3_A 51
#define LM3S69XX_IRQ_TIMER_3_B 52
#define LM3S69XX_IRQ_I2C_1 53
#define LM3S69XX_IRQ_QEI_1 54
#define LM3S69XX_IRQ_ETHERNET_CONTROLLER 58
#define LM3S69XX_IRQ_HIBERNATION_MODULE 59
#define LM3S69XX_IRQ_PRIORITY_VALUE_MIN 0
#define LM3S69XX_IRQ_PRIORITY_VALUE_MAX 7
#define LM3S69XX_IRQ_PRIORITY_COUNT (LM3S69XX_IRQ_PRIORITY_VALUE_MAX + 1)
#define LM3S69XX_IRQ_PRIORITY_HIGHEST LM3S69XX_IRQ_PRIORITY_VALUE_MIN
#define LM3S69XX_IRQ_PRIORITY_LOWEST LM3S69XX_IRQ_PRIORITY_VALUE_MAX
#define BSP_INTERRUPT_VECTOR_MIN 0
#define BSP_INTERRUPT_VECTOR_MAX 59
#endif /* LIBBSP_ARM_LM3S69XX_IRQ_H */

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#ifndef LIBBSP_ARM_LM3S69XX_LM3S69XX_H
#define LIBBSP_ARM_LM3S69XX_LM3S69XX_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define LM3S69XX_UART_0_BASE 0x4000c000
#define LM3S69XX_UART_1_BASE 0x4000d000
#define LM3S69XX_UART_2_BASE 0x4000e000
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LIBBSP_ARM_LM3S69XX_LM3S69XX_H */

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#ifndef LIBBSP_ARM_LM3S69XX_UART_H
#define LIBBSP_ARM_LM3S69XX_UART_H
#include <libchip/serial.h>
#include <bsp/utility.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct {
#define UARTDR_OE BSP_BIT32(11)
#define UARTDR_BE BSP_BIT32(10)
#define UARTDR_PE BSP_BIT32(9)
#define UARTDR_FE BSP_BIT32(8)
#define UARTDR_DATA(val) BSP_FLD32(val, 0, 7)
uint32_t dr;
uint32_t rsr_ecr;
uint32_t reserved [4];
#define UARTFR_TXFE BSP_BIT32(7)
#define UARTFR_RXFF BSP_BIT32(6)
#define UARTFR_TXFF BSP_BIT32(5)
#define UARTFR_RXFE BSP_BIT32(4)
#define UARTFR_BUSY BSP_BIT32(3)
uint32_t fr;
uint32_t ilpr;
uint32_t ibrd;
uint32_t fbrd;
#define UARTLCRH_SPS BSP_BIT32(7)
#define UARTLCRH_WLEN(val) BSP_FLD32(val, 5, 6)
#define UARTLCRH_FEN BSP_BIT32(4)
#define UARTLCRH_STP2 BSP_BIT32(3)
#define UARTLCRH_EPS BSP_BIT32(2)
#define UARTLCRH_PEN BSP_BIT32(1)
#define UARTLCRH_BRK BSP_BIT32(0)
uint32_t lcrh;
#define UARTCTL_RXE BSP_BIT32(9)
#define UARTCTL_TXE BSP_BIT32(8)
#define UARTCTL_LBE BSP_BIT32(7)
#define UARTCTL_SIRLP BSP_BIT32(2)
#define UARTCTL_SIREN BSP_BIT32(1)
#define UARTCTL_UARTEN BSP_BIT32(0)
uint32_t ctl;
#define UARTIFLS_RXIFLSEL(val) BSP_FLD32(val, 3, 5)
#define UARTIFLS_TXIFLSEL(val) BSP_FLD32(val, 0, 2)
uint32_t ifls;
#define UARTI_OE BSP_BIT32(10)
#define UARTI_BE BSP_BIT32(9)
#define UARTI_PE BSP_BIT32(8)
#define UARTI_FE BSP_BIT32(7)
#define UARTI_RT BSP_BIT32(6)
#define UARTI_TX BSP_BIT32(5)
#define UARTI_RX BSP_BIT32(4)
uint32_t im;
uint32_t ris;
uint32_t mis;
uint32_t icr;
} lm3s69xx_uart;
extern console_fns lm3s69xx_uart_fns;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LIBBSP_ARM_LM3S69XX_UART_H */

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <string.h>
#include <rtems/score/armv7m.h>
#include <bsp.h>
#include <bsp/irq.h>
#include <bsp/irq-generic.h>
#include <bsp/lm3s69xx.h>
static __attribute__((aligned(128))) ARMV7M_Exception_handler
lm3s69xx_vector_table [BSP_INTERRUPT_VECTOR_MAX + 1];
void bsp_interrupt_dispatch(void)
{
}
rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
{
return RTEMS_SUCCESSFUL;
}
rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
{
return RTEMS_SUCCESSFUL;
}
rtems_status_code bsp_interrupt_facility_initialize(void)
{
memcpy(&lm3s69xx_vector_table [0], (void *) 0, sizeof(lm3s69xx_vector_table));
_ARMV7M_SCB->vtor = &lm3s69xx_vector_table [0];
return RTEMS_SUCCESSFUL;
}
void bsp_interrupt_handler_default(rtems_vector_number vector)
{
printk("spurious interrupt: %u\n", vector);
}

View File

@@ -0,0 +1,7 @@
#
# Config file for LM3S6965.
#
# $Id$
#
include $(RTEMS_ROOT)/make/custom/lm3s69xx.inc

View File

@@ -0,0 +1,19 @@
#
# Config file for LM3S69XX.
#
# $Id$
#
include $(RTEMS_ROOT)/make/custom/default.cfg
RTEMS_CPU = arm
CPU_CFLAGS = -mstructure-size-boundary=8 -march=armv7-m -mthumb \
-fno-schedule-insns2 -fno-common
CFLAGS_OPTIMIZE_V = -O2 -g
define bsp-post-link
$(default-bsp-post-link)
$(OBJCOPY) -O binary $(basename $@).exe $(basename $@).ralf
endef

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2011 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <rtems/asm.h>
#include <rtems/system.h>
#include <rtems/score/cpu.h>
#include <bspopts.h>
#include <bsp/irq.h>
#include <bsp/linker-symbols.h>
/* External symbols */
.extern bsp_start_hook
.extern boot_card
.extern bsp_reset
/* Global symbols */
.globl _start
.syntax unified
.section ".bsp_start_text", "ax"
.thumb
.word bsp_stack_main_end
.word _start /* Reset */
.word bsp_reset /* NMI */
.word bsp_reset /* Hard Fault */
.word bsp_reset /* MPU Fault */
.word bsp_reset /* Bus Fault */
.word bsp_reset /* Usage Fault */
.word 0 /* Reserved */
.word 0 /* Reserved */
.word 0 /* Reserved */
.word 0 /* Reserved */
.word bsp_reset /* SVC */
.word bsp_reset /* Debug Monitor */
.word 0 /* Reserved */
.word bsp_reset /* PendSV */
.word bsp_reset /* SysTick */
.rept BSP_INTERRUPT_VECTOR_MAX - 15
.word bsp_reset /* IRQ */
.endr
.thumb_func
_start:
bl bsp_start_hook_0
mov r0, #0
bl boot_card
twiddle:
bl bsp_reset
b twiddle

View File

@@ -0,0 +1,28 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <rtems.h>
#include <rtems/score/armv7m.h>
#include <bsp/bootcard.h>
void bsp_reset(void)
{
rtems_interrupt_level level;
rtems_interrupt_disable(level);
_ARMV7M_NVIC->reserved_5 [0] = 0;
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* 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.
*
* $Id$
*/
#include <bsp.h>
#include <bsp/bootcard.h>
#include <bsp/irq-generic.h>
#include <bsp/irq.h>
#include <bsp/linker-symbols.h>
void bsp_start(void)
{
if (bsp_interrupt_initialize() != RTEMS_SUCCESSFUL) {
_CPU_Fatal_halt(0xe);
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <bspopts.h>
#include <bsp/start.h>
#include <bsp/linker-symbols.h>
static void BSP_START_TEXT_SECTION copy(int *dst, const int *src, int n)
{
if (src != dst) {
const int *end = dst + (n + sizeof(int) - 1) / sizeof(int);
while (dst != end) {
*dst = *src;
++src;
++dst;
}
}
}
static void BSP_START_TEXT_SECTION clear_bss(void)
{
int *dst = (int *) bsp_section_bss_begin;
int n = (int) bsp_section_bss_size;
const int *end = dst + (n + sizeof(int) - 1) / sizeof(int);
while (dst != end) {
*dst = 0;
++dst;
}
}
void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
{
/* Copy .text section */
copy(
(int *) bsp_section_text_begin,
(const int *) bsp_section_text_load_begin,
(size_t) bsp_section_text_size
);
/* Copy .rodata section */
copy(
(int *) bsp_section_rodata_begin,
(const int *) bsp_section_rodata_load_begin,
(size_t) bsp_section_rodata_size
);
/* Copy .data section */
copy(
(int *) bsp_section_data_begin,
(const int *) bsp_section_data_load_begin,
(size_t) bsp_section_data_size
);
/* Copy .fast_text section */
copy(
(int *) bsp_section_fast_text_begin,
(const int *) bsp_section_fast_text_load_begin,
(size_t) bsp_section_fast_text_size
);
/* Copy .fast_data section */
copy(
(int *) bsp_section_fast_data_begin,
(const int *) bsp_section_fast_data_load_begin,
(size_t) bsp_section_fast_data_size
);
/* Clear .bss section */
clear_bss();
/* At this point we can use objects outside the .start section */
}

View File

@@ -0,0 +1,29 @@
/**
* @file
*
* @brief Memory map.
*/
MEMORY {
RAM_INT (AIW) : ORIGIN = 0x20000000, LENGTH = 16M
ROM_INT (RX) : ORIGIN = 0x00000000, LENGTH = 64M
NIRVANA : ORIGIN = 0, LENGTH = 0
}
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);
INCLUDE linkcmds.armv7

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2011 Sebastian Huber. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <rtems/btimer.h>
static bool benchmark_timer_find_average_overhead = false;
void benchmark_timer_initialize(void)
{
/* TODO */
}
uint32_t benchmark_timer_read(void)
{
/* TODO */
return 0;
}
void benchmark_timer_disable_subtracting_average_overhead(
bool find_average_overhead
)
{
benchmark_timer_find_average_overhead = find_average_overhead;
}