diff options
| author | Miguel <m.i@gmx.at> | 2018-08-18 16:20:26 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-08-18 16:20:26 +0200 |
| commit | 639c3d47b09114628f8e1f8817c27c10bf1fb28c (patch) | |
| tree | f0381de25cc8f2de96a87b47cc76f7d09548bf7e /kernel/timer.c | |
| parent | 7b0d88b2dff9b635d9ff69f6d51b6832c1ca4c40 (diff) | |
reviving old drivers: mouse, pci, e1000
Diffstat (limited to 'kernel/timer.c')
| -rw-r--r-- | kernel/timer.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel/timer.c b/kernel/timer.c index a339d70..3f7ab0f 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -38,6 +38,7 @@ // TODO: use mutex? do we need volatile at all!?? // abstract atomic variable set,get,increment static volatile uint64_t task_system_clock=0; +static volatile uint64_t task_system_clock_start=0; //called by interrupt void timer_tick() @@ -52,12 +53,18 @@ uint64_t timer_get_ticks() } /// + uint64_t timer_get_ms() { uint64_t t=timer_get_ticks(); uint64_t s=t/25; - uint64_t ms=0; // TODO ms - return s*1000; + uint64_t ms=t*1000/25-s*1000; + return s*1000+ms; +} + +uint64_t timer_get_uptime_ms() +{ + return timer_get_ms()-task_system_clock_start*1000; } // CMOS RTC @@ -213,8 +220,9 @@ uint64_t get_rtc_time() void timer_init() { uint64_t epoch_time=get_rtc_time(); - epoch_time*=25; - task_system_clock=epoch_time; + + task_system_clock_start=epoch_time; + task_system_clock=epoch_time*25; // config out timer on channel 0 : mode 2 (sys timer) // http://en.wikipedia.org/wiki/Intel_8253#Control_Word_Register |
