Merge branch 'master' of ssh://dispatch.rtems.org/data/git/rtems

This commit is contained in:
Joel Sherrill
2015-05-21 18:08:32 -05:00
367 changed files with 13780 additions and 4945 deletions

18
SUPPORT
View File

@@ -1,18 +0,0 @@
On-Line Applications Research Corporation (OAR) offers support,
customization, and training for RTEMS. Custom RTEMS development services
includes porting RTEMS to new processors and the development of custom board
support packages and device drivers. In addition, OAR is available
to assist in the development of your real-time embedded application.
For more information, email Joel Sherrill joel.sherrill@OARcorp.com
or contact OAR at:
On-Line Applications Research Corporation
7047 Old Madison Pike Suite 320
Huntsville AL 35806
Voice: (256) 722-9985
Fax: (256) 722-0985
RTEMS maintenance and development is funded solely by RTEMS users.
The future of RTEMS depends on its user base.

View File

@@ -1,5 +0,0 @@
#
# This file is automatically generated -- DO NOT EDIT!!!
#
RTEMS Version 4.10.99.0

View File

@@ -12,6 +12,7 @@ AC_DEFUN([RTEMS_CPU_SUBDIRS],
case $RTEMS_CPU in
_RTEMS_CPU_SUBDIR([arm],[$1]);;
_RTEMS_CPU_SUBDIR([bfin],[$1]);;
_RTEMS_CPU_SUBDIR([epiphany],[$1]);;
_RTEMS_CPU_SUBDIR([avr],[$1]);;
_RTEMS_CPU_SUBDIR([h8300],[$1]);;
_RTEMS_CPU_SUBDIR([i386],[$1]);;

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -15,11 +15,12 @@
*/
#include <rtems.h>
#include <rtems/timecounter.h>
#include <bsp.h>
#include <libcpu/omap_timer.h>
#ifdef ARM_MULTILIB_ARCH_V4
static struct timecounter beagle_clock_tc;
static omap_timer_registers_t regs_v1 = {
.TIDR = OMAP3_TIMER_TIDR,
@@ -115,8 +116,6 @@ static struct omap_timer *timer = &am335x_timer;
#endif
static int done = 0;
#if IS_AM335X
#define FRCLOCK_HZ (16*1500000)
#endif
@@ -181,20 +180,14 @@ omap3_frclock_init(void)
/* Start timer, without prescaler */
mmio_set(fr_timer->base + fr_timer->regs->TCLR,
OMAP3_TCLR_OVF_TRG | OMAP3_TCLR_AR | OMAP3_TCLR_ST);
done = 1;
}
static inline uint32_t
read_frc(void)
static uint32_t
beagle_clock_get_timecount(struct timecounter *tc)
{
if (done == 0) {
return 0;
}
return mmio_read(fr_timer->base + fr_timer->regs->TCRR);
}
static uint32_t last_tick_nanoseconds;
static void
beagle_clock_initialize(void)
{
@@ -262,12 +255,16 @@ beagle_clock_initialize(void)
while(mmio_read(AM335X_WDT_BASE+AM335X_WDT_WWPS) != 0) ;
#endif
/* Install timecounter */ \
beagle_clock_tc.tc_get_timecount = beagle_clock_get_timecount;
beagle_clock_tc.tc_counter_mask = 0xffffffff;
beagle_clock_tc.tc_frequency = FRCLOCK_HZ;
beagle_clock_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(&beagle_clock_tc);
}
static void beagle_clock_at_tick(void)
{
last_tick_nanoseconds = read_frc();
mmio_write(timer->base + timer->regs->TISR,
OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG |
OMAP3_TISR_TCAR_IT_FLAG);
@@ -315,14 +312,6 @@ static void beagle_clock_cleanup(void)
mmio_clear(fr_timer->base + fr_timer->regs->TCLR, OMAP3_TCLR_ST);
}
static inline uint32_t beagle_clock_nanoseconds_since_last_tick(void)
{
/* this arithmetic also works if read_frc() wraps around, as long
* as the subtraction wraps around too
*/
return (read_frc() - (uint64_t) last_tick_nanoseconds) * 1000000000 / FRCLOCK_HZ;
}
#define Clock_driver_support_at_tick() beagle_clock_at_tick()
#define Clock_driver_support_initialize_hardware() beagle_clock_initialize()
#define Clock_driver_support_install_isr(isr, old_isr) \
@@ -332,10 +321,6 @@ static inline uint32_t beagle_clock_nanoseconds_since_last_tick(void)
} while (0)
#define Clock_driver_support_shutdown_hardware() beagle_clock_cleanup()
#define Clock_driver_nanoseconds_since_last_tick \
beagle_clock_nanoseconds_since_last_tick
/* Include shared source clock driver code */
#include "../../shared/clockdrv_shell.h"
#endif /* ARM_MULTILIB_ARCH_V4 */

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -68,4 +68,6 @@ void Clock_isr(void * arg);
assert(status == RTEMS_SUCCESSFUL); \
} while (0)
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -10,5 +10,5 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -Bstatic -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -92,4 +92,6 @@ void Clock_driver_support_initialize_hardware(void)
GBA_REG_TM3CNT = (0x00c0|GBA_TMCNT_PS);
}
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -33,6 +33,7 @@ extern "C" {
#define LPC_CLOCK_INTERRUPT LPC176X_IRQ_TIMER_0
#define LPC_CLOCK_TIMER_BASE TMR0_BASE_ADDR
#define LPC_CLOCK_TIMECOUNTER_BASE TMR1_BASE_ADDR
#define LPC_CLOCK_REFERENCE LPC176X_PCLK
#define LPC_CLOCK_MODULE_ENABLE() \
lpc176x_module_enable( LPC176X_MODULE_TIMER_0, LPC176X_MODULE_PCLK_DEFAULT )

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -35,6 +35,8 @@ extern "C" {
#define LPC_CLOCK_TIMER_BASE TMR0_BASE_ADDR
#define LPC_CLOCK_TIMECOUNTER_BASE TMR1_BASE_ADDR
#define LPC_CLOCK_REFERENCE LPC24XX_PCLK
#define LPC_CLOCK_MODULE_ENABLE() \

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -44,6 +44,8 @@ extern "C" {
#define LPC_CLOCK_TIMER_BASE LPC32XX_BASE_TIMER_0
#define LPC_CLOCK_TIMECOUNTER_BASE LPC32XX_BASE_TIMER_1
#define LPC_CLOCK_REFERENCE LPC32XX_PERIPH_CLK
#define LPC_CLOCK_MODULE_ENABLE()

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -81,4 +81,6 @@ void Clock_driver_support_initialize_hardware (void)
TIMER_DATA (0) = TIMER_FREQ_64 ((uint16_t) freq);
}
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -72,14 +72,6 @@ static void raspberrypi_clock_cleanup(void)
}
}
/*
* Return the nanoseconds since last tick
*/
static uint32_t raspberrypi_clock_nanoseconds_since_last_tick(void)
{
return 0;
}
#define Clock_driver_support_at_tick() raspberrypi_clock_at_tick()
#define Clock_driver_support_initialize_hardware() raspberrypi_clock_initialize()
@@ -92,8 +84,6 @@ static uint32_t raspberrypi_clock_nanoseconds_since_last_tick(void)
#define Clock_driver_support_shutdown_hardware() raspberrypi_clock_cleanup()
#define Clock_driver_nanoseconds_since_last_tick \
raspberrypi_clock_nanoseconds_since_last_tick
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved.
* Copyright (c) 2013-2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -17,14 +17,11 @@
#include <bsp/irq.h>
#include <bsp/arm-a9mpcore-regs.h>
#include <bsp/arm-a9mpcore-clock.h>
#include <rtems/timecounter.h>
#define A9MPCORE_GT ((volatile a9mpcore_gt *) BSP_ARM_A9MPCORE_GT_BASE)
static uint64_t a9mpcore_clock_last_tick_k;
static uint32_t a9mpcore_clock_last_tick_cmpvallower;
static uint32_t a9mpcore_clock_autoinc;
static struct timecounter a9mpcore_tc;
/* This is defined in clockdrv_shell.h */
void Clock_isr(rtems_irq_hdl_param arg);
@@ -39,13 +36,6 @@ static void a9mpcore_clock_at_tick(void)
{
volatile a9mpcore_gt *gt = A9MPCORE_GT;
/*
* FIXME: Now the _TOD_Get_with_nanoseconds() yields wrong values until
* _TOD_Tickle_ticks() managed to update the uptime. See also PR2180.
*/
a9mpcore_clock_last_tick_cmpvallower =
gt->cmpvallower - a9mpcore_clock_autoinc;
gt->irqst = A9MPCORE_GT_IRQST_EFLG;
}
@@ -80,6 +70,13 @@ static uint64_t a9mpcore_clock_get_counter(volatile a9mpcore_gt *gt)
return ((uint64_t) cu2 << 32) | cl;
}
static uint32_t a9mpcore_clock_get_timecount(struct timecounter *tc)
{
volatile a9mpcore_gt *gt = A9MPCORE_GT;
return gt->cntrlower;
}
static void a9mpcore_clock_initialize(void)
{
volatile a9mpcore_gt *gt = A9MPCORE_GT;
@@ -98,14 +95,16 @@ static void a9mpcore_clock_initialize(void)
gt->cmpvalupper = (uint32_t) (cmpval >> 32);
gt->autoinc = interval;
a9mpcore_clock_last_tick_k = (UINT64_C(1000000000) << 32) / periphclk;
a9mpcore_clock_last_tick_cmpvallower = (uint32_t) cmpval - interval;
a9mpcore_clock_autoinc = interval;
gt->ctrl = A9MPCORE_GT_CTRL_AUTOINC_EN
| A9MPCORE_GT_CTRL_IRQ_EN
| A9MPCORE_GT_CTRL_COMP_EN
| A9MPCORE_GT_CTRL_TMR_EN;
a9mpcore_tc.tc_get_timecount = a9mpcore_clock_get_timecount;
a9mpcore_tc.tc_counter_mask = 0xffffffff;
a9mpcore_tc.tc_frequency = periphclk;
a9mpcore_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(&a9mpcore_tc);
}
CPU_Counter_ticks _CPU_Counter_read(void)
@@ -147,16 +146,6 @@ static void a9mpcore_clock_cleanup(void)
}
}
static uint32_t a9mpcore_clock_nanoseconds_since_last_tick(void)
{
volatile a9mpcore_gt *gt = A9MPCORE_GT;
uint64_t k = a9mpcore_clock_last_tick_k;
uint32_t n = a9mpcore_clock_last_tick_cmpvallower;
uint32_t c = gt->cntrlower;
return (uint32_t) (((c - n) * k) >> 32);
}
#define Clock_driver_support_at_tick() \
a9mpcore_clock_at_tick()
@@ -165,15 +154,12 @@ static uint32_t a9mpcore_clock_nanoseconds_since_last_tick(void)
#define Clock_driver_support_install_isr(isr, old_isr) \
do { \
a9mpcore_clock_handler_install(); \
a9mpcore_clock_handler_install(); \
old_isr = NULL; \
} while (0)
#define Clock_driver_support_shutdown_hardware() \
a9mpcore_clock_cleanup()
#define Clock_driver_nanoseconds_since_last_tick \
a9mpcore_clock_nanoseconds_since_last_tick
/* Include shared source clock driver code */
#include "../../shared/clockdrv_shell.h"

View File

@@ -13,6 +13,7 @@
*/
#include <rtems.h>
#include <rtems/timecounter.h>
#include <rtems/score/armv7m.h>
#include <bsp.h>
@@ -22,15 +23,35 @@
/* This is defined in clockdrv_shell.h */
static void Clock_isr(void *arg);
#define _ARMV7M_Systick_get_factor(freq) \
((1000000000ULL << 32) / (freq))
static rtems_timecounter_simple _ARMV7M_TC;
#ifdef BSP_ARMV7M_SYSTICK_FREQUENCY
#define _ARMV7M_Systick_factor \
_ARMV7M_Systick_get_factor(BSP_ARMV7M_SYSTICK_FREQUENCY)
#else
static uint64_t _ARMV7M_Systick_factor;
#endif
static uint32_t _ARMV7M_TC_get(rtems_timecounter_simple *tc)
{
volatile ARMV7M_Systick *systick = _ARMV7M_Systick;
return systick->cvr;
}
static bool _ARMV7M_TC_is_pending(rtems_timecounter_simple *tc)
{
volatile ARMV7M_SCB *scb = _ARMV7M_SCB;
return ((scb->icsr & ARMV7M_SCB_ICSR_PENDSTSET) != 0);
}
static uint32_t _ARMV7M_TC_get_timecount(struct timecounter *tc)
{
return rtems_timecounter_simple_downcounter_get(
tc,
_ARMV7M_TC_get,
_ARMV7M_TC_is_pending
);
}
static void _ARMV7M_TC_tick(void)
{
rtems_timecounter_simple_downcounter_tick(&_ARMV7M_TC, _ARMV7M_TC_get);
}
static void _ARMV7M_Systick_at_tick(void)
{
@@ -67,15 +88,18 @@ static void _ARMV7M_Systick_initialize(void)
uint64_t us_per_tick = rtems_configuration_get_microseconds_per_tick();
uint64_t interval = (freq * us_per_tick) / 1000000ULL;
#ifndef BSP_ARMV7M_SYSTICK_FREQUENCY
_ARMV7M_Systick_factor = _ARMV7M_Systick_get_factor(freq);
#endif
systick->rvr = (uint32_t) interval;
systick->cvr = 0;
systick->csr = ARMV7M_SYSTICK_CSR_ENABLE
| ARMV7M_SYSTICK_CSR_TICKINT
| ARMV7M_SYSTICK_CSR_CLKSOURCE;
rtems_timecounter_simple_install(
&_ARMV7M_TC,
freq,
interval,
_ARMV7M_TC_get_timecount
);
}
static void _ARMV7M_Systick_cleanup(void)
@@ -85,19 +109,7 @@ static void _ARMV7M_Systick_cleanup(void)
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_timecounter_tick() _ARMV7M_TC_tick()
#define Clock_driver_support_at_tick() \
_ARMV7M_Systick_at_tick()
@@ -114,9 +126,6 @@ static uint32_t _ARMV7M_Systick_nanoseconds_since_last_tick(void)
#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

