]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/timer-hpet.cpp
2e573d7ab52f9f39eefbd3954fc8ffc48d916ca2
[l4.git] / kernel / fiasco / src / kern / timer-hpet.cpp
1 INTERFACE [hpet_timer]:
2
3 EXTENSION class Timer
4 {
5   static int hpet_irq;
6 };
7
8 IMPLEMENTATION [hpet_timer]:
9
10 #include "config.h"
11 #include "cpu.h"
12 #include "hpet.h"
13 #include "irq_chip.h"
14 #include "logdefs.h"
15 #include "pit.h"
16 #include "std_macros.h"
17
18 #include <cstdio>
19
20 int Timer::hpet_irq;
21
22 PUBLIC static inline int Timer::irq() { return hpet_irq; }
23
24 PUBLIC static inline NEEDS["irq_chip.h"]
25 unsigned Timer::irq_mode()
26 { return Irq_base::Trigger_level | Irq_base::Polarity_low; }
27
28 IMPLEMENT
29 void
30 Timer::init(Cpu_number)
31 {
32   hpet_irq = -1;
33   if (!Hpet::init())
34     return;
35
36   hpet_irq = Hpet::int_num();
37   if (hpet_irq == 0 && Hpet::int_avail(2))
38     hpet_irq = 2;
39
40   if (Config::Scheduler_one_shot)
41     {
42       // tbd
43     }
44   else
45     {
46       // setup hpet for periodic here
47     }
48
49   if (!Config::Scheduler_one_shot)
50     // from now we can save energy in getchar()
51     Config::getchar_does_hlt_works_ok = Config::hlt_works_ok;
52
53   Hpet::enable();
54   Hpet::dump();
55
56   printf("Using HPET timer on IRQ %d (%s Mode) for scheduling\n",
57          hpet_irq,
58          Config::Scheduler_one_shot ? "One-Shot" : "Periodic");
59 }
60
61 PUBLIC static inline
62 void
63 Timer::acknowledge()
64 {}
65
66 static
67 void
68 Timer::update_one_shot(Unsigned64 /*wakeup*/)
69 {
70 }
71
72 IMPLEMENT inline
73 void
74 Timer::update_timer(Unsigned64 /*wakeup*/)
75 {
76 }