CVS commit: src/sys/arch/mac68k/mac68k

2021-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 28 02:28:06 UTC 2021

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

Log Message:
Change sccA address for Quadra 800 from base + 0xc000 to 0xc020.

The H/W partially decodes its address, and sccA is available at
offsets 0xc000, 0xc020,  The functionality is same, but Mac
toolbox ROM routines use 0xc020, and QEMU for Quadra 800 only
supports this address.

Thanks Mark Cave-Ayland for discussion, who is working on NetBSD
support to QEMU for Quadra 800!


To generate a diff of this commit:
cvs rdiff -u -r1.361 -r1.362 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/machdep.c
diff -u src/sys/arch/mac68k/mac68k/machdep.c:1.361 src/sys/arch/mac68k/mac68k/machdep.c:1.362
--- src/sys/arch/mac68k/mac68k/machdep.c:1.361	Wed Apr 28 02:00:58 2021
+++ src/sys/arch/mac68k/mac68k/machdep.c	Wed Apr 28 02:28:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.361 2021/04/28 02:00:58 rin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.362 2021/04/28 02:28:05 rin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.361 2021/04/28 02:00:58 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.362 2021/04/28 02:28:05 rin Exp $");
 
 #include "opt_adb.h"
 #include "opt_compat_netbsd.h"
@@ -2122,6 +2122,15 @@ mac68k_set_io_offsets(vaddr_t base)
 			mac68k_machine.scsi96_2 = 1;
 			iop_init(0);	/* For console */
 			break;
+		case MACH_MACQ800:
+			/*
+			 * The H/W partially decode address for sccA; it is
+			 * available at offsets 0xc000, 0xc020,  Here,
+			 * we choose 0xc020, where Mac toolbox ROM uses.
+			 */
+			sccA = (volatile u_char *)base + 0xc020;
+			SCSIBase = base + 0x1;
+			break;
 		case MACH_MACQ700:
 			sccA = (volatile u_char *)base + 0xc000;
 			SCSIBase = base + 0xf000;



CVS commit: src/sys/arch/mac68k/mac68k

2021-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 28 02:00:59 UTC 2021

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

Log Message:
Make mac68k_set_io_offsets() a little bit cleaner:

- Via1Base is always ``base'' for all supported models.
- Set sccA and SCSIBase for each model of MACH_CLASSQ class.
- Some style fixes.

No functional changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.360 -r1.361 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/machdep.c
diff -u src/sys/arch/mac68k/mac68k/machdep.c:1.360 src/sys/arch/mac68k/mac68k/machdep.c:1.361
--- src/sys/arch/mac68k/mac68k/machdep.c:1.360	Fri Feb 26 10:54:12 2021
+++ src/sys/arch/mac68k/mac68k/machdep.c	Wed Apr 28 02:00:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.360 2021/02/26 10:54:12 rin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.361 2021/04/28 02:00:58 rin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.360 2021/02/26 10:54:12 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.361 2021/04/28 02:00:58 rin Exp $");
 
 #include "opt_adb.h"
 #include "opt_compat_netbsd.h"
