aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers')
-rw-r--r--kernel/drivers/acpi.c3
-rw-r--r--kernel/drivers/timer.c5
2 files changed, 6 insertions, 2 deletions
diff --git a/kernel/drivers/acpi.c b/kernel/drivers/acpi.c
index 15007d7..4c7a1a8 100644
--- a/kernel/drivers/acpi.c
+++ b/kernel/drivers/acpi.c
@@ -78,11 +78,12 @@ void hpet_install(int period)
{
if (hpet && hpet->legacy_replacement && hpet->comparator_count > 0) {
struct hpet_registers *r = (struct hpet_registers *)hpet->address.phys;
- printf("HPET tick period: %dns\n", r->tick_period / 1000000);
+ printf("HPET tick period: %dns\n", HPET_MAX_PERIOD / r->tick_period);
if ((r->timer0 & hpet_periodic_support) == hpet_periodic_support) {
r->config |= hpet_enable;
r->config |= hpet_legacy_replacement;
r->timer0 |= hpet_periodic | hpet_set_accumulator | hpet_enable_timer;
+ assert(r->tick_period + period < HPET_MAX_PERIOD);
r->timer_comparator0 = r->tick_period + period;
r->timer_comparator0 = period;
}
diff --git a/kernel/drivers/timer.c b/kernel/drivers/timer.c
index 788e286..8029a2a 100644
--- a/kernel/drivers/timer.c
+++ b/kernel/drivers/timer.c
@@ -22,7 +22,10 @@ u32 timer_get()
void timer_handler()
{
- timer_ticks++;
+ if (timer_ticks >= U32_MAX)
+ timer_ticks = 0;
+ else
+ timer_ticks++;
}
// "Delay" function with CPU sleep