]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/i386/lib/timer.c
8fc68cdcb899a72b87e8b8aec4f26c1f92860a32
2 * (C) Copyright 2008,2009
3 * Graeme Russ, <graeme.russ@gmail.com>
6 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #include <asm/i8254.h>
31 #include <asm/ibmpc.h>
33 struct timer_isr_function
{
34 struct timer_isr_function
*next
;
35 timer_fnc_t
*isr_func
;
38 static struct timer_isr_function
*first_timer_isr
= NULL
;
39 static volatile unsigned long system_ticks
= 0;
42 * register_timer_isr() allows multiple architecture and board specific
43 * functions to be called every millisecond. Keep the execution time of
44 * each function as low as possible
46 int register_timer_isr (timer_fnc_t
*isr_func
)
48 struct timer_isr_function
*new_func
;
49 struct timer_isr_function
*temp
;
52 new_func
= malloc(sizeof(struct timer_isr_function
));
57 new_func
->isr_func
= isr_func
;
58 new_func
->next
= NULL
;
61 * Don't allow timer interrupts while the
62 * linked list is being modified
64 flag
= disable_interrupts ();
66 if (first_timer_isr
== NULL
) {
67 first_timer_isr
= new_func
;
69 temp
= first_timer_isr
;
70 while (temp
->next
!= NULL
)
72 temp
->next
= new_func
;
82 * timer_isr() MUST be the registered interrupt handler for
84 void timer_isr(void *unused
)
86 struct timer_isr_function
*temp
= first_timer_isr
;
90 /* Execute each registered function */
91 while (temp
!= NULL
) {
97 void reset_timer (void)
102 ulong
get_timer (ulong base
)
104 return (system_ticks
- base
);
107 void set_timer (ulong t
)