CVS commit: src/sys/arch/alpha

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 07:34:11 UTC 2024

Modified Files:
src/sys/arch/alpha/alpha: mcclock.c mcclockvar.h
src/sys/arch/alpha/gbus: mcclock_gbus.c

Log Message:
Alpha systems based on the "Laser" and "TurboLaser" system architecture
have an interesting feature: the RTC and console UART are present on each
CPU module, but only those peripherals on the "primary" CPU module matter,
because each CPU's module's periperals are mapped to the same physical
address, but are only accessible by that CPU module.  The firmware selects
a primary CPU to boot the system, and that CPU's RTC and UART are the
system RTC and console, respectively.

To handle this, on systems where it's needed, we wrap the RTC gettime/settime
calls and, if not running on the primary CPU already, cross-call to the primary
to perform the RTC access.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/alpha/alpha/mcclock.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/alpha/mcclockvar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/gbus/mcclock_gbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/alpha

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 07:34:11 UTC 2024

Modified Files:
src/sys/arch/alpha/alpha: mcclock.c mcclockvar.h
src/sys/arch/alpha/gbus: mcclock_gbus.c

Log Message:
Alpha systems based on the "Laser" and "TurboLaser" system architecture
have an interesting feature: the RTC and console UART are present on each
CPU module, but only those peripherals on the "primary" CPU module matter,
because each CPU's module's periperals are mapped to the same physical
address, but are only accessible by that CPU module.  The firmware selects
a primary CPU to boot the system, and that CPU's RTC and UART are the
system RTC and console, respectively.

To handle this, on systems where it's needed, we wrap the RTC gettime/settime
calls and, if not running on the primary CPU already, cross-call to the primary
to perform the RTC access.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/alpha/alpha/mcclock.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/alpha/mcclockvar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/gbus/mcclock_gbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/alpha/mcclock.c
diff -u src/sys/arch/alpha/alpha/mcclock.c:1.22 src/sys/arch/alpha/alpha/mcclock.c:1.23
--- src/sys/arch/alpha/alpha/mcclock.c:1.22	Wed Mar  6 06:30:48 2024
+++ src/sys/arch/alpha/alpha/mcclock.c	Wed Mar  6 07:34:11 2024
@@ -1,4 +1,33 @@
-/* $NetBSD: mcclock.c,v 1.22 2024/03/06 06:30:48 thorpej Exp $ */
+/* $NetBSD: mcclock.c,v 1.23 2024/03/06 07:34:11 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,9 +58,10 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.22 2024/03/06 06:30:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.23 2024/03/06 07:34:11 thorpej Exp $");
 
 #include "opt_clock_compat_osf1.h"
+#include "opt_multiprocessor.h"
 
 #include 
 #include 
@@ -40,6 +70,9 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 
 #include 
 #include 
 #include 
+#if defined(MULTIPROCESSOR)
+#include 
+#endif
 
 #include 
 
@@ -64,18 +97,95 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 
 #define UNIX_YEAR_OFFSET 0
 #endif
 
-
 static void mcclock_set_pcc_freq(struct mc146818_softc *);
 static void mcclock_init(void *);
 
+#if defined(MULTIPROCESSOR)
+struct mcclock_trampoline_arg {
+	todr_chip_handle_t	handle;	/* IN */
+	struct clock_ymdhms	*dt;	/* IN */
+	int			rv;	/* OUT */
+};
+
+static void
+mcclock_trampoline(void *arg1, void *arg2)
+{
+	int (*func)(todr_chip_handle_t, struct clock_ymdhms *) = arg1;
+	struct mcclock_trampoline_arg *arg = arg2;
+
+	arg->rv = (*func)(arg->handle, arg->dt);
+}
+
+static int
+mcclock_bounce(int (*func)(todr_chip_handle_t, struct clock_ymdhms *),
+struct mcclock_trampoline_arg *arg)
+{
+	/*
+	 * If we're not on the primary CPU, then we need to make
+	 * a cross-call to the primary to access the clock registers.
+	 * But we do a little work to avoid even calling into the
+	 * cross-call code if we can avoid it.
+	 */
+	int bound = curlwp_bind();
+
+	if (CPU_IS_PRIMARY(curcpu())) {
+		mcclock_trampoline(func, arg);
+		curlwp_bindx(bound);
+	} else {
+		curlwp_bindx(bound);
+		uint64_t token = xc_unicast(0, mcclock_trampoline,
+		func, arg, _info_primary);
+		xc_wait(token);
+	}
+	return arg->rv;
+}
+
+static int

CVS commit: src/sys/arch/alpha/alpha

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 07:22:45 UTC 2024

Modified Files:
src/sys/arch/alpha/alpha: cpu.c

Log Message:
Statically initialize the PRIMARY and RUNNING flags in cpu_info_primary.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/alpha/alpha/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/alpha/alpha

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 07:22:45 UTC 2024

Modified Files:
src/sys/arch/alpha/alpha: cpu.c

Log Message:
Statically initialize the PRIMARY and RUNNING flags in cpu_info_primary.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/alpha/alpha/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/alpha/cpu.c
diff -u src/sys/arch/alpha/alpha/cpu.c:1.107 src/sys/arch/alpha/alpha/cpu.c:1.108
--- src/sys/arch/alpha/alpha/cpu.c:1.107	Sun May 22 11:27:33 2022
+++ src/sys/arch/alpha/alpha/cpu.c	Wed Mar  6 07:22:45 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.107 2022/05/22 11:27:33 andvar Exp $ */
+/* $NetBSD: cpu.c,v 1.108 2024/03/06 07:22:45 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2020 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.107 2022/05/22 11:27:33 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.108 2024/03/06 07:22:45 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -82,7 +82,8 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.10
 #include 
 
 struct cpu_info cpu_info_primary __cacheline_aligned = {
-	.ci_curlwp = 
+	.ci_curlwp = ,
+	.ci_flags  = CPUF_PRIMARY|CPUF_RUNNING,
 };
 struct cpu_info *cpu_info_list __read_mostly = _info_primary;
 
@@ -450,7 +451,8 @@ cpuattach(device_t parent, device_t self
 	if (primary) {
 		cpu_announce_extensions(ci);
 #if defined(MULTIPROCESSOR)
-		ci->ci_flags |= CPUF_PRIMARY|CPUF_RUNNING;
+		KASSERT(ci->ci_flags & CPUF_PRIMARY);
+		KASSERT(ci->ci_flags & CPUF_RUNNING);
 		atomic_or_ulong(_booted, (1UL << ma->ma_slot));
 		atomic_or_ulong(_running, (1UL << ma->ma_slot));
 #endif /* MULTIPROCESSOR */



CVS commit: src/sys/arch/alpha

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 06:30:49 UTC 2024

Modified Files:
src/sys/arch/alpha/alpha: mcclock.c mcclockvar.h
src/sys/arch/alpha/gbus: mcclock_gbus.c
src/sys/arch/alpha/isa: mcclock_isa.c
src/sys/arch/alpha/jensenio: mcclock_jensenio.c
src/sys/arch/alpha/tc: mcclock_ioasic.c

Log Message:
Wrap the mcclock driver's mc146818_softc inside a new mcclock_softc.
This commit represents no functional change, but forms the basis for
a future functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/alpha/alpha/mcclock.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/alpha/mcclockvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/alpha/gbus/mcclock_gbus.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/alpha/isa/mcclock_isa.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/alpha/jensenio/mcclock_jensenio.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/alpha/tc/mcclock_ioasic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/alpha

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 06:30:49 UTC 2024

Modified Files:
src/sys/arch/alpha/alpha: mcclock.c mcclockvar.h
src/sys/arch/alpha/gbus: mcclock_gbus.c
src/sys/arch/alpha/isa: mcclock_isa.c
src/sys/arch/alpha/jensenio: mcclock_jensenio.c
src/sys/arch/alpha/tc: mcclock_ioasic.c

Log Message:
Wrap the mcclock driver's mc146818_softc inside a new mcclock_softc.
This commit represents no functional change, but forms the basis for
a future functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/alpha/alpha/mcclock.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/alpha/mcclockvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/alpha/gbus/mcclock_gbus.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/alpha/isa/mcclock_isa.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/alpha/jensenio/mcclock_jensenio.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/alpha/tc/mcclock_ioasic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/alpha/mcclock.c
diff -u src/sys/arch/alpha/alpha/mcclock.c:1.21 src/sys/arch/alpha/alpha/mcclock.c:1.22
--- src/sys/arch/alpha/alpha/mcclock.c:1.21	Thu Oct  1 07:21:36 2020
+++ src/sys/arch/alpha/alpha/mcclock.c	Wed Mar  6 06:30:48 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcclock.c,v 1.21 2020/10/01 07:21:36 skrll Exp $ */
+/* $NetBSD: mcclock.c,v 1.22 2024/03/06 06:30:48 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.21 2020/10/01 07:21:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcclock.c,v 1.22 2024/03/06 06:30:48 thorpej Exp $");
 
 #include "opt_clock_compat_osf1.h"
 
@@ -69,8 +69,9 @@ static void mcclock_set_pcc_freq(struct 
 static void mcclock_init(void *);
 
 void
-mcclock_attach(struct mc146818_softc *sc)
+mcclock_attach(struct mcclock_softc *msc)
 {
+	struct mc146818_softc *sc = >sc_mc146818;
 
 	sc->sc_year0 = 1900 + UNIX_YEAR_OFFSET;
 	sc->sc_flag = 0;	/* BINARY, 24HR */

