1 #ifndef _TIMER_H_ 2 #define _TIMER_H_ 3 4 #include "cpu.h" 5 6 extern int timer_start; 7 8 #define timer_start_period(cycles) \ 9 timer_start = cycles; 10 11 #define timer_end_period(cycles) \ 12 do \ 13 { \ 14 int diff = timer_start - (cycles); \ 15 timer_count -= diff; \ 16 timer_start = cycles; \ 17 if (timer_count <= 0) \ 18 { \ 19 timer_process(); \ 20 timer_update_outstanding(); \ 21 } \ 22 } while (0) 23 24 #define timer_clock() \ 25 do \ 26 { \ 27 int diff; \ 28 if (AT) \ 29 { \ 30 diff = timer_start - (cycles << TIMER_SHIFT); \ 31 timer_start = cycles << TIMER_SHIFT; \ 32 } \ 33 else \ 34 { \ 35 diff = timer_start - (cycles * xt_cpu_multi); \ 36 timer_start = cycles * xt_cpu_multi; \ 37 } \ 38 timer_count -= diff; \ 39 timer_process(); \ 40 timer_update_outstanding(); \ 41 } while (0) 42 43 void timer_process(); 44 void timer_update_outstanding(); 45 void timer_reset(); 46 int timer_add(void (*callback)(void *priv), int *count, int *enable, void *priv); 47 void timer_set_callback(int timer, void (*callback)(void *priv)); 48 49 #define TIMER_ALWAYS_ENABLED &timer_one 50 51 extern int timer_count; 52 extern int timer_one; 53 54 #define TIMER_SHIFT 6 55 56 extern int TIMER_USEC; 57 58 #endif /*_TIMER_H_*/ 59