@@ -7,10 +7,10 @@
*/
/*
* Copyright (c) 2009-2012 embedded brains GmbH. All rights reserved.
* Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* Dornierstr. 4
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
@@ -21,6 +21,7 @@
*/
#include <rtems.h>
#include <rtems/timecounter.h>
#include <bsp/lpc-clock-config.h>
#include <bsp/lpc-timer.h>
@@ -33,6 +34,16 @@ void Clock_isr(rtems_irq_hdl_param arg);
static volatile lpc_timer *const lpc_clock =
(volatile lpc_timer *) LPC_CLOCK_TIMER_BASE;
static volatile lpc_timer *const lpc_timecounter =
(volatile lpc_timer *) LPC_CLOCK_TIMECOUNTER_BASE;
static struct timecounter lpc_clock_tc;
static uint32_t lpc_clock_tc_get_timecount(struct timecounter *tc)
{
return lpc_timecounter->tc;
}
static void lpc_clock_at_tick(void)
{
lpc_clock->ir = LPC_TIMER_IR_MR0;
@@ -85,6 +96,13 @@ static void lpc_clock_initialize(void)
/* Enable timer */
lpc_clock->tcr = LPC_TIMER_TCR_EN;
/* Install timecounter */
lpc_clock_tc.tc_get_timecount = lpc_clock_tc_get_timecount;
lpc_clock_tc.tc_counter_mask = 0xffffffff;
lpc_clock_tc.tc_frequency = LPC_CLOCK_REFERENCE;
lpc_clock_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(&lpc_clock_tc);
}
static void lpc_clock_cleanup(void)
@@ -105,18 +123,6 @@ static void lpc_clock_cleanup(void)
}
}
static uint32_t lpc_clock_nanoseconds_since_last_tick(void)
{
uint64_t k = (1000000000ULL << 32) / LPC_CLOCK_REFERENCE;
uint64_t c = lpc_clock->tc;
if ((lpc_clock->ir & LPC_TIMER_IR_MR0) != 0) {
c = lpc_clock->tc + lpc_clock->mr0;
}
return (uint32_t) ((c * k) >> 32);
}
#define Clock_driver_support_at_tick() lpc_clock_at_tick()
#define Clock_driver_support_initialize_hardware() lpc_clock_initialize()
#define Clock_driver_support_install_isr(isr, old_isr) \
@@ -126,8 +132,6 @@ static uint32_t lpc_clock_nanoseconds_since_last_tick(void)
} while (0)
#define Clock_driver_support_shutdown_hardware() lpc_clock_cleanup()
#define Clock_driver_nanoseconds_since_last_tick \
lpc_clock_nanoseconds_since_last_tick
/* Include shared source clock driver code */
#include "../../../../shared/clockdrv_shell.h"

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N -EB }
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -30,13 +30,14 @@
#include <bsp/irq.h>
#include <bsp/tms570-rti.h>
#include <rtems/counter.h>
#include <rtems/timecounter.h>
/**
* holds HW counter value since last interrupt event
* sets in tms570_clock_driver_support_at_tick
* used in tms570_clock_driver_nanoseconds_since_last_tick
*/
static uint32_t tms570_rti_last_tick_fcr0;
static struct timecounter tms570_rti_tc;
static uint32_t tms570_rti_get_timecount(struct timecounter *tc)
{
return TMS570_RTI.RTIFRC0;
}
/**
* @brief Initialize the HW peripheral for clock driver
@@ -72,6 +73,12 @@ static void tms570_clock_driver_support_initialize_hardware( void )
TMS570_RTI.RTISETINTENA = 0x1;
/* enable timer */
TMS570_RTI.RTIGCTRL = 1;
/* set timecounter */
tms570_rti_tc.tc_get_timecount = tms570_rti_get_timecount;
tms570_rti_tc.tc_counter_mask = 0xffffffff;
tms570_rti_tc.tc_frequency = BSP_PLL_OUT_CLOCK;
tms570_rti_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(&tms570_rti_tc);
}
/**
@@ -82,7 +89,6 @@ static void tms570_clock_driver_support_initialize_hardware( void )
static void tms570_clock_driver_support_at_tick( void )
{
TMS570_RTI.RTIINTFLAG = 0x00000001;
tms570_rti_last_tick_fcr0 = TMS570_RTI.RTICOMP0 - TMS570_RTI.RTIUDCP0;
}
/**
@@ -124,24 +130,6 @@ static void tms570_clock_driver_support_shutdown_hardware( void )
TMS570_RTI.RTICLEARINTENA = 0x20000;
}
/**
* @brief returns the nanoseconds since last tick
*
* Return the nanoseconds since last tick
*
* @retval x nanoseconds
*
*/
static uint32_t tms570_clock_driver_nanoseconds_since_last_tick( void )
{
uint32_t actual_fcr0 = TMS570_RTI.RTIFRC0;
uint32_t usec_since_tick;
usec_since_tick = actual_fcr0 - tms570_rti_last_tick_fcr0;
return usec_since_tick * 1000;
}
#define Clock_driver_support_initialize_hardware \
tms570_clock_driver_support_initialize_hardware
#define Clock_driver_support_at_tick \
@@ -150,8 +138,6 @@ static uint32_t tms570_clock_driver_nanoseconds_since_last_tick( void )
tms570_clock_driver_support_initialize_hardware
#define Clock_driver_support_shutdown_hardware \
tms570_clock_driver_support_shutdown_hardware
#define Clock_driver_nanoseconds_since_last_tick \
tms570_clock_driver_nanoseconds_since_last_tick
#define Clock_driver_support_install_isr(Clock_isr, Old_ticker ) \
tms570_clock_driver_support_install_isr( Clock_isr )

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }

View File

@@ -0,0 +1,8 @@
ACLOCAL_AMFLAGS = -I ../../../aclocal
## Descend into the @RTEMS_BSP_FAMILY@ directory
## Currently, the shared directory is not explicitly
## added but it is present in the source tree.
SUBDIRS = @RTEMS_BSP_FAMILY@
include $(srcdir)/preinstall.am
include $(top_srcdir)/../../../automake/subdirs.am
include $(top_srcdir)/../../../automake/local.am

View File

@@ -0,0 +1,10 @@
# RTEMS_CHECK_BSPDIR(RTEMS_BSP_FAMILY)
AC_DEFUN([RTEMS_CHECK_BSPDIR],
[
case "$1" in
epiphany_sim )
AC_CONFIG_SUBDIRS([epiphany_sim]);;
*)
AC_MSG_ERROR([Invalid BSP]);;
esac
])

View File

@@ -0,0 +1,19 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([rtems-c-src-lib-libbsp-epiphany],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
AC_CONFIG_SRCDIR([epiphany_sim])
RTEMS_TOP(../../../../..)
RTEMS_CANONICAL_TARGET_CPU
AM_INIT_AUTOMAKE([no-define foreign subdir-objects 1.12.2])
AM_MAINTAINER_MODE
RTEMS_ENV_RTEMSBSP
RTEMS_PROJECT_ROOT
RTEMS_CHECK_BSPDIR([$RTEMS_BSP_FAMILY])
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@@ -0,0 +1,95 @@
##
#
# @brief Makefile of LibBSP for the Epiphany simulator.
#
#
ACLOCAL_AMFLAGS = -I ../../../../aclocal
include $(top_srcdir)/../../../../automake/compile.am
include_bspdir = $(includedir)/bsp
include_libcpudir = $(includedir)/libcpu
dist_project_lib_DATA = bsp_specs
###############################################################################
# Header #
###############################################################################
include_HEADERS = include/bsp.h
include_HEADERS += include/tm27.h
include_HEADERS += ../../shared/include/coverhd.h
nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
include_bsp_HEADERS = ../shared/include/linker-symbols.h
include_bsp_HEADERS += ../../../libbsp/shared/include/mm.h
include_bsp_HEADERS += ../../shared/include/utility.h
include_bsp_HEADERS += ../../shared/include/irq-generic.h
include_bsp_HEADERS += ../../shared/include/irq-info.h
include_bsp_HEADERS += ../../shared/include/stackalloc.h
include_bsp_HEADERS += ../../shared/include/console-polled.h
include_bsp_HEADERS += include/irq.h
nodist_include_HEADERS = include/bspopts.h
###############################################################################
# Data #
###############################################################################
noinst_LIBRARIES = libbspstart.a
libbspstart_a_SOURCES = start/start.S
project_lib_DATA = start/start.$(OBJEXT)
project_lib_DATA += startup/linkcmds
###############################################################################
# LibBSP #
###############################################################################
noinst_LIBRARIES += libbsp.a
# Startup
libbsp_a_SOURCES = ../../shared/bspreset.c
libbsp_a_SOURCES += ../../shared/bspstart.c
# Shared
libbsp_a_SOURCES += ../../shared/bootcard.c
libbsp_a_SOURCES += ../../shared/bspclean.c
libbsp_a_SOURCES += ../../shared/bsplibc.c
libbsp_a_SOURCES += ../../shared/bsppost.c
libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
libbsp_a_SOURCES += ../../shared/bsppretaskinghook.c
libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
libbsp_a_SOURCES += ../../shared/sbrk.c
libbsp_a_SOURCES += ../../shared/src/stackalloc.c
libbsp_a_SOURCES += ../../shared/bspgetworkarea.c
# clock
libbsp_a_SOURCES += ../../shared/clock_driver_simidle.c
# Timer
libbsp_a_SOURCES += timer/timer.c
# console
libbsp_a_SOURCES += ../../shared/console-polled.c
# IRQ
libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c
libbsp_a_SOURCES += ../../shared/src/irq-generic.c
libbsp_a_SOURCES += ../../shared/src/irq-info.c
libbsp_a_SOURCES += irq/irq.c
# Cache
libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
libbsp_a_SOURCES += ../../shared/include/cache_.h
libbsp_a_CPPFLAGS = -I$(srcdir)/../../shared/include
# debugio
libbsp_a_SOURCES += console/console-io.c
DISTCLEANFILES = include/bspopts.h
include $(srcdir)/preinstall.am
include $(top_srcdir)/../../../../automake/local.am

View File

@@ -0,0 +1,6 @@
This BSP is intended to run on epiphany-*-run simulator.
From command line type:
$ epiphany-rtems4.11-run -e=on --memory-region 0x8e000000,0x2000000 \
$PATH_TO_RTEMS_EXE

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,36 @@
##
#
# @file
#
# @brief Configure script of LibBSP for epiphany_sim BSP.
#
AC_PREREQ(2.69)
AC_INIT([rtems-c-src-lib-libbsp-epiphany-sim],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
AC_CONFIG_SRCDIR([bsp_specs])
RTEMS_TOP(../../../../../..)
RTEMS_CANONICAL_TARGET_CPU
AM_INIT_AUTOMAKE([no-define nostdinc foreign subdir-objects 1.12.2])
RTEMS_BSP_CONFIGURE
RTEMS_BSPOPTS_SET([BSP_START_RESET_VECTOR],[*],[])
RTEMS_BSPOPTS_HELP([BSP_START_RESET_VECTOR],[reset vector address for BSP
start])
RTEMS_BSPOPTS_SET([BSP_EPIPHANY_PERIPHCLK],[*],[100000000U])
RTEMS_BSPOPTS_HELP([BSP_EPIPHANY_PERIPHCLK],[epiphany PERIPHCLK clock
frequency in Hz])
RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm])
RTEMS_CANONICALIZE_TOOLS
RTEMS_PROG_CCAS
RTEMS_CHECK_SMP
AM_CONDITIONAL(HAS_SMP,[test "$rtems_cv_HAS_SMP" = "yes"])
RTEMS_BSP_CLEANUP_OPTIONS(0, 1)
RTEMS_BSP_LINKCMDS
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@@ -0,0 +1,104 @@
/*
* Copyright (c) 2015 University of York.
* Hesham ALMatary <hmka501@york.ac.uk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <bsp.h>
#include <bsp/console-polled.h>
#include <rtems/libio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
static void outbyte_console( char );
static char inbyte_console( void );
void console_initialize_hardware(void)
{
/* Do nothing */
}
/* Epiphany simulator would handle this system call */
static void outbyte_console(char c)
{
register int chan asm("r0") = STDOUT_FILENO;
register void* addr asm("r1") = &c;
register int len asm("r2") = 1;
/* Invoke write system call to be handled by Epiphany simulator */
__asm__ __volatile__ ("trap 0" : : "r" (chan), "r" (addr), "r" (len));
}
static char inbyte_console(void)
{
char c;
register int chan asm("r0") = STDIN_FILENO;
register void* addr asm("r1") = &c;
register int len asm("r2") = 1;
/* Invoke read system call to be handled by Epiphany simulator */
asm ("trap 1" :: "r" (chan), "r" (addr), "r" (len));
return c;
}
/*
* console_outbyte_polled
*
* This routine transmits a character using polling.
*/
void console_outbyte_polled(
int port,
char ch
)
{
outbyte_console( ch );
}
/*
* console_inbyte_nonblocking
*
* This routine polls for a character.
*/
int console_inbyte_nonblocking(int port)
{
char c;
c = inbyte_console();
if (!c)
return -1;
return (int) c;
}
/*
* To support printk
*/
#include <rtems/bspIo.h>
static void Epiphany_output_char(char c) { console_outbyte_polled( 0, c ); }
BSP_output_char_function_type BSP_output_char = Epiphany_output_char;
BSP_polling_getchar_function_type BSP_poll_char =
(void *)console_inbyte_nonblocking;

View File

@@ -0,0 +1,55 @@
/*
*
* Copyright (c) 2015 University of York.
* Hesham ALMatary <hmka501@york.ac.uk>
*
* COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef LIBBSP_EPIPHANY_EPIPHANY_SIM_H
#define LIBBSP_EPIPHANY_EPIPHANY_SIM_H
#include <rtems.h>
#include <rtems/clockdrv.h>
#include <rtems/console.h>
#include <bspopts.h>
#include <bsp/default-initial-extension.h>
#include <rtems/devnull.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Constants */
Thread clock_driver_sim_idle_body(uintptr_t);
#define BSP_IDLE_TASK_BODY clock_driver_sim_idle_body
#ifdef __cplusplus
}
#endif
#endif /* LIBBSP_EPIPHANY_PARALLELLA_H */

View File

@@ -0,0 +1,68 @@
/*
*
* Copyright (c) 2015 University of York.
* Hesham ALMatary <hmka501@york.ac.uk>
*
* COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* include/bspopts.h.in. Generated from configure.ac by autoheader. */
/* If defined, then the BSP Framework will put a non-zero pattern into the
RTEMS Workspace and C program heap. This should assist in finding code that
assumes memory starts set to zero. */
#undef BSP_DIRTY_MEMORY
/* If defined, print a message and wait until pressed before resetting board
when application exits. */
#undef BSP_PRESS_KEY_FOR_RESET
/* If defined, prints the exception context when an unexpected exception
occurs. */
#undef BSP_PRINT_EXCEPTION_CONTEXT
/* If defined, reset the board when the application exits. */
#undef BSP_RESET_BOARD_AT_EXIT
/* reset vector address for BSP start */
#undef BSP_START_RESET_VECTOR
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION

View File

