CVS commit: src/sys/arch/virt68k/virt68k

2024-02-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Feb 25 14:35:31 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: trap.c

Log Message:
Don't crash in copyin/copyout when a NULL pointer is passed.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/virt68k/trap.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/virt68k/virt68k

2024-02-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Feb 25 14:35:31 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: trap.c

Log Message:
Don't crash in copyin/copyout when a NULL pointer is passed.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/virt68k/trap.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/virt68k/trap.c
diff -u src/sys/arch/virt68k/virt68k/trap.c:1.2 src/sys/arch/virt68k/virt68k/trap.c:1.3
--- src/sys/arch/virt68k/virt68k/trap.c:1.2	Sat Jan 20 00:15:33 2024
+++ src/sys/arch/virt68k/virt68k/trap.c	Sun Feb 25 14:35:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.2 2024/01/20 00:15:33 thorpej Exp $	*/
+/*	$NetBSD: trap.c,v 1.3 2024/02/25 14:35:31 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.2 2024/01/20 00:15:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.3 2024/02/25 14:35:31 mlelstv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -554,7 +554,7 @@ trap(struct frame *fp, int type, unsigne
 
 		va = trunc_page((vaddr_t)v);
 
-		if (map == kernel_map && va == 0) {
+		if (map == kernel_map && va == 0 && onfault == 0) {
 			printf("trap: bad kernel %s access at 0x%x\n",
 			(ftype & VM_PROT_WRITE) ? "read/write" :
 			"read", v);



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-18 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Jan 18 12:07:51 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: locore.s

Log Message:
Set TT0 register to recognize the I/O space even on the 68030 case.

http://mail-index.netbsd.org/port-m68k/2024/01/17/msg000870.html


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/virt68k/virt68k/locore.s

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/virt68k/locore.s
diff -u src/sys/arch/virt68k/virt68k/locore.s:1.13 src/sys/arch/virt68k/virt68k/locore.s:1.14
--- src/sys/arch/virt68k/virt68k/locore.s:1.13	Wed Jan 17 12:33:51 2024
+++ src/sys/arch/virt68k/virt68k/locore.s	Thu Jan 18 12:07:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.13 2024/01/17 12:33:51 thorpej Exp $	*/
+/*	$NetBSD: locore.s,v 1.14 2024/01/18 12:07:51 isaki Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -199,8 +199,13 @@ Lnot060cache:
 	jmp	Lenab1
 
 Lmotommu2:
+	movl	#VIRT68K_TT30_IO,%sp@-	| TT0 maps the I/O space
+	.long	0xf0170800		| pmove %sp@,%tt0
+	clrl	%sp@			| ensure TT1 is disabled
+	.long	0xf0170c00		| pmove %sp@,%tt1
+
 	pflusha
-	movl	#MMU51_TCR_BITS,%sp@-	| value to load TC with
+	movl	#MMU51_TCR_BITS,%sp@	| value to load TC with
 	pmove	%sp@,%tc		| load it
 
 /*



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-18 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Jan 18 12:07:51 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: locore.s

Log Message:
Set TT0 register to recognize the I/O space even on the 68030 case.

http://mail-index.netbsd.org/port-m68k/2024/01/17/msg000870.html


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/virt68k/virt68k/locore.s

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



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jan 17 05:22:11 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: locore.s

Log Message:
G/C intrcnt[].


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/virt68k/virt68k/locore.s

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/virt68k/locore.s
diff -u src/sys/arch/virt68k/virt68k/locore.s:1.10 src/sys/arch/virt68k/virt68k/locore.s:1.11
--- src/sys/arch/virt68k/virt68k/locore.s:1.10	Tue Jan 16 15:38:58 2024
+++ src/sys/arch/virt68k/virt68k/locore.s	Wed Jan 17 05:22:11 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.10 2024/01/16 15:38:58 thorpej Exp $	*/
+/*	$NetBSD: locore.s,v 1.11 2024/01/17 05:22:11 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -622,24 +622,3 @@ GLOBAL(cputype)
 
 GLOBAL(fputype)
 	.long	FPU_68040	| default to FPU_68040
-
-/*
- * interrupt counters.
- * XXXSCW: Will go away soon; kept here to keep vmstat happy
- */
-GLOBAL(intrnames)
-	.asciz	"spur"
-	.asciz	"lev1"
-	.asciz	"lev2"
-	.asciz	"lev3"
-	.asciz	"lev4"
-	.asciz	"clock"
-	.asciz	"lev6"
-	.asciz	"nmi"
-	.asciz	"statclock"
-GLOBAL(eintrnames)
-	.even
-
-GLOBAL(intrcnt)
-	.long	0,0,0,0,0,0,0,0,0
-GLOBAL(eintrcnt)



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jan 17 05:22:11 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: locore.s

