3 * Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/i8254.h>
28 #include <asm/ibmpc.h>
30 struct timer_isr_function {
31 struct timer_isr_function *next;
32 timer_fnc_t *isr_func;
35 static struct timer_isr_function *first_timer_isr = NULL;
36 static volatile unsigned long system_ticks = 0;
39 * register_timer_isr() allows multiple architecture and board specific
40 * functions to be called every millisecond. Keep the execution time of
41 * each function as low as possible
43 int register_timer_isr (timer_fnc_t *isr_func)
45 struct timer_isr_function *new_func;
46 struct timer_isr_function *temp;
49 new_func = malloc(sizeof(struct timer_isr_function));
54 new_func->isr_func = isr_func + gd->reloc_off;
55 new_func->next = NULL;
58 * Don't allow timer interrupts while the
59 * linked list is being modified
61 flag = disable_interrupts ();
63 if (first_timer_isr == NULL) {
64 first_timer_isr = new_func;
66 temp = first_timer_isr;
67 while (temp->next != NULL)
69 temp->next = new_func;
79 * timer_isr() MUST be the registered interrupt handler for
81 void timer_isr(void *unused)
83 struct timer_isr_function *temp = first_timer_isr;
87 /* Execute each registered function */
88 while (temp != NULL) {
94 void reset_timer (void)
99 ulong get_timer (ulong base)
101 return (system_ticks - base);
104 void set_timer (ulong t)