@@ -0,0 +1,49 @@
/**
* @file
*
* @ingroup Epiphany_IRQ
*
* @brief Interrupt definitions.
*/
/*
*
* Copyright (c) 2015 University of York.
* Hesham ALMatary <hmka501@york.ac.uk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef LIBBSP_GENERIC_EPIPHANY_IRQ_H
#define LIBBSP_GENERIC_EPIPHANY_IRQ_H
#ifndef ASM
#include <rtems.h>
#include <rtems/irq.h>
#include <rtems/irq-extension.h>
#define BSP_INTERRUPT_VECTOR_MIN 0x0
#define BSP_INTERRUPT_VECTOR_MAX 0x24
#endif /* ASM */
#endif /* LIBBSP_GENERIC_OR1K_IRQ_H */

View File

@@ -0,0 +1,53 @@
/*
*
* Copyright (c) 2015 University of York.
* Hesham ALMatary <hmka501@york.ac.uk>
*
* COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _RTEMS_TMTEST27
#error "This is an RTEMS internal file you must not include directly."
#endif
#ifndef __tm27_h
#define __tm27_h
/**
* @name Interrupt mechanisms for Time Test 27
* @{
*/
#define MUST_WAIT_FOR_INTERRUPT 0
#define Install_tm27_vector( handler ) /* empty */
#define Cause_tm27_intr() /* empty */
#define Clear_tm27_intr() /* empty */
#define Lower_tm27_intr() /* empty */
#endif

View File

@@ -0,0 +1,62 @@
/**
* @file
*
* @ingroup epiphany_interrupt
*
* @brief Interrupt support.
*/
/*
* Epiphany CPU Dependent Source
*
* Copyright (c) 2015 University of York.
* Hesham ALMatary <hmka501@york.ac.uk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <bsp/irq.h>
#include <bsp/irq-generic.h>
/* Almost all of the jobs that the following functions should
* do are implemented in cpukit
*/
void bsp_interrupt_handler_default(rtems_vector_number vector)
{
printk("spurious interrupt: %u\n", vector);
}
rtems_status_code bsp_interrupt_facility_initialize()
{
return 0;
}
rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
{
return 0;
}
rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
{
return 0;
}

View File

@@ -0,0 +1,7 @@
include $(RTEMS_ROOT)/make/custom/default.cfg
RTEMS_CPU = epiphany
CPU_CFLAGS =
CFLAGS_OPTIMIZE_V ?= -O0 -g

View File

