From 636b2309e49379b11fef804e580f01eb475bf8f9 Mon Sep 17 00:00:00 2001 From: p-szafonimateusz Date: Fri, 1 Mar 2024 10:37:40 +0100 Subject: [PATCH] arch/intel64: cosmetic changes for TSC cosmetic changes for TSC: - remove unused variables - add g_ prefix to global variables Signed-off-by: p-szafonimateusz --- arch/x86_64/src/intel64/intel64_tsc_tickless.c | 12 ++++++------ arch/x86_64/src/intel64/intel64_tsc_timerisr.c | 10 +++------- boards/x86_64/intel64/qemu-intel64/src/qemu_freq.c | 8 ++++---- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/arch/x86_64/src/intel64/intel64_tsc_tickless.c b/arch/x86_64/src/intel64/intel64_tsc_tickless.c index 205ab71f90..13c643d187 100644 --- a/arch/x86_64/src/intel64/intel64_tsc_tickless.c +++ b/arch/x86_64/src/intel64/intel64_tsc_tickless.c @@ -74,7 +74,7 @@ * Private Data ****************************************************************************/ -unsigned long x86_64_timer_freq; +unsigned long g_x86_64_timer_freq; static struct timespec g_goal_time_ts; static uint64_t g_last_stop_time; @@ -138,16 +138,16 @@ void up_timer_initialize(void) static inline uint64_t up_ts2tick(const struct timespec *ts) { - return ROUND_INT_DIV((uint64_t)ts->tv_nsec * x86_64_timer_freq, + return ROUND_INT_DIV((uint64_t)ts->tv_nsec * g_x86_64_timer_freq, NS_PER_SEC) + - (uint64_t)ts->tv_sec * x86_64_timer_freq; + (uint64_t)ts->tv_sec * g_x86_64_timer_freq; } static inline void up_tick2ts(uint64_t tick, struct timespec *ts) { - ts->tv_sec = (tick / x86_64_timer_freq); - ts->tv_nsec = (uint64_t)(ROUND_INT_DIV((tick % x86_64_timer_freq) * - NSEC_PER_SEC, x86_64_timer_freq)); + ts->tv_sec = (tick / g_x86_64_timer_freq); + ts->tv_nsec = (uint64_t)(ROUND_INT_DIV((tick % g_x86_64_timer_freq) * + NSEC_PER_SEC, g_x86_64_timer_freq)); } static inline void up_tmr_sync_up(void) diff --git a/arch/x86_64/src/intel64/intel64_tsc_timerisr.c b/arch/x86_64/src/intel64/intel64_tsc_timerisr.c index 4375c4b262..9fe54174ea 100644 --- a/arch/x86_64/src/intel64/intel64_tsc_timerisr.c +++ b/arch/x86_64/src/intel64/intel64_tsc_timerisr.c @@ -53,11 +53,7 @@ * Private Data ****************************************************************************/ -unsigned long x86_64_timer_freq; - -static unsigned long tsc_overflow; -static unsigned long tsc_last; -static unsigned long tsc_overflows; +unsigned long g_x86_64_timer_freq; /**************************************************************************** * Private Functions @@ -74,7 +70,8 @@ static unsigned long tsc_overflows; void apic_timer_set(unsigned long timeout_ns) { unsigned long long ticks = - (unsigned long long)timeout_ns * x86_64_timer_freq / NS_PER_SEC; + (unsigned long long)timeout_ns * g_x86_64_timer_freq / NS_PER_SEC; + #ifdef CONFIG_ARCH_INTEL64_TSC_DEADLINE write_msr(MSR_IA32_TSC_DEADLINE, rdtsc() + ticks); #else @@ -115,7 +112,6 @@ static int intel64_timerisr(int irq, uint32_t *regs, void *arg) void up_timer_initialize(void) { - unsigned long ecx; uint32_t vector = IRQ0; irq_attach(IRQ0, (xcpt_t)intel64_timerisr, NULL); diff --git a/boards/x86_64/intel64/qemu-intel64/src/qemu_freq.c b/boards/x86_64/intel64/qemu-intel64/src/qemu_freq.c index 75a6a306b5..1a8c6a2eff 100644 --- a/boards/x86_64/intel64/qemu-intel64/src/qemu_freq.c +++ b/boards/x86_64/intel64/qemu-intel64/src/qemu_freq.c @@ -38,7 +38,7 @@ * Public Data ****************************************************************************/ -extern unsigned long x86_64_timer_freq; +extern unsigned long g_x86_64_timer_freq; /**************************************************************************** * Public Functions @@ -84,14 +84,14 @@ void x86_64_timer_calibrate_freq(void) if (numerator == 0 || denominator == 0 || crystal_freq == 0) { - x86_64_timer_freq = CONFIG_ARCH_INTEL64_CORE_FREQ_KHZ * 1000L; + g_x86_64_timer_freq = CONFIG_ARCH_INTEL64_CORE_FREQ_KHZ * 1000L; } else { - x86_64_timer_freq = crystal_freq / denominator * numerator; + g_x86_64_timer_freq = crystal_freq / denominator * numerator; } #elif defined(CONFIG_ARCH_INTEL64_TSC) - x86_64_timer_freq = CONFIG_ARCH_INTEL64_APIC_FREQ_KHZ * 1000L; + g_x86_64_timer_freq = CONFIG_ARCH_INTEL64_APIC_FREQ_KHZ * 1000L; #endif }