Index: src/sys/arch/alpha/alpha/mcclockvar.h
diff -u src/sys/arch/alpha/alpha/mcclockvar.h:1.5 src/sys/arch/alpha/alpha/mcclockvar.h:1.6
--- src/sys/arch/alpha/alpha/mcclockvar.h:1.5	Sat Jul 21 11:59:56 2007
+++ src/sys/arch/alpha/alpha/mcclockvar.h	Wed Mar  6 06:30:48 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcclockvar.h,v 1.5 2007/07/21 11:59:56 tsutsui Exp $ */
+/* $NetBSD: mcclockvar.h,v 1.6 2024/03/06 06:30:48 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996 Carnegie-Mellon University.
@@ -27,4 +27,13 @@
  * rights to redistribute these changes.
  */
 
-void mcclock_attach(struct mc146818_softc *);
+#ifndef _ALPHA_ALPHA_MCCLOCKVAR_H_
+#define	_ALPHA_ALPHA_MCCLOCKVAR_H_
+
+struct mcclock_softc {
+	struct mc146818_softc	sc_mc146818;
+};
+
+void	mcclock_attach(struct mcclock_softc *);
+
+#endif /* _ALPHA_ALPHA_MCCLOCKVAR_H_ */

Index: src/sys/arch/alpha/gbus/mcclock_gbus.c
diff -u src/sys/arch/alpha/gbus/mcclock_gbus.c:1.3 src/sys/arch/alpha/gbus/mcclock_gbus.c:1.4
--- src/sys/arch/alpha/gbus/mcclock_gbus.c:1.3	Wed Mar  6 05:44:44 2024
+++ src/sys/arch/alpha/gbus/mcclock_gbus.c	Wed Mar  6 06:30:49 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcclock_gbus.c,v 1.3 2024/03/06 05:44:44 thorpej Exp $ */
+/* $NetBSD: mcclock_gbus.c,v 1.4 2024/03/06 06:30:49 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: mcclock_gbus.c,v 1.3 2024/03/06 05:44:44 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcclock_gbus.c,v 1.4 2024/03/06 06:30:49 thorpej Exp $");
 
 #include 
 #include 
@@ -55,7 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_gbus
 static int	mcclock_gbus_match(device_t, cfdata_t, void *);
 static void	mcclock_gbus_attach(device_t, device_t, void *);
 
-CFATTACH_DECL_NEW(mcclock_gbus, sizeof(struct mc146818_softc),
+CFATTACH_DECL_NEW(mcclock_gbus, sizeof(struct mcclock_softc),
 mcclock_gbus_match, mcclock_gbus_attach, NULL, NULL);
 
 static void	mcclock_gbus_write(struct mc146818_softc *, u_int, u_int);
@@ -74,7 +74,8 @@ mcclock_gbus_match(device_t parent, cfda
 static void
 mcclock_gbus_attach(device_t parent, device_t self, void *aux)
 {
-	struct mc146818_softc *sc = device_private(self);
+	struct mcclock_softc *msc = device_private(self);
+	struct mc146818_softc *sc = >sc_mc146818;
 	struct gbus_attach_args *ga = aux;
 
 	sc->sc_dev = self;
@@ -88,7 +89,7 @@ mcclock_gbus_attach(device_t parent, dev
 	sc->sc_mcread  = mcclock_gbus_read;
 	sc->sc_mcwrite = mcclock_gbus_write;
 
-	mcclock_attach(sc);
+	mcclock_attach(msc);
 }
 
 static void

Index: src/sys/arch/alpha/isa/mcclock_isa.c
diff -u src/sys/arch/alpha/isa/mcclock_isa.c:1.21 src/sys/arch/alpha/isa/mcclock_isa.c:1.22
--- src/sys/arch/alpha/isa/mcclock_isa.c:1.21	Fri May  7 16:58:33 2021
+++ 

CVS commit: src/sys/arch/alpha/gbus

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 05:44:44 UTC 2024

Modified Files:
src/sys/arch/alpha/gbus: mcclock_gbus.c

Log Message:
bus_space-ify.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/alpha/gbus/mcclock_gbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/gbus/mcclock_gbus.c
diff -u src/sys/arch/alpha/gbus/mcclock_gbus.c:1.2 src/sys/arch/alpha/gbus/mcclock_gbus.c:1.3
--- src/sys/arch/alpha/gbus/mcclock_gbus.c:1.2	Sat Mar  2 22:58:29 2024
+++ src/sys/arch/alpha/gbus/mcclock_gbus.c	Wed Mar  6 05:44:44 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcclock_gbus.c,v 1.2 2024/03/02 22:58:29 thorpej Exp $ */
+/* $NetBSD: mcclock_gbus.c,v 1.3 2024/03/06 05:44:44 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: mcclock_gbus.c,v 1.2 2024/03/02 22:58:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcclock_gbus.c,v 1.3 2024/03/06 05:44:44 thorpej Exp $");
 
 #include 
 #include 
@@ -43,8 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_gbus
 
 #include 
 
-#include 		/* XXX */
-
 #include 
 
 #include 
@@ -54,27 +52,15 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_gbus
 
 #include "ioconf.h"
 
-#define	KV(_addr)	((void *)ALPHA_PHYS_TO_K0SEG((_addr)))
-/*
- * Registers are 64 bytes apart (and 1 byte wide)
- */
-#define	REGSHIFT	6
-
-struct mcclock_gbus_softc {
-	struct mc146818_softc	sc_mc146818;
-	unsigned long regbase;
-};
-
 static int	mcclock_gbus_match(device_t, cfdata_t, void *);
 static void	mcclock_gbus_attach(device_t, device_t, void *);
 