@@ -0,0 +1,104 @@
## Automatically generated by ampolish3 - Do not edit
if AMPOLISH3
$(srcdir)/preinstall.am: Makefile.am
$(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
endif
PREINSTALL_DIRS =
DISTCLEANFILES += $(PREINSTALL_DIRS)
all-am: $(PREINSTALL_FILES)
PREINSTALL_FILES =
CLEANFILES = $(PREINSTALL_FILES)
all-local: $(TMPINSTALL_FILES)
TMPINSTALL_FILES =
CLEANFILES += $(TMPINSTALL_FILES)
$(PROJECT_LIB)/$(dirstamp):
@$(MKDIR_P) $(PROJECT_LIB)
@: > $(PROJECT_LIB)/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp)
$(PROJECT_INCLUDE)/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)
@: > $(PROJECT_INCLUDE)/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp)
$(PROJECT_INCLUDE)/bsp/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/bsp
@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(PROJECT_INCLUDE)/libcpu/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu
@: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
$(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
$(PROJECT_INCLUDE)/bsp.h: include/bsp.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
$(PROJECT_INCLUDE)/tm27.h: include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
$(PROJECT_INCLUDE)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
$(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
$(PROJECT_INCLUDE)/bsp/linker-symbols.h: ../shared/include/linker-symbols.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/linker-symbols.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/linker-symbols.h
$(PROJECT_INCLUDE)/bsp/mm.h: ../../../libbsp/shared/include/mm.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mm.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mm.h
$(PROJECT_INCLUDE)/bsp/utility.h: ../../shared/include/utility.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/utility.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/utility.h
$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
$(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h
$(PROJECT_INCLUDE)/bsp/stackalloc.h: ../../shared/include/stackalloc.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/stackalloc.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/stackalloc.h
$(PROJECT_INCLUDE)/bsp/console-polled.h: ../../shared/include/console-polled.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/console-polled.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/console-polled.h
$(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
$(PROJECT_INCLUDE)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h
$(PROJECT_LIB)/start.$(OBJEXT): start/start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
$(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
TMPINSTALL_FILES += $(PROJECT_LIB)/linkcmds

View File

@@ -0,0 +1,167 @@
/*
* Copyright (c) 2015 University of York.
* Hesham ALMatary <hmka501@york.ac.uk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <bsp/linker-symbols.h>
#include <rtems/asm.h>
EXTERN(bsp_section_bss_begin)
EXTERN(bsp_section_bss_end)
EXTERN(ISR_Handler)
EXTERN(bsp_start_vector_table_end)
EXTERN(bsp_start_vector_table_size)
EXTERN(bsp_vector_table_size)
EXTERN(bsp_section_stack_begin)
PUBLIC(EPIPHANY_Exception_default)
PUBLIC(bsp_start_vector_table_begin)
PUBLIC(start)
.section .vector, "wax"
TYPE_FUNC(start)
SYM(start):
.balign 4 ;
b .normal_start
.balign 4 ; 0x4
b .sw_exception
.balign 4 ; 0x8
b .normal_start
.balign 4 ; 0xc
b .clock_isr
.balign 4 ; 0x10
b .timer1_isr
.balign 4 ; 0x14
b _EPIPHANY_Exception_default
.balign 4 ; 0x18
b _EPIPHANY_Exception_default
.balign 4 ; 0x1c
b _EPIPHANY_Exception_default
.balign 4 ; 0x20
b _EPIPHANY_Exception_default
.balign 4 ; 0x24
b _EPIPHANY_Exception_default
_bsp_start_vector_table_begin:
.word .normal_start /* Reset */
.word _EPIPHANY_Exception_default /* SW exception */
.word _EPIPHANY_Exception_default /* Data Page Fault */
.word _EPIPHANY_Exception_default /* Timer 0 */
.word _EPIPHANY_Exception_default /* Timer 1 */
.word _EPIPHANY_Exception_default /* Message int */
.word _EPIPHANY_Exception_default /* DMA0 int */
.word _EPIPHANY_Exception_default /* DMA1 int */
.word _EPIPHANY_Exception_default /* WAND */
.word _EPIPHANY_Exception_default /* User interrupt */
_bsp_start_vector_table_end:
.size _start, .-_start
.section .start,"ax"
.align 4
.type _external_start, %function
.normal_start:
/* Initialize the stack and frame pointers */
mov sp, %low(bsp_section_stack_begin)
movt sp, %high(bsp_section_stack_begin)
mov fp, sp
cpu0:
/* Zero .bss section */
mov r0, %low(bsp_section_bss_begin)
movt r0, %high(bsp_section_bss_begin)
mov r1, sp
mov r2,#0
mov r3,#0
_bss_clear_loop:
strd r2, [r0], +#1
sub r5, r1, r0
bne _bss_clear_loop
/* Clear the reset interrupt flag */
mov r0, %low(_jump_to_c)
movt r0, %high(_jump_to_c)
movts iret, r0
rti
_jump_to_c:
/* Jump to bootcard */
mov r3, %low(_boot_card)
movt r3, %high(_boot_card)
jalr r3
/* Should never reach here */
idle
.size .normal_start, .-.normal_start
.balign 4
.type .sw_exception, %function
.sw_exception:
idle
.balign 4
.type .clock_isr, %function
.clock_isr:
/*
* r62 and r63 are saved here, and restored from _ISR_Handler, they
* and hold vector number and _ISR_Handler address repsectively.
*/
add sp, sp, #-8
str r62, [sp, #0]
str r63, [sp, #4]
mov r62, 3
mov r63, %low(_ISR_Handler)
movt r63, %high(_ISR_Handler)
jr r6
.balign 4
.type .timer1_isr, %function
.timer1_isr:
/*
* r62 and r63 are saved here, and restored from _ISR_Handler, they
* and hold vector number and _ISR_Handler address repsectively.
*/
add sp, sp, #-8
str r62, [sp, 0]
str r63, [sp, 4]
mov r62, 4
mov r63, %low(_ISR_Handler)
movt r63, %high(_ISR_Handler)
jr r63
.balign 4
TYPE_FUNC(EPIPHANY_Exception_default)
SYM(EPIPHANY_Exception_default):
idle

View File

@@ -0,0 +1,369 @@
/**
* @file
*
* @ingroup bsp_linker
*
* @brief Memory map
*/
/*
*
* Copyright (c) 2015 University of York.
* Hesham ALMatary <hmka501@york.ac.uk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
OUTPUT_FORMAT("elf32-epiphany", "elf32-epiphany", "elf32-epiphany")
OUTPUT_ARCH (epiphany)
ENTRY (_start)
MEMORY
{
VECTOR_RAM (AIW) : ORIGIN = 0x00000000, LENGTH = 0xB0
LOCAL_MEM (AIW) : ORIGIN = 0x000000B0, LENGTH = 0x00007FC0 /* 32KiB Local memory */
RAM : ORIGIN = 0x8E000000, LENGTH = 0x01000000 /* 16MiB external RAM */
}
REGION_ALIAS ("REGION_START", LOCAL_MEM);
REGION_ALIAS ("REGION_VECTOR", VECTOR_RAM);
REGION_ALIAS ("REGION_TEXT", RAM);
REGION_ALIAS ("REGION_TEXT_LOAD", RAM);
REGION_ALIAS ("REGION_RODATA", RAM);
REGION_ALIAS ("REGION_RODATA_LOAD", RAM);
REGION_ALIAS ("REGION_DATA", RAM);
REGION_ALIAS ("REGION_DATA_LOAD", RAM);
REGION_ALIAS ("REGION_FAST_DATA", RAM);
REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM);
REGION_ALIAS ("REGION_BSS", RAM);
REGION_ALIAS ("REGION_WORK", RAM);
REGION_ALIAS ("REGION_STACK", RAM);
/* The following address is used for text output */
bsp_section_outbut_buffer = 0x8F800000;
bsp_section_vector_begin = 0x00000000;
/*
* Global symbols that may be defined externally
*/
bsp_vector_table_size = DEFINED (bsp_vector_table_size) ? bsp_vector_table_size : 64;
bsp_section_xbarrier_align = DEFINED (bsp_section_xbarrier_align) ? bsp_section_xbarrier_align : 1;
bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1;
bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1;
bsp_stack_align = DEFINED (bsp_stack_align) ? bsp_stack_align : 8;
bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 1024;
bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
_bsp_processor_count = DEFINED (_bsp_processor_count) ? _bsp_processor_count : 1;
SECTIONS {
.vector :
{
*(.vector)
. = ALIGN(bsp_vector_table_size);
bsp_section_vector_end = .;
} > REGION_VECTOR AT > REGION_VECTOR
bsp_section_vector_size = bsp_section_vector_end - bsp_section_vector_begin;
bsp_vector_table_begin = bsp_section_vector_begin;
bsp_vector_table_end = bsp_vector_table_begin + bsp_vector_table_size;
.start :
{
. = ALIGN(8);
bsp_section_start_begin = .;
KEEP (*(.bsp_start_text))
KEEP (*(.bsp_start_data))
bsp_section_start_end = .;
} > REGION_START AT > REGION_START
bsp_section_start_size = bsp_section_start_end - bsp_section_start_begin;
.xbarrier : {
. = ALIGN (bsp_section_xbarrier_align);
} > REGION_VECTOR AT > REGION_VECTOR
.text : {
. = ALIGN(8);
bsp_section_text_begin = .;
*(.text.unlikely .text.*_unlikely)
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
} > REGION_TEXT AT > REGION_TEXT_LOAD
.init : {
KEEP (*(.init))
} > REGION_TEXT AT > REGION_TEXT_LOAD
.fini : {
KEEP (*(.fini))
. = ALIGN(8);
bsp_section_text_end = .;
} > REGION_TEXT AT > REGION_TEXT_LOAD
bsp_section_text_size = bsp_section_text_end - bsp_section_text_begin;
bsp_section_text_load_begin = LOADADDR (.text);
bsp_section_text_load_end = bsp_section_text_load_begin + bsp_section_text_size;
.robarrier : {
. = ALIGN (bsp_section_robarrier_align);
} > REGION_RODATA AT > REGION_RODATA
.rodata : {
. = ALIGN(8);
bsp_section_rodata_begin = .;
*(.rodata .rodata.* .gnu.linkonce.r.*)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.eh_frame : {
KEEP (*(.eh_frame))
} > REGION_RODATA AT > REGION_RODATA_LOAD
.gcc_except_table : {
*(.gcc_except_table .gcc_except_table.*)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.tdata : {
__TLS_Data_begin = .;
*(.tdata .tdata.* .gnu.linkonce.td.*)
__TLS_Data_end = .;
} > REGION_RODATA AT > REGION_RODATA_LOAD
.tbss : {
__TLS_BSS_begin = .;
*(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
__TLS_BSS_end = .;
} > REGION_RODATA AT > REGION_RODATA_LOAD
__TLS_Data_size = __TLS_Data_end - __TLS_Data_begin;
__TLS_Data_begin = __TLS_Data_size != 0 ? __TLS_Data_begin : __TLS_BSS_begin;
__TLS_Data_end = __TLS_Data_size != 0 ? __TLS_Data_end : __TLS_BSS_begin;
__TLS_BSS_size = __TLS_BSS_end - __TLS_BSS_begin;
__TLS_Size = __TLS_BSS_end - __TLS_Data_begin;
__TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
} > REGION_RODATA AT > REGION_RODATA_LOAD
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
} > REGION_RODATA AT > REGION_RODATA_LOAD
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} > REGION_RODATA AT > REGION_RODATA_LOAD
.ctors : {
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
} > REGION_RODATA AT > REGION_RODATA_LOAD
.dtors : {
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
} > REGION_RODATA AT > REGION_RODATA_LOAD
.data.rel.ro : {
*(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*)
*(.data.rel.ro* .gnu.linkonce.d.rel.ro.*)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.jcr : {
KEEP (*(.jcr))
} > REGION_RODATA AT > REGION_RODATA_LOAD
.interp : {
*(.interp)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.note.gnu.build-id : {
*(.note.gnu.build-id)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.hash : {
*(.hash)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.gnu.hash : {
*(.gnu.hash)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.dynsym : {
*(.dynsym)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.dynstr : {
*(.dynstr)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.gnu.version : {
*(.gnu.version)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.gnu.version_d : {
*(.gnu.version_d)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.gnu.version_r : {
*(.gnu.version_r)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.rel.dyn : {
*(.rel.init)
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
*(.rel.fini)
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
*(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
*(.rel.ctors)
*(.rel.dtors)
*(.rel.got)
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
PROVIDE_HIDDEN (__rel_iplt_start = .);
*(.rel.iplt)
PROVIDE_HIDDEN (__rel_iplt_end = .);
PROVIDE_HIDDEN (__rela_iplt_start = .);
PROVIDE_HIDDEN (__rela_iplt_end = .);
} > REGION_RODATA AT > REGION_RODATA_LOAD
.rela.dyn : {
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.ctors)
*(.rela.dtors)
*(.rela.got)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
PROVIDE_HIDDEN (__rel_iplt_start = .);
PROVIDE_HIDDEN (__rel_iplt_end = .);
PROVIDE_HIDDEN (__rela_iplt_start = .);
*(.rela.iplt)
PROVIDE_HIDDEN (__rela_iplt_end = .);
} > REGION_RODATA AT > REGION_RODATA_LOAD
.rel.plt : {
*(.rel.plt)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.rela.plt : {
*(.rela.plt)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.plt : {
*(.plt)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.iplt : {
*(.iplt)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.dynamic : {
*(.dynamic)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.got : {
*(.got.plt) *(.igot.plt) *(.got) *(.igot)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.rtemsroset : {
/* Special FreeBSD linker set sections */
__start_set_sysctl_set = .;
*(set_sysctl_*);
__stop_set_sysctl_set = .;
*(set_domain_*);
*(set_pseudo_*);
KEEP (*(SORT(.rtemsroset.*)))
. = ALIGN(8);
bsp_section_rodata_end = .;
} > REGION_RODATA AT > REGION_RODATA_LOAD
bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin;
bsp_section_rodata_load_begin = LOADADDR (.rodata);
bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size;
.rwbarrier : {
. = ALIGN(8);
. = ALIGN (bsp_section_rwbarrier_align);
} > REGION_DATA AT > REGION_DATA
.data : {
. = ALIGN(8);
bsp_section_data_begin = .;
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
} > REGION_DATA AT > REGION_DATA_LOAD
.data1 : {
*(.data1)
} > REGION_DATA AT > REGION_DATA_LOAD
.rtemsrwset : {
KEEP (*(SORT(.rtemsrwset.*)))
. = ALIGN(8);
bsp_section_data_end = .;
} > REGION_DATA AT > REGION_DATA_LOAD
bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin;
bsp_section_data_load_begin = LOADADDR (.data);
bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size;
.bss : {
. = ALIGN(8);
bsp_section_bss_begin = .;
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(8);
bsp_section_bss_end = .;
} > REGION_BSS AT > REGION_BSS
bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin;
.work : {
/*
* The work section will occupy the remaining REGION_WORK region and
* contains the RTEMS work space and heap.
*/
. = ALIGN(8);
bsp_section_work_begin = .;
. += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.);
. = ALIGN(8);
bsp_section_work_end = .;
} > REGION_WORK AT > REGION_WORK
bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin;
.stack : {
. = ALIGN(8);
bsp_section_stack_begin = .;
. += ORIGIN (REGION_STACK) + LENGTH (REGION_STACK) - ABSOLUTE (.);
. = ALIGN(8);
bsp_section_stack_end = .;
} > REGION_STACK AT > REGION_STACK
bsp_section_stack_size = bsp_section_stack_begin - bsp_section_stack_end;
_RamBase = ORIGIN (REGION_WORK);
_RamSize = LENGTH (REGION_WORK);
_WorkAreaBase = bsp_section_work_begin;
_HeapSize = 0;
}

View File

@@ -0,0 +1,109 @@
/*
* Copyright (c) 2015 University of York.
* Hesham ALMatary <hmka501@york.ac.uk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <rtems.h>
#include <bsp.h>
#include <rtems/btimer.h>
#include <rtems/score/epiphany-utility.h>
extern char bsp_start_vector_table_begin[];
bool benchmark_timer_find_average_overhead;
static void benchmark_timer1_interrupt_handler(void)
{
unsigned int val = 0xFFFFFFFF;
unsigned int event_type = 0x1;
/* Embed assembly code for setting timer1 */
__asm__ __volatile__ ("movts ctimer1, %[val] \t \n" :: [val] "r" (val));
__asm__ __volatile__ ("movfs r16, config; \t \n"
"mov r17, %%low(0xfffff0ff);\t \n"
"movt r17, %%high(0xffff0ff);\t \n"
"lsl r18, %[event_type], 0x8; \t \n"
"and r16, r16, r17; \t \n"
"orr r16, r16, r18; \t \n"
"movts config, r16; \t \n"
:: [event_type] "r" (event_type));
}
/* Start eCore tiemr 1 usef for profiling and timing analysis */
void benchmark_timer_initialize( void )
{
/* Install interrupt handler for timer 1 */
proc_ptr *table =
(proc_ptr *) bsp_start_vector_table_begin;
table[TIMER1] = benchmark_timer1_interrupt_handler;
benchmark_timer1_interrupt_handler();
}
/*
* The following controls the behavior of benchmark_timer_read().
*
* AVG_OVEREHAD is the overhead for starting and stopping the timer. It
* is usually deducted from the number returned.
*
* LEAST_VALID is the lowest number this routine should trust. Numbers
* below this are "noise" and zero is returned.
*/
#define AVG_OVERHEAD 0 /* It typically takes X.X microseconds */
/* (Y countdowns) to start/stop the timer. */
/* This value is in microseconds. */
#define LEAST_VALID 1 /* Don't trust a clicks value lower than this */
benchmark_timer_t benchmark_timer_read( void )
{
uint32_t timer_val = 0;
uint32_t total;
__asm__ __volatile__ ("movfs %[timer_val], ctimer1 \t \n"
:[timer_val] "=r" (timer_val):);
total = (0xFFFFFFFF - timer_val);
if ( benchmark_timer_find_average_overhead == true )
return total;
else {
if ( total < LEAST_VALID )
return 0; /* below timer resolution */
/*
* Somehow convert total into microseconds
*/
return (total - AVG_OVERHEAD);
}
}
void benchmark_timer_disable_subtracting_average_overhead(
bool find_flag
)
{
benchmark_timer_find_average_overhead = find_flag;
}

View File

@@ -0,0 +1,7 @@
## Automatically generated by ampolish3 - Do not edit
if AMPOLISH3
$(srcdir)/preinstall.am: Makefile.am
$(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
endif

View File

@@ -0,0 +1,81 @@
#ifndef LIBBSP_EPIPHANY_SHARED_LINKER_SYMBOLS_H
#define LIBBSP_EPIPHANY_SHARED_LINKER_SYMBOLS_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @defgroup epiphany_linker Linker Support
*
* @ingroup epiphany_shared
*
* @brief Linker support.
*
* @{
*/
#ifndef ASM
#define LINKER_SYMBOL(sym) extern char sym [];
#else
#define LINKER_SYMBOL(sym) .extern sym
#endif
LINKER_SYMBOL(bsp_section_start_begin)
LINKER_SYMBOL(bsp_section_start_end)
LINKER_SYMBOL(bsp_section_start_size)
LINKER_SYMBOL(bsp_section_vector_begin)
LINKER_SYMBOL(bsp_section_vector_end)
LINKER_SYMBOL(bsp_section_vector_size)
LINKER_SYMBOL(bsp_section_text_begin)
LINKER_SYMBOL(bsp_section_text_end)
LINKER_SYMBOL(bsp_section_text_size)
LINKER_SYMBOL(bsp_section_text_load_begin)
LINKER_SYMBOL(bsp_section_text_load_end)
LINKER_SYMBOL(bsp_section_rodata_begin)
LINKER_SYMBOL(bsp_section_rodata_end)
LINKER_SYMBOL(bsp_section_rodata_size)
LINKER_SYMBOL(bsp_section_rodata_load_begin)
LINKER_SYMBOL(bsp_section_rodata_load_end)
LINKER_SYMBOL(bsp_section_data_begin)
LINKER_SYMBOL(bsp_section_data_end)
LINKER_SYMBOL(bsp_section_data_size)
LINKER_SYMBOL(bsp_section_data_load_begin)
LINKER_SYMBOL(bsp_section_data_load_end)
LINKER_SYMBOL(bsp_section_bss_begin)
LINKER_SYMBOL(bsp_section_bss_end)
LINKER_SYMBOL(bsp_section_bss_size)
LINKER_SYMBOL(bsp_section_work_begin)
LINKER_SYMBOL(bsp_section_work_end)
LINKER_SYMBOL(bsp_section_work_size)
LINKER_SYMBOL(bsp_section_stack_begin)
LINKER_SYMBOL(bsp_section_stack_end)
LINKER_SYMBOL(bsp_section_stack_size)
LINKER_SYMBOL(bsp_vector_table_begin)
LINKER_SYMBOL(bsp_vector_table_end)
LINKER_SYMBOL(bsp_vector_table_size)
LINKER_SYMBOL(bsp_start_vector_table_begin)
LINKER_SYMBOL(bsp_start_vector_table_end)
LINKER_SYMBOL(bsp_start_vector_table_size)
LINKER_SYMBOL(bsp_translation_table_base)
LINKER_SYMBOL(bsp_translation_table_end)
LINKER_SYMBOL(_bsp_processor_count)
/** @} */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LIBBSP_EPIPHANY_SHARED_LINKER_SYMBOLS_H */

View File

@@ -28,6 +28,7 @@
#include <bspopts.h>
#include <libcpu/cpuModel.h>
#include <assert.h>
#include <rtems/timecounter.h>
#define CLOCK_VECTOR 0
@@ -37,31 +38,25 @@ uint32_t pc386_clock_click_count;
/* forward declaration */
void Clock_isr(void *param);
static void Clock_driver_support_at_tick_empty(void);
static void clockOff(void);
static void Clock_driver_support_at_tick_tsc(void);
static uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void);
static uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void);
static void Clock_isr_handler(void *param);
/*
* Roughly the number of cycles per tick and per nanosecond. Note that these
* Roughly the number of cycles per second. Note that these
* will be wildly inaccurate if the chip speed changes due to power saving
* or thermal modes.
*
* NOTE: These are only used when the TSC method is used.
*/
uint64_t pc586_tsc_per_tick;
uint64_t pc586_nanoseconds_per_tick;
static uint64_t pc586_tsc_frequency;
uint64_t pc586_tsc_at_tick;
static struct timecounter pc386_tc;
/* this driver may need to count ISRs per tick */
#define CLOCK_DRIVER_ISRS_PER_TICK 1
#define CLOCK_DRIVER_ISRS_PER_TICK_VALUE pc386_isrs_per_tick
/* The driver uses the count in Clock_driver_support_at_tick */
extern volatile uint32_t Clock_driver_isrs;
extern volatile uint32_t Clock_driver_ticks;
#define READ_8254( _lsb, _msb ) \
do { outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_LATCH); \
@@ -74,60 +69,21 @@ extern volatile uint32_t Clock_driver_isrs;
* Hooks which get swapped based upon which nanoseconds since last
* tick method is preferred.
*/
void (*Clock_driver_support_at_tick)(void) = NULL;
uint32_t (*Clock_driver_nanoseconds_since_last_tick)(void) = NULL;
/*
* What do we do at each clock tick?
*/
static void Clock_driver_support_at_tick_tsc(void)
{
pc586_tsc_at_tick = rdtsc();
}
static void Clock_driver_support_at_tick_empty(void)
{
}
#define Clock_driver_support_at_tick()
#define Clock_driver_support_install_isr( _new, _old ) \
do { \
_old = NULL; \
} while(0)
/*
* Get nanoseconds using Pentium-compatible TSC register
*/
static uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void)
static uint32_t pc386_get_timecount_tsc(struct timecounter *tc)
{
uint64_t diff_nsec;
diff_nsec = rdtsc() - pc586_tsc_at_tick;
/*
* At this point, with a hypothetical 10 GHz CPU clock and 100 Hz tick
* clock, diff_nsec <= 27 bits.
*/
diff_nsec *= pc586_nanoseconds_per_tick; /* <= 54 bits */
diff_nsec /= pc586_tsc_per_tick;
if (diff_nsec > pc586_nanoseconds_per_tick)
/*
* Hmmm... Some drift or rounding. Pin the value to 1 nanosecond before
* the next tick.
*/
/* diff_nsec = pc586_nanoseconds_per_tick - 1; */
diff_nsec = 12345;
return (uint32_t)diff_nsec;
return (uint32_t)rdtsc();
}
/*
* Get nanoseconds using 8254 timer chip
*/
static uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void)
static uint32_t pc386_get_timecount_i8254(struct timecounter *tc)
{
uint32_t usecs, clicks, isrs;
uint32_t usecs1, usecs2;
uint32_t irqs;
uint8_t lsb, msb;
rtems_interrupt_level level;
@@ -136,34 +92,10 @@ static uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void)
*/
rtems_interrupt_disable(level);
READ_8254(lsb, msb);
isrs = Clock_driver_isrs;
irqs = Clock_driver_ticks;
rtems_interrupt_enable(level);
/*
* Now do the math
*/
/* convert values read into counter clicks */
clicks = ((msb << 8) | lsb);
/* whole ISRs we have done since the last tick */
usecs1 = (pc386_isrs_per_tick - isrs - 1) * pc386_microseconds_per_isr;
/* the partial ISR we in the middle of now */
usecs2 = pc386_microseconds_per_isr - TICK_TO_US(clicks);
/* total microseconds */
usecs = usecs1 + usecs2;
#if 0
printk( "usecs1=%d usecs2=%d ", usecs1, usecs2 );
printk( "maxclicks=%d clicks=%d ISRs=%d ISRsper=%d usersPer=%d usecs=%d\n",
pc386_clock_click_count, clicks,
Clock_driver_isrs, pc386_isrs_per_tick,
pc386_microseconds_per_isr, usecs );
#endif
/* return it in nanoseconds */
return usecs * 1000;
return (irqs + 1) * pc386_microseconds_per_isr - ((msb << 8) | lsb);
}
/*
@@ -175,9 +107,6 @@ static void calibrate_tsc(void)
uint8_t then_lsb, then_msb, now_lsb, now_msb;
uint32_t i;
pc586_nanoseconds_per_tick =
rtems_configuration_get_microseconds_per_tick() * 1000;
/*
* We just reset the timer, so we know we're at the beginning of a tick.
*/
@@ -204,16 +133,11 @@ static void calibrate_tsc(void)
} while (1);
}
pc586_tsc_per_tick = rdtsc() - begin_time;
/* Initialize "previous tick" counters */
pc586_tsc_at_tick = rdtsc();
pc586_tsc_frequency = rdtsc() - begin_time;
#if 0
printk( "CPU clock at %u MHz\n", (uint32_t)(pc586_tsc_per_tick / 1000000));
printk( "CPU clock at %u MHz\n", (uint32_t)(pc586_tsc_frequency / 1000000));
#endif
pc586_tsc_per_tick /= rtems_clock_get_ticks_per_second();
}
static void clockOn(void)
@@ -299,24 +223,18 @@ void Clock_driver_support_initialize_hardware(void)
if ( use_8254 ) {
/* printk( "Use 8254\n" ); */
Clock_driver_support_at_tick = Clock_driver_support_at_tick_empty;
Clock_driver_nanoseconds_since_last_tick =
bsp_clock_nanoseconds_since_last_tick_i8254;
pc386_tc.tc_get_timecount = pc386_get_timecount_i8254;
pc386_tc.tc_counter_mask = 0xffffffff;
pc386_tc.tc_frequency = TIMER_TICK;
} else {
/* printk( "Use TSC\n" ); */
Clock_driver_support_at_tick = Clock_driver_support_at_tick_tsc;
Clock_driver_nanoseconds_since_last_tick =
bsp_clock_nanoseconds_since_last_tick_tsc;
pc386_tc.tc_get_timecount = pc386_get_timecount_tsc;
pc386_tc.tc_counter_mask = 0xffffffff;
pc386_tc.tc_frequency = pc586_tsc_frequency;
}
/* Shell installs nanosecond handler before calling
* Clock_driver_support_initialize_hardware() :-(
* so we do it again now that we're ready.
*/
rtems_clock_set_nanoseconds_extension(
Clock_driver_nanoseconds_since_last_tick
);
pc386_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(&pc386_tc);
Clock_isr_enabled = true;
}

View File

@@ -75,5 +75,7 @@ static void Clock_driver_support_shutdown_hardware(void)
clockwrite(LM32_CLOCK_CR, LM32_CLOCK_CR_STOP);
}
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -46,4 +46,6 @@ static void Clock_driver_support_shutdown_hardware(void)
MM_WRITE(MM_TIMER0_CONTROL, 0);
}
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -10,4 +10,4 @@
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
*endfile:
%{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtfini.o%s }
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtfini.o%s }

View File

@@ -58,4 +58,6 @@
MCF5282_PIT_PCSR_EN; \
} while (0)
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -98,4 +98,6 @@ extern int m360_clock_rate;
m360.pitr |= divisor; \
} while (0)
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -98,5 +98,7 @@
MCF548X_SLT_SCR0 |= (MCF548X_SLT_SCR_TEN | MCF548X_SLT_SCR_RUN | MCF548X_SLT_SCR_IEN); \
} while (0)
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -3,6 +3,7 @@
*/
#include <rtems.h>
#include <rtems/timecounter.h>
#include <bsp.h>
/*
@@ -10,34 +11,37 @@
*/
#define CLOCK_VECTOR (64+56)
static uint32_t s_pcntrAtTick = 0;
static uint32_t s_nanoScale = 0;
static rtems_timecounter_simple mcf52235_tc;
/*
* Provide nanosecond extension
* Interrupts are disabled when this is called
*/
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
static uint32_t mcf52235_tc_get(rtems_timecounter_simple *tc)
{
uint32_t i;
if (MCF_PIT1_PCSR & MCF_PIT_PCSR_PIF) {
i = s_pcntrAtTick + (MCF_PIT1_PMR - MCF_PIT1_PCNTR);
}
else {
i = s_pcntrAtTick - MCF_PIT1_PCNTR;
}
return i * s_nanoScale;
return MCF_PIT1_PCNTR;
}
#define Clock_driver_nanoseconds_since_last_tick bsp_clock_nanoseconds_since_last_tick
static bool mcf52235_tc_is_pending(rtems_timecounter_simple *tc)
{
return (MCF_PIT1_PCSR & MCF_PIT_PCSR_PIF) != 0;
}
static uint32_t mcf52235_tc_get_timecount(struct timecounter *tc)
{
return rtems_timecounter_simple_downcounter_get(
tc,
mcf52235_tc_get,
mcf52235_tc_is_pending
);
}
static void mcf52235_tc_tick(void)
{
rtems_timecounter_simple_downcounter_tick(&mcf52235_tc, mcf52235_tc_get);
}
/*
* Periodic interval timer interrupt handler
*/
#define Clock_driver_support_at_tick() \
do { \
s_pcntrAtTick = MCF_PIT1_PCNTR; \
MCF_PIT1_PCSR |= MCF_PIT_PCSR_PIF; \
} while (0) \
@@ -76,7 +80,6 @@ static void Clock_driver_support_initialize_hardware(void)
break;
preScaleCode++;
}
s_nanoScale = 1000000000 / (clk >> preScaleCode);
MCF_INTC0_ICR56 = MCF_INTC_ICR_IL(PIT3_IRQ_LEVEL) |
MCF_INTC_ICR_IP(PIT3_IRQ_PRIORITY);
@@ -90,7 +93,15 @@ static void Clock_driver_support_initialize_hardware(void)
MCF_PIT1_PMR = pmr;
MCF_PIT1_PCSR = MCF_PIT_PCSR_PRE(preScaleCode) |
MCF_PIT_PCSR_PIE | MCF_PIT_PCSR_RLD | MCF_PIT_PCSR_EN;
s_pcntrAtTick = MCF_PIT1_PCNTR;
rtems_timecounter_simple_install(
&mcf52235_tc,
clk >> preScaleCode,
pmr,
mcf52235_tc_get_timecount
);
}
#define Clock_driver_timecounter_tick() mcf52235_tc_tick()
#include "../../../shared/clockdrv_shell.h"

View File

@@ -25,5 +25,6 @@ monitor02
paranoia
pppd
spstkalloc02
syscall01
tmfine01
utf8proc01

View File

@@ -3,6 +3,7 @@
*/
#include <rtems.h>
#include <rtems/timecounter.h>
#include <bsp.h>
/*
@@ -10,26 +11,37 @@
*/
#define CLOCK_VECTOR (64+56)
static uint32_t s_pcntrAtTick = 0;
static uint32_t s_nanoScale = 0;
static rtems_timecounter_simple mcf5225x_tc;
/*
* Provide nanosecond extension
* Interrupts are disabled when this is called
*/
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
static uint32_t mcf5225x_tc_get(rtems_timecounter_simple *tc)
{
return MCF_PIT1_PCSR & MCF_PIT_PCSR_PIF ? (s_pcntrAtTick + (MCF_PIT1_PMR - MCF_PIT1_PCNTR)) * s_nanoScale : (s_pcntrAtTick - MCF_PIT1_PCNTR) * s_nanoScale;
return MCF_PIT1_PCNTR;
}
#define Clock_driver_nanoseconds_since_last_tick bsp_clock_nanoseconds_since_last_tick
static bool mcf5225x_tc_is_pending(rtems_timecounter_simple *tc)
{
return (MCF_PIT1_PCSR & MCF_PIT_PCSR_PIF) != 0;
}
static uint32_t mcf5225x_tc_get_timecount(struct timecounter *tc)
{
return rtems_timecounter_simple_downcounter_get(
tc,
mcf5225x_tc_get,
mcf5225x_tc_is_pending
);
}
static void mcf5225x_tc_tick(void)
{
rtems_timecounter_simple_downcounter_tick(&mcf5225x_tc, mcf5225x_tc_get);
}
/*
* Periodic interval timer interrupt handler
*/
#define Clock_driver_support_at_tick() \
do { \
s_pcntrAtTick = MCF_PIT1_PCNTR; \
MCF_PIT1_PCSR |= MCF_PIT_PCSR_PIF; \
} while (0) \
@@ -68,7 +80,6 @@ static void Clock_driver_support_initialize_hardware(void)
break;
preScaleCode++;
}
s_nanoScale = 1000000000 / (clk >> preScaleCode);
MCF_INTC0_ICR56 = MCF_INTC_ICR_IL(PIT3_IRQ_LEVEL) |
MCF_INTC_ICR_IP(PIT3_IRQ_PRIORITY);
@@ -82,7 +93,15 @@ static void Clock_driver_support_initialize_hardware(void)
MCF_PIT1_PMR = pmr;
MCF_PIT1_PCSR = MCF_PIT_PCSR_PRE(preScaleCode) |
MCF_PIT_PCSR_PIE | MCF_PIT_PCSR_RLD | MCF_PIT_PCSR_EN;
s_pcntrAtTick = MCF_PIT1_PCNTR;
rtems_timecounter_simple_install(
&mcf5225x_tc,
clk >> preScaleCode,
pmr,
mcf5225x_tc_get_timecount
);
}
#define Clock_driver_timecounter_tick() mcf5225x_tc_tick()
#include "../../../shared/clockdrv_shell.h"

View File

@@ -58,4 +58,6 @@
MCF5235_PIT_PCSR_EN; \
} while (0)
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -3,6 +3,7 @@
*/
#include <rtems.h>
#include <rtems/timecounter.h>
#include <bsp.h>
/*
@@ -10,36 +11,40 @@
*/
#define CLOCK_VECTOR (128+46)
static uint32_t s_pcntrAtTick = 0;
static uint32_t s_nanoScale = 0;
static rtems_timecounter_simple mcf5329_tc;
/*
* Provide nanosecond extension
*/
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
static uint32_t mcf5329_tc_get(rtems_timecounter_simple *tc)
{
uint32_t i;
if (MCF_PIT3_PCSR & MCF_PIT_PCSR_PIF) {
i = s_pcntrAtTick + (MCF_PIT3_PMR - MCF_PIT3_PCNTR);
} else {
i = s_pcntrAtTick - MCF_PIT3_PCNTR;
}
return i * s_nanoScale;
return MCF_PIT3_PCNTR;
}
#define Clock_driver_nanoseconds_since_last_tick bsp_clock_nanoseconds_since_last_tick
static bool mcf5329_tc_is_pending(rtems_timecounter_simple *tc)
{
return (MCF_PIT3_PCSR & MCF_PIT_PCSR_PIF) != 0;
}
static uint32_t mcf5329_tc_get_timecount(struct timecounter *tc)
{
return rtems_timecounter_simple_downcounter_get(
tc,
mcf5329_tc_get,
mcf5329_tc_is_pending
);
}
static void mcf5329_tc_tick(void)
{
rtems_timecounter_simple_downcounter_tick(&mcf5329_tc, mcf5329_tc_get);
}
/*
* Periodic interval timer interrupt handler
*/
#define Clock_driver_support_at_tick() \
do { \
s_pcntrAtTick = MCF_PIT3_PCNTR; \
MCF_PIT3_PCSR |= MCF_PIT_PCSR_PIF; \
} while (0) \
/*
* Attach clock interrupt handler
*/
@@ -75,8 +80,6 @@ static void Clock_driver_support_initialize_hardware(void)
break;
preScaleCode++;
}
s_nanoScale = 1000000000 / (clk >> preScaleCode);
MCF_INTC1_ICR46 = MCF_INTC_ICR_IL(PIT3_IRQ_LEVEL);
rtems_interrupt_disable(level);
@@ -89,7 +92,15 @@ static void Clock_driver_support_initialize_hardware(void)
MCF_PIT3_PMR = pmr;
MCF_PIT3_PCSR = MCF_PIT_PCSR_PRE(preScaleCode) |
MCF_PIT_PCSR_PIE | MCF_PIT_PCSR_RLD | MCF_PIT_PCSR_EN;
s_pcntrAtTick = MCF_PIT3_PCNTR;
rtems_timecounter_simple_install(
&mcf5329_tc,
clk >> preScaleCode,
pmr,
mcf5329_tc_get_timecount
);
}
#define Clock_driver_timecounter_tick() mcf5329_tc_tick()
#include "../../../shared/clockdrv_shell.h"

