Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/bouyer-xenpvh]: src/sys/arch Centralize initialisations of delay_func an...



details:   https://anonhg.NetBSD.org/src/rev/45b7fd8cfa94
branches:  bouyer-xenpvh
changeset: 982945:45b7fd8cfa94
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Apr 18 14:47:55 2020 +0000

description:
Centralize initialisations of delay_func and initclock_func
in x86_machdep.c and export from <x86/machdep.h>
Introduce a x86_dummy_initclock() and a x86_cpu_initclock_func pointer,
to be used later for Xen HVM native clock support.
rename rtclock_tval to x86_rtclock_tval and export from <x86/machdep.h>,
for the benefit of lapic.c

diffstat:

 sys/arch/amd64/amd64/machdep.c |  18 ++----------------
 sys/arch/i386/i386/machdep.c   |  19 ++-----------------
 sys/arch/x86/include/machdep.h |   8 +++++++-
 sys/arch/x86/isa/clock.c       |  29 +++++++++++++++--------------
 sys/arch/x86/x86/lapic.c       |  13 ++++++-------
 sys/arch/x86/x86/x86_machdep.c |  25 +++++++++++++++++++++++--
 6 files changed, 55 insertions(+), 57 deletions(-)

diffs (truncated from 319 to 300 lines):

diff -r d73c7b89c421 -r 45b7fd8cfa94 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Thu Apr 16 20:21:44 2020 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Sat Apr 18 14:47:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.346.4.2 2020/04/16 09:45:56 bouyer Exp $ */
+/*     $NetBSD: machdep.c,v 1.346.4.3 2020/04/18 14:47:55 bouyer Exp $ */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.346.4.2 2020/04/16 09:45:56 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.346.4.3 2020/04/18 14:47:55 bouyer Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -280,14 +280,6 @@
 extern paddr_t pmap_pa_start, pmap_pa_end;
 #endif
 
-#ifndef XENPV
-void (*delay_func)(unsigned int) = i8254_delay;
-void (*initclock_func)(void) = i8254_initclocks;
-#else /* XENPV */
-void (*delay_func)(unsigned int) = xen_delay;
-void (*initclock_func)(void) = xen_initclocks;
-#endif
-
 struct nmistore {
        uint64_t cr3;
        uint64_t scratch;
@@ -2129,12 +2121,6 @@
        return 0;
 }
 
-void
-cpu_initclocks(void)
-{
-       (*initclock_func)();
-}
-
 int
 mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled)
 {
diff -r d73c7b89c421 -r 45b7fd8cfa94 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Thu Apr 16 20:21:44 2020 +0000
+++ b/sys/arch/i386/i386/machdep.c      Sat Apr 18 14:47:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.825.4.2 2020/04/16 08:46:34 bouyer Exp $ */
+/*     $NetBSD: machdep.c,v 1.825.4.3 2020/04/18 14:47:55 bouyer Exp $ */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.825.4.2 2020/04/16 08:46:34 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.825.4.3 2020/04/18 14:47:55 bouyer Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -235,14 +235,6 @@
 void failsafe_callback(void);
 #endif
 
-#ifdef XENPV
-void (*delay_func)(unsigned int) = xen_delay;
-void (*initclock_func)(void) = xen_initclocks;
-#else
-void (*delay_func)(unsigned int) = i8254_delay;
-void (*initclock_func)(void) = i8254_initclocks;
-#endif
-
 /*
  * Size of memory segments, before any memory is stolen.
  */
@@ -1624,13 +1616,6 @@
        return (0);
 }
 
-void
-cpu_initclocks(void)
-{
-
-       (*initclock_func)();
-}
-
 #define        DEV_IO 14               /* iopl for compat_10 */
 
 int
