2004-08-02 Jay Monkman <jtm@lopingdog.com>

* Makefile.am, configure.ac: Added CSB360 BSP
	* mcf5272/.cvsignore, mcf5272/ChangeLog, mcf5272/Makefile.am,
	mcf5272/clock/.cvsignore, mcf5272/clock/ckinit.c,
	mcf5272/include/.cvsignore, mcf5272/include/mcf5272.h,
	mcf5272/timer/.cvsignore, mcf5272/timer/timer.c,
	mcf5272/timer/timerisr.S: New files.
This commit is contained in:
Jay Monkman
2004-08-03 04:59:11 +00:00
parent cf862059ff
commit 3cfd52051f
13 changed files with 1275 additions and 1 deletions
+9
View File
@@ -1,3 +1,12 @@
2004-08-02 Jay Monkman <jtm@lopingdog.com>
* Makefile.am, configure.ac: Added CSB360 BSP
* mcf5272/.cvsignore, mcf5272/ChangeLog, mcf5272/Makefile.am,
mcf5272/clock/.cvsignore, mcf5272/clock/ckinit.c,
mcf5272/include/.cvsignore, mcf5272/include/mcf5272.h,
mcf5272/timer/.cvsignore, mcf5272/timer/timer.c,
mcf5272/timer/timerisr.S: New files.
2004-04-02 Ralf Corsepius <ralf_corsepius@rtems.org>
* mcf5206/timer/timerisr.S: Include <rtems/asm.h> instead of <asm.h>.
+1 -1
View File
@@ -4,7 +4,7 @@
ACLOCAL_AMFLAGS = -I ../../../aclocal
SUBDIRS = shared m68040 mcf5206
SUBDIRS = shared m68040 mcf5206 mcf5272
include $(top_srcdir)/../../../automake/subdirs.am
include $(top_srcdir)/../../../automake/local.am
+1
View File
@@ -48,5 +48,6 @@ AC_CONFIG_FILES([Makefile
shared/Makefile
m68040/Makefile
mcf5206/Makefile
mcf5272/Makefile
])
AC_OUTPUT
+14
View File
@@ -0,0 +1,14 @@
aclocal.m4
autom4te*.cache
config.cache
config.guess
config.log
config.status
config.sub
configure
depcomp
install-sh
Makefile
Makefile.in
missing
mkinstalldirs
+6
View File
@@ -0,0 +1,6 @@
2004-08-02 Jay Monkman <jtm@lopingdog.com>
* .cvsignore, ChangeLog, Makefile.am, clock/.cvsignore, clock/ckinit.c,
include/.cvsignore, include/mcf5272.h, timer/.cvsignore,
timer/timer.c, timer/timerisr.S: New files.
+83
View File
@@ -0,0 +1,83 @@
##
## $Id$
##
include $(top_srcdir)/../../../automake/compile.am
CLEANFILES =
EXTRA_PROGRAMS =
noinst_DATA =
if mcf5272
# include
include_mcf5272dir = $(includedir)/mcf5272
include_mcf5272_HEADERS = include/mcf5272.h
## clock
EXTRA_PROGRAMS += clock.rel
CLEANFILES += clock.rel
clock_rel_SOURCES = clock/ckinit.c
clock_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_OPTIMIZE_V)
clock_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
EXTRA_PROGRAMS += clock_g.rel
CLEANFILES += clock_g.rel
clock_g_rel_SOURCES = $(clock_rel_SOURCES)
clock_g_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_DEBUG_V)
clock_g_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
noinst_DATA += clock$(LIB_VARIANT).rel
## console
#EXTRA_PROGRAMS += console.rel
#CLEANFILES += console.rel
#console_rel_SOURCES = console/console-io.c ../../../../libbsp/shared/console-polled.c
#console_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_OPTIMIZE_V)
#console_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
#EXTRA_PROGRAMS += console_g.rel
#CLEANFILES += console_g.rel
#console_g_rel_SOURCES = $(console_rel_SOURCES)
#console_g_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_DEBUG_V)
#console_g_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
#
#noinst_DATA += console$(LIB_VARIANT).rel
## timer
EXTRA_PROGRAMS += timer.rel
CLEANFILES += timer.rel
timer_rel_SOURCES = timer/timer.c timer/timerisr.S
timer_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_OPTIMIZE_V)
timer_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
EXTRA_PROGRAMS += timer_g.rel
CLEANFILES += timer_g.rel
timer_g_rel_SOURCES = $(timer_rel_SOURCES)
timer_g_rel_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAGS_DEBUG_V)
timer_g_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
noinst_DATA += timer$(LIB_VARIANT).rel
endif
all-local: $(PREINSTALL_FILES)
PREINSTALL_DIRS =
PREINSTALL_FILES =
if mcf5272
$(PROJECT_INCLUDE)/mcf5272/$(dirstamp):
@$(mkdir_p) $(PROJECT_INCLUDE)/mcf5272
@: > $(PROJECT_INCLUDE)/mcf5272/$(dirstamp)
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/mcf5272/$(dirstamp)
$(PROJECT_INCLUDE)/mcf5272/mcf5272.h: include/mcf5272.h $(PROJECT_INCLUDE)/mcf5272/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/mcf5272/mcf5272.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/mcf5272/mcf5272.h
endif
CLEANFILES += $(PREINSTALL_FILES)
DISTCLEANFILES = $(PREINSTALL_DIRS)
include $(top_srcdir)/../../../automake/local.am
@@ -0,0 +1,2 @@
Makefile
Makefile.in
@@ -0,0 +1,226 @@
/*
* Clock Driver for MCF5272 CPU
*
* This driver initailizes timer1 on the MCF5272 as the
* main system clock
*
* Copyright 2004 Cogent Computer Systems
* Author: Jay Monkman <jtm@lopingdog.com>
*
* Based on MCF5206 clock driver by
* Victor V. Vengerov <vvv@oktet.ru>
*
* Based on work:
* David Fiddes, D.J@fiddes.surfaid.org
* http://www.calm.hw.ac.uk/davidf/coldfire/
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.OARcorp.com/rtems/license.html.
*
* ckinit.c,v 1.1 2001/10/26 19:32:40 joel Exp
*/
#include <stdlib.h>
#include <bsp.h>
#include <rtems/libio.h>
#include <mcf5272/mcf5272.h>
/*
* Clock_driver_ticks is a monotonically increasing counter of the
* number of clock ticks since the driver was initialized.
*/
volatile rtems_unsigned32 Clock_driver_ticks;
/*
* These are set by clock driver during its init
*/
rtems_device_major_number rtems_clock_major = ~0;
rtems_device_minor_number rtems_clock_minor;
rtems_isr (*rtems_clock_hook)(rtems_vector_number) = NULL;
/* Clock_isr --
* This handles the timer interrupt by clearing the timer's interrupt
* flag and announcing the clock tick to the system.
*
* PARAMETERS:
* vector - timer interrupt vector number
* RETURNS:
* none
*/
rtems_isr
Clock_isr (rtems_vector_number vector)
{
/* Clear pending interrupt... */
g_timer_regs->ter1 = MCF5272_TER_REF | MCF5272_TER_CAP;
/* Announce the clock tick */
Clock_driver_ticks++;
rtems_clock_tick();
if (rtems_clock_hook != NULL) {
rtems_clock_hook(vector);
}
}
/* Clock_exit --
* This shuts down the timer if it was enabled and removes it
* from the MCF5206E interrupt mask.
*
* PARAMETERS:
* none
*
* RETURNS:
* none
*/
void
Clock_exit(void)
{
if (BSP_Configuration.ticks_per_timeslice) {
unsigned32 icr;
/* disable all timer1 interrupts */
icr = g_intctrl_regs->icr1;
icr = icr & ~(MCF5272_ICR1_TMR1_MASK | MCF5272_ICR1_TMR1_PI);
icr |= (MCF5272_ICR1_TMR1_IPL(0) | MCF5272_ICR1_TMR1_PI);
g_intctrl_regs->icr1 = icr;
/* reset timer1 */
g_timer_regs->tmr1 = MCF5272_TMR_CLK_STOP;
/* clear pending */
g_timer_regs->ter1 = MCF5272_TER_REF | MCF5272_TER_CAP;
}
}
/* Install_clock --
* This initialises timer1 with the BSP timeslice config value
* as a reference and sets up the interrupt handler for clock ticks.
*
* PARAMETERS:
* clock_isr - clock interrupt handler routine
*
* RETURNS:
* none.
*/
static void
Install_clock(rtems_isr_entry clock_isr)
{
unsigned32 icr;
Clock_driver_ticks = 0;
if (BSP_Configuration.ticks_per_timeslice) {
/* Register the interrupt handler */
set_vector(clock_isr, BSP_INTVEC_TMR1, 1);
/* Reset timer 1 */
g_timer_regs->tmr1 = MCF5272_TMR_RST;
g_timer_regs->tmr1 = MCF5272_TMR_CLK_STOP;
g_timer_regs->tmr1 = MCF5272_TMR_RST;
g_timer_regs->tcn1 = 0; /* reset counter */
g_timer_regs->ter1 = MCF5272_TER_REF | MCF5272_TER_CAP;
/* Set Timer 1 prescaler so that it counts in microseconds */
g_timer_regs->tmr1 = (
((((BSP_SYSTEM_FREQUENCY / 1000000) - 1) << MCF5272_TMR_PS_SHIFT) |
MCF5272_TMR_CE_DISABLE |
MCF5272_TMR_ORI |
MCF5272_TMR_FRR |
MCF5272_TMR_CLK_MSTR |
MCF5272_TMR_RST));
/* Set the timer timeout value from the BSP config */
g_timer_regs->trr1 = BSP_Configuration.microseconds_per_tick - 1;
/* Feed system frequency to the timer */
g_timer_regs->tmr1 |= MCF5272_TMR_CLK_MSTR;
/* Configure timer1 interrupts */
icr = g_intctrl_regs->icr1;
icr = icr & ~(MCF5272_ICR1_TMR1_MASK | MCF5272_ICR1_TMR1_PI);
icr |= (MCF5272_ICR1_TMR1_IPL(BSP_INTLVL_TMR1) | MCF5272_ICR1_TMR1_PI);
g_intctrl_regs->icr1 = icr;
/* Register the driver exit procedure so we can shutdown */
atexit(Clock_exit);
}
}
/* Clock_initialize --
* This is called to setup the clock driver. It calls the hardware
* setup function and make the driver major/minor values available
* for other.
*
* PARAMETERS:
* major - clock device major number
* minor - clock device minor number
* pargp - device driver initialization argument (not used)
*
* RETURNS:
* RTEMS status code
*/
rtems_device_driver
Clock_initialize(rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp)
{
Install_clock (Clock_isr);
/* Make major/minor avail to others such as shared memory driver */
rtems_clock_major = major;
rtems_clock_minor = minor;
return RTEMS_SUCCESSFUL;
}
/* Clock_control --
* I/O control (IOCTL) function for Clock driver. At this moment this
* just runs the interrupt handler or re-registers the interrupt handler
* on request.
*
* PARAMETERS:
* major - clock major device number
* minor - clock minor device number
* pargp - pointer to IOCTL arguments
*
* RETURNS:
* RTEMS status code
*/
rtems_device_driver
Clock_control(rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp)
{
rtems_unsigned32 isrlevel;
rtems_libio_ioctl_args_t *args = pargp;
if (args)
{
/*
* This is hokey, but until we get a defined interface
* to do this, it will just be this simple...
*/
if (args->command == rtems_build_name('I', 'S', 'R', ' '))
{
Clock_isr(BSP_INTVEC_TMR1);
}
else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
{
rtems_interrupt_disable( isrlevel );
(void) set_vector( args->buffer, BSP_INTVEC_TMR1, 1 );
rtems_interrupt_enable( isrlevel );
}
}
return RTEMS_SUCCESSFUL;
}
@@ -0,0 +1,2 @@
Makefile
Makefile.in
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,2 @@
Makefile
Makefile.in
+177
View File
@@ -0,0 +1,177 @@
/*
* Timer Init
*
* This module initializes TIMER 2 for on the MCF5272 for benchmarks.
*
* Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia
* Author: Victor V. Vengerov <vvv@oktet.ru>
*
* Based on work:
* Author:
* David Fiddes, D.J@fiddes.surfaid.org
* http://www.calm.hw.ac.uk/davidf/coldfire/
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.OARcorp.com/rtems/license.html.
*
* timer.c,v 1.1 2001/10/26 19:32:40 joel Exp
*/
#include <rtems.h>
#include <bsp.h>
#include <mcf5272/mcf5272.h>
#define TRR2_VAL 65530
rtems_unsigned32 Timer_interrupts;
rtems_boolean Timer_driver_Find_average_overhead;
/* External assembler interrupt handler routine */
extern rtems_isr timerisr(rtems_vector_number vector);
/* Timer_initialize --
* Initialize timer 2 for accurate time measurement.
*
* PARAMETERS:
* none
*
* RETURNS:
* none
*/
void
Timer_initialize(void)
{
unsigned32 icr;
/* Catch timer2 interrupts */
set_vector(timerisr, BSP_INTVEC_TMR2, 0);
/* Reset Timer */
g_timer_regs->tmr2 = MCF5272_TMR_RST;
g_timer_regs->tmr2 = MCF5272_TMR_CLK_STOP;
g_timer_regs->tmr2 = MCF5272_TMR_RST;
g_timer_regs->tcn2 = 0; /* reset counter */
Timer_interrupts = 0; /* Clear timer ISR counter */
g_timer_regs->ter2 = MCF5272_TER_REF | MCF5272_TER_CAP;
g_timer_regs->trr2 = TRR2_VAL -1 ;
/* Set Timer 2 prescaler so that it counts in microseconds */
g_timer_regs->tmr2 = (
(((BSP_SYSTEM_FREQUENCY / 1000000) - 1) << MCF5272_TMR_PS_SHIFT) |
MCF5272_TMR_CE_DISABLE |
MCF5272_TMR_ORI |
MCF5272_TMR_FRR |
MCF5272_TMR_CLK_MSTR |
MCF5272_TMR_RST);
/* Initialize interrupts for timer2 */
icr = g_intctrl_regs->icr1;
icr = icr & ~(MCF5272_ICR1_TMR2_MASK | MCF5272_ICR1_TMR2_PI);
icr |= (MCF5272_ICR1_TMR2_IPL(BSP_INTLVL_TMR2) | MCF5272_ICR1_TMR2_PI);
g_intctrl_regs->icr1 = icr;
}
/*
* The following controls the behavior of Read_timer().
*
* FIND_AVG_OVERHEAD * instructs the routine to return the "raw" count.
*
* 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 2.0 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 */
/* Read_timer --
* Read timer value in microsecond units since timer start.
*
* PARAMETERS:
* none
*
* RETURNS:
* number of microseconds since timer has been started
*/
int
Read_timer( void )
{
rtems_unsigned16 clicks;
rtems_unsigned32 total;
/*
* Read the timer and see how many clicks it has been since counter
* rolled over.
*/
clicks = g_timer_regs->tcn2;
/* Stop Timer... */
g_timer_regs->tmr2 = MCF5272_TMR_CLK_STOP | MCF5272_TMR_RST;
/*
* Total is calculated by taking into account the number of timer
* overflow interrupts since the timer was initialized and clicks
* since the last interrupts.
*/
total = (Timer_interrupts * TRR2_VAL) + clicks;
if ( Timer_driver_Find_average_overhead == 1 )
return total; /* in XXX microsecond units */
if ( total < LEAST_VALID )
return 0; /* below timer resolution */
/*
* Return the count in microseconds
*/
return (total - AVG_OVERHEAD);
}
/* Empty_function --
* Empty function call used in loops to measure basic cost of looping
* in Timing Test Suite.
*
* PARAMETERS:
* none
*
* RETURNS:
* RTEMS_SUCCESSFUL
*/
rtems_status_code
Empty_function(void)
{
return RTEMS_SUCCESSFUL;
}
/* Set_find_average_overhead --
* This routine is invoked by the "Check Timer" (tmck) test in the
* RTEMS Timing Test Suite. It makes the Read_timer routine not
* subtract the overhead required to initialize and read the benchmark
* timer.
*
* PARAMETERS:
* find_flag - boolean flag, TRUE if overhead must not be subtracted.
*
* RETURNS:
* none
*/
void
Set_find_average_overhead(rtems_boolean find_flag)
{
Timer_driver_Find_average_overhead = find_flag;
}
@@ -0,0 +1,50 @@
/*
* Handle MCF5272 TIMER2 interrupts.
*
* All code in this routine is pure overhead which can perturb the
* accuracy of RTEMS' timing test suite.
*
* See also: Read_timer()
*
* To reduce overhead this is best to be the "rawest" hardware interupt
* handler you can write. This should be the only interrupt which can
* occur during the measured time period.
*
* An external counter, Timer_interrupts, is incremented.
*
* Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia
* Author: Victor V. Vengerov <vvv@oktet.ru>
*
* This file based on work:
* Author:
* David Fiddes, D.J@fiddes.surfaid.org
* http://www.calm.hw.ac.uk/davidf/coldfire/
*
* COPYRIGHT (c) 1989-1998.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
*
* http://www.OARcorp.com/rtems/license.html.
*
* timerisr.S,v 1.1 2001/10/26 19:32:40 joel Exp
*/
#include "asm.h"
#include "bsp.h"
/*
#include "mcf5272/mcf5272.h"
*/
BEGIN_CODE
PUBLIC(timerisr)
SYM(timerisr):
move.l a0, a7@-
move.b # (MCF5272_TER_REF + MCF5272_TER_CAP), (a0)
addq.l #1,SYM(Timer_interrupts) | increment timer value
move.l a7@+, a0
rte
END_CODE
END