View File

@@ -48,4 +48,6 @@ static void Clock_driver_support_shutdown_hardware(void)
t->cr = 0xA0; /* initialize with timer disabled */
}
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -12,6 +12,7 @@
*/
#include <rtems.h>
#include <rtems/timecounter.h>
#include <bsp.h>
#include <mcf5282/mcf5282.h>
@@ -20,6 +21,32 @@
*/
#define CLOCK_VECTOR (64+58)
static rtems_timecounter_simple uC5282_tc;
static uint32_t uC5282_tc_get(rtems_timecounter_simple *tc)
{
return MCF5282_PIT3_PCNTR;
}
static bool uC5282_tc_is_pending(rtems_timecounter_simple *tc)
{
return (MCF5282_PIT3_PCSR & MCF5282_PIT_PCSR_PIF) != 0;
}
static uint32_t uC5282_tc_get_timecount(struct timecounter *tc)
{
return rtems_timecounter_simple_downcounter_get(
tc,
uC5282_tc_get,
uC5282_tc_is_pending
);
}
static void uC5282_tc_tick(void)
{
rtems_timecounter_simple_downcounter_tick(&uC5282_tc, uC5282_tc_get);
}
/*
* CPU load counters
* Place in static RAM so updates don't hit the SDRAM
@@ -31,17 +58,6 @@
#define NSEC_PER_PITC __SRAMBASE.nsec_per_pitc
#define FILTER_SHIFT 6
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
{
int i = MCF5282_PIT3_PCNTR;
if (MCF5282_PIT3_PCSR & MCF5282_PIT_PCSR_PIF)
i = MCF5282_PIT3_PCNTR - PITC_PER_TICK;
return (PITC_PER_TICK - i) * NSEC_PER_PITC;
}
#define Clock_driver_nanoseconds_since_last_tick \
bsp_clock_nanoseconds_since_last_tick
/*
* Periodic interval timer interrupt handler
*/
@@ -83,7 +99,7 @@ static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
*/
#define Clock_driver_support_initialize_hardware() \
do { \
unsigned long long N; \
unsigned long long N; \
int level; \
int preScaleCode = 0; \
N = bsp_get_CPU_clock_speed(); \
@@ -116,6 +132,12 @@ static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
MCF5282_PIT_PCSR_PIE | \
MCF5282_PIT_PCSR_RLD | \
MCF5282_PIT_PCSR_EN; \
rtems_timecounter_simple_install( \
&uC5282_tc, \
bsp_get_CPU_clock_speed() >> (preScaleCode + 1), \
PITC_PER_TICK, \
uC5282_tc_get_timecount \
); \
} while (0)
/*
@@ -135,4 +157,6 @@ int bsp_cpu_load_percentage(void)
0;
}
#define Clock_driver_timecounter_tick() uC5282_tc_tick()
#include "../../../shared/clockdrv_shell.h"

View File

@@ -88,4 +88,6 @@ void au1x00_clock_init(void)
#define Clock_driver_support_shutdown_hardware()
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -54,4 +54,6 @@
#define Clock_driver_support_shutdown_hardware() \
MONGOOSEV_WRITE_REGISTER( CLOCK_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0 )
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -55,4 +55,6 @@
#define Clock_driver_support_shutdown_hardware()
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -123,5 +123,6 @@
TX4925_REG_WRITE( TX4925_REG_BASE, TX4925_TIMER0_BASE + TX4925_TIMER_TCR, 0x0 ); /* Disable timer */ \
} while(0)
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -114,4 +114,6 @@ void new_brk_esr(void)
} while(0)
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -43,17 +43,11 @@ static uint32_t mips_timer_rate = 0;
mips_enable_in_interrupt_mask(CLOCK_VECTOR_MASK); \
} while(0)
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
{
return 0;
}
#define Clock_driver_nanoseconds_since_last_tick \
bsp_clock_nanoseconds_since_last_tick
#define Clock_driver_support_shutdown_hardware() \
do { \
mips_disable_in_interrupt_mask(CLOCK_VECTOR_MASK); \
} while (0)
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -49,5 +49,7 @@ static void Clock_driver_support_initialize_hardware(void)
NIOS2_IENABLE(1 << CLOCK_VECTOR);
}
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -22,11 +22,14 @@
#include <bsp/generic_or1k.h>
#include <rtems/score/cpu.h>
#include <rtems/score/or1k-utility.h>
#include <rtems/timecounter.h>
/* The number of clock cycles before generating a tick timer interrupt. */
#define TTMR_NUM_OF_CLOCK_TICKS_INTERRUPT 0x09ED9
#define OR1K_CLOCK_CYCLE_TIME_NANOSECONDS 10
static struct timecounter or1ksim_tc;
/* CPU counter */
static CPU_Counter_ticks cpu_counter_ticks;
@@ -69,8 +72,23 @@ static void generic_or1k_clock_handler_install(
}
}
static uint32_t or1ksim_get_timecount(struct timecounter *tc)
{
uint32_t ticks_since_last_timer_interrupt;
ticks_since_last_timer_interrupt = _OR1K_mfspr(CPU_OR1K_SPR_TTCR);
return cpu_counter_ticks + ticks_since_last_timer_interrupt;
}
CPU_Counter_ticks _CPU_Counter_read(void)
{
return or1ksim_get_timecount(NULL);
}
static void generic_or1k_clock_initialize(void)
{
uint64_t frequency = (1000000000 / OR1K_CLOCK_CYCLE_TIME_NANOSECONDS);
uint32_t TTMR;
/* For TTMR register,
@@ -90,11 +108,15 @@ static void generic_or1k_clock_initialize(void)
_OR1K_mtspr(CPU_OR1K_SPR_TTMR, TTMR);
_OR1K_mtspr(CPU_OR1K_SPR_TTCR, 0);
/* Initialize CPU Counter */
cpu_counter_ticks = 0;
/* Initialize timecounter */
or1ksim_tc.tc_get_timecount = or1ksim_get_timecount;
or1ksim_tc.tc_counter_mask = 0xffffffff;
or1ksim_tc.tc_frequency = frequency;
or1ksim_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(&or1ksim_tc);
}
static void generic_or1k_clock_cleanup(void)
static void generic_or1k_clock_cleanup(void)
{
uint32_t sr;
@@ -109,24 +131,6 @@ static void generic_or1k_clock_initialize(void)
_OR1K_mtspr(CPU_OR1K_SPR_TTMR, 0);
}
/*
* Return the nanoseconds since last tick
*/
static uint32_t generic_or1k_clock_nanoseconds_since_last_tick(void)
{
return
TTMR_NUM_OF_CLOCK_TICKS_INTERRUPT * OR1K_CLOCK_CYCLE_TIME_NANOSECONDS;
}
CPU_Counter_ticks _CPU_Counter_read(void)
{
uint32_t ticks_since_last_timer_interrupt;
ticks_since_last_timer_interrupt = _OR1K_mfspr(CPU_OR1K_SPR_TTCR);
return cpu_counter_ticks + ticks_since_last_timer_interrupt;
}
CPU_Counter_ticks _CPU_Counter_difference(
CPU_Counter_ticks second,
CPU_Counter_ticks first
@@ -134,6 +138,7 @@ CPU_Counter_ticks _CPU_Counter_difference(
{
return second - first;
}
#define Clock_driver_support_at_tick() generic_or1k_clock_at_tick()
#define Clock_driver_support_initialize_hardware() generic_or1k_clock_initialize()
@@ -146,7 +151,4 @@ CPU_Counter_ticks _CPU_Counter_difference(
#define Clock_driver_support_shutdown_hardware() generic_or1k_clock_cleanup()
#define Clock_driver_nanoseconds_since_last_tick \
generic_or1k_clock_nanoseconds_since_last_tick
#include "../../../shared/clockdrv_shell.h"

View File

@@ -26,14 +26,40 @@
#include <mpc55xx/regs.h>
#include <rtems/timecounter.h>
void Clock_isr(void *arg);
static uint64_t mpc55xx_clock_factor;
static rtems_timecounter_simple mpc55xx_tc;
#if defined(MPC55XX_CLOCK_EMIOS_CHANNEL)
#include <mpc55xx/emios.h>
static uint32_t mpc55xx_tc_get(rtems_timecounter_simple *tc)
{
return EMIOS.CH [MPC55XX_CLOCK_EMIOS_CHANNEL].CCNTR.R;
}
static bool mpc55xx_tc_is_pending(rtems_timecounter_simple *tc)
{
return EMIOS.CH [MPC55XX_CLOCK_EMIOS_CHANNEL].CSR.B.FLAG != 0;
}
static uint32_t mpc55xx_tc_get_timecount(struct timecounter *tc)
{
return rtems_timecounter_simple_upcounter_get(
tc,
mpc55xx_tc_get,
mpc55xx_tc_is_pending
);
}
static void mpc55xx_tc_tick(void)
{
rtems_timecounter_simple_upcounter_tick(&mpc55xx_tc, mpc55xx_tc_get);
}
static void mpc55xx_clock_at_tick(void)
{
union EMIOS_CSR_tag csr = MPC55XX_ZERO_FLAGS;
@@ -68,8 +94,6 @@ static void mpc55xx_clock_initialize(void)
uint64_t us_per_tick = rtems_configuration_get_microseconds_per_tick();
uint64_t interval = (reference_clock * us_per_tick) / 1000000;
mpc55xx_clock_factor = (1000000000ULL << 32) / reference_clock;
/* Apply prescaler */
if (prescaler > 0) {
interval /= (uint64_t) prescaler;
@@ -110,6 +134,13 @@ static void mpc55xx_clock_initialize(void)
ccr.B.FEN = 1;
ccr.B.FREN = 1;
regs->CCR.R = ccr.R;
rtems_timecounter_simple_install(
&mpc55xx_tc,
reference_clock,
interval,
mpc55xx_tc_get_timecount
);
}
static void mpc55xx_clock_cleanup(void)
@@ -122,21 +153,31 @@ static void mpc55xx_clock_cleanup(void)
regs->CCR.R = ccr.R;
}
static uint32_t mpc55xx_clock_nanoseconds_since_last_tick(void)
#elif defined(MPC55XX_CLOCK_PIT_CHANNEL)
static uint32_t mpc55xx_tc_get(rtems_timecounter_simple *tc)
{
volatile struct EMIOS_CH_tag *regs = &EMIOS.CH [MPC55XX_CLOCK_EMIOS_CHANNEL];
uint64_t c = regs->CCNTR.R;
union EMIOS_CSR_tag csr = { .R = regs->CSR.R };
uint64_t k = mpc55xx_clock_factor;
if (csr.B.FLAG != 0) {
c = regs->CCNTR.R + regs->CADR.R + 1;
}
return (uint32_t) ((c * k) >> 32);
return PIT_RTI.CHANNEL [MPC55XX_CLOCK_PIT_CHANNEL].CVAL.R;
}
#elif defined(MPC55XX_CLOCK_PIT_CHANNEL)
static bool mpc55xx_tc_is_pending(rtems_timecounter_simple *tc)
{
return PIT_RTI.CHANNEL [MPC55XX_CLOCK_PIT_CHANNEL].TFLG.B.TIF != 0;
}
static uint32_t mpc55xx_tc_get_timecount(struct timecounter *tc)
{
return rtems_timecounter_simple_downcounter_get(
tc,
mpc55xx_tc_get,
mpc55xx_tc_is_pending
);
}
static void mpc55xx_tc_tick(void)
{
rtems_timecounter_simple_downcounter_tick(&mpc55xx_tc, mpc55xx_tc_get);
}
static void mpc55xx_clock_at_tick(void)
{
@@ -174,11 +215,16 @@ static void mpc55xx_clock_initialize(void)
PIT_RTI_PITMCR_32B_tag pitmcr = { .B = { .FRZ = 1 } };
PIT_RTI_TCTRL_32B_tag tctrl = { .B = { .TIE = 1, .TEN = 1 } };
mpc55xx_clock_factor = (1000000000ULL << 32) / reference_clock;
PIT_RTI.PITMCR.R = pitmcr.R;
channel->LDVAL.R = interval;
channel->TCTRL.R = tctrl.R;
rtems_timecounter_simple_install(
&mpc55xx_tc,
reference_clock,
interval,
mpc55xx_tc_get_timecount
);
}
static void mpc55xx_clock_cleanup(void)
@@ -189,23 +235,9 @@ static void mpc55xx_clock_cleanup(void)
channel->TCTRL.R = 0;
}
static uint32_t mpc55xx_clock_nanoseconds_since_last_tick(void)
{
volatile PIT_RTI_CHANNEL_tag *channel =
&PIT_RTI.CHANNEL [MPC55XX_CLOCK_PIT_CHANNEL];
uint32_t c = channel->CVAL.R;
uint32_t i = channel->LDVAL.R;
uint64_t k = mpc55xx_clock_factor;
if (channel->TFLG.B.TIF != 0) {
c = channel->CVAL.R - i;
}
return (uint32_t) (((i - c) * k) >> 32);
}
#endif
#define Clock_driver_timecounter_tick() mpc55xx_tc_tick()
#define Clock_driver_support_at_tick() \
mpc55xx_clock_at_tick()
#define Clock_driver_support_initialize_hardware() \
@@ -217,8 +249,6 @@ static uint32_t mpc55xx_clock_nanoseconds_since_last_tick(void)
} while (0)
#define Clock_driver_support_shutdown_hardware() \
mpc55xx_clock_cleanup()
#define Clock_driver_nanoseconds_since_last_tick \
mpc55xx_clock_nanoseconds_since_last_tick
/* Include shared source clock driver code */
#include "../../../../libbsp/shared/clockdrv_shell.h"

View File

@@ -7,10 +7,10 @@
*/
/*
* Copyright (c) 2011-2012 embedded brains GmbH. All rights reserved.
* Copyright (c) 2011-2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
* Dornierstr. 4
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
@@ -20,6 +20,8 @@
* http://www.rtems.org/license/LICENSE.
*/
#include <rtems/timecounter.h>
#include <libcpu/powerpc-utility.h>
#include <bsp.h>
@@ -29,10 +31,6 @@
/* This is defined in clockdrv_shell.h */
static rtems_isr Clock_isr(void *arg);
static uint32_t qoriq_clock_last_ccr;
static uint32_t qoriq_clock_nanoseconds_per_timer_tick;
static volatile qoriq_pic_global_timer *const qoriq_clock =
#if QORIQ_CLOCK_TIMER < 4
&qoriq.pic.gta [QORIQ_CLOCK_TIMER];
@@ -40,8 +38,17 @@ static volatile qoriq_pic_global_timer *const qoriq_clock =
&qoriq.pic.gtb [QORIQ_CLOCK_TIMER - 4];
#endif
static volatile qoriq_pic_global_timer *const qoriq_timecounter =
#if QORIQ_CLOCK_TIMECOUNTER < 4
&qoriq.pic.gta [QORIQ_CLOCK_TIMECOUNTER];
#else
&qoriq.pic.gtb [QORIQ_CLOCK_TIMECOUNTER - 4];
#endif
#define CLOCK_INTERRUPT (QORIQ_IRQ_GT_BASE + QORIQ_CLOCK_TIMER)
static struct timecounter qoriq_clock_tc;
static void qoriq_clock_handler_install(rtems_isr_entry *old_isr)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
@@ -77,18 +84,28 @@ static void qoriq_clock_handler_install(rtems_isr_entry *old_isr)
}
}
static uint32_t qoriq_clock_get_timecount(struct timecounter *tc)
{
uint32_t ccr = qoriq_timecounter->ccr;
return GTCCR_COUNT_GET(-ccr);
}
static void qoriq_clock_initialize(void)
{
uint32_t timer_frequency = BSP_bus_frequency / 8;
uint32_t nanoseconds_per_second = 1000000000;
uint32_t interval = (uint32_t) (((uint64_t) timer_frequency
* (uint64_t) rtems_configuration_get_microseconds_per_tick()) / 1000000);
qoriq_clock_nanoseconds_per_timer_tick =
nanoseconds_per_second / timer_frequency;
qoriq_clock->bcr = GTBCR_COUNT(interval);
qoriq_clock_last_ccr = qoriq_clock->ccr;
qoriq_timecounter->bcr = GTBCR_COUNT(0xffffffff);
qoriq_clock_tc.tc_get_timecount = qoriq_clock_get_timecount;
qoriq_clock_tc.tc_counter_mask = GTCCR_COUNT_GET(0xffffffff);
qoriq_clock_tc.tc_frequency = timer_frequency;
qoriq_clock_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(&qoriq_clock_tc);
}
static void qoriq_clock_cleanup(void)
@@ -107,33 +124,13 @@ static void qoriq_clock_cleanup(void)
}
}
static void qoriq_clock_at_tick(void)
{
qoriq_clock_last_ccr = qoriq_clock->ccr;
}
static uint32_t qoriq_clock_nanoseconds_since_last_tick(void)
{
uint32_t ccr = qoriq_clock->ccr;
uint32_t bcr = qoriq_clock->bcr;
if ((ccr & GTCCR_TOG) != (qoriq_clock_last_ccr & GTCCR_TOG)) {
bcr += bcr;
}
return (bcr - GTCCR_COUNT_GET(ccr)) * qoriq_clock_nanoseconds_per_timer_tick;
}
#define Clock_driver_support_at_tick() \
qoriq_clock_at_tick()
#define Clock_driver_support_at_tick()
#define Clock_driver_support_initialize_hardware() \
qoriq_clock_initialize()
#define Clock_driver_support_install_isr(clock_isr, old_isr) \
qoriq_clock_handler_install(&old_isr)
#define Clock_driver_support_shutdown_hardware() \
qoriq_clock_cleanup()
#define Clock_driver_nanoseconds_since_last_tick \
qoriq_clock_nanoseconds_since_last_tick
/* Include shared source clock driver code */
#include "../../../shared/clockdrv_shell.h"

