On 3/6/20 4:44 PM, Gerd Hoffmann wrote:
Factor out TimerKHz and ShiftTSC calculation to tsctimer_configure().

Signed-off-by: Gerd Hoffmann <kra...@redhat.com>
---
  src/hw/timer.c | 21 +++++++++++++--------
  1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/hw/timer.c b/src/hw/timer.c
index bdcb3bfca211..ce3d63cd75f6 100644
--- a/src/hw/timer.c
+++ b/src/hw/timer.c
@@ -58,6 +58,18 @@ u8 ShiftTSC VARFSEG;
   * Internal timer setup
   ****************************************************************/
+static void
+tsctimer_configure(u64 t)
+{
+    while (t >= (1<<24)) {
+        ShiftTSC++;
+        t = (t + 1) >> 1;
+    }
+    TimerKHz = DIV_ROUND_UP((u32)t, 1000 * PMTIMER_TO_PIT);
+    TimerPort = 0;
+    dprintf(1, "CPU Mhz=%u\n", (TimerKHz << ShiftTSC) / 1000);
+}
+
  #define CALIBRATE_COUNT 0x800   // Approx 1.7ms
// Calibrate the CPU time-stamp-counter
@@ -87,14 +99,7 @@ tsctimer_setup(void)
      dprintf(6, "tsc calibrate start=%u end=%u diff=%u\n"
              , (u32)start, (u32)end, (u32)diff);
      u64 t = DIV_ROUND_UP(diff * PMTIMER_HZ, CALIBRATE_COUNT);
-    while (t >= (1<<24)) {
-        ShiftTSC++;
-        t = (t + 1) >> 1;
-    }
-    TimerKHz = DIV_ROUND_UP((u32)t, 1000 * PMTIMER_TO_PIT);
-    TimerPort = 0;
-
-    dprintf(1, "CPU Mhz=%u\n", (TimerKHz << ShiftTSC) / 1000);
+    tsctimer_configure(t);
  }
// Setup internal timers.


Reviewed-by: Philippe Mathieu-Daudé <phi...@redhat.com>
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-le...@seabios.org

Reply via email to