Make grub_cpu_is_tsc_supported generally available.

This commit is contained in:
Vladimir Serbinenko 2016-02-12 11:38:51 +01:00
parent b29638222e
commit 1933d37371
2 changed files with 16 additions and 16 deletions

View file

@ -43,22 +43,6 @@ grub_tsc_get_time_ms (void)
return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate; return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate;
} }
static __inline int
grub_cpu_is_tsc_supported (void)
{
#ifndef GRUB_MACHINE_XEN
grub_uint32_t a,b,c,d;
if (! grub_cpu_is_cpuid_supported ())
return 0;
grub_cpuid(1,a,b,c,d);
return (d & (1 << 4)) != 0;
#else
return 1;
#endif
}
static int static int
calibrate_tsc_hardcode (void) calibrate_tsc_hardcode (void)
{ {

View file

@ -51,4 +51,20 @@ grub_get_tsc (void)
return (((grub_uint64_t) hi) << 32) | lo; return (((grub_uint64_t) hi) << 32) | lo;
} }
static __inline int
grub_cpu_is_tsc_supported (void)
{
#ifndef GRUB_MACHINE_XEN
grub_uint32_t a,b,c,d;
if (! grub_cpu_is_cpuid_supported ())
return 0;
grub_cpuid(1,a,b,c,d);
return (d & (1 << 4)) != 0;
#else
return 1;
#endif
}
#endif /* ! KERNEL_CPU_TSC_HEADER */ #endif /* ! KERNEL_CPU_TSC_HEADER */