View File

@@ -154,6 +154,10 @@ RTEMS_BSPOPTS_SET([QORIQ_CLOCK_TIMER],[qoriq_core_1],[4])
RTEMS_BSPOPTS_SET([QORIQ_CLOCK_TIMER],[*],[0])
RTEMS_BSPOPTS_HELP([QORIQ_CLOCK_TIMER],[global timer used for system clock, 0..3 maps to A0..A3, and 4..7 maps to B0..B3])
RTEMS_BSPOPTS_SET([QORIQ_CLOCK_TIMECOUNTER],[qoriq_core_1],[5])
RTEMS_BSPOPTS_SET([QORIQ_CLOCK_TIMECOUNTER],[*],[1])
RTEMS_BSPOPTS_HELP([QORIQ_CLOCK_TIMECOUNTER],[global timer used for the timecounter, 0..3 maps to A0..A3, and 4..7 maps to B0..B3])
RTEMS_BSPOPTS_SET([QORIQ_CHIP_VARIANT],[qoriq_t2080*],[QORIQ_CHIP_T2080])
RTEMS_BSPOPTS_SET([QORIQ_CHIP_VARIANT],[qoriq_t4240*],[QORIQ_CHIP_T4240])
RTEMS_BSPOPTS_SET([QORIQ_CHIP_VARIANT],[*],[QORIQ_CHIP_P1020])

