X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=drv%2Ftimer.c;h=a941f355db4b968b3dabc9d3741238b8711c108d;hb=27c90e14b9a2600bc38486f046187a7e690b24fb;hp=385ef9c3f811b9c95441207c7329e00f1a42cf68;hpb=f5944176b5a027ad5d7922429f0045f797b0b727;p=bertos.git diff --git a/drv/timer.c b/drv/timer.c index 385ef9c3..a941f355 100755 --- a/drv/timer.c +++ b/drv/timer.c @@ -15,6 +15,9 @@ /* * $Log$ + * Revision 1.6 2004/06/07 18:10:06 aleph + * Remove free pool of timers; use user-provided Timer structure instead + * * Revision 1.5 2004/06/07 15:56:55 aleph * Some tabs cleanup and add timer strobe macros * @@ -36,8 +39,8 @@ #include "kdebug.h" #include "timer.h" -#ifdef CONFIG_KERN_SIGNALS -#include +#if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS + #include #endif #if (ARCH & ARCH_EMUL) @@ -53,59 +56,12 @@ #endif -/*! Number of available timers */ -#define MAX_TIMERS 4 - - //! Master system clock (1ms accuracy) volatile time_t _clock; -static Timer soft_timers[MAX_TIMERS]; /*!< Pool of Timer structures */ -static List timers_pool; /*!< Pool of free timers */ REGISTER static List timers_queue; /*!< Active timers */ -/*! - * Return a new timer picking and removing it from the available - * timers pool. Return NULL if no more timers are available. - */ -Timer *timer_new(void) -{ - Timer *timer; - cpuflags_t flags; - - DISABLE_IRQSAVE(flags); - - /* Should never happen */ - if (ISLISTEMPTY(&timers_pool)) - { - ENABLE_IRQRESTORE(flags); - DB(kprintf("Tmrspool empty\n");) - return NULL; - } - - /* Get a timer from the free pool */ - timer = (Timer *)timers_pool.head; - REMOVE((Node *)timer); - - ENABLE_IRQRESTORE(flags); - - return timer; -} - - -/*! - * Delete a timer, putting it in the available timers queue. - */ -void timer_delete(Timer *timer) -{ - cpuflags_t flags; - DISABLE_IRQSAVE(flags); - ADDHEAD(&timers_pool, &timer->link); - ENABLE_IRQRESTORE(flags); -} - - /*! * Add the specified timer to the software timer service queue. * When the delay indicated by the timer expires, the timer @@ -260,19 +216,11 @@ DEFINE_TIMER_ISR */ void timer_init(void) { - int i; - TIMER_STROBE_INIT; INITLIST(&timers_queue); - INITLIST(&timers_pool); - - /* Init all software timers in the free pool */ - for (i = 0; i < MAX_TIMERS; i++) - ADDTAIL(&timers_pool, (Node *)&soft_timers[i]); _clock = 0; timer_hw_init(); } -