Log Message:
G/C intrcnt[].


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/virt68k/virt68k/locore.s

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



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-09 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  9 14:24:08 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: locore.s machdep.c

Log Message:
Properly implement mm_md_physacc() and garbage-collect the now unused
"lowram" variable (hold-over from hp300 lineage).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/virt68k/virt68k/locore.s
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/virt68k/virt68k/machdep.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/virt68k/locore.s
diff -u src/sys/arch/virt68k/virt68k/locore.s:1.5 src/sys/arch/virt68k/virt68k/locore.s:1.6
--- src/sys/arch/virt68k/virt68k/locore.s:1.5	Tue Jan  9 07:28:26 2024
+++ src/sys/arch/virt68k/virt68k/locore.s	Tue Jan  9 14:24:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.5 2024/01/09 07:28:26 thorpej Exp $	*/
+/*	$NetBSD: locore.s,v 1.6 2024/01/09 14:24:08 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -83,7 +83,6 @@ ASLOCAL(tmpstk)
 #define	RELOC(var, ar)		_RELOC(_C_LABEL(var), ar)
 #define	ASRELOC(var, ar)	_RELOC(_ASM_LABEL(var), ar)
 
-BSS(lowram,4)
 BSS(esym,4)
 
 	.globl	_C_LABEL(edata)
@@ -113,9 +112,6 @@ ASENTRY_NOPROFILE(start)
 1:	clrl	%a0@+
 	dbra	%d0,1b
 
-	RELOC(lowram, %a0)
-	movl	%a5,%a0@		| store start of physical memory
-
 	/*
 	 * Qemu does not pass us the symbols, so leave esym alone.
 	 * The bootinfo immediately follows the kernel.  Go parse

Index: src/sys/arch/virt68k/virt68k/machdep.c
diff -u src/sys/arch/virt68k/virt68k/machdep.c:1.6 src/sys/arch/virt68k/virt68k/machdep.c:1.7
--- src/sys/arch/virt68k/virt68k/machdep.c:1.6	Mon Jan  8 05:10:51 2024
+++ src/sys/arch/virt68k/virt68k/machdep.c	Tue Jan  9 14:24:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.6 2024/01/08 05:10:51 thorpej Exp $	*/
+/*	$NetBSD: machdep.c,v 1.7 2024/01/09 14:24:08 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.6 2024/01/08 05:10:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.7 2024/01/09 14:24:08 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m060sp.h"
@@ -113,7 +113,6 @@ paddr_t msgbufpa;		/* PA of message buff
 
 // int	maxmem;			/* max memory per process */
 
-extern	u_int lowram;
 extern	short exframesize[];
 
 /* prototypes for local functions */ 