View File

@@ -7,7 +7,7 @@
*/
/*
* Copyright (c) 2008-2013 embedded brains GmbH. All rights reserved.
* Copyright (c) 2008-2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Obere Lagerstr. 30
@@ -22,6 +22,7 @@
#include <rtems.h>
#include <rtems/clockdrv.h>
#include <rtems/timecounter.h>
#include <libcpu/powerpc-utility.h>
#include <bsp/vectors.h>
@@ -46,7 +47,12 @@ static uint32_t ppc_clock_decrementer_value = PPC_CLOCK_DECREMENTER_MAX;
static uint32_t ppc_clock_next_time_base;
static uint64_t ppc_clock_factor;
static struct timecounter ppc_tc;
static uint32_t ppc_get_timecount(struct timecounter *tc)
{
return ppc_time_base();
}
static void ppc_clock_no_tick(void)
{
@@ -161,28 +167,6 @@ static int ppc_clock_exception_handler_ppc405(BSP_Exception_frame *frame, unsign
return 0;
}
static uint32_t ppc_clock_nanoseconds_since_last_tick(void)
{
uint64_t k = ppc_clock_factor;
uint32_t c = ppc_decrementer_register();
uint32_t i = ppc_clock_decrementer_value + 1;
return (uint32_t) (((i - c) * k) >> 32);
}
static uint32_t ppc_clock_nanoseconds_since_last_tick_ppc405(void)
{
uint64_t k = ppc_clock_factor;
uint32_t i = ppc_clock_decrementer_value;
uint32_t c = i - PPC_SPECIAL_PURPOSE_REGISTER(PPC405_PIT);
if ((PPC_SPECIAL_PURPOSE_REGISTER(PPC405_TSR) & BOOKE_TSR_DIS) != 0) {
c = i - PPC_SPECIAL_PURPOSE_REGISTER(PPC405_PIT) + i;
}
return (uint32_t) ((c * k) >> 32);
}
void Clock_exit(void)
{
/* Set the decrementer to the maximum value */
@@ -204,15 +188,8 @@ rtems_device_driver Clock_initialize(
/*
* Set default ticker.
*
* The function rtems_clock_tick() returns a status code. This value
* will be discarded since the RTEMS documentation claims that it is
* always successful.
*/
ppc_clock_tick = (void (*)(void)) rtems_clock_tick;
/* Factor for nano seconds extension */
ppc_clock_factor = (1000000000ULL << 32) / frequency;
ppc_clock_tick = rtems_timecounter_tick;
if (ppc_cpu_is_bookE() != PPC_BOOKE_405) {
/* Decrementer value */
@@ -223,10 +200,6 @@ rtems_device_driver Clock_initialize(
ppc_clock_decrementer_value = PPC_CLOCK_DECREMENTER_MAX;
RTEMS_SYSLOG_ERROR( "decrementer value would be zero, will be set to maximum value instead\n");
}
/* Set the nanoseconds since last tick handler */
rtems_clock_set_nanoseconds_extension( ppc_clock_nanoseconds_since_last_tick);
if (ppc_cpu_is_bookE()) {
/* Set decrementer auto-reload value */
PPC_SET_SPECIAL_PURPOSE_REGISTER( BOOKE_DECAR, ppc_clock_decrementer_value);
@@ -253,9 +226,6 @@ rtems_device_driver Clock_initialize(
/* PIT interval value */
ppc_clock_decrementer_value = interval;
/* Set the nanoseconds since last tick handler */
rtems_clock_set_nanoseconds_extension(ppc_clock_nanoseconds_since_last_tick_ppc405);
/* Install exception handler */
ppc_exc_set_handler(ASM_BOOKE_DEC_VECTOR, ppc_clock_exception_handler_ppc405);
@@ -266,5 +236,12 @@ rtems_device_driver Clock_initialize(
PPC_SET_SPECIAL_PURPOSE_REGISTER(PPC405_PIT, interval);
}
/* Install timecounter */
ppc_tc.tc_get_timecount = ppc_get_timecount;
ppc_tc.tc_counter_mask = 0xffffffff;
ppc_tc.tc_frequency = frequency;
ppc_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(&ppc_tc);
return RTEMS_SUCCESSFUL;
}

View File

@@ -7,6 +7,7 @@
include: testdata/require-tick-isr.tcfg
include: testdata/disable-intrcritical-tests.tcfg
fileio
fsdosfsname01
iostream
utf8proc01

View File

@@ -6,6 +6,7 @@
include: testdata/require-tick-isr.tcfg
include: testdata/disable-intrcritical-tests.tcfg
fileio
fsdosfsname01
iostream
utf8proc01

View File

@@ -28,6 +28,8 @@ volatile bool clock_driver_enabled;
clock_driver_enabled = false; \
} while (0)
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "clockdrv_shell.h"
/*

View File

@@ -20,6 +20,10 @@
#include <bsp.h>
#include <rtems/clockdrv.h>
#ifdef Clock_driver_nanoseconds_since_last_tick
#error "Update driver to use the timecounter instead of nanoseconds extension"
#endif
/**
* @defgroup bsp_clock Clock Support
*
@@ -39,6 +43,18 @@
#define Clock_driver_support_find_timer()
#endif
/*
* A specialized clock driver may use for example rtems_timecounter_tick_simple()
* instead of the default.
*/
#ifndef Clock_driver_timecounter_tick
#ifdef CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#define Clock_driver_timecounter_tick() rtems_clock_tick()
#else
#define Clock_driver_timecounter_tick() rtems_timecounter_tick()
#endif
#endif
/**
* @brief ISRs until next clock tick
*/
@@ -78,16 +94,24 @@ rtems_isr Clock_isr(
Clock_driver_ticks += 1;
#if CLOCK_DRIVER_USE_FAST_IDLE
do {
rtems_clock_tick();
} while (
_Thread_Heir == _Thread_Executing
&& _Thread_Executing->Start.entry_point
== (Thread_Entry) rtems_configuration_get_idle_task()
);
{
struct timecounter *tc = _Timecounter;
uint64_t us_per_tick = rtems_configuration_get_microseconds_per_tick();
uint32_t interval = (uint32_t)
((tc->tc_frequency * us_per_tick) / 1000000);
Clock_driver_support_at_tick();
return;
Clock_driver_timecounter_tick();
while (
_Thread_Heir == _Thread_Executing
&& _Thread_Executing->Start.entry_point
== (Thread_Entry) rtems_configuration_get_idle_task()
) {
_Timecounter_Tick_simple(interval, (*tc->tc_get_timecount)(tc));
}
Clock_driver_support_at_tick();
}
#else
/*
* Do the hardware specific per-tick action.
@@ -101,7 +125,7 @@ rtems_isr Clock_isr(
* The driver is multiple ISRs per clock tick.
*/
if ( !Clock_driver_isrs ) {
rtems_clock_tick();
Clock_driver_timecounter_tick();
Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK;
}
@@ -110,7 +134,7 @@ rtems_isr Clock_isr(
/*
* The driver is one ISR per clock tick.
*/
rtems_clock_tick();
Clock_driver_timecounter_tick();
#endif
#endif
}
@@ -160,12 +184,6 @@ rtems_device_driver Clock_initialize(
(void) Old_ticker;
Clock_driver_support_install_isr( Clock_isr, Old_ticker );
#if defined(Clock_driver_nanoseconds_since_last_tick)
rtems_clock_set_nanoseconds_extension(
Clock_driver_nanoseconds_since_last_tick
);
#endif
/*
* Now initialize the hardware that is the source of the tick ISR.
*/

View File

@@ -25,6 +25,7 @@
#include <bsp.h>
#include <bspopts.h>
#include <rtems/counter.h>
#include <rtems/timecounter.h>
#if SIMSPARC_FAST_IDLE==1
#define CLOCK_DRIVER_USE_FAST_IDLE 1
@@ -44,24 +45,34 @@
extern int CLOCK_SPEED;
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
static rtems_timecounter_simple erc32_tc;
static uint32_t erc32_tc_get( rtems_timecounter_simple *tc )
{
uint32_t clicks;
uint32_t usecs;
clicks = ERC32_MEC.Real_Time_Clock_Counter;
if ( ERC32_Is_interrupt_pending( ERC32_INTERRUPT_REAL_TIME_CLOCK ) ) {
clicks = ERC32_MEC.Real_Time_Clock_Counter;
usecs = (2*rtems_configuration_get_microseconds_per_tick() - clicks);
} else {
usecs = (rtems_configuration_get_microseconds_per_tick() - clicks);
}
return usecs * 1000;
return ERC32_MEC.Real_Time_Clock_Counter;
}
#define Clock_driver_nanoseconds_since_last_tick \
bsp_clock_nanoseconds_since_last_tick
static bool erc32_tc_is_pending( rtems_timecounter_simple *tc )
{
return ERC32_Is_interrupt_pending( ERC32_INTERRUPT_REAL_TIME_CLOCK );
}
static uint32_t erc32_tc_get_timecount( struct timecounter *tc )
{
return rtems_timecounter_simple_downcounter_get(
tc,
erc32_tc_get,
erc32_tc_is_pending
);
}
static void erc32_tc_tick( void )
{
rtems_timecounter_simple_downcounter_tick(
&erc32_tc,
erc32_tc_get
);
}
static CPU_Counter_ticks erc32_counter_difference(
CPU_Counter_ticks second,
@@ -75,6 +86,7 @@ static CPU_Counter_ticks erc32_counter_difference(
#define Clock_driver_support_initialize_hardware() \
do { \
uint32_t frequency = 1000000; \
/* approximately 1 us per countdown */ \
ERC32_MEC.Real_Time_Clock_Scalar = CLOCK_SPEED - 1; \
ERC32_MEC.Real_Time_Clock_Counter = \
@@ -89,14 +101,22 @@ static CPU_Counter_ticks erc32_counter_difference(
ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \
ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING | \
ERC32_MEC_TIMER_COUNTER_RELOAD_AT_ZERO \
); \
rtems_timecounter_simple_install( \
&erc32_tc, \
frequency, \
rtems_configuration_get_microseconds_per_tick(), \
erc32_tc_get_timecount \
); \
_SPARC_Counter_initialize( \
&ERC32_MEC.Real_Time_Clock_Counter, \
erc32_counter_difference \
); \
rtems_counter_initialize_converter(1000000); \
rtems_counter_initialize_converter( frequency ); \
} while (0)
#define Clock_driver_timecounter_tick() erc32_tc_tick()
#define Clock_driver_support_shutdown_hardware() \
do { \
ERC32_Mask_interrupt( ERC32_INTERRUPT_REAL_TIME_CLOCK ); \

View File

@@ -24,11 +24,38 @@
#include <bsp.h>
#include <bspopts.h>
#include <rtems/timecounter.h>
#if SIMSPARC_FAST_IDLE==1
#define CLOCK_DRIVER_USE_FAST_IDLE 1
#endif
static rtems_timecounter_simple leon2_tc;
static uint32_t leon2_tc_get( rtems_timecounter_simple *tc )
{
return LEON_REG.Timer_Counter_1;
}
static bool leon2_tc_is_pending( rtems_timecounter_simple *tc )
{
return LEON_Is_interrupt_pending( LEON_INTERRUPT_TIMER1 );
}
static uint32_t leon2_tc_get_timecount( struct timecounter *tc )
{
return rtems_timecounter_simple_downcounter_get(
tc,
leon2_tc_get,
leon2_tc_is_pending
);
}
static void leon2_tc_tick( void )
{
rtems_timecounter_simple_downcounter_tick( &leon2_tc, leon2_tc_get );
}
/*
* The Real Time Clock Counter Timer uses this trap type.
*/
@@ -54,6 +81,12 @@ extern int CLOCK_SPEED;
LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO | \
LEON_REG_TIMER_COUNTER_LOAD_COUNTER \
); \
rtems_timecounter_simple_install( \
&leon2_tc, \
1000000, \
rtems_configuration_get_microseconds_per_tick(), \
leon2_tc_get_timecount \
); \
} while (0)
#define Clock_driver_support_shutdown_hardware() \
@@ -62,23 +95,6 @@ extern int CLOCK_SPEED;
LEON_REG.Timer_Control_1 = 0; \
} while (0)
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
{
uint32_t clicks;
uint32_t usecs;
clicks = LEON_REG.Timer_Counter_1;
if ( LEON_Is_interrupt_pending( LEON_INTERRUPT_TIMER1 ) ) {
clicks = LEON_REG.Timer_Counter_1;
usecs = (2*rtems_configuration_get_microseconds_per_tick() - clicks);
} else {
usecs = (rtems_configuration_get_microseconds_per_tick() - clicks);
}
return usecs * 1000;
}
#define Clock_driver_nanoseconds_since_last_tick \
bsp_clock_nanoseconds_since_last_tick
#define Clock_driver_timecounter_tick() leon2_tc_tick()
#include "../../../shared/clockdrv_shell.h"

View File

@@ -24,6 +24,7 @@
#include <rtems/rtems/intr.h>
#include <ambapp.h>
#include <rtems/score/profiling.h>
#include <rtems/timecounter.h>
/* The LEON3 BSP Timer driver can rely on the Driver Manager if the
* DrvMgr is initialized during startup. Otherwise the classic driver
@@ -40,6 +41,43 @@
/* LEON3 Timer system interrupt number */
static int clkirq;
static bool leon3_tc_use_irqmp;
static rtems_timecounter_simple leon3_tc;
static uint32_t leon3_tc_get(rtems_timecounter_simple *tc)
{
return LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].value;
}
static bool leon3_tc_is_pending(rtems_timecounter_simple *tc)
{
return LEON_Is_interrupt_pending(clkirq);
}
static uint32_t leon3_tc_get_timecount(struct timecounter *tc)
{
return rtems_timecounter_simple_downcounter_get(
tc,
leon3_tc_get,
leon3_tc_is_pending
);
}
static uint32_t leon3_tc_get_timecount_irqmp(struct timecounter *tc)
{
return LEON3_IrqCtrl_Regs->timestamp[0].counter;
}
static void leon3_tc_tick(void)
{
if (leon3_tc_use_irqmp) {
rtems_timecounter_tick();
} else {
rtems_timecounter_simple_downcounter_tick(&leon3_tc, leon3_tc_get);
}
}
static void leon3_clock_profiling_interrupt_delay(void)
{
#ifdef RTEMS_PROFILING
@@ -112,15 +150,36 @@ static void bsp_clock_handler_install(rtems_isr *new)
}
}
static void leon3_clock_initialize(void)
{
volatile struct irqmp_timestamp_regs *irqmp_ts =
&LEON3_IrqCtrl_Regs->timestamp[0];
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload =
rtems_configuration_get_microseconds_per_tick() - 1;
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].ctrl =
GPTIMER_TIMER_CTRL_EN | GPTIMER_TIMER_CTRL_RS |
GPTIMER_TIMER_CTRL_LD | GPTIMER_TIMER_CTRL_IE;
if (leon3_irqmp_has_timestamp(irqmp_ts)) {
leon3_tc.tc.tc_get_timecount = leon3_tc_get_timecount_irqmp;
leon3_tc.tc.tc_counter_mask = 0xffffffff;
leon3_tc.tc.tc_frequency = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev);
leon3_tc.tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
leon3_tc_use_irqmp = true;
rtems_timecounter_install(&leon3_tc.tc);
} else {
rtems_timecounter_simple_install(
&leon3_tc,
LEON3_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER,
rtems_configuration_get_microseconds_per_tick(),
leon3_tc_get_timecount
);
}
}
#define Clock_driver_support_initialize_hardware() \
do { \
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = \
rtems_configuration_get_microseconds_per_tick() - 1; \
\
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].ctrl = \
GPTIMER_TIMER_CTRL_EN | GPTIMER_TIMER_CTRL_RS | \
GPTIMER_TIMER_CTRL_LD | GPTIMER_TIMER_CTRL_IE; \
} while (0)
leon3_clock_initialize()
#define Clock_driver_support_shutdown_hardware() \
do { \
@@ -128,27 +187,7 @@ static void bsp_clock_handler_install(rtems_isr *new)
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].ctrl = 0; \
} while (0)
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
{
uint32_t clicks;
uint32_t usecs;
if ( !LEON3_Timer_Regs )
return 0;
clicks = LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].value;
if ( LEON_Is_interrupt_pending( clkirq ) ) {
clicks = LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].value;
usecs = (2*rtems_configuration_get_microseconds_per_tick() - clicks);
} else {
usecs = (rtems_configuration_get_microseconds_per_tick() - clicks);
}
return usecs * 1000;
}
#define Clock_driver_nanoseconds_since_last_tick \
bsp_clock_nanoseconds_since_last_tick
#define Clock_driver_timecounter_tick() leon3_tc_tick()
#include "../../../shared/clockdrv_shell.h"

