From 0b05a31d2ef7287e75ef870bd2cb16c4fce851a8 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 25 Feb 2009 21:32:53 +0000 Subject: 2009-02-25 Joel Sherrill * shared/clock/ckinit.c: Use shared Clock Driver Template and support fast idle on simulator. --- c/src/lib/libbsp/lm32/ChangeLog | 5 + c/src/lib/libbsp/lm32/shared/clock/ckinit.c | 136 ++++------------------------ 2 files changed, 24 insertions(+), 117 deletions(-) (limited to 'c') diff --git a/c/src/lib/libbsp/lm32/ChangeLog b/c/src/lib/libbsp/lm32/ChangeLog index 63dc383d6d..80d691d8e6 100644 --- a/c/src/lib/libbsp/lm32/ChangeLog +++ b/c/src/lib/libbsp/lm32/ChangeLog @@ -1,3 +1,8 @@ +2009-02-25 Joel Sherrill + + * shared/clock/ckinit.c: Use shared Clock Driver Template and support + fast idle on simulator. + 2008-12-05 Joel Sherrill * .cvsignore: New file. diff --git a/c/src/lib/libbsp/lm32/shared/clock/ckinit.c b/c/src/lib/libbsp/lm32/shared/clock/ckinit.c index 433d3d5d72..832213f806 100644 --- a/c/src/lib/libbsp/lm32/shared/clock/ckinit.c +++ b/c/src/lib/libbsp/lm32/shared/clock/ckinit.c @@ -2,7 +2,7 @@ * * Clock device driver for Lattice Mico32 (lm32). * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -15,12 +15,14 @@ * Micro-Research Finland Oy */ -#include - -#include #include #include "../include/system_conf.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) { @@ -32,11 +34,6 @@ static inline void clockwrite(unsigned int reg, int 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 * driver. @@ -45,82 +42,20 @@ extern lm32_isr_entry set_vector(rtems_isr_entry handler, #define CLOCK_VECTOR ( TIMER0_IRQ ) #define CLOCK_IRQMASK ( 1 << CLOCK_VECTOR ) -/* - * Clock_driver_ticks is a monotonically increasing counter of the - * number of clock ticks since the driver was initialized. - */ - -volatile uint32_t 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; - -/* - * The previous ISR on this clock tick interrupt vector. - */ +#define Clock_driver_support_at_tick() \ + do { \ + /* Clear overflow flag */ \ + clockwrite(LM32_CLOCK_SR, 0); \ + lm32_interrupt_ack(CLOCK_IRQMASK); \ + } while (0) -rtems_isr_entry Old_ticker; +#define Clock_driver_support_install_isr(_new, _old ) \ + do { \ + _old = (rtems_isr_entry) set_vector( _new, CLOCK_VECTOR, 1 ); \ + } while (0) -void Clock_exit( void ); - -/* - * Isr Handler - */ - -rtems_isr Clock_isr( - rtems_vector_number vector -) +void Clock_driver_support_initialize_hardware(void) { -/* - * 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 */ clockwrite(LM32_CLOCK_PERIOD, (CPU_FREQUENCY / @@ -132,19 +67,9 @@ void Install_clock( LM32_CLOCK_CR_START); lm32_interrupt_unmask(CLOCK_IRQMASK); - - /* - * Schedule the clock cleanup routine to execute if the application exits. - */ - - atexit( Clock_exit ); } -/* - * Clean up before the application exits - */ - -void Clock_exit( void ) +void Clock_driver_support_shutdown_hardware(void) { /* Disable clock interrupts and stop */ @@ -152,28 +77,5 @@ void Clock_exit( void ) clockwrite(LM32_CLOCK_CR, LM32_CLOCK_CR_STOP); } -/* - * 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 ); +#include "../../../shared/clockdrv_shell.h" - /* - * make major/minor avail to others such as shared memory driver - */ - - rtems_clock_major = major; - rtems_clock_minor = minor; - - return RTEMS_SUCCESSFUL; -} -- cgit v1.2.3