-CFATTACH_DECL_NEW(mcclock_gbus, sizeof(struct mcclock_gbus_softc),
+CFATTACH_DECL_NEW(mcclock_gbus, sizeof(struct mc146818_softc),
 mcclock_gbus_match, mcclock_gbus_attach, NULL, NULL);
 
 static void	mcclock_gbus_write(struct mc146818_softc *, u_int, u_int);
 static u_int	mcclock_gbus_read(struct mc146818_softc *, u_int);
 
-
 static int
 mcclock_gbus_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -88,14 +74,17 @@ mcclock_gbus_match(device_t parent, cfda
 static void
 mcclock_gbus_attach(device_t parent, device_t self, void *aux)
 {
-	struct mcclock_gbus_softc *tsc = device_private(self);
+	struct mc146818_softc *sc = device_private(self);
 	struct gbus_attach_args *ga = aux;
-	struct mc146818_softc *sc = >sc_mc146818;
-
-	/* XXX Should be bus.h'd, so we can accommodate the kn7aa. */
-	tsc->regbase = TLSB_GBUS_BASE + ga->ga_offset;
 
 	sc->sc_dev = self;
+	sc->sc_bst = ga->ga_iot;
+
+	if (bus_space_map(sc->sc_bst, ga->ga_offset, MC_NREGS+MC_NVRAM_SIZE,
+			  0, >sc_bsh) != 0) {
+		panic("mcclock_gbus_attach: couldn't map clock I/O space");
+	}
+
 	sc->sc_mcread  = mcclock_gbus_read;
 	sc->sc_mcwrite = mcclock_gbus_write;
 
@@ -105,19 +94,11 @@ mcclock_gbus_attach(device_t parent, dev
 static void
 mcclock_gbus_write(struct mc146818_softc *sc, u_int reg, u_int val)
 {
-	struct mcclock_gbus_softc *tsc = (void *)sc;
-	unsigned char *ptr = (unsigned char *)
-		KV(tsc->regbase + (reg << REGSHIFT));
-
-	*ptr = val;
+	bus_space_write_1(sc->sc_bst, sc->sc_bsh, reg, (uint8_t)val);
 }
 
 static u_int
 mcclock_gbus_read(struct mc146818_softc *sc, u_int reg)
 {
-	struct mcclock_gbus_softc *tsc = (void *)sc;
-	unsigned char *ptr = (unsigned char *)
-		KV(tsc->regbase + (reg << REGSHIFT));
-
-	return *ptr;
+	return bus_space_read_1(sc->sc_bst, sc->sc_bsh, reg);
 }



CVS commit: src/sys/arch/alpha/gbus

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 05:44:44 UTC 2024

Modified Files:
src/sys/arch/alpha/gbus: mcclock_gbus.c

Log Message:
bus_space-ify.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/alpha/gbus/mcclock_gbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/alpha

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 05:33:09 UTC 2024

Modified Files:
src/sys/arch/alpha/conf: files.alpha
src/sys/arch/alpha/gbus: gbus.c gbusvar.h
Added Files:
src/sys/arch/alpha/gbus: gbus_io.c

Log Message:
Add a bus space implementation for the Gbus, the general 8-bit bus present
on Laser / TurboLaser CPU modules.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/sys/arch/alpha/conf/files.alpha
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/alpha/gbus/gbus.c \
src/sys/arch/alpha/gbus/gbusvar.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/alpha/gbus/gbus_io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/conf/files.alpha
diff -u src/sys/arch/alpha/conf/files.alpha:1.196 src/sys/arch/alpha/conf/files.alpha:1.197
--- src/sys/arch/alpha/conf/files.alpha:1.196	Sat Mar  2 20:15:33 2024
+++ src/sys/arch/alpha/conf/files.alpha	Wed Mar  6 05:33:09 2024
@@ -1,4 +1,4 @@
-# $NetBSD: files.alpha,v 1.196 2024/03/02 20:15:33 thorpej Exp $
+# $NetBSD: files.alpha,v 1.197 2024/03/06 05:33:09 thorpej Exp $
 #
 # alpha-specific configuration info
 
@@ -104,6 +104,7 @@ file	arch/alpha/tlsb/tlsbmem.c	tlsbmem
 device	gbus { offset = -1 }
 attach	gbus at tlsb
 file	arch/alpha/gbus/gbus.c		gbus
+file	arch/alpha/gbus/gbus_io.c	gbus
 
 #
 # MCBUS support

Index: src/sys/arch/alpha/gbus/gbus.c
diff -u src/sys/arch/alpha/gbus/gbus.c:1.1 src/sys/arch/alpha/gbus/gbus.c:1.2
--- src/sys/arch/alpha/gbus/gbus.c:1.1	Sat Mar  2 19:57:57 2024
+++ src/sys/arch/alpha/gbus/gbus.c	Wed Mar  6 05:33:09 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: gbus.c,v 1.1 2024/03/02 19:57:57 thorpej Exp $ */
+/* $NetBSD: gbus.c,v 1.2 2024/03/06 05:33:09 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -37,7 +37,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: gbus.c,v 1.1 2024/03/02 19:57:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gbus.c,v 1.2 2024/03/06 05:33:09 thorpej Exp $");
 
 #include 
 #include 
@@ -70,10 +70,10 @@ CFATTACH_DECL_NEW(gbus, sizeof(struct gb
 static int	gbusprint(void *, const char *);
 
 static const struct gbus_attach_args gbus_children[] = {
-	{ "zsc",	GBUS_DUART0_OFFSET },
-	{ "zsc",	GBUS_DUART1_OFFSET },
-	{ "mcclock",	GBUS_CLOCK_OFFSET },
-	{ NULL,		0 },
+	{ "zsc",	NULL,	GBUS_DUART0_OFFSET },
+	{ "zsc",	NULL,	GBUS_DUART1_OFFSET },
+	{ "mcclock",	NULL,	GBUS_CLOCK_OFFSET },
+	{ NULL,		NULL,	0 },
 };
 
 static int
@@ -113,6 +113,7 @@ gbusattach(device_t parent, device_t sel
 	struct gbus_softc *sc = device_private(self);
 	struct tlsb_dev_attach_args *ta = aux;
 	const struct gbus_attach_args *ga;
+	bus_space_tag_t iot = gbus_io_init(TLSB_GBUS_BASE);
 	int locs[GBUSCF_NLOCS];
 
 	aprint_normal("\n");
@@ -123,6 +124,7 @@ gbusattach(device_t parent, device_t sel
 	/* Attach the children. */
 	for (ga = gbus_children; ga->ga_name != NULL; ga++) {
 		struct gbus_attach_args gaa = *ga;
+		gaa.ga_iot = iot;
 		locs[GBUSCF_OFFSET] = gaa.ga_offset;
 		config_found(self, , gbusprint,
 		CFARGS(.submatch = config_stdsubmatch,
Index: src/sys/arch/alpha/gbus/gbusvar.h
diff -u src/sys/arch/alpha/gbus/gbusvar.h:1.1 src/sys/arch/alpha/gbus/gbusvar.h:1.2
--- src/sys/arch/alpha/gbus/gbusvar.h:1.1	Sat Mar  2 19:57:57 2024
+++ src/sys/arch/alpha/gbus/gbusvar.h	Wed Mar  6 05:33:09 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: gbusvar.h,v 1.1 2024/03/02 19:57:57 thorpej Exp $ */
+/* $NetBSD: gbusvar.h,v 1.2 2024/03/06 05:33:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,6 +30,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef _ALPHA_GBUS_GBUSVAR_H_
+#define	_ALPHA_GBUS_GBUSVAR_H_
+
 /*
  * Autoconfiguration definitions for the Gbus found on TurboLaser CPU modules.
  */
@@ -37,6 +40,11 @@
 #include 
 
 struct gbus_attach_args {
-	const char *ga_name;		/* name of device */
-	bus_addr_t  ga_offset;		/* offset from Gbus base */
+	const char *	ga_name;	/* name of device */
+	bus_space_tag_t	ga_iot;		/* I/O space tag */
+	bus_addr_t	ga_offset;	/* offset from Gbus base */
 };
+
+bus_space_tag_t	gbus_io_init(paddr_t);
+
+#endif /* _ALPHA_GBUS_GBUSVAR_H_ */

Added files:

Index: src/sys/arch/alpha/gbus/gbus_io.c
diff -u /dev/null src/sys/arch/alpha/gbus/gbus_io.c:1.1
--- /dev/null	Wed Mar  6 05:33:10 2024
+++ src/sys/arch/alpha/gbus/gbus_io.c	Wed Mar  6 05:33:09 2024
@@ -0,0 +1,177 @@
+/* $NetBSD: gbus_io.c,v 1.1 2024/03/06 05:33:09 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2024 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the 

CVS commit: src/sys/arch/alpha

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 05:33:09 UTC 2024

Modified Files:
src/sys/arch/alpha/conf: files.alpha
src/sys/arch/alpha/gbus: gbus.c gbusvar.h
Added Files:
src/sys/arch/alpha/gbus: gbus_io.c

Log Message:
Add a bus space implementation for the Gbus, the general 8-bit bus present
on Laser / TurboLaser CPU modules.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/sys/arch/alpha/conf/files.alpha
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/alpha/gbus/gbus.c \
src/sys/arch/alpha/gbus/gbusvar.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/alpha/gbus/gbus_io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 02:31:44 UTC 2024

Modified Files:
src/sys/dev/ic: mc146818.c mc146818var.h

Log Message:
Expose mc146818_{get,set}time_ymdhms() and allow a front-end to override
these function pointers in the TODR handle, allowing the front-end to
wrap mc146818_{get,set}time_ymdhms() with special handling, if needed.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/ic/mc146818.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/mc146818var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/mc146818.c
diff -u src/sys/dev/ic/mc146818.c:1.20 src/sys/dev/ic/mc146818.c:1.21
--- src/sys/dev/ic/mc146818.c:1.20	Wed Jan  1 19:24:03 2020
+++ src/sys/dev/ic/mc146818.c	Wed Mar  6 02:31:44 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mc146818.c,v 1.20 2020/01/01 19:24:03 thorpej Exp $	*/
+/*	$NetBSD: mc146818.c,v 1.21 2024/03/06 02:31:44 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2003 Izumi Tsutsui.  All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mc146818.c,v 1.20 2020/01/01 19:24:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mc146818.c,v 1.21 2024/03/06 02:31:44 thorpej Exp $");
 
 #include 
 #include 
@@ -43,9 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: mc146818.c,v
 #include 
 #include 
 
-int mc146818_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
-int mc146818_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
-
 void
 mc146818_attach(struct mc146818_softc *sc)
 {
@@ -61,11 +58,14 @@ mc146818_attach(struct mc146818_softc *s
 
 	handle = >sc_handle;
 	handle->cookie = sc;
-	handle->todr_gettime = NULL;
-	handle->todr_settime = NULL;
-	handle->todr_gettime_ymdhms = mc146818_gettime_ymdhms;
-	handle->todr_settime_ymdhms = mc146818_settime_ymdhms;
-	handle->todr_setwen  = NULL;
+	KASSERT(handle->todr_gettime == NULL);
+	KASSERT(handle->todr_settime == NULL);
+	if (handle->todr_gettime_ymdhms == NULL) {
+		handle->todr_gettime_ymdhms = mc146818_gettime_ymdhms;
+	}
+	if (handle->todr_settime_ymdhms == NULL) {
+		handle->todr_settime_ymdhms = mc146818_settime_ymdhms;
+	}
 
 	todr_attach(handle);
 }
@@ -103,7 +103,7 @@ mc146818_gettime_ymdhms(todr_chip_handle
 	dt->dt_wday = FROMREG((*sc->sc_mcread)(sc, MC_DOW));
 	dt->dt_day  = FROMREG((*sc->sc_mcread)(sc, MC_DOM));
 	dt->dt_mon  = FROMREG((*sc->sc_mcread)(sc, MC_MONTH));
-	year   = FROMREG((*sc->sc_mcread)(sc, MC_YEAR));
+	year= FROMREG((*sc->sc_mcread)(sc, MC_YEAR));
 	if (sc->sc_getcent) {
 		cent = (*sc->sc_getcent)(sc);
 		year += cent * 100;

Index: src/sys/dev/ic/mc146818var.h
diff -u src/sys/dev/ic/mc146818var.h:1.7 src/sys/dev/ic/mc146818var.h:1.8
--- src/sys/dev/ic/mc146818var.h:1.7	Wed May 14 13:29:29 2008
+++ src/sys/dev/ic/mc146818var.h	Wed Mar  6 02:31:44 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mc146818var.h,v 1.7 2008/05/14 13:29:29 tsutsui Exp $	*/
+/*	$NetBSD: mc146818var.h,v 1.8 2024/03/06 02:31:44 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2003 Izumi Tsutsui.  All rights reserved.
@@ -24,6 +24,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef _DEV_IC_MC146818VAR_H_
+#define	_DEV_IC_MC146818VAR_H_
+
 struct mc146818_softc {
 	device_t sc_dev;
 
@@ -45,4 +48,8 @@ struct mc146818_softc {
 	void (*sc_setcent)(struct mc146818_softc *, u_int);
 };
 
-void mc146818_attach(struct mc146818_softc *);
+void	mc146818_attach(struct mc146818_softc *);
+int	mc146818_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
+int	mc146818_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
+
+#endif /* _DEV_IC_MC146818VAR_H_ */



CVS commit: src/sys/dev/ic

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 02:31:44 UTC 2024

Modified Files:
src/sys/dev/ic: mc146818.c mc146818var.h

Log Message:
Expose mc146818_{get,set}time_ymdhms() and allow a front-end to override
these function pointers in the TODR handle, allowing the front-end to
wrap mc146818_{get,set}time_ymdhms() with special handling, if needed.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/ic/mc146818.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/mc146818var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2024-03-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  5 23:07:58 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: var-scope-local.exp var-scope-local.mk

Log Message:
tests/make: clean up test for local scope variables

Use the same style of quotes for both kinds of variables.  To make the
variable values more easily comparable, write them to a single line.
Add the output to the 'expect' lines.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-scope-local.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-scope-local.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2024-03-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  5 23:07:58 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: var-scope-local.exp var-scope-local.mk

Log Message:
tests/make: clean up test for local scope variables

Use the same style of quotes for both kinds of variables.  To make the
variable values more easily comparable, write them to a single line.
Add the output to the 'expect' lines.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-scope-local.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-scope-local.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/var-scope-local.exp
diff -u src/usr.bin/make/unit-tests/var-scope-local.exp:1.8 src/usr.bin/make/unit-tests/var-scope-local.exp:1.9
--- src/usr.bin/make/unit-tests/var-scope-local.exp:1.8	Fri Mar  1 20:15:59 2024
+++ src/usr.bin/make/unit-tests/var-scope-local.exp	Tue Mar  5 23:07:58 2024
@@ -60,19 +60,12 @@ dir/subdir/inference-rule-chain.ir-to: *
 : Making var-scope-local.c out of nothing.
 : Making var-scope-local.o from var-scope-local.c.
 : Making basename "var-scope-local.o" in "." from "var-scope-local.c" in ".".
-: Making var-scope-local-assign.o with VAR="local".
-var-scope-local-assign.o env has VAR='local'
-: Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
-var-scope-local-append.o env has VAR='local to var-scope-local-append.o'
-: Making var-scope-local-append-global.o with VAR="global+local".
-var-scope-local-append-global.o env has VAR='global+local'
-: Making var-scope-local-default.o with VAR="global".
-var-scope-local-default.o env has VAR='global'
-: Making var-scope-local-subst.o with VAR="global+local".
-var-scope-local-subst.o env has VAR='global+local'
-: Making var-scope-local-shell.o with VAR="output".
-var-scope-local-shell.o env has VAR='output'
-: var-scope-local-use.o uses .USE VAR="global"
-var-scope-local-use.o env has VAR='global'
+Making var-scope-local-assign.o with make 'local' and env 'local'.
+Making var-scope-local-append.o with make 'local to var-scope-local-append.o' and env 'local to var-scope-local-append.o'.
+Making var-scope-local-append-global.o with make 'global+local' and env 'global+local'.
+Making var-scope-local-default.o with make 'global' and env 'global'.
+Making var-scope-local-subst.o with make 'global+local' and env 'global+local'.
+Making var-scope-local-shell.o with make 'output' and env 'output'.
+Making .USE var-scope-local-use.o with make 'global' and env 'global'.
 : all overwritten
 exit status 0

Index: src/usr.bin/make/unit-tests/var-scope-local.mk
diff -u src/usr.bin/make/unit-tests/var-scope-local.mk:1.10 src/usr.bin/make/unit-tests/var-scope-local.mk:1.11
--- src/usr.bin/make/unit-tests/var-scope-local.mk:1.10	Fri Mar  1 20:15:59 2024
+++ src/usr.bin/make/unit-tests/var-scope-local.mk	Tue Mar  5 23:07:58 2024
@@ -1,4 +1,4 @@
-# $NetBSD: var-scope-local.mk,v 1.10 2024/03/01 20:15:59 sjg Exp $
+# $NetBSD: var-scope-local.mk,v 1.11 2024/03/05 23:07:58 rillig Exp $
 #
 # Tests for target-local variables, such as ${.TARGET} or $@.  These variables
 # are relatively short-lived as they are created just before making the
@@ -199,8 +199,7 @@ var-scope-local-append-global.o \
 var-scope-local-default.o \
 var-scope-local-subst.o \
 var-scope-local-shell.o:
-	: Making ${.TARGET} with VAR="${VAR}".
-	@echo "${.TARGET} env has VAR='$$VAR'"
+	@echo "Making ${.TARGET} with make '"${VAR:Q}"' and env '$$VAR'."
 
 # Target-local variables are enabled by default.  Force them to be enabled
 # just in case a test above has disabled them.
@@ -215,7 +214,7 @@ VAR=	global
 # irrelevant.
 #
 # expect-reset
-# expect: : Making var-scope-local-assign.o with VAR="local".
+# expect: Making var-scope-local-assign.o with make 'local' and env 'local'.
 var-scope-local-assign.o: VAR= local
 
 # Assignments using '+=' do *not* look up the global value, instead they only
@@ -225,7 +224,7 @@ var-scope-local-append.o: VAR+= local
 # behaves as expected.  Note that the expression '${.TARGET}' is not resolved
 # when parsing the dependency line, its evaluation is deferred until the
 # target is actually made.
-# expect: : Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
+# expect: Making var-scope-local-append.o with make 'local to var-scope-local-append.o' and env 'local to var-scope-local-append.o'.
 var-scope-local-append.o: VAR += to ${.TARGET}
 # To access the value of a global variable, use an expression.  This
 # expression is expanded before parsing the whole dependency line.  Since the
@@ -235,7 +234,7 @@ var-scope-local-append.o: VAR += to ${.T
 # not influence the parsing of the variable assignment.  The effective
 # variable assignment, after expanding the whole line first, is thus
 # 'VAR= global+local'.
-# expect: : Making 

CVS commit: src/sys

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar  5 20:59:41 UTC 2024

Modified Files:
src/sys/kern: init_main.c subr_cpu.c
src/sys/sys: cpu.h

Log Message:
Revert previous until I can diagnose a failure reported by gson.


To generate a diff of this commit:
cvs rdiff -u -r1.548 -r1.549 src/sys/kern/init_main.c
cvs rdiff -u -r1.21 -r1.22 src/sys/kern/subr_cpu.c
cvs rdiff -u -r1.53 -r1.54 src/sys/sys/cpu.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar  5 20:59:41 UTC 2024

Modified Files:
src/sys/kern: init_main.c subr_cpu.c
src/sys/sys: cpu.h

Log Message:
Revert previous until I can diagnose a failure reported by gson.


To generate a diff of this commit:
cvs rdiff -u -r1.548 -r1.549 src/sys/kern/init_main.c
cvs rdiff -u -r1.21 -r1.22 src/sys/kern/subr_cpu.c
cvs rdiff -u -r1.53 -r1.54 src/sys/sys/cpu.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.548 src/sys/kern/init_main.c:1.549
--- src/sys/kern/init_main.c:1.548	Tue Mar  5 14:39:29 2024
+++ src/sys/kern/init_main.c	Tue Mar  5 20:59:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.548 2024/03/05 14:39:29 thorpej Exp $	*/
+/*	$NetBSD: init_main.c,v 1.549 2024/03/05 20:59:41 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019, 2023 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.548 2024/03/05 14:39:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.549 2024/03/05 20:59:41 thorpej Exp $");
 
 #include "opt_cnmagic.h"
 #include "opt_ddb.h"
@@ -275,8 +275,7 @@ main(void)
 #ifdef DIAGNOSTIC
 	/*
 	 * Verify that CPU_INFO_FOREACH() knows about the boot CPU
-	 * and only the boot CPU at this point.  The boot CPU should
-	 * also be marked PRIMARY.
+	 * and only the boot CPU at this point.
 	 */
 	int cpucount = 0;
 	for (CPU_INFO_FOREACH(cii, ci)) {
@@ -284,12 +283,8 @@ main(void)
 		cpucount++;
 	}
 	KASSERT(cpucount == 1);
-	KASSERT(CPU_IS_PRIMARY(curcpu()));
 #endif
 
-	/* Stash a pointer to the boot CPU for quick reference wheen needed. */
-	boot_cpu = curcpu();
-
 	l = 
 #ifndef LWP0_CPU_INFO
 	l->l_cpu = curcpu();

Index: src/sys/kern/subr_cpu.c
diff -u src/sys/kern/subr_cpu.c:1.21 src/sys/kern/subr_cpu.c:1.22
--- src/sys/kern/subr_cpu.c:1.21	Tue Mar  5 14:39:29 2024
+++ src/sys/kern/subr_cpu.c	Tue Mar  5 20:59:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cpu.c,v 1.21 2024/03/05 14:39:29 thorpej Exp $	*/
+/*	$NetBSD: subr_cpu.c,v 1.22 2024/03/05 20:59:41 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019, 2020
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.21 2024/03/05 14:39:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.22 2024/03/05 20:59:41 thorpej Exp $");
 
 #include 
 #include 
@@ -86,9 +86,6 @@ int64_t		cpu_counts[CPU_COUNT_MAX];
 /* An array of CPUs.  There are ncpu entries. */
 struct cpu_info **cpu_infos		__read_mostly;
 
-/* A pointer to the boot CPU, for quick reference when needed. */
-struct cpu_info *boot_cpu		__read_mostly;
-
 /* Note: set on mi_cpu_attach() and idle_loop(). */
 kcpuset_t *	kcpuset_attached	__read_mostly	= NULL;
 kcpuset_t *	kcpuset_running		__read_mostly	= NULL;

Index: src/sys/sys/cpu.h
diff -u src/sys/sys/cpu.h:1.53 src/sys/sys/cpu.h:1.54
--- src/sys/sys/cpu.h:1.53	Tue Mar  5 14:39:29 2024
+++ src/sys/sys/cpu.h	Tue Mar  5 20:59:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.53 2024/03/05 14:39:29 thorpej Exp $	*/
+/*	$NetBSD: cpu.h,v 1.54 2024/03/05 20:59:41 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2007 YAMAMOTO Takashi,
@@ -100,7 +100,6 @@ void	cpu_topology_init(void);
 extern kmutex_t cpu_lock;
 extern u_int maxcpus;
 extern struct cpu_info **cpu_infos;
-extern struct cpu_info *boot_cpu;
 extern kcpuset_t *kcpuset_attached;
 extern kcpuset_t *kcpuset_running;
 



CVS commit: src/sys/arch

2024-03-05 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Mar  5 20:58:05 UTC 2024

Modified Files:
src/sys/arch/mac68k/dev: adb_direct.c
src/sys/arch/macppc/dev: adb_direct.c
src/sys/arch/x86/x86: intr.c

Log Message:
Remove duplicate "when" word in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/mac68k/dev/adb_direct.c
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/macppc/dev/adb_direct.c
cvs rdiff -u -r1.166 -r1.167 src/sys/arch/x86/x86/intr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch

2024-03-05 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Mar  5 20:58:05 UTC 2024

Modified Files:
src/sys/arch/mac68k/dev: adb_direct.c
src/sys/arch/macppc/dev: adb_direct.c
src/sys/arch/x86/x86: intr.c

Log Message:
Remove duplicate "when" word in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/mac68k/dev/adb_direct.c
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/macppc/dev/adb_direct.c
cvs rdiff -u -r1.166 -r1.167 src/sys/arch/x86/x86/intr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mac68k/dev/adb_direct.c
diff -u src/sys/arch/mac68k/dev/adb_direct.c:1.71 src/sys/arch/mac68k/dev/adb_direct.c:1.72
--- src/sys/arch/mac68k/dev/adb_direct.c:1.71	Wed Feb 28 13:05:39 2024
+++ src/sys/arch/mac68k/dev/adb_direct.c	Tue Mar  5 20:58:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: adb_direct.c,v 1.71 2024/02/28 13:05:39 thorpej Exp $	*/
+/*	$NetBSD: adb_direct.c,v 1.72 2024/03/05 20:58:05 andvar Exp $	*/
 
 /* From: adb_direct.c 2.02 4/18/97 jpw */
 
@@ -62,7 +62,7 @@
 #ifdef __NetBSD__
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adb_direct.c,v 1.71 2024/02/28 13:05:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adb_direct.c,v 1.72 2024/03/05 20:58:05 andvar Exp $");
 
 #include "opt_adb.h"
 
@@ -394,7 +394,7 @@ adb_cuda_tickle(void)
 }
 
 /*
- * called when when an adb interrupt happens
+ * called when an adb interrupt happens
  *
  * Cuda version of adb_intr
  * TO DO: do we want to add some calls to intr_dispatch() here to
@@ -1208,7 +1208,7 @@ adb_guess_next_device(void)
 
 
 /*
- * Called when when an adb interrupt happens.
+ * Called when an adb interrupt happens.
  * This routine simply transfers control over to the appropriate
  * code for the machine we are running on.
  */
@@ -1241,7 +1241,7 @@ adb_intr(void *arg)
 
 
 /*
- * called when when an adb interrupt happens
+ * called when an adb interrupt happens
  *
  * IIsi version of adb_intr
  *

Index: src/sys/arch/macppc/dev/adb_direct.c
diff -u src/sys/arch/macppc/dev/adb_direct.c:1.45 src/sys/arch/macppc/dev/adb_direct.c:1.46
--- src/sys/arch/macppc/dev/adb_direct.c:1.45	Thu Sep 21 09:31:49 2023
+++ src/sys/arch/macppc/dev/adb_direct.c	Tue Mar  5 20:58:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: adb_direct.c,v 1.45 2023/09/21 09:31:49 msaitoh Exp $	*/
+/*	$NetBSD: adb_direct.c,v 1.46 2024/03/05 20:58:05 andvar Exp $	*/
 
 /* From: adb_direct.c 2.02 4/18/97 jpw */
 
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adb_direct.c,v 1.45 2023/09/21 09:31:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adb_direct.c,v 1.46 2024/03/05 20:58:05 andvar Exp $");
 
 #include 
 #include 
@@ -319,7 +319,7 @@ adb_cuda_tickle(void)
 }
 
 /*
- * called when when an adb interrupt happens
+ * called when an adb interrupt happens
  *
  * Cuda version of adb_intr
  * TO DO: do we want to add some calls to intr_dispatch() here to

Index: src/sys/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.166 src/sys/arch/x86/x86/intr.c:1.167
--- src/sys/arch/x86/x86/intr.c:1.166	Wed Nov 29 11:40:37 2023
+++ src/sys/arch/x86/x86/intr.c	Tue Mar  5 20:58:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.166 2023/11/29 11:40:37 mlelstv Exp $	*/
+/*	$NetBSD: intr.c,v 1.167 2024/03/05 20:58:05 andvar Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.166 2023/11/29 11:40:37 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.167 2024/03/05 20:58:05 andvar Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -1056,7 +1056,7 @@ intr_mask_xcall(void *arg1, void *arg2)
 			 * For level-sensitive interrupts, the hardware
 			 * will let us know.  For everything else, we
 			 * need to explicitly handle interrupts that
-			 * happened when when the source was masked.
+			 * happened when the source was masked.
 			 */
 			const uint64_t bit = (1U << ih->ih_slot);
 			if (ci->ci_imasked & bit) {



CVS commit: src/sys

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar  5 14:39:30 UTC 2024

Modified Files:
src/sys/kern: init_main.c subr_cpu.c
src/sys/sys: cpu.h

Log Message:
Early in main(), assert that curcpu() evaluates as the primary CPU and
stash away a pointer to it as the boot CPU for quick reference later.


To generate a diff of this commit:
cvs rdiff -u -r1.547 -r1.548 src/sys/kern/init_main.c
cvs rdiff -u -r1.20 -r1.21 src/sys/kern/subr_cpu.c
cvs rdiff -u -r1.52 -r1.53 src/sys/sys/cpu.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.547 src/sys/kern/init_main.c:1.548
--- src/sys/kern/init_main.c:1.547	Wed Jan 17 10:18:41 2024
+++ src/sys/kern/init_main.c	Tue Mar  5 14:39:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.547 2024/01/17 10:18:41 hannken Exp $	*/
+/*	$NetBSD: init_main.c,v 1.548 2024/03/05 14:39:29 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019, 2023 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.547 2024/01/17 10:18:41 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.548 2024/03/05 14:39:29 thorpej Exp $");
 
 #include "opt_cnmagic.h"
 #include "opt_ddb.h"
@@ -275,7 +275,8 @@ main(void)
 #ifdef DIAGNOSTIC
 	/*
 	 * Verify that CPU_INFO_FOREACH() knows about the boot CPU
-	 * and only the boot CPU at this point.
+	 * and only the boot CPU at this point.  The boot CPU should
+	 * also be marked PRIMARY.
 	 */
 	int cpucount = 0;
 	for (CPU_INFO_FOREACH(cii, ci)) {
@@ -283,8 +284,12 @@ main(void)
 		cpucount++;
 	}
 	KASSERT(cpucount == 1);
+	KASSERT(CPU_IS_PRIMARY(curcpu()));
 #endif
 
+	/* Stash a pointer to the boot CPU for quick reference wheen needed. */
+	boot_cpu = curcpu();
+
 	l = 
 #ifndef LWP0_CPU_INFO
 	l->l_cpu = curcpu();

Index: src/sys/kern/subr_cpu.c
diff -u src/sys/kern/subr_cpu.c:1.20 src/sys/kern/subr_cpu.c:1.21
--- src/sys/kern/subr_cpu.c:1.20	Thu Jan  4 11:18:19 2024
+++ src/sys/kern/subr_cpu.c	Tue Mar  5 14:39:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cpu.c,v 1.20 2024/01/04 11:18:19 mlelstv Exp $	*/
+/*	$NetBSD: subr_cpu.c,v 1.21 2024/03/05 14:39:29 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019, 2020
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.20 2024/01/04 11:18:19 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.21 2024/03/05 14:39:29 thorpej Exp $");
 
 #include 
 #include 
@@ -86,6 +86,9 @@ int64_t		cpu_counts[CPU_COUNT_MAX];
 /* An array of CPUs.  There are ncpu entries. */
 struct cpu_info **cpu_infos		__read_mostly;
 
+/* A pointer to the boot CPU, for quick reference when needed. */
+struct cpu_info *boot_cpu		__read_mostly;
+
 /* Note: set on mi_cpu_attach() and idle_loop(). */
 kcpuset_t *	kcpuset_attached	__read_mostly	= NULL;
 kcpuset_t *	kcpuset_running		__read_mostly	= NULL;

Index: src/sys/sys/cpu.h
diff -u src/sys/sys/cpu.h:1.52 src/sys/sys/cpu.h:1.53
--- src/sys/sys/cpu.h:1.52	Sat Jul  8 13:59:05 2023
+++ src/sys/sys/cpu.h	Tue Mar  5 14:39:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.52 2023/07/08 13:59:05 riastradh Exp $	*/
+/*	$NetBSD: cpu.h,v 1.53 2024/03/05 14:39:29 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2007 YAMAMOTO Takashi,
@@ -100,6 +100,7 @@ void	cpu_topology_init(void);
 extern kmutex_t cpu_lock;
 extern u_int maxcpus;
 extern struct cpu_info **cpu_infos;
+extern struct cpu_info *boot_cpu;
 extern kcpuset_t *kcpuset_attached;
 extern kcpuset_t *kcpuset_running;
 



CVS commit: src/sys

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar  5 14:39:30 UTC 2024

Modified Files:
src/sys/kern: init_main.c subr_cpu.c
src/sys/sys: cpu.h

Log Message:
Early in main(), assert that curcpu() evaluates as the primary CPU and
stash away a pointer to it as the boot CPU for quick reference later.


To generate a diff of this commit:
cvs rdiff -u -r1.547 -r1.548 src/sys/kern/init_main.c
cvs rdiff -u -r1.20 -r1.21 src/sys/kern/subr_cpu.c
cvs rdiff -u -r1.52 -r1.53 src/sys/sys/cpu.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/uvm

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar  5 14:33:50 UTC 2024

Modified Files:
src/sys/uvm: uvm_page.c

Log Message:
Rename the local "boot_cpu" variable to "uvm_boot_cpu".


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/uvm/uvm_page.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/uvm

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar  5 14:33:50 UTC 2024

Modified Files:
src/sys/uvm: uvm_page.c

Log Message:
Rename the local "boot_cpu" variable to "uvm_boot_cpu".


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/uvm/uvm_page.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/uvm/uvm_page.c
diff -u src/sys/uvm/uvm_page.c:1.255 src/sys/uvm/uvm_page.c:1.256
--- src/sys/uvm/uvm_page.c:1.255	Sat Feb 10 09:24:18 2024
+++ src/sys/uvm/uvm_page.c	Tue Mar  5 14:33:50 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_page.c,v 1.255 2024/02/10 09:24:18 andvar Exp $	*/
+/*	$NetBSD: uvm_page.c,v 1.256 2024/03/05 14:33:50 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.255 2024/02/10 09:24:18 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.256 2024/03/05 14:33:50 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvm.h"
@@ -328,7 +328,7 @@ uvm_page_init_bucket(struct pgfreelist *
 void
 uvm_page_init(vaddr_t *kvm_startp, vaddr_t *kvm_endp)
 {
-	static struct uvm_cpu boot_cpu __cacheline_aligned;
+	static struct uvm_cpu uvm_boot_cpu __cacheline_aligned;
 	psize_t freepages, pagecount, bucketsize, n;
 	struct pgflbucket *pgb;
 	struct vm_page *pagearray;
@@ -344,7 +344,7 @@ uvm_page_init(vaddr_t *kvm_startp, vaddr
 	 * structures).
 	 */
 
-	curcpu()->ci_data.cpu_uvm = _cpu;
+	curcpu()->ci_data.cpu_uvm = _boot_cpu;
 	uvmpdpol_init();
 	for (b = 0; b < __arraycount(uvm_freelist_locks); b++) {
 		mutex_init(_freelist_locks[b].lock, MUTEX_DEFAULT, IPL_VM);



CVS commit: src/sys

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar  5 14:15:36 UTC 2024

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_reboot.c
src/sys/arch/algor/algor: machdep.c
src/sys/arch/alpha/alpha: machdep.c
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/amiga/amiga: machdep.c
src/sys/arch/amigappc/amigappc: machdep.c
src/sys/arch/amigappc/include: autoconf.h
src/sys/arch/arc/arc: machdep.c
src/sys/arch/arm/arm32: arm32_machdep.c
src/sys/arch/atari/atari: machdep.c
src/sys/arch/bebox/bebox: machdep.c
src/sys/arch/cesfic/cesfic: machdep.c
src/sys/arch/cobalt/cobalt: machdep.c
src/sys/arch/dreamcast/dreamcast: machdep.c
src/sys/arch/emips/emips: machdep.c
src/sys/arch/evbarm/imx23_olinuxino: imx23_olinuxino_machdep.c
src/sys/arch/evbmips/adm5120: machdep.c
src/sys/arch/evbmips/alchemy: machdep.c
src/sys/arch/evbmips/atheros: machdep.c
src/sys/arch/evbmips/cavium: machdep.c
src/sys/arch/evbmips/gdium: machdep.c
src/sys/arch/evbmips/ingenic: machdep.c
src/sys/arch/evbmips/loongson: machdep.c
src/sys/arch/evbmips/malta: machdep.c
src/sys/arch/evbmips/mipssim: machdep.c
src/sys/arch/evbmips/rasoc: machdep.c
src/sys/arch/evbmips/rmixl: machdep.c
src/sys/arch/evbmips/sbmips: machdep.c
src/sys/arch/evbppc/ev64260: machdep.c
src/sys/arch/evbppc/pmppc: machdep.c
src/sys/arch/evbppc/wii: machdep.c
src/sys/arch/ews4800mips/ews4800mips: machdep.c
src/sys/arch/hp300/hp300: machdep.c
src/sys/arch/hpcmips/hpcmips: machdep.c
src/sys/arch/hpcsh/hpcsh: machdep.c
src/sys/arch/hppa/hppa: machdep.c
src/sys/arch/i386/i386: machdep.c
src/sys/arch/ibmnws/ibmnws: machdep.c
src/sys/arch/landisk/landisk: machdep.c
src/sys/arch/luna68k/luna68k: machdep.c
src/sys/arch/macppc/macppc: machdep.c
src/sys/arch/mipsco/mipsco: machdep.c
src/sys/arch/mvme68k/mvme68k: machdep.c
src/sys/arch/mvmeppc/mvmeppc: machdep.c
src/sys/arch/news68k/news68k: machdep.c
src/sys/arch/newsmips/newsmips: machdep.c
src/sys/arch/next68k/next68k: machdep.c
src/sys/arch/ofppc/include: autoconf.h
src/sys/arch/ofppc/ofppc: machdep.c
src/sys/arch/playstation2/playstation2: machdep.c
src/sys/arch/pmax/pmax: machdep.c
src/sys/arch/powerpc/booke: booke_machdep.c
src/sys/arch/powerpc/ibm4xx: ibm4xx_machdep.c
src/sys/arch/prep/prep: machdep.c
src/sys/arch/riscv/riscv: riscv_machdep.c
src/sys/arch/rs6000/include: autoconf.h
src/sys/arch/sandpoint/sandpoint: machdep.c
src/sys/arch/sbmips/sbmips: machdep.c
src/sys/arch/sgimips/sgimips: machdep.c
src/sys/arch/sparc/sparc: machdep.c
src/sys/arch/sparc64/sparc64: machdep.c
src/sys/arch/vax/vax: machdep.c
src/sys/arch/virt68k/virt68k: machdep.c
src/sys/arch/zaurus/zaurus: machdep.c
src/sys/kern: kern_reboot.c

Log Message:
Move the at-shutdown call to resettodr() from cpu_reboot() to kern_reboot().

It's a small step, but it's a step.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/aarch64_reboot.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/algor/algor/machdep.c
cvs rdiff -u -r1.377 -r1.378 src/sys/arch/alpha/alpha/machdep.c
cvs rdiff -u -r1.367 -r1.368 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.254 -r1.255 src/sys/arch/amiga/amiga/machdep.c
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/amigappc/amigappc/machdep.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amigappc/include/autoconf.h
cvs rdiff -u -r1.133 -r1.134 src/sys/arch/arc/arc/machdep.c
cvs rdiff -u -r1.146 -r1.147 src/sys/arch/arm/arm32/arm32_machdep.c
cvs rdiff -u -r1.190 -r1.191 src/sys/arch/atari/atari/machdep.c
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/bebox/bebox/machdep.c
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/cesfic/cesfic/machdep.c
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/cobalt/cobalt/machdep.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/dreamcast/dreamcast/machdep.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/emips/emips/machdep.c
cvs rdiff -u -r1.15 -r1.16 \
src/sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/evbmips/adm5120/machdep.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/evbmips/alchemy/machdep.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/evbmips/atheros/machdep.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/evbmips/cavium/machdep.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/evbmips/gdium/machdep.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/evbmips/ingenic/machdep.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbmips/loongson/machdep.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/evbmips/malta/machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbmips/mipssim/machdep.c
cvs 

CVS commit: src/sys

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Mar  5 14:15:36 UTC 2024

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_reboot.c
src/sys/arch/algor/algor: machdep.c
src/sys/arch/alpha/alpha: machdep.c
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/amiga/amiga: machdep.c
src/sys/arch/amigappc/amigappc: machdep.c
src/sys/arch/amigappc/include: autoconf.h
src/sys/arch/arc/arc: machdep.c
src/sys/arch/arm/arm32: arm32_machdep.c
src/sys/arch/atari/atari: machdep.c
src/sys/arch/bebox/bebox: machdep.c
src/sys/arch/cesfic/cesfic: machdep.c
src/sys/arch/cobalt/cobalt: machdep.c
src/sys/arch/dreamcast/dreamcast: machdep.c
src/sys/arch/emips/emips: machdep.c
src/sys/arch/evbarm/imx23_olinuxino: imx23_olinuxino_machdep.c
src/sys/arch/evbmips/adm5120: machdep.c
src/sys/arch/evbmips/alchemy: machdep.c
src/sys/arch/evbmips/atheros: machdep.c
src/sys/arch/evbmips/cavium: machdep.c
src/sys/arch/evbmips/gdium: machdep.c
src/sys/arch/evbmips/ingenic: machdep.c
src/sys/arch/evbmips/loongson: machdep.c
src/sys/arch/evbmips/malta: machdep.c
src/sys/arch/evbmips/mipssim: machdep.c
src/sys/arch/evbmips/rasoc: machdep.c
src/sys/arch/evbmips/rmixl: machdep.c
src/sys/arch/evbmips/sbmips: machdep.c
src/sys/arch/evbppc/ev64260: machdep.c
src/sys/arch/evbppc/pmppc: machdep.c
src/sys/arch/evbppc/wii: machdep.c
src/sys/arch/ews4800mips/ews4800mips: machdep.c
src/sys/arch/hp300/hp300: machdep.c
src/sys/arch/hpcmips/hpcmips: machdep.c
src/sys/arch/hpcsh/hpcsh: machdep.c
src/sys/arch/hppa/hppa: machdep.c
src/sys/arch/i386/i386: machdep.c
src/sys/arch/ibmnws/ibmnws: machdep.c
src/sys/arch/landisk/landisk: machdep.c
src/sys/arch/luna68k/luna68k: machdep.c
src/sys/arch/macppc/macppc: machdep.c
src/sys/arch/mipsco/mipsco: machdep.c
src/sys/arch/mvme68k/mvme68k: machdep.c
src/sys/arch/mvmeppc/mvmeppc: machdep.c
src/sys/arch/news68k/news68k: machdep.c
src/sys/arch/newsmips/newsmips: machdep.c
src/sys/arch/next68k/next68k: machdep.c
src/sys/arch/ofppc/include: autoconf.h
src/sys/arch/ofppc/ofppc: machdep.c
src/sys/arch/playstation2/playstation2: machdep.c
src/sys/arch/pmax/pmax: machdep.c
src/sys/arch/powerpc/booke: booke_machdep.c
src/sys/arch/powerpc/ibm4xx: ibm4xx_machdep.c
src/sys/arch/prep/prep: machdep.c
src/sys/arch/riscv/riscv: riscv_machdep.c
src/sys/arch/rs6000/include: autoconf.h
src/sys/arch/sandpoint/sandpoint: machdep.c
src/sys/arch/sbmips/sbmips: machdep.c
src/sys/arch/sgimips/sgimips: machdep.c
src/sys/arch/sparc/sparc: machdep.c
src/sys/arch/sparc64/sparc64: machdep.c
src/sys/arch/vax/vax: machdep.c
src/sys/arch/virt68k/virt68k: machdep.c
src/sys/arch/zaurus/zaurus: machdep.c
src/sys/kern: kern_reboot.c

Log Message:
Move the at-shutdown call to resettodr() from cpu_reboot() to kern_reboot().

It's a small step, but it's a step.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/aarch64_reboot.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/algor/algor/machdep.c
cvs rdiff -u -r1.377 -r1.378 src/sys/arch/alpha/alpha/machdep.c
cvs rdiff -u -r1.367 -r1.368 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.254 -r1.255 src/sys/arch/amiga/amiga/machdep.c
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/amigappc/amigappc/machdep.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amigappc/include/autoconf.h
cvs rdiff -u -r1.133 -r1.134 src/sys/arch/arc/arc/machdep.c
cvs rdiff -u -r1.146 -r1.147 src/sys/arch/arm/arm32/arm32_machdep.c
cvs rdiff -u -r1.190 -r1.191 src/sys/arch/atari/atari/machdep.c
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/bebox/bebox/machdep.c
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/cesfic/cesfic/machdep.c
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/cobalt/cobalt/machdep.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/dreamcast/dreamcast/machdep.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/emips/emips/machdep.c
cvs rdiff -u -r1.15 -r1.16 \
src/sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/evbmips/adm5120/machdep.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/evbmips/alchemy/machdep.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/evbmips/atheros/machdep.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/evbmips/cavium/machdep.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/evbmips/gdium/machdep.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/evbmips/ingenic/machdep.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbmips/loongson/machdep.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/evbmips/malta/machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbmips/mipssim/machdep.c
cvs 

CVS commit: src/sys/uvm/pmap

2024-03-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Mar  5 13:16:29 UTC 2024

Modified Files:
src/sys/uvm/pmap: pmap.c

Log Message:
Change the PMAP_STEAL_MEMORY debug output from aprint_debug.

The new printfs are conditional on pmap_stealdebug and the DEBUG compile
option. The former defaults to true, but can be changed at a boot -d ddb
prompt.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/uvm/pmap/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/uvm/pmap/pmap.c
diff -u src/sys/uvm/pmap/pmap.c:1.75 src/sys/uvm/pmap/pmap.c:1.76
--- src/sys/uvm/pmap/pmap.c:1.75	Sun Feb 26 07:13:55 2023
+++ src/sys/uvm/pmap/pmap.c	Tue Mar  5 13:16:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.75 2023/02/26 07:13:55 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.76 2024/03/05 13:16:29 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.75 2023/02/26 07:13:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.76 2024/03/05 13:16:29 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -366,6 +366,12 @@ kmutex_t pmap_pvlist_mutex	__cacheline_a
  */
 
 #ifdef DEBUG
+
+bool pmap_stealdebug = true;
+
+#define DPRINTF(...)			 \
+do { if (pmap_stealdebug) { printf(__VA_ARGS__); } } while (false)
+
 static inline void
 pmap_asid_check(pmap_t pm, const char *func)
 {
@@ -378,6 +384,10 @@ pmap_asid_check(pmap_t pm, const char *f
 		panic("%s: inconsistency for active TLB update: %u <-> %u",
 		func, asid, pai->pai_asid);
 }
+#else
+
+#define DPRINTF(...) __nothing
+
 #endif
 
 static void
@@ -564,7 +574,7 @@ pmap_steal_memory(vsize_t size, vaddr_t 
 	size = round_page(size);
 	npgs = atop(size);
 
-	aprint_debug("%s: need %zu pages\n", __func__, npgs);
+	DPRINTF("%s: need %zu pages\n", __func__, npgs);
 
 	for (uvm_physseg_t bank = uvm_physseg_get_first();
 	 uvm_physseg_valid_p(bank);
@@ -573,19 +583,19 @@ pmap_steal_memory(vsize_t size, vaddr_t 
 		if (uvm.page_init_done == true)
 			panic("pmap_steal_memory: called _after_ bootstrap");
 
-		aprint_debug("%s: seg %"PRIxPHYSSEG": %#"PRIxPADDR" %#"PRIxPADDR" %#"PRIxPADDR" %#"PRIxPADDR"\n",
+		DPRINTF("%s: seg %"PRIxPHYSSEG": %#"PRIxPADDR" %#"PRIxPADDR" %#"PRIxPADDR" %#"PRIxPADDR"\n",
 		__func__, bank,
 		uvm_physseg_get_avail_start(bank), uvm_physseg_get_start(bank),
 		uvm_physseg_get_avail_end(bank), uvm_physseg_get_end(bank));
 
 		if (uvm_physseg_get_avail_start(bank) != uvm_physseg_get_start(bank)
 		|| uvm_physseg_get_avail_start(bank) >= uvm_physseg_get_avail_end(bank)) {
-			aprint_debug("%s: seg %"PRIxPHYSSEG": bad start\n", __func__, bank);
+			DPRINTF("%s: seg %"PRIxPHYSSEG": bad start\n", __func__, bank);
 			continue;
 		}
 
 		if (uvm_physseg_get_avail_end(bank) - uvm_physseg_get_avail_start(bank) < npgs) {
-			aprint_debug("%s: seg %"PRIxPHYSSEG": too small for %zu pages\n",
+			DPRINTF("%s: seg %"PRIxPHYSSEG": too small for %zu pages\n",
 			__func__, bank, npgs);
 			continue;
 		}
@@ -614,7 +624,7 @@ pmap_steal_memory(vsize_t size, vaddr_t 
 		pa = ptoa(uvm_physseg_get_start(bank));
 		uvm_physseg_unplug(atop(pa), npgs);
 
-		aprint_debug("%s: seg %"PRIxPHYSSEG": %zu pages stolen (%#"PRIxPADDR" left)\n",
+		DPRINTF("%s: seg %"PRIxPHYSSEG": %zu pages stolen (%#"PRIxPADDR" left)\n",
 		__func__, bank, npgs, VM_PHYSMEM_SPACE(bank));
 
 		va = pmap_md_map_poolpage(pa, size);



CVS commit: src/sys/uvm/pmap

2024-03-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Mar  5 13:16:29 UTC 2024

Modified Files:
src/sys/uvm/pmap: pmap.c

Log Message:
Change the PMAP_STEAL_MEMORY debug output from aprint_debug.

The new printfs are conditional on pmap_stealdebug and the DEBUG compile
option. The former defaults to true, but can be changed at a boot -d ddb
prompt.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/uvm/pmap/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys

2024-03-05 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Mar  5 11:19:30 UTC 2024

Modified Files:
src/sys/arch/virt68k/dev: gfrtc_mainbus.c
src/sys/dev/goldfish: gfrtc.c

Log Message:
Fix two problems that the time runs late on virt68k.
- The time between the time the alarm occurred and the time read by
  TIME_* register in the next interrupt handler was not accumulated.
- With the one-shot timer method, once the host time prolongs, the
  guest time will never be able to catch up with the host time again.
New one does:
- The driver maintains its (guest's) time (as sc_alarm_time) and always
  set the next alarm sc_interval_ns after the previous alarm.
- gfrtc_set_alarm() takes an absolute time instead of a relative time
  as the argument.
PR kern/57980.  Confirmed on QEMU.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/dev/gfrtc_mainbus.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/goldfish/gfrtc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/virt68k/dev/gfrtc_mainbus.c
diff -u src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.2 src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.3
--- src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.2	Fri Jan 12 06:23:20 2024
+++ src/sys/arch/virt68k/dev/gfrtc_mainbus.c	Tue Mar  5 11:19:30 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gfrtc_mainbus.c,v 1.2 2024/01/12 06:23:20 mlelstv Exp $	*/
+/*	$NetBSD: gfrtc_mainbus.c,v 1.3 2024/03/05 11:19:30 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2023, 2024 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gfrtc_mainbus.c,v 1.2 2024/01/12 06:23:20 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gfrtc_mainbus.c,v 1.3 2024/03/05 11:19:30 isaki Exp $");
 
 #include 
 #include 
@@ -58,6 +58,7 @@ struct gfrtc_mainbus_softc {
 	struct gfrtc_softc	sc_gfrtc;
 	struct clock_attach_args sc_clock_args;
 	uint64_t		sc_interval_ns;
+	uint64_t		sc_alarm_time;
 	void			(*sc_handler)(struct clockframe *);
 	struct evcnt *		sc_evcnt;
 	void *			sc_ih;
@@ -68,8 +69,9 @@ do {	\
 	/* Clear the interrupt condition. */\
 	gfrtc_clear_interrupt(>sc_gfrtc);\
 	\
-	/* Get the next alarm set ASAP. */\
-	gfrtc_set_alarm(>sc_gfrtc, sc->sc_interval_ns);		\
+	/* Get the next alarm set. */	\
+	sc->sc_alarm_time += sc->sc_interval_ns;			\
+	gfrtc_set_alarm(>sc_gfrtc, sc->sc_alarm_time);		\
 	\
 	/* Increment the counter and call the handler. */		\
 	sc->sc_evcnt->ev_count++;	\
@@ -103,7 +105,8 @@ gfrtc_mainbus_initclock(void *arg, unsig
 	gfrtc_enable_interrupt(>sc_gfrtc);
 
 	/* Start the first alarm! */
-	gfrtc_set_alarm(>sc_gfrtc, sc->sc_interval_ns);
+	sc->sc_alarm_time = gfrtc_get_time(>sc_gfrtc) + sc->sc_interval_ns;
+	gfrtc_set_alarm(>sc_gfrtc, sc->sc_alarm_time);
 }
 
 static int

Index: src/sys/dev/goldfish/gfrtc.c
diff -u src/sys/dev/goldfish/gfrtc.c:1.4 src/sys/dev/goldfish/gfrtc.c:1.5
--- src/sys/dev/goldfish/gfrtc.c:1.4	Thu Jan  4 12:02:11 2024
+++ src/sys/dev/goldfish/gfrtc.c	Tue Mar  5 11:19:30 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gfrtc.c,v 1.4 2024/01/04 12:02:11 simonb Exp $	*/
+/*	$NetBSD: gfrtc.c,v 1.5 2024/03/05 11:19:30 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gfrtc.c,v 1.4 2024/01/04 12:02:11 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gfrtc.c,v 1.5 2024/03/05 11:19:30 isaki Exp $");
 
 #include 
 
@@ -141,10 +141,8 @@ gfrtc_get_time(struct gfrtc_softc * cons
 
 
 void
-gfrtc_set_alarm(struct gfrtc_softc * const sc, const uint64_t nsec)
+gfrtc_set_alarm(struct gfrtc_softc * const sc, const uint64_t next)
 {
-	uint64_t next = gfrtc_get_time(sc) + nsec;
-
 	GOLDFISH_RTC_WRITE(sc, GOLDFISH_RTC_ALARM_HIGH, (uint32_t)(next >> 32));
 	GOLDFISH_RTC_WRITE(sc, GOLDFISH_RTC_ALARM_LOW, (uint32_t)next);
 }



CVS commit: src/sys

2024-03-05 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Mar  5 11:19:30 UTC 2024

Modified Files:
src/sys/arch/virt68k/dev: gfrtc_mainbus.c
src/sys/dev/goldfish: gfrtc.c

Log Message:
Fix two problems that the time runs late on virt68k.
- The time between the time the alarm occurred and the time read by
  TIME_* register in the next interrupt handler was not accumulated.
- With the one-shot timer method, once the host time prolongs, the
  guest time will never be able to catch up with the host time again.
New one does:
- The driver maintains its (guest's) time (as sc_alarm_time) and always
  set the next alarm sc_interval_ns after the previous alarm.
- gfrtc_set_alarm() takes an absolute time instead of a relative time
  as the argument.
PR kern/57980.  Confirmed on QEMU.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/dev/gfrtc_mainbus.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/goldfish/gfrtc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.