View File

@@ -114,5 +114,7 @@ static void Clock_driver_support_initialize_hardware(void)
\
} while ( 0 )
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../shared/clockdrv_shell.h"

View File

@@ -22,8 +22,6 @@
#include <at91rm9200.h>
#include <at91rm9200_pmc.h>
static unsigned long st_pimr_reload;
/**
* Enables clock interrupt.
*
@@ -77,17 +75,16 @@ rtems_irq_connect_data clock_isr_data = {
BSP_install_rtems_irq_handler(&clock_isr_data); \
} while(0)
uint16_t st_pimr_value;
static void Clock_driver_support_initialize_hardware(void)
{
uint32_t st_str;
int slck;
unsigned long value;
/* the system timer is driven from SLCK */
slck = at91rm9200_get_slck();
st_pimr_value = (((rtems_configuration_get_microseconds_per_tick() * slck) +
value = (((rtems_configuration_get_microseconds_per_tick() * slck) +
(1000000/2))/ 1000000);
st_pimr_reload = st_pimr_value;
/* read the status to clear the int */
st_str = ST_REG(ST_SR);
@@ -97,21 +94,9 @@ static void Clock_driver_support_initialize_hardware(void)
AIC_SMR_REG(AIC_SMR_SYSIRQ) = AIC_SMR_PRIOR(0x7);
/* set the timer value */
ST_REG(ST_PIMR) = st_pimr_reload;
ST_REG(ST_PIMR) = value;
}
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
{
uint16_t slck_counts;
slck_counts = st_pimr_value - st_pimr_reload;
return (rtems_configuration_get_microseconds_per_tick() * slck_counts * 1000)
/ st_pimr_value;
}
#define Clock_driver_nanoseconds_since_last_tick \
bsp_clock_nanoseconds_since_last_tick
#define Clock_driver_support_at_tick() \
do { \
uint32_t st_str; \
@@ -126,4 +111,6 @@ static void Clock_driver_support_shutdown_hardware( void )
BSP_remove_rtems_irq_handler(&clock_isr_data);
}
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../../libbsp/shared/clockdrv_shell.h"

View File

@@ -17,12 +17,39 @@
#include <bsp/irq.h>
#include <lpc22xx.h>
#include <rtems/bspIo.h> /* for printk */
#include <rtems/timecounter.h>
void Clock_isr(rtems_irq_hdl_param arg);
static void clock_isr_on(const rtems_irq_connect_data *unused);
static void clock_isr_off(const rtems_irq_connect_data *unused);
static int clock_isr_is_on(const rtems_irq_connect_data *irq);
static rtems_timecounter_simple lpc22xx_tc;
static uint32_t lpc22xx_tc_get(rtems_timecounter_simple *tc)
{
return T0TC;
}
static bool lpc22xx_tc_is_pending(rtems_timecounter_simple *tc)
{
return (T0IR & 0x1) != 0;
}
static uint32_t lpc22xx_tc_get_timecount(struct timecounter *tc)
{
return rtems_timecounter_simple_upcounter_get(
tc,
lpc22xx_tc_get,
lpc22xx_tc_is_pending
);
}
static void lpc22xx_tc_tick(void)
{
rtems_timecounter_simple_upcounter_tick(&lpc22xx_tc, lpc22xx_tc_get);
}
/* Replace the first value with the clock's interrupt name. */
rtems_irq_connect_data clock_isr_data = {
.name = LPC22xx_INTERRUPT_TIMER0,
@@ -76,7 +103,7 @@ rtems_irq_connect_data clock_isr_data = {
do { \
/* disable and clear timer 0, set to */ \
T0TCR &= 0; \
/* TC is incrementet on every pclk.*/ \
/* TC is incremented on every pclk.*/ \
T0PC = 0; \
/* initialize the timer period and prescaler */ \
T0MR0 = ((LPC22xx_Fpclk/1000 * \
@@ -89,6 +116,13 @@ rtems_irq_connect_data clock_isr_data = {
T0TCR = 1; \
/* enable interrupt, skyeye will check this*/ \
T0IR |= 0x01; \
/* install timecounter */ \
rtems_timecounter_simple_install( \
&lpc22xx_tc, \
LPC22xx_Fpclk, \
T0MR0, \
lpc22xx_tc_get_timecount \
); \
} while (0)
/**
@@ -104,20 +138,6 @@ rtems_irq_connect_data clock_isr_data = {
BSP_remove_rtems_irq_handler(&clock_isr_data); \
} while (0)
static uint32_t bsp_clock_nanoseconds_since_last_tick(void)
{
uint32_t clicks;
uint32_t microseconds;
clicks = T0TC; /* T0TC is the 32bit time counter 0 */
microseconds = (rtems_configuration_get_microseconds_per_tick() - clicks);
return microseconds * 1000;
}
#define Clock_driver_nanoseconds_since_last_tick \
bsp_clock_nanoseconds_since_last_tick
/**
* Enables clock interrupt.
*
@@ -149,6 +169,8 @@ static int clock_isr_is_on(const rtems_irq_connect_data *irq)
return T0IR & 0x01; /* MR0 mask */
}
#define Clock_driver_timecounter_tick() lpc22xx_tc_tick()
/* Make sure to include this, and only at the end of the file */
#include "../../../../libbsp/shared/clockdrv_shell.h"

View File

@@ -130,5 +130,8 @@ static int clock_isr_is_on(const rtems_irq_connect_data *irq)
return MC9328MXL_TMR1_TCTL & MC9328MXL_TMR_TCTL_IRQEN;
}
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
/* Make sure to include this, and only at the end of the file */
#include "../../../../libbsp/shared/clockdrv_shell.h"

View File

@@ -116,4 +116,6 @@ static void Clock_driver_support_shutdown_hardware( void )
BSP_remove_rtems_irq_handler(&clock_isr_data);
}
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
#include "../../../../libbsp/shared/clockdrv_shell.h"

View File

@@ -27,17 +27,6 @@ rtems_irq_connect_data clock_isr_data = {
.isOn = clock_isr_is_on,
};
/**
* Return the nanoseconds since last tick
*/
static uint32_t clock_driver_get_nanoseconds_since_last_tick(void)
{
return 0;
}
#define Clock_driver_nanoseconds_since_last_tick \
clock_driver_get_nanoseconds_since_last_tick
/**
* When we get the clock interrupt
* - clear the interrupt bit?
@@ -131,5 +120,7 @@ static int clock_isr_is_on(const rtems_irq_connect_data *irq)
return 1;
}
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
/* Make sure to include this, and only at the end of the file */
#include "../../../../libbsp/shared/clockdrv_shell.h"

View File

@@ -29,6 +29,7 @@
#include <libcpu/spr.h>
#include <rtems/bspIo.h> /* for printk() */
#include <libcpu/powerpc-utility.h>
#include <rtems/timecounter.h>
#include <bspopts.h> /* for CLOCK_DRIVER_USE_FAST_IDLE */
@@ -48,11 +49,12 @@ volatile uint32_t Clock_driver_ticks;
*/
static uint32_t Clock_Decrementer_value;
/*
* This is the value by which elapsed count down timer ticks are multiplied to
* give an elapsed duration in nanoseconds, left-shifted by 32 bits
*/
static uint64_t Clock_Decrementer_reference;
static struct timecounter Clock_TC;
static uint32_t Clock_Get_timecount(struct timecounter *tc)
{
return ppc_time_base();
}
void clockOff(void* unused)
{
@@ -94,16 +96,27 @@ void clockOn(void* unused)
static void clockHandler(void)
{
#if (CLOCK_DRIVER_USE_FAST_IDLE == 1)
do {
rtems_clock_tick();
} while (
rtems_interrupt_level level;
uint32_t tb;
rtems_interrupt_disable(level);
tb = ppc_time_base();
rtems_timecounter_tick();
while (
_Thread_Heir == _Thread_Executing
&& _Thread_Executing->Start.entry_point
== (Thread_Entry) rtems_configuration_get_idle_task()
);
) {
tb += Clock_Decrementer_value;
ppc_set_time_base( tb );
rtems_timecounter_tick();
}
rtems_interrupt_enable(level);
#else
rtems_clock_tick();
rtems_timecounter_tick();
#endif
}
@@ -141,7 +154,6 @@ void clockIsr(void *unused)
rtems_interrupt_enable(flags);
Clock_driver_ticks += 1;
/*
* Real Time Clock counter/timer is set to automatically reload.
*/
@@ -187,7 +199,6 @@ int clockIsOn(void* unused)
return 0;
}
/*
* Clock_exit
*
@@ -199,53 +210,6 @@ void Clock_exit( void )
(void) BSP_disconnect_clock_handler ();
}
static uint32_t Clock_driver_nanoseconds_since_last_tick(void)
{
uint32_t clicks, tmp;
PPC_Get_decrementer( clicks );
/*
* Multiply by 1000 here separately from below so we do not overflow
* and get a negative value.
*/
tmp = (Clock_Decrementer_value - clicks) * 1000;
tmp /= (BSP_bus_frequency/BSP_time_base_divisor);
return tmp * 1000;
}
static uint32_t Clock_driver_nanoseconds_since_last_tick_bookE(void)
{
uint32_t clicks;
uint64_t c;
PPC_Get_decrementer( clicks );
c = Clock_Decrementer_value - clicks;
/*
* Check whether a clock tick interrupt is pending and hence that the
* decrementer's wrapped. If it has, we'll compensate by returning a time one
* tick period longer.
*
* We have to check interrupt status after reading the decrementer. If we
* don't, we may miss an interrupt and read a wrapped decrementer value
* without compensating for it
*/
if ( _read_BOOKE_TSR() & BOOKE_TSR_DIS )
{
/*
* Re-read the decrementer: The tick interrupt may have been
* generated and the decrementer wrapped during the time since we
* last read it and the time we checked the interrupt status
*/
PPC_Get_decrementer( clicks );
c = (Clock_Decrementer_value - clicks) + Clock_Decrementer_value;
}
return (uint32_t)((c * Clock_Decrementer_reference) >> 32);
}
/*
* Clock_initialize
*
@@ -262,9 +226,6 @@ rtems_device_driver Clock_initialize(
Clock_Decrementer_value = (BSP_bus_frequency/BSP_time_base_divisor)*
rtems_configuration_get_milliseconds_per_tick();
Clock_Decrementer_reference = ((uint64_t)1000000U<<32)/
(BSP_bus_frequency/BSP_time_base_divisor);
/* set the decrementer now, prior to installing the handler
* so no interrupts will happen in a while.
*/
@@ -283,23 +244,13 @@ rtems_device_driver Clock_initialize(
_write_BOOKE_TCR(tcr);
rtems_interrupt_enable(l);
}
/*
* Set the nanoseconds since last tick handler
*/
rtems_clock_set_nanoseconds_extension(
Clock_driver_nanoseconds_since_last_tick_bookE
);
}
else
{
/*
* Set the nanoseconds since last tick handler
*/
rtems_clock_set_nanoseconds_extension(
Clock_driver_nanoseconds_since_last_tick
);
}
Clock_TC.tc_get_timecount = Clock_Get_timecount;
Clock_TC.tc_counter_mask = 0xffffffff;
Clock_TC.tc_frequency = (1000 * BSP_bus_frequency) / BSP_time_base_divisor;
Clock_TC.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(&Clock_TC);
/*
* If a decrementer exception was pending, it is cleared by

View File

@@ -453,6 +453,7 @@ score/cpu/Makefile
score/cpu/arm/Makefile
score/cpu/bfin/Makefile
score/cpu/avr/Makefile
score/cpu/epiphany/Makefile
score/cpu/h8300/Makefile
score/cpu/i386/Makefile
score/cpu/lm32/Makefile

Some files were not shown because too many files have changed in this diff Show More