@@ -2110,24 +2110,24 @@ void
 mac68k_set_io_offsets(vaddr_t base)
 {
 
+	Via1Base = (volatile u_char *)base;
+	Via2Base = Via1Base + 0x2000 * VIA2;
 	switch (current_mac_model->class) {
 	case MACH_CLASSQ:
-		Via1Base = (volatile u_char *)base;
-
-		/* The following two may be overridden. */
-		sccA = (volatile u_char *)base + 0xc000;
-		SCSIBase = base + 0xf000;
-
 		switch (current_mac_model->machineid) {
 		case MACH_MACQ900:
 		case MACH_MACQ950:
-			mac68k_machine.scsi96_2 = 1;
 			sccA = (volatile u_char *)base + 0xc020;
+			SCSIBase = base + 0xf000;
+			mac68k_machine.scsi96_2 = 1;
 			iop_init(0);	/* For console */
 			break;
 		case MACH_MACQ700:
+			sccA = (volatile u_char *)base + 0xc000;
+			SCSIBase = base + 0xf000;
 			break;
 		default:
+			sccA = (volatile u_char *)base + 0xc000;
 			SCSIBase = base + 0x1;
 			break;
 		}
@@ -2138,7 +2138,6 @@ mac68k_set_io_offsets(vaddr_t base)
 		 * machines.  This seems to be common on many of the
 		 * Quadra-type machines.
 		 */
-		Via1Base = (volatile u_char *)base;
 		sccA = (volatile u_char *)base + 0xc020;
 		SCSIBase = base + 0x1;
 		break;
@@ -2147,12 +2146,10 @@ mac68k_set_io_offsets(vaddr_t base)
 		 * Here's a queer bird... it seems to be a cross between
 		 * the two different Quadra classes.
 		 */
-		Via1Base = (volatile u_char *) base;
-		sccA = (volatile u_char *) base + 0xc020;
+		sccA = (volatile u_char *)base + 0xc020;
 		SCSIBase = base;
 		break;
 	case MACH_CLASSAV:
-		Via1Base = (volatile u_char *)base;
 		sccA = (volatile u_char *)base + 0x4000;
 		SCSIBase = base + 0x18000;
 		PSCBase = (volatile u_char *)base + 0x31000;
@@ -2164,8 +2161,7 @@ mac68k_set_io_offsets(vaddr_t base)
 	case MACH_CLASSIIsi:
 	case MACH_CLASSIIvx:
 	case MACH_CLASSLC:
-		Via1Base = (volatile u_char *)base;
-		sccA = (volatile u_char *) base + 0x4000;
+		sccA = (volatile u_char *)base + 0x4000;
 		SCSIBase = base;
 		break;
 	case MACH_CLASSIIfx:
@@ -2174,7 +2170,6 @@ mac68k_set_io_offsets(vaddr_t base)
 		 * the serial port in `compatible' mode (set in
 		 * the Serial Switch control panel before booting).
 		 */
-		Via1Base = (volatile u_char *)base;
 		sccA = (volatile u_char *)base + 0x4020;
 		SCSIBase = base;
 		iop_init(0);	/* For console */
@@ -2185,7 +2180,6 @@ mac68k_set_io_offsets(vaddr_t base)
 		current_mac_model->class);
 		break;
 	}
-	Via2Base = Via1Base + 0x2000 * VIA2;
 }
 
 #if GRAYBARS



CVS commit: src/sys/arch/mac68k/mac68k

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 03:25:01 UTC 2021

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

Log Message:
Fix DJMEMCMAX option for Quadra/Centris 650/800.

- Use jeq instead of jra for conditional branch.
- Use cmpl instead of cmp (= cmpw) for int variables.

Now, my Quadra 800 recognizes full 520MB memory!


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/locore.s
diff -u src/sys/arch/mac68k/mac68k/locore.s:1.173 src/sys/arch/mac68k/mac68k/locore.s:1.174
--- src/sys/arch/mac68k/mac68k/locore.s:1.173	Tue Jul 21 06:10:26 2020
+++ src/sys/arch/mac68k/mac68k/locore.s	Sun Mar 14 03:25:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.173 2020/07/21 06:10:26 rin Exp $	*/
+/*	$NetBSD: locore.s,v 1.174 2021/03/14 03:25:01 rin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -275,16 +275,16 @@ Lstart3:
 
 #if defined(DJMEMCMAX)
 	movl	%a3,%sp@-
-	cmp	#MACH_MACC610,_C_LABEL(machineid)
-	jra	Ldjmemc610
-	cmp	#MACH_MACQ610,_C_LABEL(machineid)
-	jra	Ldjmemc610
-	cmp	#MACH_MACC650,_C_LABEL(machineid)
-	jra	Ldjmemccfg
-	cmp	#MACH_MACQ650,_C_LABEL(machineid)
-	jra	Ldjmemccfg
-	cmp	#MACH_MACQ800,_C_LABEL(machineid)
-	jra	Ldjmemccfg
+	cmpl	#MACH_MACC610,_C_LABEL(machineid)
+	jeq	Ldjmemc610
+	cmpl	#MACH_MACQ610,_C_LABEL(machineid)
+	jeq	Ldjmemc610
+	cmpl	#MACH_MACC650,_C_LABEL(machineid)
+	jeq	Ldjmemccfg
+	cmpl	#MACH_MACQ650,_C_LABEL(machineid)
+	jeq	Ldjmemccfg
+	cmpl	#MACH_MACQ800,_C_LABEL(machineid)
+	jeq	Ldjmemccfg
 
 	jra	Lnodjmemc




CVS commit: src/sys/arch/mac68k/mac68k

2021-02-26 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 26 10:47:24 UTC 2021

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

Log Message:
Sort opt_*.h. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.358 -r1.359 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/machdep.c
diff -u src/sys/arch/mac68k/mac68k/machdep.c:1.358 src/sys/arch/mac68k/mac68k/machdep.c:1.359
--- src/sys/arch/mac68k/mac68k/machdep.c:1.358	Thu Jun 11 19:20:44 2020
+++ src/sys/arch/mac68k/mac68k/machdep.c	Fri Feb 26 10:47:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.358 2020/06/11 19:20:44 ad Exp $	*/
+/*	$NetBSD: machdep.c,v 1.359 2021/02/26 10:47:24 rin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -74,15 +74,16 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.358 2020/06/11 19:20:44 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.359 2021/02/26 10:47:24 rin Exp $");
 
 #include "opt_adb.h"
+#include "opt_compat_netbsd.h"
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
 #include "opt_ddbparam.h"
 #include "opt_kgdb.h"
 #include "opt_modular.h"
-#include "opt_compat_netbsd.h"
+
 #include "akbd.h"
 #include "genfb.h"
 #include "macfb.h"



CVS commit: src/sys/arch/mac68k/mac68k

2020-07-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jul 21 06:10:26 UTC 2020

Modified Files:
src/sys/arch/mac68k/mac68k: intr.c locore.s via.c

Log Message:
For GCC8, do not omit frame pointer for intr_dispatch() and via1_intr()
(-fomit-frame-pointer is enabled for -O and higher for GCC8).

This is required by rtclock_intr() which unwinds stack frame of caller!

XX
We need to get rid of this hackest hack for rtclock_intr(). This problem
was discussed back in 2014:

http://mail-index.netbsd.org/port-mac68k/2014/08/15/msg000595.html
http://mail-index.netbsd.org/port-mac68k/2014/08/17/msg000600.html
http://mail-index.netbsd.org/port-mac68k/2014/08/17/msg000601.html

However, unfortunately, the problem has been left untouched until today.

The patch attached in the third message works around the problem. But,
it adds hard-coded magic numbers to intr_dispatch() and via1_intr().
For real fix, we should probably reconsider whole interrupt handling.

Anyway, now kernel compiled by GCC8 works fine as far as I can see.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/mac68k/mac68k/intr.c
cvs rdiff -u -r1.172 -r1.173 src/sys/arch/mac68k/mac68k/locore.s
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/mac68k/mac68k/via.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/mac68k/intr.c
diff -u src/sys/arch/mac68k/mac68k/intr.c:1.30 src/sys/arch/mac68k/mac68k/intr.c:1.31
--- src/sys/arch/mac68k/mac68k/intr.c:1.30	Tue Feb 19 00:34:50 2019
+++ src/sys/arch/mac68k/mac68k/intr.c	Tue Jul 21 06:10:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.30 2019/02/19 00:34:50 mrg Exp $	*/
+/*	$NetBSD: intr.c,v 1.31 2020/07/21 06:10:26 rin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.30 2019/02/19 00:34:50 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.31 2020/07/21 06:10:26 rin Exp $");
 
 #include 
 #include 
@@ -206,6 +206,13 @@ intr_disestablish(int ipl)
  *
  * XXX Note: see the warning in intr_establish()
  */
+#if __GNUC_PREREQ__(8, 0)
+/*
+ * XXX rtclock_intr() requires this for unwinding stack frame.
+ */
+#pragma GCC push_options
+#pragma GCC optimize "-fno-omit-frame-pointer"
+#endif
 void
 intr_dispatch(int evec)		/* format | vector offset */
 {
@@ -225,6 +232,9 @@ intr_dispatch(int evec)		/* format | vec
 	(void)(*intr_func[ipl])(intr_arg[ipl]);
 	idepth--;
 }
+#if __GNUC_PREREQ__(8, 0)
+#pragma GCC pop_options
+#endif
 
 /*
  * Default interrupt handler:  do nothing.

Index: src/sys/arch/mac68k/mac68k/locore.s
diff -u src/sys/arch/mac68k/mac68k/locore.s:1.172 src/sys/arch/mac68k/mac68k/locore.s:1.173
--- src/sys/arch/mac68k/mac68k/locore.s:1.172	Tue Jul 21 05:45:38 2020
+++ src/sys/arch/mac68k/mac68k/locore.s	Tue Jul 21 06:10:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.172 2020/07/21 05:45:38 rin Exp $	*/
+/*	$NetBSD: locore.s,v 1.173 2020/07/21 06:10:26 rin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -794,6 +794,7 @@ ENTRY_NOPROFILE(rtclock_intr)
 	movw	_C_LABEL(ipl2psl_table)+IPL_CLOCK*2,%sr
 	| raise SPL to splclock()
 	movl	%a6@,%a1		| unwind to frame in intr_dispatch
+	| XXX FIXME
 	lea	%a1@(28),%a1		| push pointer to interrupt frame
 	movl	%a1,%sp@-			| 28 = 16 for regs in intrhand,
 	|+ 4 for args to intr_dispatch

Index: src/sys/arch/mac68k/mac68k/via.c
diff -u src/sys/arch/mac68k/mac68k/via.c:1.75 src/sys/arch/mac68k/mac68k/via.c:1.76
--- src/sys/arch/mac68k/mac68k/via.c:1.75	Sun Dec 11 12:18:03 2005
+++ src/sys/arch/mac68k/mac68k/via.c	Tue Jul 21 06:10:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: via.c,v 1.75 2005/12/11 12:18:03 christos Exp $	*/
+/*	$NetBSD: via.c,v 1.76 2020/07/21 06:10:26 rin Exp $	*/
 
 /*-
  * Copyright (C) 1993	Allen K. Briggs, Chris P. Caputo,
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: via.c,v 1.75 2005/12/11 12:18:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via.c,v 1.76 2020/07/21 06:10:26 rin Exp $");
 
 #include "opt_mac68k.h"
 
@@ -239,6 +239,13 @@ via_set_modem(int onoff)
 		via_reg(VIA1, vBufA) &= ~DA1O_vSync;
 }
 
+#if __GNUC_PREREQ__(8, 0)
+/*
+ * XXX rtclock_intr() requires this for unwinding stack frame.
+ */
+#pragma GCC push_options
+#pragma GCC optimize "-fno-omit-frame-pointer"
+#endif
 void
 via1_intr(void *intr_arg)
 {
@@ -269,6 +276,9 @@ via1_intr(void *intr_arg)
 		++bitnum;
 	} while (intbits >= mask);
 }
+#if __GNUC_PREREQ__(8, 0)
+#pragma GCC pop_options
+#endif
 
 void
 via2_intr(void *intr_arg)



CVS commit: src/sys/arch/mac68k/mac68k

2020-07-20 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jul 21 05:45:38 UTC 2020

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

Log Message:
Align tmpstk to 4-byte boundary as required by System V (ELF) ABI.

Fix GCC8-compiled kernel crash during very early boot stage when
printf decimal numbers; __umoddi3 corrupts stack frame which is not
aligned properly.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/locore.s
diff -u src/sys/arch/mac68k/mac68k/locore.s:1.171 src/sys/arch/mac68k/mac68k/locore.s:1.172
--- src/sys/arch/mac68k/mac68k/locore.s:1.171	Wed Dec 19 13:57:48 2018
+++ src/sys/arch/mac68k/mac68k/locore.s	Tue Jul 21 05:45:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.171 2018/12/19 13:57:48 maxv Exp $	*/
+/*	$NetBSD: locore.s,v 1.172 2020/07/21 05:45:38 rin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -1367,6 +1367,7 @@ GLOBAL(sanity_check)
 	.long	0x18621862	| this is our stack overflow checker.
 
 	.space	4 * PAGE_SIZE
+	.align	4
 ASLOCAL(tmpstk)
 
 GLOBAL(machineid)



CVS commit: src/sys/arch/mac68k/mac68k

2020-06-19 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Jun 19 16:30:31 UTC 2020

Modified Files:
src/sys/arch/mac68k/mac68k: pram.c

Log Message:
KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/mac68k/mac68k/pram.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/mac68k/pram.c
diff -u src/sys/arch/mac68k/mac68k/pram.c:1.23 src/sys/arch/mac68k/mac68k/pram.c:1.24
--- src/sys/arch/mac68k/mac68k/pram.c:1.23	Wed Mar 26 17:46:04 2014
+++ src/sys/arch/mac68k/mac68k/pram.c	Fri Jun 19 16:30:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pram.c,v 1.23 2014/03/26 17:46:04 christos Exp $	*/
+/*	$NetBSD: pram.c,v 1.24 2020/06/19 16:30:31 tsutsui Exp $	*/
 
 /*-
  * Copyright (C) 1993	Allen K. Briggs, Chris P. Caputo,
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pram.c,v 1.23 2014/03/26 17:46:04 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pram.c,v 1.24 2020/06/19 16:30:31 tsutsui Exp $");
 
 #include "opt_adb.h"
 
@@ -54,107 +54,102 @@ __KERNEL_RCSID(0, "$NetBSD: pram.c,v 1.2
 #if DEBUG
 static const char *convtime(unsigned long t)
 {
-  static long daypmon[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
-  static const char *monstr[] = {"January","February","March","April","May",
-"June","July","August","September","October","November","December" };
-  static char s[200];
-  long year,month,day,hour,minute,seconds,i,dayperyear;
-
-  year=1904;
-  month=0;  /* Jan */
-  day=1;
-  hour=0;
-  minute=0;
-  seconds=0;
-
-  if(t == 0x)
- return("");
-
-  while (t > 0)
-  {
-if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
-{
-  dayperyear=366;
-  daypmon[1]=29;
-}
-else
-{
-  dayperyear=365;
-  daypmon[1]=28;
-}
-i=dayperyear*60*60*24;
-if (t >= i)
-{
-  t-=i;
-  year++;
-  continue;
-}
-i=daypmon[month]*60*60*24;
-if (t >= i)
-{
-  t-=i;
-  month++;
-  continue;
-}
-i=60*60*24;
-if (t >= i)
-{
-  t-=i;
-  day++;
-  continue;
-}
-i=60*60;
-if (t >= i)
-{
-  t-=i;
-  hour++;
-  continue;
-}
-i=60;
-if (t >= i)
-{
-  t-=i;
-  minute++;
-  continue;
-}
-seconds=t;
-t=0;
-  }
+	static long daypmon[] =
+	{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+	static const char *monstr[] = {
+	"January", "February", "March", "April", "May", "June",
+	"July", "August", "September", "October", "November", "December"
+	};
+	static char s[200];
+	long year, month, day, hour, minute, seconds, i, dayperyear;
+
+	year = 1904;
+	month = 0;	/* Jan */
+	day = 1;
+	hour = 0;
+	minute = 0;
+	seconds = 0;
+
+	if (t == 0x)
+		return "";
+
+	while (t > 0) {
+		if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) {
+			dayperyear = 366;
+			daypmon[1] = 29;
+		} else {
+			dayperyear = 365;
+			daypmon[1] = 28;
+		}
+		i = dayperyear * 60 * 60 * 24;
+		if (t >= i) {
+			t -= i;
+			year++;
+			continue;
+		}
+		i = daypmon[month] * 60 * 60 * 24;
+		if (t >= i) {
+			t -= i;
+			month++;
+			continue;
+		}
+		i = 60 * 60 * 24;
+		if (t >= i) {
+			t -= i;
+			day++;
+			continue;
+		}
+		i = 60 * 60;
+		if (t >= i) {
+			t -= i;
+			hour++;
+			continue;
+		}
+		i = 60;
+		if (t >= i) {
+			t -= i;
+			minute++;
+			continue;
+		}
+		seconds = t;
+		t = 0;
+	}
 
-  snprintf(s, sizeof(s), "%s %ld, %ld   %ld:%ld:%ld",
-  monstr[month], day, year, hour, minute, seconds);
+	snprintf(s, sizeof(s), "%s %ld, %ld   %ld:%ld:%ld",
+	monstr[month], day, year, hour, minute, seconds);
 
-  return s;
+	return s;
 }
 #endif
 
 unsigned long
 pram_readtime(void)
 {
-   unsigned long	timedata;
+	unsigned long	timedata;
 
 #ifdef MRG_ADB
-   if (0 == jClkNoMem)
-	timedata = 0;	/* cause comparision of MacOS boottime */
-			/* and PRAM time to fail */
-   else
+	if (0 == jClkNoMem)
+		timedata = 0;	/* cause comparision of MacOS boottime */
+/* and PRAM time to fail */
+	else
 #endif
 	timedata = getPramTime();
 #if DEBUG
-   printf("time read from PRAM: 0x%lx\n", timedata);
-   printf("Date and time: %s\n",convtime(timedata));
+	printf("time read from PRAM: 0x%lx\n", timedata);
+	printf("Date and time: %s\n",convtime(timedata));
 #endif
 
-   return(timedata);
+	return timedata;
 }
 
 void
 pram_settime(unsigned long curtime)
 {
+
 #ifdef MRG_ADB
-   if (0 == jClkNoMem)
-	return;
-   else
+	if (0 == jClkNoMem)
+		return;
+	else
 #endif
 	return setPramTime(curtime);
 }
@@ -211,6 +206,7 @@ getPramTime(void)
 void
 setPramTime(unsigned long curtime)
 {
+
 	switch (adbHardware) {
 	case ADB_HW_IOP:
 	case ADB_HW_II:		/* access PRAM via ADB interface */



CVS commit: src/sys/arch/mac68k/mac68k

2019-02-18 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Feb 19 00:34:50 UTC 2019

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

Log Message:
convert 'extern long intrnames' to 'extern char intrnames[MAX_INAME_LENGTH]'.
also, assert that MAX_INAME_LENGTH is not larger than eintrnames - intrnames.

fixes gcc 7's object size checker checks.  tested by martin@.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/mac68k/mac68k/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/mac68k/intr.c
diff -u src/sys/arch/mac68k/mac68k/intr.c:1.29 src/sys/arch/mac68k/mac68k/intr.c:1.30
--- src/sys/arch/mac68k/mac68k/intr.c:1.29	Mon Dec 20 00:25:36 2010
+++ src/sys/arch/mac68k/mac68k/intr.c	Tue Feb 19 00:34:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.29 2010/12/20 00:25:36 matt Exp $	*/
+/*	$NetBSD: intr.c,v 1.30 2019/02/19 00:34:50 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.29 2010/12/20 00:25:36 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.30 2019/02/19 00:34:50 mrg Exp $");
 
 #include 
 #include 
@@ -100,9 +100,9 @@ void	intr_computeipl(void);
 void
 intr_init(void)
 {
-	extern long	intrnames;
+	extern char	intrnames[MAX_INAME_LENGTH];
+	extern char	eintrnames[] __diagused;
 	const char	*inames;
-	char		*g_inames;
 
 	ipl2psl_table[IPL_NONE]   = 0;
 	ipl2psl_table[IPL_SOFTCLOCK]  = PSL_S|PSL_IPL1;
@@ -111,7 +111,6 @@ intr_init(void)
 	ipl2psl_table[IPL_SOFTBIO]= PSL_S|PSL_IPL1;
 	ipl2psl_table[IPL_HIGH]   = PSL_S|PSL_IPL7;
 
-	g_inames = (char *) 
 	if (mac68k_machine.aux_interrupts) {
 		inames = AUX_INAMES;
 
@@ -132,7 +131,9 @@ intr_init(void)
 		}
 	}
 
-	memcpy(g_inames, inames, MAX_INAME_LENGTH);
+	KASSERT(MAX_INAME_LENGTH <=
+		((uintptr_t)eintrnames - (uintptr_t)intrnames));
+	memcpy(intrnames, inames, MAX_INAME_LENGTH);
 
 	intr_computeipl();
 



CVS commit: src/sys/arch/mac68k/mac68k

2017-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov  7 14:56:03 UTC 2017

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

Log Message:
Don't define ELFSIZE


To generate a diff of this commit:
cvs rdiff -u -r1.351 -r1.352 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/machdep.c
diff -u src/sys/arch/mac68k/mac68k/machdep.c:1.351 src/sys/arch/mac68k/mac68k/machdep.c:1.352
--- src/sys/arch/mac68k/mac68k/machdep.c:1.351	Tue Aug 15 05:26:56 2017
+++ src/sys/arch/mac68k/mac68k/machdep.c	Tue Nov  7 09:56:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.351 2017/08/15 09:26:56 maya Exp $	*/
+/*	$NetBSD: machdep.c,v 1.352 2017/11/07 14:56:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.351 2017/08/15 09:26:56 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.352 2017/11/07 14:56:03 christos Exp $");
 
 #include "opt_adb.h"
 #include "opt_copy_symtab.h"
@@ -114,7 +114,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #ifdef	KGDB
 #include 
 #endif
-#define ELFSIZE 32
 #include 
 #include 
 #include 



CVS commit: src/sys/arch/mac68k/mac68k

2017-08-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Aug 15 09:26:56 UTC 2017

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

Log Message:
Remove dead code. it isn't possible to do non-__ELF__ build


To generate a diff of this commit:
cvs rdiff -u -r1.350 -r1.351 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/machdep.c
diff -u src/sys/arch/mac68k/mac68k/machdep.c:1.350 src/sys/arch/mac68k/mac68k/machdep.c:1.351
--- src/sys/arch/mac68k/mac68k/machdep.c:1.350	Mon Apr  3 17:36:17 2017
+++ src/sys/arch/mac68k/mac68k/machdep.c	Tue Aug 15 09:26:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.350 2017/04/03 17:36:17 christos Exp $	*/
+/*	$NetBSD: machdep.c,v 1.351 2017/08/15 09:26:56 maya Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.350 2017/04/03 17:36:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.351 2017/08/15 09:26:56 maya Exp $");
 
 #include "opt_adb.h"
 #include "opt_copy_symtab.h"
@@ -872,12 +872,10 @@ getenvvars(u_long flag, char *buf)
 	extern long macos_gmtbias;
 	int root_scsi_id;
 	u_long root_ata_dev;
-#ifdef	__ELF__
 	int i;
 	Elf_Ehdr *ehdr;
 	Elf_Shdr *shp;
 	vaddr_t minsym;
-#endif
 
 	/*
 	 * If flag & 0x8000 == 0, then we're booting with the old booter
@@ -990,7 +988,6 @@ getenvvars(u_long flag, char *buf)
  	ADBReInit_JTBL = getenv("ADBREINIT_JTBL");
  	mrg_ADBIntrPtr = (void *)getenv("ADBINTERRUPT");
 
-#ifdef	__ELF__
 	/*
 	 * Check the ELF headers.
 	 */
@@ -1017,10 +1014,6 @@ getenvvars(u_long flag, char *buf)
 
 	symsize = 1;
 	ssym = (int *)ehdr;
-#else
-	symsize = *(int *)
-	ssym = ((int *)) + 1;
-#endif
 }
 
 static long



CVS commit: src/sys/arch/mac68k/mac68k

2017-04-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr  3 17:36:17 UTC 2017

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

Log Message:
PR/52134: David Binderman: Fix loop bounds checking.


To generate a diff of this commit:
cvs rdiff -u -r1.349 -r1.350 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/machdep.c
diff -u src/sys/arch/mac68k/mac68k/machdep.c:1.349 src/sys/arch/mac68k/mac68k/machdep.c:1.350
--- src/sys/arch/mac68k/mac68k/machdep.c:1.349	Sat Aug 29 21:46:03 2015
+++ src/sys/arch/mac68k/mac68k/machdep.c	Mon Apr  3 13:36:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.349 2015/08/30 01:46:03 uebayasi Exp $	*/
+/*	$NetBSD: machdep.c,v 1.350 2017/04/03 17:36:17 christos Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.349 2015/08/30 01:46:03 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.350 2017/04/03 17:36:17 christos Exp $");
 
 #include "opt_adb.h"
 #include "opt_copy_symtab.h"
@@ -646,7 +646,7 @@ cpu_dumpconf(void)
 	chdrsize = cpu_dumpsize();
 
 	dumpsize = 0;
-	for (i = 0; m->ram_segs[i].size && i < M68K_NPHYS_RAM_SEGS; i++)
+	for (i = 0; i < M68K_NPHYS_RAM_SEGS && m->ram_segs[i].size; i++)
 		dumpsize += btoc(m->ram_segs[i].size);
 
 	/*



CVS commit: src/sys/arch/mac68k/mac68k

2015-03-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Mar  3 20:36:31 UTC 2015

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

Log Message:
Handle EINVAL in the fault path and send SIGBUS on mmap'd access past EOF.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/trap.c
diff -u src/sys/arch/mac68k/mac68k/trap.c:1.146 src/sys/arch/mac68k/mac68k/trap.c:1.147
--- src/sys/arch/mac68k/mac68k/trap.c:1.146	Sun Feb 19 21:06:15 2012
+++ src/sys/arch/mac68k/mac68k/trap.c	Tue Mar  3 20:36:31 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.146 2012/02/19 21:06:15 rmind Exp $	*/
+/*	$NetBSD: trap.c,v 1.147 2015/03/03 20:36:31 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.146 2012/02/19 21:06:15 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.147 2015/03/03 20:36:31 martin Exp $);
 
 #include opt_ddb.h
 #include opt_execfmt.h
@@ -585,11 +585,6 @@ copyfault:
 			}
 			goto out;
 		}
-		if (rv == EACCES) {
-			ksi.ksi_code = SEGV_ACCERR;
-			rv = EFAULT;
-		} else
-			ksi.ksi_code = SEGV_MAPERR;
 		if (type == T_MMUFLT) {
 			if (onfault)
 goto copyfault;
@@ -600,14 +595,26 @@ copyfault:
 			goto dopanic;
 		}
 		ksi.ksi_addr = (void *)v;
-		if (rv == ENOMEM) {
+		switch (rv) {
+		case ENOMEM:
 			printf(UVM: pid %d (%s), uid %d killed: out of swap\n,
 			   p-p_pid, p-p_comm,
 			   l-l_cred ?
 			   kauth_cred_geteuid(l-l_cred) : -1);
 			ksi.ksi_signo = SIGKILL;
-		} else {
+			break;
+		case EINVAL:
+			ksi.ksi_signo = SIGBUS;
+			ksi.ksi_code = BUS_ADRERR;
+			break;
+		case EACCES:
 			ksi.ksi_signo = SIGSEGV;
+			ksi.ksi_code = SEGV_ACCERR;
+			break;
+		default:
+			ksi.ksi_signo = SIGSEGV;
+			ksi.ksi_code = SEGV_MAPERR;
+			break;
 		}
 		break;
 	}



CVS commit: src/sys/arch/mac68k/mac68k

2014-03-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 26 17:46:04 UTC 2014

Modified Files:
src/sys/arch/mac68k/mac68k: pram.c

Log Message:
kill sprintf


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/mac68k/mac68k/pram.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/mac68k/pram.c
diff -u src/sys/arch/mac68k/mac68k/pram.c:1.22 src/sys/arch/mac68k/mac68k/pram.c:1.23
--- src/sys/arch/mac68k/mac68k/pram.c:1.22	Tue Jun 20 20:02:26 2006
+++ src/sys/arch/mac68k/mac68k/pram.c	Wed Mar 26 13:46:04 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pram.c,v 1.22 2006/06/21 00:02:26 rjs Exp $	*/
+/*	$NetBSD: pram.c,v 1.23 2014/03/26 17:46:04 christos Exp $	*/
 
 /*-
  * Copyright (C) 1993	Allen K. Briggs, Chris P. Caputo,
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pram.c,v 1.22 2006/06/21 00:02:26 rjs Exp $);
+__KERNEL_RCSID(0, $NetBSD: pram.c,v 1.23 2014/03/26 17:46:04 christos Exp $);
 
 #include opt_adb.h
 
@@ -121,7 +121,8 @@ static const char *convtime(unsigned lon
 t=0;
   }
 
-  sprintf(s,%s %ld, %ld   %ld:%ld:%ld,monstr[month],day,year,hour,minute,seconds);
+  snprintf(s, sizeof(s), %s %ld, %ld   %ld:%ld:%ld,
+  monstr[month], day, year, hour, minute, seconds);
 
   return s;
 }



CVS commit: src/sys/arch/mac68k/mac68k

2014-03-15 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Mar 15 12:11:23 UTC 2014

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

Log Message:
Use common m68k/busaddrerr.s for bus error and address error handlers.

No binary changes on GENERIC.


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/locore.s
diff -u src/sys/arch/mac68k/mac68k/locore.s:1.169 src/sys/arch/mac68k/mac68k/locore.s:1.170
--- src/sys/arch/mac68k/mac68k/locore.s:1.169	Sun Mar  9 16:28:43 2014
+++ src/sys/arch/mac68k/mac68k/locore.s	Sat Mar 15 12:11:23 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.169 2014/03/09 16:28:43 tsutsui Exp $	*/
+/*	$NetBSD: locore.s,v 1.170 2014/03/15 12:11:23 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -474,187 +474,16 @@ Lnocache0:
  */ 
 #include m68k/m68k/trap_subr.s
 
+/*
+ * Use common m68k bus error and address error handlers.
+ */
 	.data
 GLOBAL(mac68k_a2_fromfault)
 	.long	0
 GLOBAL(m68k_fault_addr)
 	.long	0
 
-#if defined(M68040) || defined(M68060)
-ENTRY_NOPROFILE(addrerr4060)
-	clrl	%sp@-			| stack adjust count
-	moveml	#0x,%sp@-		| save user registers
-	movl	%usp,%a0		| save %USP
-	movl	%a0,%sp@(FR_SP)		|   in the savearea
-	movl	%sp@(FR_HW+8),%sp@-
-	clrl	%sp@-			| dummy code
-	movl	#T_ADDRERR,%sp@-	| mark address error
-	jra	_ASM_LABEL(faultstkadj)	| and deal with it
-#endif
-
-#if defined(M68060)
-ENTRY_NOPROFILE(buserr60)
-	clrl	%sp@-			| stack adjust count
-	moveml	#0x,%sp@-		| save user registers
-	movl	%usp,%a0		| save %USP
-	movl	%a0,%sp@(FR_SP)		|   in the savearea
-	movel	%sp@(FR_HW+12),%d0	| FSLW
-	btst	#2,%d0			| branch prediction error?
-	jeq	Lnobpe			
-	movc	%cacr,%d2
-	orl	#IC60_CABC,%d2		| clear all branch cache entries
-	movc	%d2,%cacr
-	movl	%d0,%d1
-	andl	#0x7ffd,%d1
-	jeq	_ASM_LABEL(faultstkadjnotrap2)
-Lnobpe:
-| we need to adjust for misaligned addresses
-	movl	%sp@(FR_HW+8),%d1	| grab VA
-	btst	#27,%d0			| check for mis-aligned access
-	jeq	Lberr3			| no, skip
-	addl	#28,%d1			| yes, get into next page
-	| operand case: 3,
-	| instruction case: 4+12+12
-	andl	#PG_FRAME,%d1   | and truncate
-Lberr3:
-	movl	%d1,%sp@-
-	movl	%d0,%sp@-		| code is FSLW now.
-	andw	#0x1f80,%d0 
-	jeq	Lberr60			| it is a bus error
-	movl	#T_MMUFLT,%sp@-		| show that we are an MMU fault
-	jra	_ASM_LABEL(faultstkadj)	| and deal with it
-Lberr60:
-	tstl	_C_LABEL(nofault)	| catch bus error?
-	jeq	Lisberr			| no, handle as usual
-	movl	%a2,_C_LABEL(mac68k_a2_fromfault) | save %a2
-	movl	%sp@(FR_HW+8+8),_C_LABEL(m68k_fault_addr) | save fault addr
-	movl	_C_LABEL(nofault),%sp@-	| yes,
-	jbsr	_C_LABEL(longjmp)	|  longjmp(nofault)
-	/* NOTREACHED */
-#endif
-#if defined(M68040)
-ENTRY_NOPROFILE(buserr40)
-	clrl	%sp@-			| stack adjust count
-	moveml	#0x,%sp@-		| save user registers
-	movl	%usp,%a0		| save %USP
-	movl	%a0,%sp@(FR_SP)		|   in the savearea
-	movl	%sp@(FR_HW+20),%d1	| get fault address
-	moveq	#0,%d0
-	movw	%sp@(FR_HW+12),%d0	| get SSW
-	btst	#11,%d0			| check for mis-aligned
-	jeq	Lbe1stpg		| no skip
-	addl	#3,%d1			| get into next page
-	andl	#PG_FRAME,%d1		| and truncate
-Lbe1stpg:
-	movl	%d1,%sp@-		| pass fault address.
-	movl	%d0,%sp@-		| pass SSW as code
-	btst	#10,%d0			| test ATC
-	jeq	Lberr40			| it is a bus error
-	movl	#T_MMUFLT,%sp@-		| show that we are an MMU fault
-	jra	_ASM_LABEL(faultstkadj)	| and deal with it
-Lberr40:
-	tstl	_C_LABEL(nofault)	| catch bus error?
-	jeq	Lisberr			| no, handle as usual
-	movl	%a2,_C_LABEL(mac68k_a2_fromfault) | save %a2
-	movl	%sp@(FR_HW+8+20),_C_LABEL(m68k_fault_addr) | save fault addr
-	movl	_C_LABEL(nofault),%sp@-	| yes,
-	jbsr	_C_LABEL(longjmp)	|  longjmp(nofault)
-	/* NOTREACHED */
-#endif
-
-ENTRY_NOPROFILE(busaddrerr2030)
-#if !(defined(M68020) || defined(M68030))
-	jra	_C_LABEL(badtrap)
-#else
-	clrl	%sp@-			| stack adjust count
-	moveml	#0x,%sp@-		| save user registers
-	movl	%usp,%a0		| save %USP
-	movl	%a0,%sp@(FR_SP)		|   in the savearea
-	moveq	#0,%d0
-	movw	%sp@(FR_HW+10),%d0	| grab SSW for fault processing
-	btst	#12,%d0			| RB set?
-	jeq	LbeX0			| no, test RC
-	bset	#14,%d0			| yes, must set FB
-	movw	%d0,%sp@(FR_HW+10)	| for hardware too
-LbeX0:
-	btst	#13,%d0			| RC set?
-	jeq	LbeX1			| no, skip
-	bset	#15,%d0			| yes, must set FC
-	movw	%d0,%sp@(FR_HW+10)	| for hardware too
-LbeX1:
-	btst	#8,%d0			| data fault?
-	jeq	Lbe0			| no, check for hard cases
-	movl	%sp@(FR_HW+16),%d1	| fault address is as given in frame
-	jra	Lbe10			| thats it
-Lbe0:
-	btst	#4,%sp@(FR_HW+6)	| long (type B) stack frame?
-	jne	Lbe4			| yes, go handle
-	movl	%sp@(FR_HW+2),%d1	| no, can use save PC
-	btst	#14,%d0			| FB set?
-	jeq	Lbe3			| no, try FC
-	addql	#4,%d1			| yes, adjust address
-	jra	Lbe10			| done
-Lbe3:
-	btst	#15,%d0			| FC set?
-	jeq	Lbe10			| no, 

CVS commit: src/sys/arch/mac68k/mac68k

2013-10-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Oct 19 19:08:39 UTC 2013

Modified Files:
src/sys/arch/mac68k/mac68k: bus_space.c

Log Message:
Avoid unused variables


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/mac68k/mac68k/bus_space.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/mac68k/bus_space.c
diff -u src/sys/arch/mac68k/mac68k/bus_space.c:1.31 src/sys/arch/mac68k/mac68k/bus_space.c:1.32
--- src/sys/arch/mac68k/mac68k/bus_space.c:1.31	Mon Apr 28 20:23:27 2008
+++ src/sys/arch/mac68k/mac68k/bus_space.c	Sat Oct 19 19:08:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_space.c,v 1.31 2008/04/28 20:23:27 martin Exp $	*/
+/*	$NetBSD: bus_space.c,v 1.32 2013/10/19 19:08:39 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bus_space.c,v 1.31 2008/04/28 20:23:27 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: bus_space.c,v 1.32 2013/10/19 19:08:39 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -139,7 +139,9 @@ int
 bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
 	  bus_space_handle_t *hp)
 {
+#ifdef DIAGNOSTIC
 	paddr_t pa, endpa;
+#endif
 	int error;
 
 	/*
@@ -151,10 +153,10 @@ bus_space_map(bus_space_tag_t t, bus_add
 	if (error)
 		return (error);
 
+#ifdef DIAGNOSTIC
 	pa = m68k_trunc_page(bpa + t);
 	endpa = m68k_round_page((bpa + t + size) - 1);
 
-#ifdef DIAGNOSTIC
 	if (endpa = pa)
 		panic(bus_space_map: overflow);
 #endif
@@ -269,7 +271,6 @@ int
 mac68k_bus_space_probe(bus_space_tag_t t, bus_space_handle_t h,
 		   bus_size_t offset, int size)
 {
-	int i;
 	label_t faultbuf;
 
 	nofault = faultbuf;
@@ -280,13 +281,13 @@ mac68k_bus_space_probe(bus_space_tag_t t
 
 	switch (size) {
 	case 1:
-		i = bus_space_read_1(t, h, offset);
+		bus_space_read_1(t, h, offset);
 		break;
 	case 2:
-		i = bus_space_read_2(t, h, offset);
+		bus_space_read_2(t, h, offset);
 		break;
 	case 4:
-		i = bus_space_read_4(t, h, offset);
+		bus_space_read_4(t, h, offset);
 		break;
 	case 8:
 	default:



CVS commit: src/sys/arch/mac68k/mac68k

2012-08-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Aug  4 17:18:39 UTC 2012

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

Log Message:
No need to statically initialize physmem here, it is set to the correct
value in pmap_bootstrap(), which is early enough.
Tested on my Centris 660AV.


To generate a diff of this commit:
cvs rdiff -u -r1.344 -r1.345 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/machdep.c
diff -u src/sys/arch/mac68k/mac68k/machdep.c:1.344 src/sys/arch/mac68k/mac68k/machdep.c:1.345
--- src/sys/arch/mac68k/mac68k/machdep.c:1.344	Fri Jul 27 05:36:11 2012
+++ src/sys/arch/mac68k/mac68k/machdep.c	Sat Aug  4 17:18:38 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.344 2012/07/27 05:36:11 matt Exp $	*/
+/*	$NetBSD: machdep.c,v 1.345 2012/08/04 17:18:38 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -74,7 +74,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.344 2012/07/27 05:36:11 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.345 2012/08/04 17:18:38 martin Exp $);
 
 #include opt_adb.h
 #include opt_ddb.h
@@ -191,7 +191,6 @@ void *	mac68k_bell_cookie;
 struct vm_map *phys_map = NULL;
 
 int	maxmem;			/* max memory per process */
-int	physmem = MAXMEM;	/* max supported memory, changes to actual */
 
 /*
  * Extent maps to manage all memory space, including I/O ranges.  Allocate



CVS commit: src/sys/arch/mac68k/mac68k

2011-01-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jan  2 18:16:59 UTC 2011

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

Log Message:
Pull code that maps the kernel segment table cache invalidated for 040/060,
to reduce diffs from other m68k ports.

Tested on LC630 (with 68LC040) upto single user.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/pmap_bootstrap.c
diff -u src/sys/arch/mac68k/mac68k/pmap_bootstrap.c:1.90 src/sys/arch/mac68k/mac68k/pmap_bootstrap.c:1.91
--- src/sys/arch/mac68k/mac68k/pmap_bootstrap.c:1.90	Sun Jan  2 08:40:55 2011
+++ src/sys/arch/mac68k/mac68k/pmap_bootstrap.c	Sun Jan  2 18:16:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_bootstrap.c,v 1.90 2011/01/02 08:40:55 tsutsui Exp $	*/
+/*	$NetBSD: pmap_bootstrap.c,v 1.91 2011/01/02 18:16:59 tsutsui Exp $	*/
 
 /* 
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap_bootstrap.c,v 1.90 2011/01/02 08:40:55 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap_bootstrap.c,v 1.91 2011/01/02 18:16:59 tsutsui Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -370,11 +370,11 @@
 	}
 	/*
 	 * Validate PTEs for kernel data/bss, dynamic data allocated
-	 * by us so far (nextpa - firstpa bytes), and pages for lwp0
+	 * by us so far (kstpa - firstpa bytes), and pages for lwp0
 	 * u-area and page table allocated below (RW).
 	 */
 	epte = PA2VA(kptpa, pt_entry_t *);
-	epte = epte[m68k_btop(nextpa - firstpa)];
+	epte = epte[m68k_btop(kstpa - firstpa)];
 	protopte = (protopte  ~PG_PROT) | PG_RW;
 	/*
 	 * Enable copy-back caching of data pages
@@ -385,6 +385,26 @@
 		*pte++ = protopte;
 		protopte += PAGE_SIZE;
 	}
+	/*
+	 * map the kernel segment table cache invalidated for
+	 * these machines (for the 68040 not strictly necessary, but
+	 * recommended by Motorola; for the 68060 mandatory)
+	 */
+	epte = PA2VA(kptpa, pt_entry_t *);
+	epte = epte[m68k_btop(nextpa - firstpa)];
+	protopte = (protopte  ~PG_PROT) | PG_RW;
+	if (mmutype == MMU_68040) {
+		protopte = ~PG_CCB;
+		protopte |= PG_CIN;
+	}
+	while (pte  epte) {
+		*pte++ = protopte;
+		protopte += PAGE_SIZE;
+	}
+
+	/*
+	 * Finally, validate the internal IO space PTEs (RW+CI).
+	 */
 
 #define	PTE2VA(pte)	m68k_ptob(pte - PA2VA(kptpa, pt_entry_t *))
 



CVS commit: src/sys/arch/mac68k/mac68k

2009-12-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Dec  4 16:57:18 UTC 2009

Modified Files:
src/sys/arch/mac68k/mac68k: locore.s pmap_bootstrap.c

Log Message:
Use common pmap_bootstrap_finalize() to initialize lwp0 uarea etc.
Tested on LC630.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/arch/mac68k/mac68k/locore.s
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/mac68k/mac68k/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/mac68k/mac68k/locore.s
diff -u src/sys/arch/mac68k/mac68k/locore.s:1.156 src/sys/arch/mac68k/mac68k/locore.s:1.157
--- src/sys/arch/mac68k/mac68k/locore.s:1.156	Thu Nov 26 00:19:18 2009
+++ src/sys/arch/mac68k/mac68k/locore.s	Fri Dec  4 16:57:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.156 2009/11/26 00:19:18 matt Exp $	*/
+/*	$NetBSD: locore.s,v 1.157 2009/12/04 16:57:18 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -336,15 +336,13 @@
 /* select the software page size now */
 	lea	_ASM_LABEL(tmpstk),%sp	| temporary stack
 	jbsr	_C_LABEL(uvm_setpagesize)  | select software page size
-
+/* call final pmap setup which initialize lwp0, curlwp, and curpcb */
+	jbsr	_C_LABEL(pmap_bootstrap_finalize)
 /* set kernel stack, user SP, lwp0, and initial pcb */
-	lea	_C_LABEL(lwp0),%a2	| get lwp0.l_addr
-	movl	%a2@(L_ADDR),%a1	|   set kernel stack to end of area 
-	lea	%a1@(USPACE-4),%sp	|   and curlwp so that we don't
-	movl	%a2,_C_LABEL(curlwp)	|   deref NULL in trap()
+	movl	_C_LABEL(lwp0uarea),%a1	| get lwp0 uarea
+	lea	%a1@(USPACE-4),%sp	|   set kernel stack to end of area
 	movl	#USRSTACK-4,%a2
 	movl	%a2,%usp		| init %USP
-	movl	%a1,_C_LABEL(curpcb)	| lwp0 is running
 
 /* flush TLB and turn on caches */
 	cmpl	#MMU_68040,_C_LABEL(mmutype) | 68040?

Index: src/sys/arch/mac68k/mac68k/pmap_bootstrap.c
diff -u src/sys/arch/mac68k/mac68k/pmap_bootstrap.c:1.80 src/sys/arch/mac68k/mac68k/pmap_bootstrap.c:1.81
--- src/sys/arch/mac68k/mac68k/pmap_bootstrap.c:1.80	Fri Nov 27 03:23:10 2009
+++ src/sys/arch/mac68k/mac68k/pmap_bootstrap.c	Fri Dec  4 16:57:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_bootstrap.c,v 1.80 2009/11/27 03:23:10 rmind Exp $	*/
+/*	$NetBSD: pmap_bootstrap.c,v 1.81 2009/12/04 16:57:18 tsutsui Exp $	*/
 
 /* 
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap_bootstrap.c,v 1.80 2009/11/27 03:23:10 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap_bootstrap.c,v 1.81 2009/12/04 16:57:18 tsutsui Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -110,7 +110,7 @@
 void
 pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
 {
-	paddr_t kstpa, kptpa, kptmpa, l0upa;
+	paddr_t kstpa, kptpa, kptmpa, lwp0upa;
 	u_int nptpages, kstsize;
 	paddr_t avail_next;
 	int avail_remaining;
@@ -138,7 +138,7 @@
 	 *
 	 *	kptmpa		kernel PT map		1 page
 	 *
-	 *	l0upa		lwp 0 u-area		UPAGES pages
+	 *	lwp0upa		lwp 0 u-area		UPAGES pages
 	 *
 	 */
 	if (mmutype == MMU_68040)
@@ -149,7 +149,7 @@
 	nextpa += kstsize * PAGE_SIZE;
 	kptmpa = nextpa;
 	nextpa += PAGE_SIZE;
-	l0upa = nextpa;
+	lwp0upa = nextpa;
 	nextpa += USPACE;
 	kptpa = nextpa;
 	nptpages = Sysptsize +
@@ -335,7 +335,7 @@
 	}
 	/*
 	 * Validate PTEs for kernel data/bss, dynamic data allocated
-	 * by us so far (nextpa - firstpa bytes), and pages for proc0
+	 * by us so far (nextpa - firstpa bytes), and pages for lwp0
 	 * u-area and page table allocated below (RW).
 	 */
 	epte = (PA2VA(kptpa, u_int *))[m68k_btop(nextpa - firstpa)];
@@ -399,21 +399,22 @@
 	Sysmap = (pt_entry_t *)m68k_ptob((NPTEPG - 1) * NPTEPG);
 
 	/*
-	 * Setup u-area for process 0.
+	 * Setup u-area for lwp 0.
 	 */
 	/*
 	 * Zero the u-area.
 	 * NOTE: `pte' and `epte' aren't PTEs here.
 	 */
-	pte = PA2VA(l0upa, u_int *);
-	epte = (u_int *)(PA2VA(l0upa, u_int) + USPACE);
+	pte = PA2VA(lwp0upa, u_int *);
+	epte = (u_int *)(PA2VA(lwp0upa, u_int) + USPACE);
 	while (pte  epte)
 		*pte++ = 0;
 
 	/*
-	 * Store the u-area address
+	 * Remember the u-area address so it can be loaded in the lwp0
+	 * via uvm_lwp_setuarea() later in pmap_bootstrap_finalize().
 	 */
-	uvm_lwp_setuarea(lwp0, PA2VA(l0upa, vaddr_t));
+	lwp0uarea = PA2VA(lwp0upa, vaddr_t);
 
 	/*
 	 * VM data structures are now initialized, set up data for