diff options
-rw-r--r-- | kernel/drivers/acpi.c | 3 | ||||
-rw-r--r-- | kernel/drivers/timer.c | 5 | ||||
-rw-r--r-- | kernel/inc/acpi.h | 4 | ||||
-rw-r--r-- | libc/inc/def.h | 15 |
4 files changed, 24 insertions, 3 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 diff --git a/kernel/inc/acpi.h b/kernel/inc/acpi.h index 3a25098..6cebf9b 100644 --- a/kernel/inc/acpi.h +++ b/kernel/inc/acpi.h @@ -11,6 +11,8 @@ #define FADT_MAGIC "FACP" #define HPET_MAGIC "HPET" +#define HPET_MAX_PERIOD 0x05F5E100 + struct address_structure { u8 address_space_id; u8 register_bit_width; @@ -110,6 +112,6 @@ struct fadt *fadt; struct hpet *hpet; void acpi_install(); -void hpet_install(int period); +void hpet_install(int frequency); #endif diff --git a/libc/inc/def.h b/libc/inc/def.h index 42939a0..2c77203 100644 --- a/libc/inc/def.h +++ b/libc/inc/def.h @@ -25,4 +25,19 @@ typedef unsigned long long u64; #define NULL ((void *)0) +#define U8_MAX 255 +#define S8_MAX 127 +#define S8_MIN -128 +#define U16_MAX 65535 +#define S16_MAX 32767 +#define S16_MIN -32768 +#define U32_MAX 4294967295 +#define S32_MAX 2147483647 +#define S32_MIN -2147483648 + +#define MILLION 1000000 +#define BILLION 1000000000 +#define TRILLION 1000000000000 +#define QUADRILLION 1000000000000000 + #endif |