Fixed ZDE build - missing header file
[ZeXOS.git] / kernel / arch / ppc / timer.c
blob299738f83688304b49d51444511917526c827a57
1 /*
2 * ZeX/OS
3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <system.h>
21 #include <arch/io.h>
24 /* This will keep track of how many ticks that the system
25 * has been running for */
26 unsigned long timer_ticks = 0;
28 /* Software timer - ticks count to 1ms */
29 unsigned long timer_swticks = 0;
31 /* This will continuously loop until the given time has
32 * been reached */
33 void timer_wait (int ticks)
35 int eticks;
37 eticks = timer_ticks + ticks;
39 while (timer_ticks < eticks)
40 kprintf("");;
43 char *time_tostring (unsigned long s)
45 return "N/A";
48 void uptime (void)
50 printf ("Uptime: %s\n", time_tostring (timer_ticks/((3579545L / 3) / HZ)));
53 void calc_freqency ()
55 /* Kernel with 1000Hz timer - dont need it ? */
56 if (kernel_attr & KERNEL_18HZ) {
57 int eticks;
59 eticks = timer_ticks + 18;
61 while (timer_ticks < eticks) {
62 ctps ++;
63 kprintf("");;
66 kprintf ("Freqency: %lluHz\n", ctps);
70 void calc_swtimer ()
72 unsigned long timer = timer_ticks;
74 while ((timer_ticks - timer) >= 1)
75 timer_swticks ++;
78 void usleep (unsigned len)
80 if (kernel_attr & KERNEL_18HZ) {
81 unsigned long long t = ctps * len;
82 unsigned long long i = 0;
84 while (t > i) {
85 i += 1000;
86 kprintf("");;
88 } else
89 timer_wait (1);
93 unsigned int timer_install ()
96 return 1;