From 940cd5fd68a013f4aac1a49488bbb9978826bfba Mon Sep 17 00:00:00 2001 From: Pawel Wieczorkiewicz Date: Wed, 6 Sep 2023 17:59:49 +0200 Subject: [PATCH] time: cleanup sleep() and msleep() API The sleep() expected miliseconds parameter, hence it should become the msleep(), and sleep() should just use the msleep() directly. Signed-off-by: Pawel Wieczorkiewicz --- arch/x86/apic.c | 2 +- include/time.h | 6 +++--- lib/time.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/apic.c b/arch/x86/apic.c index bff081da..e50f3beb 100644 --- a/arch/x86/apic.c +++ b/arch/x86/apic.c @@ -188,7 +188,7 @@ void init_apic_timer(void) { apic_write(APIC_LVT_TIMER, timer.reg); /* Sleep for 20ms to calibrate, count the ticks */ - sleep(CAL_SLEEP_TIME); + msleep(CAL_SLEEP_TIME); /* Calibrate */ uint32_t elapsed_ticks = (_U32(-1) - apic_read(APIC_TMR_CCR)) / CAL_SLEEP_TIME; diff --git a/include/time.h b/include/time.h index 6e5bad40..ef8c531b 100644 --- a/include/time.h +++ b/include/time.h @@ -27,13 +27,13 @@ typedef uint64_t time_t; -extern void sleep(time_t ms); +extern void msleep(time_t ms); extern time_t get_timer_ticks(void); /* Static declarations */ -static inline void msleep(time_t ms) { - sleep(ms); +static inline void sleep(time_t s) { + msleep(s * 1000); } #endif diff --git a/lib/time.c b/lib/time.c index f3bbd5ea..26b0bcee 100644 --- a/lib/time.c +++ b/lib/time.c @@ -32,7 +32,7 @@ void timer_interrupt_handler(void) { apic_EOI(); } -void sleep(time_t ms) { +void msleep(time_t ms) { time_t end = ticks + ms; while (ticks < end) { cpu_relax();