diff -r d73c7b89c421 -r 45b7fd8cfa94 sys/arch/x86/include/machdep.h
--- a/sys/arch/x86/include/machdep.h    Thu Apr 16 20:21:44 2020 +0000
+++ b/sys/arch/x86/include/machdep.h    Sat Apr 18 14:47:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.h,v 1.9 2016/12/26 17:54:07 cherry Exp $ */
+/* $NetBSD: machdep.h,v 1.9.26.1 2020/04/18 14:47:55 bouyer Exp $ */
 /*
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -51,6 +51,12 @@
 void   x86_cpu_idle_get(void (**)(void), char *, size_t);
 void   x86_cpu_idle_set(void (*)(void), const char *, bool);
 
+extern u_long x86_rtclock_tval;
+extern void (*x86_initclock_func)(void);
+extern void (*x86_cpu_initclock_func)(void);
+
+void x86_dummy_initclock(void);
+
 int    x86_select_freelist(uint64_t);
 
 void   init_x86_clusters(void);
diff -r d73c7b89c421 -r 45b7fd8cfa94 sys/arch/x86/isa/clock.c
--- a/sys/arch/x86/isa/clock.c  Thu Apr 16 20:21:44 2020 +0000
+++ b/sys/arch/x86/isa/clock.c  Sat Apr 18 14:47:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.36 2019/10/16 18:29:49 christos Exp $      */
+/*     $NetBSD: clock.c,v 1.36.6.1 2020/04/18 14:47:56 bouyer Exp $    */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -121,7 +121,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.36 2019/10/16 18:29:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.36.6.1 2020/04/18 14:47:56 bouyer Exp $");
 
 /* #define CLOCKDEBUG */
 /* #define CLOCK_PARANOIA */
@@ -214,7 +214,7 @@
        NULL,                   /* next */
 };
 
-u_long rtclock_tval;           /* i8254 reload value for countdown */
+u_long x86_rtclock_tval;       /* i8254 reload value for countdown */
 int    rtclock_init = 0;
 
 int clock_broken_latch = 0;
@@ -286,7 +286,7 @@
                return (v2);
 
        w1 = v2 - v3;
-       w2 = v3 - v1 + rtclock_tval;
+       w2 = v3 - v1 + x86_rtclock_tval;
        w3 = v1 - v2;
        if (w1 >= w2) {
                if (w1 >= w3)
@@ -319,7 +319,7 @@
        outb(IO_TIMER1+TIMER_CNTR0, tval % 256);
        outb(IO_TIMER1+TIMER_CNTR0, tval / 256);
 
-       rtclock_tval = tval ? tval : 0xFFFF;
+       x86_rtclock_tval = tval ? tval : 0xFFFF;
        rtclock_init = 1;
 }
 
@@ -357,12 +357,13 @@
        if (CPU_IS_PRIMARY(ci) == 0)
                return;
 #endif