@@ -902,6 +901,18 @@ const uint16_t ipl2psl_table[NIPL] = {
 int
 mm_md_physacc(paddr_t pa, vm_prot_t prot)
 {
+	psize_t size;
+	int i;
 
-	return (pa < lowram || pa >= 0xfffc) ? EFAULT : 0;
+	for (i = 0; i < bootinfo_mem_nsegments; i++) {
+		if (pa < bootinfo_mem_segments[i].mem_addr) {
+			continue;
+		}
+		size = trunc_page(bootinfo_mem_segments[i].mem_size);
+		if (pa >= bootinfo_mem_segments[i].mem_addr + size) {
+			continue;
+		}
+		return 0;
+	}
+	return EFAULT;
 }



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-09 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  9 14:24:08 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: locore.s machdep.c

Log Message:
Properly implement mm_md_physacc() and garbage-collect the now unused
"lowram" variable (hold-over from hp300 lineage).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/virt68k/virt68k/locore.s
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/virt68k/virt68k/machdep.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/virt68k/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:11:33 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: clock.c

Log Message:
Use aprint_error() rather than a bare printf() in a few spots, and
an aprint_normal() in some others.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/virt68k/clock.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/virt68k/clock.c
diff -u src/sys/arch/virt68k/virt68k/clock.c:1.1 src/sys/arch/virt68k/virt68k/clock.c:1.2
--- src/sys/arch/virt68k/virt68k/clock.c:1.1	Tue Jan  2 07:41:02 2024
+++ src/sys/arch/virt68k/virt68k/clock.c	Mon Jan  8 05:11:32 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: clock.c,v 1.1 2024/01/02 07:41:02 thorpej Exp $	*/
+/*  $NetBSD: clock.c,v 1.2 2024/01/08 05:11:32 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.1 2024/01/02 07:41:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.2 2024/01/08 05:11:32 thorpej Exp $");
 
 #include 
 #include 
@@ -174,20 +174,20 @@ cpu_initclocks(void)
 	}
 
 	if (100 % hz) {
-		printf("Cannot get %d Hz clock; using 100 Hz\n", hz);
+		aprint_error("Cannot get %d Hz clock; using 100 Hz\n", hz);
 		hz = 100;
 		tick = 100 / hz;
 	}
 
 	if (virt68k_clocks[CLOCK_STATCLOCK].args == NULL) {
-		printf("No statclock; using hardclock.\n");
+		aprint_normal("No statclock; using hardclock.\n");
 		stathz = 0;
 		statint = 0;
 	} else if (stathz == 0) {
 		stathz = hz;
 		if (100 % stathz) {
-			printf("Cannot get %d Hz statclock; using 100 Hz\n",
-			stathz);
+			aprint_error("Cannot get %d Hz statclock; "
+ "using 100 Hz\n", stathz);
 			stathz = 100;
 		}
 		profhz = stathz;	/* always */



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:11:33 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: clock.c

Log Message:
Use aprint_error() rather than a bare printf() in a few spots, and
an aprint_normal() in some others.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/virt68k/clock.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/virt68k/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:10:51 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: autoconf.c machdep.c

Log Message:
Accept "root=xxx" for the root device and "flags=xxx" as the boothowto
flags from the kernel command line arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/virt68k/autoconf.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/virt68k/virt68k/machdep.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/virt68k/autoconf.c
diff -u src/sys/arch/virt68k/virt68k/autoconf.c:1.4 src/sys/arch/virt68k/virt68k/autoconf.c:1.5
--- src/sys/arch/virt68k/virt68k/autoconf.c:1.4	Sun Jan  7 16:41:24 2024
+++ src/sys/arch/virt68k/virt68k/autoconf.c	Mon Jan  8 05:10:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.4 2024/01/07 16:41:24 thorpej Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.5 2024/01/08 05:10:51 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.4 2024/01/07 16:41:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.5 2024/01/08 05:10:51 thorpej Exp $");
 
 #include 
 #include 
@@ -96,6 +96,26 @@ void
 device_register(device_t dev, void *aux)
 {
 	device_t parent = device_parent(dev);
+	char rootname[DEVICE_XNAME_SIZE];
+	bool rootname_valid = false;
+
+	if (booted_device == NULL) {
+		rootname_valid = bootinfo_getarg("root",
+		rootname, sizeof(rootname));
+		if (rootname_valid) {
+			size_t len = strlen(rootname);
+			while (len) {
+len--;
+if (isdigit(rootname[len])) {
+	break;
+}
+rootname[len] = '\0';
+			}
+			if (strcmp(device_xname(dev), rootname) == 0) {
+booted_device = dev;
+			}
+		}
+	}
 
 	if (device_is_a(parent, "mainbus")) {
 		struct mainbus_attach_args *ma = aux;

Index: src/sys/arch/virt68k/virt68k/machdep.c
diff -u src/sys/arch/virt68k/virt68k/machdep.c:1.5 src/sys/arch/virt68k/virt68k/machdep.c:1.6
--- src/sys/arch/virt68k/virt68k/machdep.c:1.5	Sat Jan  6 21:43:37 2024
+++ src/sys/arch/virt68k/virt68k/machdep.c	Mon Jan  8 05:10:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.5 2024/01/06 21:43:37 thorpej Exp $	*/
+/*	$NetBSD: machdep.c,v 1.6 2024/01/08 05:10:51 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 2024/01/06 21:43:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.6 2024/01/08 05:10:51 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m060sp.h"
@@ -70,6 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #include 
 #include 
+#include 
 
 #include "ksyms.h"
 
@@ -100,8 +101,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include 
 #endif
 
-#define	MAXMEM	64*1024	/* XXX - from cmap.h */
-
 /* the following is used externally (sysctl_hw) */
 char	machine[] = MACHINE;	/* from  */
 
@@ -207,6 +206,17 @@ virt68k_init(void)
 
 	/* Check for RND seed from the loader. */
 	bootinfo_setup_rndseed();
+
+	char flags[32];
+	if (bootinfo_getarg("flags", flags, sizeof(flags))) {
+		for (const char *cp = flags; *cp != '\0'; cp++) {
+			/* Consume 'm' in favor of BI_RAMDISK. */
+			if (*cp == 'm') {
+continue;
+			}
+			BOOT_FLAG(*cp, boothowto);
+		}
+	}
 }
 
 /*



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  8 05:10:51 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: autoconf.c machdep.c

Log Message:
Accept "root=xxx" for the root device and "flags=xxx" as the boothowto
flags from the kernel command line arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/virt68k/autoconf.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/virt68k/virt68k/machdep.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/virt68k/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan  7 16:41:24 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: autoconf.c locore.s

Log Message:
Don't to go IPL0 right before calling main(), instead call spl0() at the
end of cpu_configure().  It seems that Qemu doesn't reset pending interrupts
correctly after a RESET request, which was causing an explosion when an
interrupt was delivered to the new kernel instance.  This change makes
reboot work.

Thx to mlelstv@ for figuring out what the problem was.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/virt68k/virt68k/autoconf.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/virt68k/locore.s

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



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan  7 16:41:24 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: autoconf.c locore.s

Log Message:
Don't to go IPL0 right before calling main(), instead call spl0() at the
end of cpu_configure().  It seems that Qemu doesn't reset pending interrupts
correctly after a RESET request, which was causing an explosion when an
interrupt was delivered to the new kernel instance.  This change makes
reboot work.

Thx to mlelstv@ for figuring out what the problem was.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/virt68k/virt68k/autoconf.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/virt68k/locore.s

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/virt68k/autoconf.c
diff -u src/sys/arch/virt68k/virt68k/autoconf.c:1.3 src/sys/arch/virt68k/virt68k/autoconf.c:1.4
--- src/sys/arch/virt68k/virt68k/autoconf.c:1.3	Tue Jan  2 16:59:14 2024
+++ src/sys/arch/virt68k/virt68k/autoconf.c	Sun Jan  7 16:41:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.3 2024/01/02 16:59:14 thorpej Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.4 2024/01/07 16:41:24 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.3 2024/01/02 16:59:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.4 2024/01/07 16:41:24 thorpej Exp $");
 
 #include 
 #include 
@@ -73,6 +73,14 @@ cpu_configure(void)
 
 	if (config_rootfound("mainbus", NULL) == NULL)
 		panic("autoconfig failed, no root");
+
+	/*
+	 * XXX Go ahead and enable interrupts now that we've configured
+	 * XXX everything.
+	 * XXX
+	 * XXX See locore.s, right before main() is called.
+	 */
+	spl0();
 }
 
 void

Index: src/sys/arch/virt68k/virt68k/locore.s
diff -u src/sys/arch/virt68k/virt68k/locore.s:1.2 src/sys/arch/virt68k/virt68k/locore.s:1.3
--- src/sys/arch/virt68k/virt68k/locore.s:1.2	Tue Jan  2 18:10:36 2024
+++ src/sys/arch/virt68k/virt68k/locore.s	Sun Jan  7 16:41:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.2 2024/01/02 18:10:36 thorpej Exp $	*/
+/*	$NetBSD: locore.s,v 1.3 2024/01/07 16:41:24 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -278,7 +278,14 @@ Lenab3:
  * later on.
  */
 	jbsr	_C_LABEL(virt68k_init)	| additional pre-main initialization
+#if 0
+	/*
+	 * XXX Don't do the spl0() here; when Qemu performs a reboot request,
+	 * XXX it seems to not clear pending interrupts, and so we blow up
+	 * XXX early when the new kernel starts up.
+	 */
 	movw	#PSL_LOWIPL,%sr		| lower SPL
+#endif
 	clrw	%sp@-			| vector offset/frame type
 	clrl	%sp@-			| PC - filled in by "execve"
 	movw	#PSL_USER,%sp@-		| in user mode



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jan  6 21:43:37 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: machdep.c

Log Message:
Fix stupid typo in cpu_set_reset_func().


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/virt68k/machdep.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/virt68k/machdep.c
diff -u src/sys/arch/virt68k/virt68k/machdep.c:1.4 src/sys/arch/virt68k/virt68k/machdep.c:1.5
--- src/sys/arch/virt68k/virt68k/machdep.c:1.4	Sat Jan  6 17:32:41 2024
+++ src/sys/arch/virt68k/virt68k/machdep.c	Sat Jan  6 21:43:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.4 2024/01/06 17:32:41 thorpej Exp $	*/
+/*	$NetBSD: machdep.c,v 1.5 2024/01/06 21:43:37 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.4 2024/01/06 17:32:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 2024/01/06 21:43:37 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m060sp.h"
@@ -429,7 +429,7 @@ void
 cpu_set_reset_func(void (*func)(void *, int), void *arg)
 {
 	if (cpu_reset_func == NULL) {
-		cpu_reset_func = cpu_reset_func;
+		cpu_reset_func = func;
 		cpu_reset_func_arg = arg;
 	}
 }



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jan  6 21:43:37 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: machdep.c

Log Message:
Fix stupid typo in cpu_set_reset_func().


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/virt68k/machdep.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/virt68k/virt68k

2024-01-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jan  6 21:40:41 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: bootinfo.c

Log Message:
Implement bootinfo_setup_rndseed().  Thx Riastradh@ for the suggestion.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/virt68k/bootinfo.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/virt68k/bootinfo.c
diff -u src/sys/arch/virt68k/virt68k/bootinfo.c:1.4 src/sys/arch/virt68k/virt68k/bootinfo.c:1.5
--- src/sys/arch/virt68k/virt68k/bootinfo.c:1.4	Sat Jan  6 17:32:41 2024
+++ src/sys/arch/virt68k/virt68k/bootinfo.c	Sat Jan  6 21:40:41 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: bootinfo.c,v 1.4 2024/01/06 17:32:41 thorpej Exp $*/  
+/*  $NetBSD: bootinfo.c,v 1.5 2024/01/06 21:40:41 thorpej Exp $*/  
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,13 +30,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bootinfo.c,v 1.4 2024/01/06 17:32:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bootinfo.c,v 1.5 2024/01/06 21:40:41 thorpej Exp $");
 
 #include "opt_md.h"
 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -413,14 +414,15 @@ bootinfo_setup_initrd(void)
 void
 bootinfo_setup_rndseed(void)
 {
+	static struct krndsource bootinfo_rndsource;
 	struct bi_record *bi = bootinfo_find(BI_RNG_SEED);
 	if (bi != NULL) {
 		struct bi_data *rnd = bootinfo_dataptr(bi);
-#if 0 /* XXX */
-		rnd_seed(rnd->data_bytes, rnd->data_length);
-#else
-		printf("WARNING: ignored %u bytes of RND_SEED data @ %p\n",
-		rnd->data_length, rnd->data_bytes);
-#endif
+		rnd_attach_source(_rndsource, "bootinfo",
+		RND_TYPE_RNG, RND_FLAG_DEFAULT);
+		rnd_add_data(_rndsource,
+		rnd->data_bytes, rnd->data_length,
+		rnd->data_length * NBBY);
+		explicit_memset(rnd->data_bytes, 0, rnd->data_length);
 	}
 }



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jan  6 21:40:41 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: bootinfo.c

Log Message:
Implement bootinfo_setup_rndseed().  Thx Riastradh@ for the suggestion.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/virt68k/bootinfo.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/virt68k/virt68k

2024-01-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  2 07:52:47 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: vectors.s

Log Message:
Remove non-applicable comments.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/virt68k/vectors.s

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/virt68k/vectors.s
diff -u src/sys/arch/virt68k/virt68k/vectors.s:1.1 src/sys/arch/virt68k/virt68k/vectors.s:1.2
--- src/sys/arch/virt68k/virt68k/vectors.s:1.1	Tue Jan  2 07:41:02 2024
+++ src/sys/arch/virt68k/virt68k/vectors.s	Tue Jan  2 07:52:47 2024
@@ -1,4 +1,4 @@
-|	$NetBSD: vectors.s,v 1.1 2024/01/02 07:41:02 thorpej Exp $
+|	$NetBSD: vectors.s,v 1.2 2024/01/02 07:52:47 thorpej Exp $
 
 | Copyright (c) 1997 Jason R. Thorpe.  All rights reserved.
 | Copyright (c) 1988 University of Utah
@@ -137,10 +137,6 @@ GLOBAL(vectab)
 	VECTOR(badtrap)		/* 62: unassigned, reserved */
 	VECTOR(badtrap)		/* 63: unassigned, reserved */
 
-	/*
-	 * PCC, PCCTWO, MC, and VME vectors are installed from 64-255
-	 * by the *intr_extablish() functions.
-	 */
 	BADTRAP16		/* 64-255: user interrupt vectors */
 	BADTRAP16		/* 64-255: user interrupt vectors */
 	BADTRAP16		/* 64-255: user interrupt vectors */



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  2 07:52:47 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: vectors.s

Log Message:
Remove non-applicable comments.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/virt68k/vectors.s

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



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  2 07:48:46 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: intr.c

Log Message:
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/virt68k/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/virt68k/virt68k/intr.c
diff -u src/sys/arch/virt68k/virt68k/intr.c:1.1 src/sys/arch/virt68k/virt68k/intr.c:1.2
--- src/sys/arch/virt68k/virt68k/intr.c:1.1	Tue Jan  2 07:41:02 2024
+++ src/sys/arch/virt68k/virt68k/intr.c	Tue Jan  2 07:48:46 2024
@@ -1,7 +1,7 @@
-/*	$NetBSD: intr.c,v 1.1 2024/01/02 07:41:02 thorpej Exp $	*/
+/*	$NetBSD: intr.c,v 1.2 2024/01/02 07:48:46 thorpej Exp $	*/
 
 /*-
- * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996, 2023 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.1 2024/01/02 07:41:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.2 2024/01/02 07:48:46 thorpej Exp $");
 
 #define _VIRT68K_INTR_PRIVATE
 



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  2 07:48:46 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: intr.c

Log Message:
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/virt68k/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/virt68k/virt68k

2024-01-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  2 07:43:29 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: pmap_bootstrap.c

Log Message:
Collect more garbage.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/virt68k/pmap_bootstrap.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/virt68k/pmap_bootstrap.c
diff -u src/sys/arch/virt68k/virt68k/pmap_bootstrap.c:1.2 src/sys/arch/virt68k/virt68k/pmap_bootstrap.c:1.3
--- src/sys/arch/virt68k/virt68k/pmap_bootstrap.c:1.2	Tue Jan  2 07:42:52 2024
+++ src/sys/arch/virt68k/virt68k/pmap_bootstrap.c	Tue Jan  2 07:43:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_bootstrap.c,v 1.2 2024/01/02 07:42:52 thorpej Exp $	*/
+/*	$NetBSD: pmap_bootstrap.c,v 1.3 2024/01/02 07:43:29 thorpej Exp $	*/
 
 /* 
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.2 2024/01/02 07:42:52 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.3 2024/01/02 07:43:29 thorpej Exp $");
 
 #include "opt_m68k_arch.h"
 
@@ -235,21 +235,6 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
 			*ste++ = protoste;
 			protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
 		}
-#if 0
-		/*
-		 * Now initialize the final portion of that block of
-		 * descriptors to map Sysmap.
-		 */
-		i = SG4_LEV1SIZE + (nl1desc * SG4_LEV2SIZE);
-		ste = (st_entry_t *)kstpa;
-		ste = [i + SG4_LEV2SIZE - (NPTEPG / SG4_LEV3SIZE)];
-		este = [NPTEPG / SG4_LEV3SIZE];
-		protoste = kptmpa | SG_U | SG_RW | SG_V;
-		while (ste < este) {
-			*ste++ = protoste;
-			protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
-		}
-#endif
 		/*
 		 * Calculate the free level 2 descriptor mask
 		 * noting that we have used:



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  2 07:46:49 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: pmap_bootstrap.c

Log Message:
Remove yet another remnant of debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/virt68k/virt68k/pmap_bootstrap.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/virt68k/pmap_bootstrap.c
diff -u src/sys/arch/virt68k/virt68k/pmap_bootstrap.c:1.3 src/sys/arch/virt68k/virt68k/pmap_bootstrap.c:1.4
--- src/sys/arch/virt68k/virt68k/pmap_bootstrap.c:1.3	Tue Jan  2 07:43:29 2024
+++ src/sys/arch/virt68k/virt68k/pmap_bootstrap.c	Tue Jan  2 07:46:49 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_bootstrap.c,v 1.3 2024/01/02 07:43:29 thorpej Exp $	*/
+/*	$NetBSD: pmap_bootstrap.c,v 1.4 2024/01/02 07:46:49 thorpej Exp $	*/
 
 /* 
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.3 2024/01/02 07:43:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.4 2024/01/02 07:46:49 thorpej Exp $");
 
 #include "opt_m68k_arch.h"
 
@@ -136,7 +136,6 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
 
 	kptpa = nextpa;
 	nptpages = RELOC(Sysptsize, int) + howmany(RELOC(physmem, int), NPTEPG);
-	nptpages <<= 1;
 	nextpa += nptpages * PAGE_SIZE;
 
 	/*



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  2 07:46:49 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: pmap_bootstrap.c

Log Message:
Remove yet another remnant of debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/virt68k/virt68k/pmap_bootstrap.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/virt68k/virt68k

2024-01-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  2 07:43:29 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: pmap_bootstrap.c

Log Message:
Collect more garbage.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/virt68k/virt68k/pmap_bootstrap.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/virt68k/virt68k

2024-01-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  2 07:42:52 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: pmap_bootstrap.c

Log Message:
G/C some scratch-pad notes.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/virt68k/pmap_bootstrap.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/virt68k/pmap_bootstrap.c
diff -u src/sys/arch/virt68k/virt68k/pmap_bootstrap.c:1.1 src/sys/arch/virt68k/virt68k/pmap_bootstrap.c:1.2
--- src/sys/arch/virt68k/virt68k/pmap_bootstrap.c:1.1	Tue Jan  2 07:41:02 2024
+++ src/sys/arch/virt68k/virt68k/pmap_bootstrap.c	Tue Jan  2 07:42:52 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_bootstrap.c,v 1.1 2024/01/02 07:41:02 thorpej Exp $	*/
+/*	$NetBSD: pmap_bootstrap.c,v 1.2 2024/01/02 07:42:52 thorpej Exp $	*/
 
 /* 
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.1 2024/01/02 07:41:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.2 2024/01/02 07:42:52 thorpej Exp $");
 
 #include "opt_m68k_arch.h"
 
@@ -172,16 +172,6 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
 		int nl1desc, nl2desc;
 
 		/*
-		 * XXX NOTES:
-		 * SYSMAP_VA == 0xfe00
-		 * pte va == 0xfe000e38
-		 *
-		 * L1 idx = 127
-		 * L2 idx = 0
-		 * L3 idx = 
-		 */
-
-		/*
 		 * First invalidate the entire "segment table" pages
 		 * (levels 1 and 2 have the same "invalid" value).
 		 */



CVS commit: src/sys/arch/virt68k/virt68k

2024-01-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jan  2 07:42:52 UTC 2024

Modified Files:
src/sys/arch/virt68k/virt68k: pmap_bootstrap.c

Log Message:
G/C some scratch-pad notes.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/virt68k/pmap_bootstrap.c

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