|
|
6b3c76 |
From af355a7fe160c6c798e416f8f14e059aaf16ea13 Mon Sep 17 00:00:00 2001
|
|
|
a85e8e |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
a85e8e |
Date: Fri, 10 Oct 2014 11:11:09 +0200
|
|
|
6b3c76 |
Subject: [PATCH 174/261] calibrate_tsc(): use the Stall() EFI boot service on
|
|
|
a85e8e |
GRUB_MACHINE_EFI
|
|
|
a85e8e |
|
|
|
a85e8e |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1150698
|
|
|
a85e8e |
|
|
|
a85e8e |
HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
|
|
|
a85e8e |
services instead.
|
|
|
a85e8e |
|
|
|
a85e8e |
Signed-off-by: RHEL Ninjas <example@example.com>
|
|
|
a85e8e |
---
|
|
|
a85e8e |
grub-core/kern/i386/tsc.c | 20 ++++++++++++++++----
|
|
|
a85e8e |
1 file changed, 16 insertions(+), 4 deletions(-)
|
|
|
a85e8e |
|
|
|
a85e8e |
diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
|
|
|
6b3c76 |
index 3a4cae601..e49964833 100644
|
|
|
a85e8e |
--- a/grub-core/kern/i386/tsc.c
|
|
|
a85e8e |
+++ b/grub-core/kern/i386/tsc.c
|
|
|
a85e8e |
@@ -26,9 +26,14 @@
|
|
|
a85e8e |
#include <grub/i386/tsc.h>
|
|
|
a85e8e |
#include <grub/i386/cpuid.h>
|
|
|
a85e8e |
#ifdef GRUB_MACHINE_XEN
|
|
|
a85e8e |
-#include <grub/xen.h>
|
|
|
a85e8e |
+# include <grub/xen.h>
|
|
|
a85e8e |
#else
|
|
|
a85e8e |
-#include <grub/i386/pit.h>
|
|
|
a85e8e |
+# ifdef GRUB_MACHINE_EFI
|
|
|
a85e8e |
+# include <grub/efi/efi.h>
|
|
|
a85e8e |
+# include <grub/efi/api.h>
|
|
|
a85e8e |
+# else
|
|
|
a85e8e |
+# include <grub/i386/pit.h>
|
|
|
a85e8e |
+# endif
|
|
|
a85e8e |
#endif
|
|
|
a85e8e |
#include <grub/cpu/io.h>
|
|
|
a85e8e |
|
|
|
a85e8e |
@@ -72,8 +77,14 @@ grub_cpu_is_tsc_supported (void)
|
|
|
a85e8e |
#ifndef GRUB_MACHINE_XEN
|
|
|
a85e8e |
|
|
|
a85e8e |
static void
|
|
|
a85e8e |
-grub_pit_wait (grub_uint16_t tics)
|
|
|
a85e8e |
+grub_stall (grub_uint16_t tics)
|
|
|
a85e8e |
{
|
|
|
a85e8e |
+# ifdef GRUB_MACHINE_EFI
|
|
|
a85e8e |
+ grub_uint64_t microseconds;
|
|
|
a85e8e |
+
|
|
|
a85e8e |
+ microseconds = (grub_uint64_t)tics * 1000 * 1000 * 3 / 3579545;
|
|
|
a85e8e |
+ efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
|
|
|
a85e8e |
+# else
|
|
|
a85e8e |
/* Disable timer2 gate and speaker. */
|
|
|
a85e8e |
grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
|
|
|
a85e8e |
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
|
|
|
a85e8e |
@@ -97,6 +108,7 @@ grub_pit_wait (grub_uint16_t tics)
|
|
|
a85e8e |
grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
|
|
|
a85e8e |
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
|
|
|
a85e8e |
GRUB_PIT_SPEAKER_PORT);
|
|
|
a85e8e |
+# endif
|
|
|
a85e8e |
}
|
|
|
a85e8e |
#endif
|
|
|
a85e8e |
|
|
|
a85e8e |
@@ -119,7 +131,7 @@ calibrate_tsc (void)
|
|
|
a85e8e |
grub_uint64_t end_tsc;
|
|
|
a85e8e |
|
|
|
a85e8e |
tsc_boot_time = grub_get_tsc ();
|
|
|
a85e8e |
- grub_pit_wait (0xffff);
|
|
|
a85e8e |
+ grub_stall (0xffff);
|
|
|
a85e8e |
end_tsc = grub_get_tsc ();
|
|
|
a85e8e |
|
|
|
a85e8e |
grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
|
|
|
6b3c76 |
--
|
|
|
6b3c76 |
2.13.5
|
|
|
6b3c76 |
|