-       if (rtclock_tval && timecounter->tc_get_timecount == i8254_get_timecount) {
+       if (x86_rtclock_tval &&
+           timecounter->tc_get_timecount == i8254_get_timecount) {
                __cpu_simple_lock(&tmr_lock);
                if (i8254_ticked)
                        i8254_ticked    = 0;
                else {
-                       i8254_offset   += rtclock_tval;
+                       i8254_offset   += x86_rtclock_tval;
                        i8254_lastcount = 0;
                }
                __cpu_simple_unlock(&tmr_lock);
@@ -402,11 +403,11 @@
        /* insb to make the read atomic */
        rdval = inb(IO_TIMER1+TIMER_CNTR0);
        rdval |= (inb(IO_TIMER1+TIMER_CNTR0) << 8);
-       count = rtclock_tval - rdval;
-       if (rtclock_tval && (count < i8254_lastcount &&
-                            (!i8254_ticked || rtclock_tval == 0xFFFF))) {
+       count = x86_rtclock_tval - rdval;
+       if (x86_rtclock_tval && (count < i8254_lastcount &&
+                            (!i8254_ticked || x86_rtclock_tval == 0xFFFF))) {
                i8254_ticked = 1;
-               i8254_offset += rtclock_tval;
+               i8254_offset += x86_rtclock_tval;
        }
        i8254_lastcount = count;
        count += i8254_offset;
@@ -481,10 +482,10 @@
                int delta;
                cur_tick = gettick();
                if (cur_tick > initial_tick)
-                       delta = rtclock_tval - (cur_tick - initial_tick);
+                       delta = x86_rtclock_tval - (cur_tick - initial_tick);
                else
                        delta = initial_tick - cur_tick;
-               if (delta < 0 || delta >= rtclock_tval / 2) {
+               if (delta < 0 || delta >= x86_rtclock_tval / 2) {
                        DPRINTF(("delay: ignore ticks %.4x-%.4x",
                                 initial_tick, cur_tick));
                        if (clock_broken_latch) {
@@ -499,7 +500,7 @@
 #else
                cur_tick = gettick();
                if (cur_tick > initial_tick)
-                       remaining -= rtclock_tval - (cur_tick - initial_tick);
+                       remaining -= x86_rtclock_tval - (cur_tick - initial_tick);
                else
                        remaining -= initial_tick - cur_tick;
 #endif
diff -r d73c7b89c421 -r 45b7fd8cfa94 sys/arch/x86/x86/lapic.c
--- a/sys/arch/x86/x86/lapic.c  Thu Apr 16 20:21:44 2020 +0000
+++ b/sys/arch/x86/x86/lapic.c  Sat Apr 18 14:47:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lapic.c,v 1.76.6.2 2020/04/16 08:46:35 bouyer Exp $    */
+/*     $NetBSD: lapic.c,v 1.76.6.3 2020/04/18 14:47:56 bouyer Exp $    */
 
 /*-
  * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.76.6.2 2020/04/16 08:46:35 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.76.6.3 2020/04/18 14:47:56 bouyer Exp $");
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -54,6 +54,7 @@
 
 #include <dev/ic/i8253reg.h>
 
+#include <x86/machdep.h>
 #include <machine/cpu.h>
 #include <machine/cpu_counter.h>
 #include <machine/cpufunc.h>
@@ -594,9 +595,6 @@
        lapic_writereg(LAPIC_EOI, 0);
 }
 
-extern u_long rtclock_tval; /* XXX put in header file */
-extern void (*initclock_func)(void); /* XXX put in header file */
-
 /*
  * Calibrate the local apic count-down timer (which is running at
  * bus-clock speed) vs. the i8254 counter/timer (which is running at
@@ -638,7 +636,7 @@
        for (seen = 0; seen < TIMER_FREQ / 100; seen += delta) {
                cur_i8254 = gettick();
                if (cur_i8254 > initial_i8254)
-                       delta = rtclock_tval - (cur_i8254 - initial_i8254);
+                       delta = x86_rtclock_tval - (cur_i8254 - initial_i8254);
                else
                        delta = initial_i8254 - cur_i8254;
                initial_i8254 = cur_i8254;
@@ -703,7 +701,8 @@
                 * for all our timing needs..
                 */
                delay_func = lapic_delay;
-               initclock_func = lapic_initclocks;
+               x86_cpu_initclock_func = lapic_initclocks;
+               x86_initclock_func = x86_dummy_initclock;
                initrtclock(0);
 
                if (lapic_timecounter.tc_frequency == 0) {
diff -r d73c7b89c421 -r 45b7fd8cfa94 sys/arch/x86/x86/x86_machdep.c
--- a/sys/arch/x86/x86/x86_machdep.c    Thu Apr 16 20:21:44 2020 +0000
+++ b/sys/arch/x86/x86/x86_machdep.c    Sat Apr 18 14:47:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_machdep.c,v 1.137.2.4 2020/04/16 09:45:57 bouyer Exp $     */
+/*     $NetBSD: x86_machdep.c,v 1.137.2.5 2020/04/18 14:47:56 bouyer Exp $     */
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.137.2.4 2020/04/16 09:45:57 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.137.2.5 2020/04/18 14:47:56 bouyer Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -100,6 +100,16 @@
 char module_machine_i386pae_xen[] = "i386pae-xen";
 #endif
 
+#ifndef XENPV
+void (*delay_func)(unsigned int) = i8254_delay;
+void (*x86_initclock_func)(void) = i8254_initclocks;
+void (*x86_cpu_initclock_func)(void) = x86_dummy_initclock;
+#else /* XENPV */
+void (*delay_func)(unsigned int) = xen_delay;
+void (*x86_initclock_func)(void) = xen_initclocks;
+void (*x86_cpu_initclock_func)(void) = xen_cpu_initclocks;
+#endif



Home | Main Index | Thread Index | Old Index