Skip to content

Commit adeb19b

Browse files
finikorgcarlescufi
authored andcommitted
drivers: apic_tsc: Use toolchain cpuid()
We have already code using toolchain provided __get_cpuid(), clean up apic_tsc and make it consistent with the rest of the code. Signed-off-by: Andrei Emeltchenko <[email protected]>
1 parent b249535 commit adeb19b

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

drivers/timer/apic_tsc.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
* Copyright (c) 2021 Intel Corporation
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5+
6+
#include <cpuid.h> /* Header provided by the toolchain. */
7+
58
#include <zephyr/init.h>
9+
#include <zephyr/arch/x86/cpuid.h>
610
#include <zephyr/drivers/timer/system_timer.h>
711
#include <zephyr/sys_clock.h>
812
#include <zephyr/spinlock.h>
@@ -149,28 +153,21 @@ void smp_timer_init(void)
149153
irq_enable(timer_irq());
150154
}
151155

152-
static inline void cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
153-
{
154-
__asm__ volatile("cpuid"
155-
: "=b"(*ebx), "=c"(*ecx), "=d"(*edx)
156-
: "a"(*eax), "c"(*ecx));
157-
}
158-
159156
static int sys_clock_driver_init(void)
160157
{
161158
#ifdef CONFIG_ASSERT
162159
uint32_t eax, ebx, ecx, edx;
163160

164-
eax = 1; ecx = 0;
165-
cpuid(&eax, &ebx, &ecx, &edx);
161+
ecx = 0; /* prevent compiler warning */
162+
__get_cpuid(CPUID_BASIC_INFO_1, &eax, &ebx, &ecx, &edx);
166163
__ASSERT((ecx & BIT(24)) != 0, "No TSC Deadline support");
167164

168-
eax = 0x80000007; ecx = 0;
169-
cpuid(&eax, &ebx, &ecx, &edx);
165+
edx = 0; /* prevent compiler warning */
166+
__get_cpuid(0x80000007, &eax, &ebx, &ecx, &edx);
170167
__ASSERT((edx & BIT(8)) != 0, "No Invariant TSC support");
171168

172-
eax = 7; ecx = 0;
173-
cpuid(&eax, &ebx, &ecx, &edx);
169+
ebx = 0; /* prevent compiler warning */
170+
__get_cpuid_count(CPUID_EXTENDED_FEATURES_LVL, 0, &eax, &ebx, &ecx, &edx);
174171
__ASSERT((ebx & BIT(1)) != 0, "No TSC_ADJUST MSR support");
175172
#endif
176173

0 commit comments

Comments
 (0)