2009-02-25 Joel Sherrill <joel.sherrill@oarcorp.com>

* shared/clock/ckinit.c: Use shared Clock Driver Template and support
	fast idle on simulator.
This commit is contained in:
Joel Sherrill
2009-02-25 21:32:53 +00:00
parent 4ce40845d3
commit 0b05a31d2e
2 changed files with 24 additions and 117 deletions

View File

@@ -1,3 +1,8 @@
2009-02-25 Joel Sherrill <joel.sherrill@oarcorp.com>
* shared/clock/ckinit.c: Use shared Clock Driver Template and support
fast idle on simulator.
2008-12-05 Joel Sherrill <joel.sherrill@oarcorp.com> 2008-12-05 Joel Sherrill <joel.sherrill@oarcorp.com>
* .cvsignore: New file. * .cvsignore: New file.

View File

@@ -2,7 +2,7 @@
* *
* Clock device driver for Lattice Mico32 (lm32). * Clock device driver for Lattice Mico32 (lm32).
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -15,12 +15,14 @@
* Micro-Research Finland Oy * Micro-Research Finland Oy
*/ */
#include <stdlib.h>
#include <rtems.h>
#include <bsp.h> #include <bsp.h>
#include "../include/system_conf.h" #include "../include/system_conf.h"
#include "clock.h" #include "clock.h"
#include "bspopts.h"
#if SIMULATOR_FAST_IDLE
#define CLOCK_DRIVER_USE_FAST_IDLE
#endif
static inline int clockread(unsigned int reg) static inline int clockread(unsigned int reg)
{ {
@@ -32,11 +34,6 @@ static inline void clockwrite(unsigned int reg, int value)
*((int*)(TIMER0_BASE_ADDRESS + reg)) = value; *((int*)(TIMER0_BASE_ADDRESS + reg)) = value;
} }
void Clock_exit( void );
rtems_isr Clock_isr( rtems_vector_number vector );
extern lm32_isr_entry set_vector(rtems_isr_entry handler,
rtems_vector_number vector, int type);
/* /*
* The interrupt vector number associated with the clock tick device * The interrupt vector number associated with the clock tick device
* driver. * driver.
@@ -45,82 +42,20 @@ extern lm32_isr_entry set_vector(rtems_isr_entry handler,
#define CLOCK_VECTOR ( TIMER0_IRQ ) #define CLOCK_VECTOR ( TIMER0_IRQ )
#define CLOCK_IRQMASK ( 1 << CLOCK_VECTOR ) #define CLOCK_IRQMASK ( 1 << CLOCK_VECTOR )
/* #define Clock_driver_support_at_tick() \
* Clock_driver_ticks is a monotonically increasing counter of the do { \
* number of clock ticks since the driver was initialized. /* Clear overflow flag */ \
*/ clockwrite(LM32_CLOCK_SR, 0); \
lm32_interrupt_ack(CLOCK_IRQMASK); \
} while (0)
volatile uint32_t Clock_driver_ticks; #define Clock_driver_support_install_isr(_new, _old ) \
do { \
_old = (rtems_isr_entry) set_vector( _new, CLOCK_VECTOR, 1 ); \
} while (0)
/* void Clock_driver_support_initialize_hardware(void)
* These are set by clock driver during its init
*/
rtems_device_major_number rtems_clock_major = ~0;
rtems_device_minor_number rtems_clock_minor;
/*
* The previous ISR on this clock tick interrupt vector.
*/
rtems_isr_entry Old_ticker;
void Clock_exit( void );
/*
* Isr Handler
*/
rtems_isr Clock_isr(
rtems_vector_number vector
)
{ {
/*
* bump the number of clock driver ticks since initialization
*
* determine if it is time to announce the passing of tick as configured
* to RTEMS through the rtems_clock_tick directive
*
* perform any timer dependent tasks
*/
/* Clear overflow flag */
clockwrite(LM32_CLOCK_SR, 0);
lm32_interrupt_ack(CLOCK_IRQMASK);
/* Increment clock ticks */
Clock_driver_ticks += 1;
rtems_clock_tick();
}
/*
* Install_clock
*
* Install a clock tick handler and reprograms the chip. This
* is used to initially establish the clock tick.
*/
void Install_clock(
rtems_isr_entry clock_isr
)
{
/*
* Initialize the clock tick device driver variables
*/
Clock_driver_ticks = 0;
Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
/*
* Hardware specific initialize goes here
*/
printk("rtems_configuration_get_microseconds_per_tick() %d\n",
rtems_configuration_get_microseconds_per_tick());
printk("PERIOD %d\n",
(CPU_FREQUENCY / (1000000 / rtems_configuration_get_microseconds_per_tick())));
/* Set clock period */ /* Set clock period */
clockwrite(LM32_CLOCK_PERIOD, clockwrite(LM32_CLOCK_PERIOD,
(CPU_FREQUENCY / (CPU_FREQUENCY /
@@ -132,19 +67,9 @@ void Install_clock(
LM32_CLOCK_CR_START); LM32_CLOCK_CR_START);
lm32_interrupt_unmask(CLOCK_IRQMASK); lm32_interrupt_unmask(CLOCK_IRQMASK);
/*
* Schedule the clock cleanup routine to execute if the application exits.
*/
atexit( Clock_exit );
} }
/* void Clock_driver_support_shutdown_hardware(void)
* Clean up before the application exits
*/
void Clock_exit( void )
{ {
/* Disable clock interrupts and stop */ /* Disable clock interrupts and stop */
@@ -152,28 +77,5 @@ void Clock_exit( void )
clockwrite(LM32_CLOCK_CR, LM32_CLOCK_CR_STOP); clockwrite(LM32_CLOCK_CR, LM32_CLOCK_CR_STOP);
} }
/* #include "../../../shared/clockdrv_shell.h"
* Clock_initialize
*
* Device driver entry point for clock tick driver initialization.
*/
rtems_device_driver Clock_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp
)
{
printk("Clock initialize %d %d\n", major, minor);
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;
}