CVS commit: src/sys/arch/m68k/m68k

2021-04-24 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Apr 24 16:14:08 UTC 2021

Modified Files:
src/sys/arch/m68k/m68k: sig_machdep.c

Log Message:
Restore comments for f_stackadj and reenter_syscall().

Taken from sys/compat/linux/arch/m68k/linux_machdep.c which was
originally implemented to use reenter_syscall() for sigreturn of
Linux binaries.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/m68k/m68k/sig_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/m68k/m68k/sig_machdep.c
diff -u src/sys/arch/m68k/m68k/sig_machdep.c:1.50 src/sys/arch/m68k/m68k/sig_machdep.c:1.51
--- src/sys/arch/m68k/m68k/sig_machdep.c:1.50	Tue Nov 27 14:09:54 2018
+++ src/sys/arch/m68k/m68k/sig_machdep.c	Sat Apr 24 16:14:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sig_machdep.c,v 1.50 2018/11/27 14:09:54 maxv Exp $	*/
+/*	$NetBSD: sig_machdep.c,v 1.51 2021/04/24 16:14:08 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -40,7 +40,7 @@
 #include "opt_m68k_arch.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.50 2018/11/27 14:09:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.51 2021/04/24 16:14:08 tsutsui Exp $");
 
 #define __M68K_SIGNAL_PRIVATE
 
@@ -236,7 +236,16 @@ cpu_getmcontext(struct lwp *l, mcontext_
 		(void)memcpy(>__mc_pad.__mc_frame.__mcf_exframe,
 		>F_u, (size_t)exframesize[format]);
 
-		/* Leave indicators, see above. */
+		/*
+		 * Leave indicators that we need to clean up the kernel
+		 * stack.  We do this by setting the "pad word" above the
+		 * hardware stack frame to the amount the stack must be
+		 * adjusted by.
+		 *
+		 * N.B. we increment rather than just set f_stackadj in
+		 * case we are called from syscall when processing a
+		 * sigreturn.  In that case, f_stackadj may be non-zero.
+		 */
 		frame->f_stackadj += exframesize[format];
 		frame->f_format = frame->f_vector = 0;
 	}
@@ -303,16 +312,26 @@ cpu_setmcontext(struct lwp *l, const mco
 			return (EINVAL);
 
 		if (frame->f_stackadj == 0) {
+			/*
+			 * Extra stack space is required but not allocated.
+			 * Allocate and re-enter syscall().
+			 */
 			reenter_syscall(frame, sz);
 			/* NOTREACHED */
 		}
 
 #ifdef DIAGNOSTIC
+		/* reenter_syscall() should adjust stack for the extra frame. */
 		if (sz != frame->f_stackadj)
 			panic("cpu_setmcontext: %d != %d",
 			sz, frame->f_stackadj);
 #endif
 
+		/*
+		 * Restore long stack frames.  Note that we do not copy
+		 * back the saved SR or PC, they were picked up below from
+		 * the sigcontext structure.
+		 */
 		frame->f_format = format;
 		frame->f_vector = mcp->__mc_pad.__mc_frame.__mcf_vector;
 		(void)memcpy(>F_u,



CVS commit: src/sys/arch/m68k/m68k

2021-04-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Apr 16 00:13:48 UTC 2021

Modified Files:
src/sys/arch/m68k/m68k: pmap_motorola.c

Log Message:
check the result value of pmap_extract() and panic if it fails.
this is a "should never fail" case, and GCC 10 noticed that it
allows an uninitialised variable use.

tested by rin@ on amiga and mac68k.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/m68k/m68k/pmap_motorola.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/m68k/m68k/pmap_motorola.c
diff -u src/sys/arch/m68k/m68k/pmap_motorola.c:1.73 src/sys/arch/m68k/m68k/pmap_motorola.c:1.74
--- src/sys/arch/m68k/m68k/pmap_motorola.c:1.73	Mon Feb  1 19:02:27 2021
+++ src/sys/arch/m68k/m68k/pmap_motorola.c	Fri Apr 16 00:13:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_motorola.c,v 1.73 2021/02/01 19:02:27 skrll Exp $*/
+/*	$NetBSD: pmap_motorola.c,v 1.74 2021/04/16 00:13:48 mrg Exp $*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -119,7 +119,7 @@
 #include "opt_m68k_arch.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.73 2021/02/01 19:02:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.74 2021/04/16 00:13:48 mrg Exp $");
 
 #include 
 #include 
@@ -1667,7 +1667,11 @@ pmap_collect1(pmap_t pmap, paddr_t start
 		 * ST and Sysptmap entries.
 		 */
 
-		(void) pmap_extract(pmap, pv->pv_va, );
+		if (!pmap_extract(pmap, pv->pv_va, )) {
+			printf("collect: freeing KPT page at %lx (ste %x@%p)\n",
+			pv->pv_va, *pv->pv_ptste, pv->pv_ptste);
+			panic("pmap_collect: mapping not found");
+		}
 		pmap_remove_mapping(pmap, pv->pv_va, NULL,
 		PRM_TFLUSH|PRM_CFLUSH, NULL);
 



CVS commit: src/sys/arch/m68k/m68k

2021-04-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr  6 16:05:17 UTC 2021

Modified Files:
src/sys/arch/m68k/m68k: db_disasm.h

Log Message:
Remove duplicate db_disasm() prototype.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/m68k/m68k/db_disasm.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/arch/m68k/m68k/db_disasm.h
diff -u src/sys/arch/m68k/m68k/db_disasm.h:1.9 src/sys/arch/m68k/m68k/db_disasm.h:1.10
--- src/sys/arch/m68k/m68k/db_disasm.h:1.9	Sat Mar 14 14:46:01 2009
+++ src/sys/arch/m68k/m68k/db_disasm.h	Tue Apr  6 16:05:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.h,v 1.9 2009/03/14 14:46:01 dsl Exp $	*/
+/*	$NetBSD: db_disasm.h,v 1.10 2021/04/06 16:05:17 simonb Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -424,5 +424,3 @@ typedef struct dis_buffer dis_buffer_t;
 #define PRINT_FPREG(dbuf, reg) addstr(dbuf, fpregs[reg])
 #define PRINT_DREG(dbuf, reg) addstr(dbuf, dregs[reg])
 #define PRINT_AREG(dbuf, reg) addstr(dbuf, aregs[reg])
-
-db_addr_t	db_disasm(db_addr_t loc, bool moto_syntax);



CVS commit: src/sys/arch/m68k/m68k

2021-04-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr  6 16:04:44 UTC 2021

Modified Files:
src/sys/arch/m68k/m68k: db_disasm.c

Log Message:
Include  to get ddb's db_disasm() prototype.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/m68k/m68k/db_disasm.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/m68k/m68k/db_disasm.c
diff -u src/sys/arch/m68k/m68k/db_disasm.c:1.44 src/sys/arch/m68k/m68k/db_disasm.c:1.45
--- src/sys/arch/m68k/m68k/db_disasm.c:1.44	Sat Oct 26 17:50:18 2019
+++ src/sys/arch/m68k/m68k/db_disasm.c	Tue Apr  6 16:04:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.44 2019/10/26 17:50:18 christos Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.45 2021/04/06 16:04:44 simonb Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.44 2019/10/26 17:50:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.45 2021/04/06 16:04:44 simonb Exp $");
 
 #include 
 #ifdef _KERNEL
@@ -72,8 +72,9 @@ __KERNEL_RCSID(0, "$NetBSD: db_disasm.c,
 
 #include 
 
-#include 
+#include 
 #include 
+#include 
 #include 
 
 static void	get_modregstr(dis_buffer_t *, int, int, int, int);



CVS commit: src/sys/arch/m68k/m68k

2021-03-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar  6 13:32:56 UTC 2021

Modified Files:
src/sys/arch/m68k/m68k: m68k_trap.c

Log Message:
Minimal (but hackish) change to make a DEBUG kernel compilable.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/m68k/m68k/m68k_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/m68k/m68k/m68k_trap.c
diff -u src/sys/arch/m68k/m68k/m68k_trap.c:1.2 src/sys/arch/m68k/m68k/m68k_trap.c:1.3
--- src/sys/arch/m68k/m68k/m68k_trap.c:1.2	Sat Apr  6 03:06:26 2019
+++ src/sys/arch/m68k/m68k/m68k_trap.c	Sat Mar  6 13:32:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: m68k_trap.c,v 1.2 2019/04/06 03:06:26 thorpej Exp $	*/
+/*	$NetBSD: m68k_trap.c,v 1.3 2021/03/06 13:32:56 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: m68k_trap.c,v 1.2 2019/04/06 03:06:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m68k_trap.c,v 1.3 2021/03/06 13:32:56 martin Exp $");
 
 #include "opt_m68k_arch.h"
 
@@ -91,6 +91,15 @@ extern int suline(void *, void *);	/* lo
 #define	KDFAULT(c)	(KDFAULT_060(c) || KDFAULT_040(c) || KDFAULT_OTH(c))
 #define	WRFAULT(c)	(WRFAULT_060(c) || WRFAULT_040(c) || WRFAULT_OTH(c))
 
+
+#ifdef DEBUG
+extern int mmudebug, mmupid;
+#define MDB_FOLLOW	1
+#define MDB_WBFOLLOW	2
+#define MDB_WBFAILED	4
+#define MDB_ISPID(pid)	((pid) == mmupid)
+#endif
+
 #ifdef M68040
 #ifdef DEBUG
 struct writebackstats {



CVS commit: src/sys/arch/m68k/m68k

2021-02-23 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Feb 23 16:54:17 UTC 2021

Modified Files:
src/sys/arch/m68k/m68k: reenter_syscall.s

Log Message:
Plug kernel stack leaks in reenter_syscall() for setcontext(2).

This fixes long standing kernel crashes (MMU fault, address error,
and silent freeze by a double bus fault etc. seen for ~10 years)
caused by kernel stack overflow, especially on x68k and sun3 running
Xorg based servers.  See PR/55990 for more details.

"This change seems perfectly reasonable" from thorpej@ and
jklos@ also reported this also solved freeze of his mac68k system
with 10 megabyes of memory.

Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/m68k/m68k/reenter_syscall.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/m68k/m68k/reenter_syscall.s
diff -u src/sys/arch/m68k/m68k/reenter_syscall.s:1.6 src/sys/arch/m68k/m68k/reenter_syscall.s:1.7
--- src/sys/arch/m68k/m68k/reenter_syscall.s:1.6	Sun Feb 21 07:23:41 2021
+++ src/sys/arch/m68k/m68k/reenter_syscall.s	Tue Feb 23 16:54:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: reenter_syscall.s,v 1.6 2021/02/21 07:23:41 tsutsui Exp $	*/
+/*	$NetBSD: reenter_syscall.s,v 1.7 2021/02/23 16:54:17 tsutsui Exp $	*/
 
 /*
  * Written by ITOH Yasufumi.
@@ -51,6 +51,19 @@ ENTRY_NOPROFILE(reenter_syscall)
 #endif
 	moveal	FR_SP(%sp),%a0		| grab and restore
 	movel	%a0,%usp		|   user SP
+	movw	FR_ADJ(%sp),%d0		| need to adjust stack?
+	jne	.Ladjstk		| yes, go to it
 	moveml	(%sp)+,#0x7FFF		| restore user registers
 	addql	#8,%sp			| pop SP and stack adjust
 	jra	_ASM_LABEL(rei)		| rte
+.Ladjstk:
+	lea	FR_HW(%sp),%a1		| pointer to HW frame
+	addql	#8,%a1			| source pointer
+	movl	%a1,%a0			| source
+	addw	%d0,%a0			|  + hole size = dest pointer
+	movl	-(%a1),-(%a0)		| copy
+	movl	-(%a1),-(%a0)		|  8 bytes
+	movl	%a0,FR_SP(%sp)		| new SSP
+	moveml	(%sp)+,#0x7FFF		| restore user register
+	movl	(%sp),%sp		| and do real RTE
+	jra	_ASM_LABEL(rei)		| rte



CVS commit: src/sys/arch/m68k/m68k

2021-02-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Feb 21 07:23:41 UTC 2021

Modified Files:
src/sys/arch/m68k/m68k: reenter_syscall.s

Log Message:
Consistently use motorola style.  No binary changes.

Seems missed in rev 1.3:
 https://mail-index.netbsd.org/source-changes/2013/08/01/msg046378.html


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/m68k/reenter_syscall.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/m68k/m68k/reenter_syscall.s
diff -u src/sys/arch/m68k/m68k/reenter_syscall.s:1.5 src/sys/arch/m68k/m68k/reenter_syscall.s:1.6
--- src/sys/arch/m68k/m68k/reenter_syscall.s:1.5	Sat Feb 20 18:04:20 2021
+++ src/sys/arch/m68k/m68k/reenter_syscall.s	Sun Feb 21 07:23:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: reenter_syscall.s,v 1.5 2021/02/20 18:04:20 tsutsui Exp $	*/
+/*	$NetBSD: reenter_syscall.s,v 1.6 2021/02/21 07:23:41 tsutsui Exp $	*/
 
 /*
  * Written by ITOH Yasufumi.
@@ -39,17 +39,17 @@ ENTRY_NOPROFILE(reenter_syscall)
 .Lcpfr:	movel	(%a0)+,(%a1)+
 	dbra	%d0,.Lcpfr
 
-	movew	%d1,%sp@(FR_ADJ)	| set stack adjust count
+	movew	%d1,FR_ADJ(%sp)		| set stack adjust count
 	movel	(%sp),-(%sp)		| push syscall no (original d0 value)
 	jbsr	_C_LABEL(syscall)	| re-enter syscall()
 	addql	#4,%sp			| pop syscall no
 #ifdef DEBUG
-	tstw	%sp@(FR_ADJ)		| stack adjust must be zero
+	tstw	FR_ADJ(%sp)		| stack adjust must be zero
 	jeq	.Ladjzero
 	PANIC("reenter_syscall")
 .Ladjzero:
 #endif
-	moveal	%sp@(FR_SP),%a0		| grab and restore
+	moveal	FR_SP(%sp),%a0		| grab and restore
 	movel	%a0,%usp		|   user SP
 	moveml	(%sp)+,#0x7FFF		| restore user registers
 	addql	#8,%sp			| pop SP and stack adjust



CVS commit: src/sys/arch/m68k/m68k

2021-02-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Feb 20 18:04:20 UTC 2021

Modified Files:
src/sys/arch/m68k/m68k: reenter_syscall.s

Log Message:
Replace magic numbers with proper macros prepared in assym.h.

No binary changes.
Note this is a preparation for a possible fix of PR port-m68k/55990.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/m68k/m68k/reenter_syscall.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/m68k/m68k/reenter_syscall.s
diff -u src/sys/arch/m68k/m68k/reenter_syscall.s:1.4 src/sys/arch/m68k/m68k/reenter_syscall.s:1.5
--- src/sys/arch/m68k/m68k/reenter_syscall.s:1.4	Sat Sep  7 19:06:29 2013
+++ src/sys/arch/m68k/m68k/reenter_syscall.s	Sat Feb 20 18:04:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: reenter_syscall.s,v 1.4 2013/09/07 19:06:29 chs Exp $	*/
+/*	$NetBSD: reenter_syscall.s,v 1.5 2021/02/20 18:04:20 tsutsui Exp $	*/
 
 /*
  * Written by ITOH Yasufumi.
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include "assym.h"
 
 /*
  * void reenter_syscall(struct frame *fp, int stkadj)
@@ -38,17 +39,17 @@ ENTRY_NOPROFILE(reenter_syscall)
 .Lcpfr:	movel	(%a0)+,(%a1)+
 	dbra	%d0,.Lcpfr
 
-	movew	%d1,%sp@(16*4+2)	| set stack adjust count
+	movew	%d1,%sp@(FR_ADJ)	| set stack adjust count
 	movel	(%sp),-(%sp)		| push syscall no (original d0 value)
 	jbsr	_C_LABEL(syscall)	| re-enter syscall()
 	addql	#4,%sp			| pop syscall no
 #ifdef DEBUG
-	tstw	%sp@(16*4+2)		| stack adjust must be zero
+	tstw	%sp@(FR_ADJ)		| stack adjust must be zero
 	jeq	.Ladjzero
 	PANIC("reenter_syscall")
 .Ladjzero:
 #endif
-	moveal	%sp@(15*4),%a0		| grab and restore
+	moveal	%sp@(FR_SP),%a0		| grab and restore
 	movel	%a0,%usp		|   user SP
 	moveml	(%sp)+,#0x7FFF		| restore user registers
 	addql	#8,%sp			| pop SP and stack adjust



CVS commit: src/sys/arch/m68k/m68k

2020-12-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec 19 21:39:24 UTC 2020

Modified Files:
src/sys/arch/m68k/m68k: bus_dma.c

Log Message:
malloc(9) -> kmem(9)


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/m68k/m68k/bus_dma.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/m68k/m68k/bus_dma.c
diff -u src/sys/arch/m68k/m68k/bus_dma.c:1.35 src/sys/arch/m68k/m68k/bus_dma.c:1.36
--- src/sys/arch/m68k/m68k/bus_dma.c:1.35	Fri Oct 25 09:46:10 2013
+++ src/sys/arch/m68k/m68k/bus_dma.c	Sat Dec 19 21:39:24 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.35 2013/10/25 09:46:10 martin Exp $ */
+/* $NetBSD: bus_dma.c,v 1.36 2020/12/19 21:39:24 thorpej Exp $ */
 
 /*
  * This file was taken from from alpha/common/bus_dma.c
@@ -41,13 +41,13 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.35 2013/10/25 09:46:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.36 2020/12/19 21:39:24 thorpej Exp $");
 
 #include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -63,6 +63,14 @@ int	_bus_dmamap_load_buffer_direct_commo
 	bus_dmamap_t, void *, bus_size_t, struct vmspace *, int,
 	paddr_t *, int *, int);
 
+static size_t
+_bus_dmamap_mapsize(int const nsegments)
+{
+	KASSERT(nsegments > 0);
+	return sizeof(struct m68k_bus_dmamap) +
+	   (sizeof(bus_dma_segment_t) * (nsegments - 1));
+}  
+
 /*
  * Common function for DMA map creation.  May be called by bus-specific
  * DMA map creation functions.
@@ -73,7 +81,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 {
 	struct m68k_bus_dmamap *map;
 	void *mapstore;
-	size_t mapsize;
 
 	/*
 	 * Allocate and initialize the DMA map.  The end of the map
@@ -87,13 +94,10 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 	 * The bus_dmamap_t includes one bus_dma_segment_t, hence
 	 * the (nsegments - 1).
 	 */
-	mapsize = sizeof(struct m68k_bus_dmamap) +
-	(sizeof(bus_dma_segment_t) * (nsegments - 1));
-	if ((mapstore = malloc(mapsize, M_DMAMAP,
-	(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
+	if ((mapstore = kmem_zalloc(_bus_dmamap_mapsize(nsegments),
+	(flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP)) == NULL)
 		return ENOMEM;
 
-	memset(mapstore, 0, mapsize);
 	map = (struct m68k_bus_dmamap *)mapstore;
 	map->_dm_size = size;
 	map->_dm_segcnt = nsegments;
@@ -119,7 +123,7 @@ void
 _bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
 {
 
-	free(map, M_DMAMAP);
+	kmem_free(map, _bus_dmamap_mapsize(map->_dm_segcnt));
 }
 
 /*



CVS commit: src/sys/arch/m68k/m68k

2020-08-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Aug 10 09:38:48 UTC 2020

Modified Files:
src/sys/arch/m68k/m68k: process_machdep.c

Log Message:
Forbid to set odd address to PC in process_write_regs() and process_set_pc().

Otherwise, address error occurs in kernel at rte instruction when returning
to the user level.

Found by tests/lib/libc/t_ptrace_*:access_regs_set_unaligned_pc_0x[137].


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/m68k/m68k/process_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/m68k/m68k/process_machdep.c
diff -u src/sys/arch/m68k/m68k/process_machdep.c:1.30 src/sys/arch/m68k/m68k/process_machdep.c:1.31
--- src/sys/arch/m68k/m68k/process_machdep.c:1.30	Sat Jan  4 00:10:02 2014
+++ src/sys/arch/m68k/m68k/process_machdep.c	Mon Aug 10 09:38:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.30 2014/01/04 00:10:02 dsl Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.31 2020/08/10 09:38:48 rin Exp $	*/
 
 /*
  * Copyright (c) 1993 Christopher G. Demetriou
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.30 2014/01/04 00:10:02 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.31 2020/08/10 09:38:48 rin Exp $");
 
 #include 
 #include 
@@ -114,13 +114,10 @@ process_write_regs(struct lwp *l, const 
 	struct frame *frame = process_frame(l);
 
 	/*
-	 * in the hp300 machdep.c _write_regs, PC alignment wasn't
-	 * checked.  If an odd address is placed in the PC and the
-	 * program is allowed to run, it will cause an Address Error
-	 * which will be transmitted to the process by a SIGBUS.
-	 * No reasonable debugger would let this happen, but
-	 * it's not our problem.
+	 * Avoid kernel address error at rte instruction.
 	 */
+	if (regs->r_pc & 1)
+		return EINVAL;
 
 	/*
 	 * XXX
@@ -171,14 +168,10 @@ process_set_pc(struct lwp *l, void *addr
 	struct frame *frame = process_frame(l);
 
 	/*
-	 * in the hp300 machdep.c _set_pc, PC alignment is guaranteed
-	 * by chopping off the low order bit of the new pc.
-	 * If an odd address was placed in the PC and the program
-	 * is allowed to run, it will cause an Address Error
-	 * which will be transmitted to the process by a SIGBUS.
-	 * No reasonable debugger would let this happen, but
-	 * it's not our problem.
+	 * Avoid kernel address error at rte instruction.
 	 */
+	if ((u_int)addr & 1)
+		return EINVAL;
 	frame->f_pc = (u_int)addr;
 
 	return 0;



CVS commit: src/sys/arch/m68k/m68k

2019-04-11 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Apr 12 03:29:24 UTC 2019

Modified Files:
src/sys/arch/m68k/m68k: copy.s

Log Message:
Fix an asm-comments-vs-preprocessor-line-continuations mistake in
UFETCH_PROLOGUE and USTORE_PROLOGUE that caused a couple of important
instructions to be omitted, resulting in a fatal trap.

Thanks isaki@ for finding my mistake and providing the fix!


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/m68k/m68k/copy.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/m68k/m68k/copy.s
diff -u src/sys/arch/m68k/m68k/copy.s:1.47 src/sys/arch/m68k/m68k/copy.s:1.48
--- src/sys/arch/m68k/m68k/copy.s:1.47	Sat Apr  6 03:06:26 2019
+++ src/sys/arch/m68k/m68k/copy.s	Fri Apr 12 03:29:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: copy.s,v 1.47 2019/04/06 03:06:26 thorpej Exp $	*/
+/*	$NetBSD: copy.s,v 1.48 2019/04/12 03:29:24 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2019 The NetBSD Foundation, Inc.
@@ -364,8 +364,8 @@ ENTRY(kcopy)
 
 #define	UFETCH_PROLOGUE			\
 	CHECK_SFC		;	\
-	movl	4(%sp),%a0		| address to read	;	\
-	GETCURPCB(%a1)			| a1 = curpcb		;	\
+	movl	4(%sp),%a0		/* address to read */	;	\
+	GETCURPCB(%a1)			/* a1 = curpcb */	;	\
 	movl	#.Lufetchstore_fault,PCB_ONFAULT(%a1)
 
 /* LINTSTUB: _ufetch_8(const uint8_t *uaddr, uint8_t *valp); */
@@ -394,8 +394,8 @@ ENTRY(_ufetch_32)
 
 #define	USTORE_PROLOGUE			\
 	CHECK_DFC		;	\
-	movl	4(%sp),%a0		| address to write	;	\
-	GETCURPCB(%a1)			| a1 = curpcb		;	\
+	movl	4(%sp),%a0		/* address to write */	;	\
+	GETCURPCB(%a1)			/* a1 = curpcb */	;	\
 	movl	#.Lufetchstore_fault,PCB_ONFAULT(%a1)
 
 /* LINTSTUB: _ustore_8(uint8_t *uaddr, uint8_t val); */



CVS commit: src/sys/arch/m68k/m68k

2019-02-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Feb  5 07:18:52 UTC 2019

Modified Files:
src/sys/arch/m68k/m68k: db_disasm.c

Log Message:
add fallthru comment.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/m68k/m68k/db_disasm.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/m68k/m68k/db_disasm.c
diff -u src/sys/arch/m68k/m68k/db_disasm.c:1.41 src/sys/arch/m68k/m68k/db_disasm.c:1.42
--- src/sys/arch/m68k/m68k/db_disasm.c:1.41	Sun Sep 21 16:32:51 2014
+++ src/sys/arch/m68k/m68k/db_disasm.c	Tue Feb  5 07:18:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.41 2014/09/21 16:32:51 christos Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.42 2019/02/05 07:18:52 mrg Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.41 2014/09/21 16:32:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.42 2019/02/05 07:18:52 mrg Exp $");
 
 #include 
 #ifdef _KERNEL
@@ -1500,6 +1500,7 @@ opcode_fpu(dis_buffer_t *dbuf, u_short o
 			addstr (dbuf, "fnop");
 			return;
 		}
+		/* FALLTHROUGH */
 	case 3:
 		addstr(dbuf, "fb");
 		print_fcond(dbuf, BITFIELD(opc,5,0));



CVS commit: src/sys/arch/m68k/m68k

2018-10-02 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Oct  2 18:37:32 UTC 2018

Modified Files:
src/sys/arch/m68k/m68k: switch_subr.s

Log Message:
fix diagnostic build.

XXX: pullup-7, pullup-8.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/m68k/m68k/switch_subr.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/m68k/m68k/switch_subr.s
diff -u src/sys/arch/m68k/m68k/switch_subr.s:1.32 src/sys/arch/m68k/m68k/switch_subr.s:1.33
--- src/sys/arch/m68k/m68k/switch_subr.s:1.32	Mon Oct 14 12:20:05 2013
+++ src/sys/arch/m68k/m68k/switch_subr.s	Tue Oct  2 18:37:31 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: switch_subr.s,v 1.32 2013/10/14 12:20:05 isaki Exp $	*/
+/*	$NetBSD: switch_subr.s,v 1.33 2018/10/02 18:37:31 mrg Exp $	*/
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation.
@@ -151,7 +151,7 @@ ENTRY(cpu_switchto)
 	movl	P_VMSPACE(%a2),%a2	| vm = p->p_vmspace
 #if defined(DIAGNOSTIC) && !defined(sun2)
 	tstl	%a2			| vm == VM_MAP_NULL?
-	jeq	Lcpu_switch_badsw	| panic
+	jeq	.Lcpu_switch_badsw	| panic
 #endif
 	pea	(%a0)			| save newlwp
 #if !defined(_SUN3X_) || defined(PMAP_DEBUG)



CVS commit: src/sys/arch/m68k/m68k

2015-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  7 18:54:57 UTC 2015

Modified Files:
src/sys/arch/m68k/m68k: linux_syscall.c m68k_syscall.c sunos_syscall.c

Log Message:
adjust to new trace_{enter,exit} signatures.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/m68k/m68k/linux_syscall.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/m68k/m68k/m68k_syscall.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/m68k/m68k/sunos_syscall.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/m68k/m68k/linux_syscall.c
diff -u src/sys/arch/m68k/m68k/linux_syscall.c:1.23 src/sys/arch/m68k/m68k/linux_syscall.c:1.24
--- src/sys/arch/m68k/m68k/linux_syscall.c:1.23	Mon Mar 24 16:06:32 2014
+++ src/sys/arch/m68k/m68k/linux_syscall.c	Sat Mar  7 13:54:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_syscall.c,v 1.23 2014/03/24 20:06:32 christos Exp $	*/
+/*	$NetBSD: linux_syscall.c,v 1.24 2015/03/07 18:54:57 christos Exp $	*/
 
 /*-
  * Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux_syscall.c,v 1.23 2014/03/24 20:06:32 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux_syscall.c,v 1.24 2015/03/07 18:54:57 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_execfmt.h
@@ -216,7 +216,7 @@ linux_syscall_fancy(register_t code, str
 		break;
 	}
 
-	if ((error = trace_enter(code, args, callp-sy_narg)) != 0)
+	if ((error = trace_enter(code, callp, args)) != 0)
 		goto out;
 
 	rval[0] = 0;
@@ -252,5 +252,5 @@ out:
 		break;
 	}
 
-	trace_exit(code, rval, error);
+	trace_exit(code, callp, args, rval, error);
 }

Index: src/sys/arch/m68k/m68k/m68k_syscall.c
diff -u src/sys/arch/m68k/m68k/m68k_syscall.c:1.49 src/sys/arch/m68k/m68k/m68k_syscall.c:1.50
--- src/sys/arch/m68k/m68k/m68k_syscall.c:1.49	Fri Oct 25 16:45:35 2013
+++ src/sys/arch/m68k/m68k/m68k_syscall.c	Sat Mar  7 13:54:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: m68k_syscall.c,v 1.49 2013/10/25 20:45:35 martin Exp $	*/
+/*	$NetBSD: m68k_syscall.c,v 1.50 2015/03/07 18:54:57 christos Exp $	*/
 
 /*-
  * Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: m68k_syscall.c,v 1.49 2013/10/25 20:45:35 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: m68k_syscall.c,v 1.50 2015/03/07 18:54:57 christos Exp $);
 
 #include opt_execfmt.h
 #include opt_compat_netbsd.h
@@ -335,7 +335,7 @@ syscall_fancy(register_t code, struct lw
 			goto bad;
 	}
 
-	if ((error = trace_enter(code, args, callp-sy_narg)) != 0)
+	if ((error = trace_enter(code, callp, args)) != 0)
 		goto out;
 
 	rval[0] = 0;
@@ -387,7 +387,7 @@ out:
 		break;
 	}
 
-	trace_exit(code, rval, error);
+	trace_exit(code, callp, args, rval, error);
 }
 
 void

Index: src/sys/arch/m68k/m68k/sunos_syscall.c
diff -u src/sys/arch/m68k/m68k/sunos_syscall.c:1.22 src/sys/arch/m68k/m68k/sunos_syscall.c:1.23
--- src/sys/arch/m68k/m68k/sunos_syscall.c:1.22	Tue Feb  8 15:20:16 2011
+++ src/sys/arch/m68k/m68k/sunos_syscall.c	Sat Mar  7 13:54:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sunos_syscall.c,v 1.22 2011/02/08 20:20:16 rmind Exp $	*/
+/*	$NetBSD: sunos_syscall.c,v 1.23 2015/03/07 18:54:57 christos Exp $	*/
 
 /*-
  * Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: sunos_syscall.c,v 1.22 2011/02/08 20:20:16 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: sunos_syscall.c,v 1.23 2015/03/07 18:54:57 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_execfmt.h
@@ -273,7 +273,7 @@ sunos_syscall_fancy(register_t code, str
 			goto bad;
 	}
 
-	if ((error = trace_enter(code, args, callp-sy_narg)) != 0)
+	if ((error = trace_enter(code, callp, args)) != 0)
 		goto out;
 
 	rval[0] = 0;
@@ -315,5 +315,5 @@ out:
 			frame-f_regs[SP] -= sizeof (int);
 	}
 
-	trace_exit(code, rval, error);
+	trace_exit(code, callp, args, rval, error);
 }



CVS commit: src/sys/arch/m68k/m68k

2014-09-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Sep 21 16:32:51 UTC 2014

Modified Files:
src/sys/arch/m68k/m68k: db_disasm.c

Log Message:
fix cut-n-paste


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/m68k/m68k/db_disasm.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/m68k/m68k/db_disasm.c
diff -u src/sys/arch/m68k/m68k/db_disasm.c:1.40 src/sys/arch/m68k/m68k/db_disasm.c:1.41
--- src/sys/arch/m68k/m68k/db_disasm.c:1.40	Sat Oct 19 15:13:51 2013
+++ src/sys/arch/m68k/m68k/db_disasm.c	Sun Sep 21 12:32:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.40 2013/10/19 19:13:51 martin Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.41 2014/09/21 16:32:51 christos Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -63,7 +63,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_disasm.c,v 1.40 2013/10/19 19:13:51 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_disasm.c,v 1.41 2014/09/21 16:32:51 christos Exp $);
 
 #include sys/param.h
 #ifdef _KERNEL
@@ -1189,7 +1189,7 @@ opcode_1000(dis_buffer_t *dbuf, u_short 
 		addstr(dbuf, @-,);
 		PRINT_AREG(dbuf,BITFIELD(opc,11,9));
 		addstr(dbuf, @-);
-	} else if (IS_INST(SBCDA,opc)) {
+	} else if (IS_INST(SBCDD,opc)) {
 		addstr(dbuf, sbcd\t);
 		PRINT_DREG(dbuf,BITFIELD(opc,2,0));
 		addchar(',');
@@ -1247,7 +1247,7 @@ opcode_1100(dis_buffer_t *dbuf, u_short 
 		addstr(dbuf, @-,);
 		PRINT_AREG(dbuf,BITFIELD(opc,11,9));
 		addstr(dbuf, @-);
-	} else if (IS_INST(ABCDA,opc)) {
+	} else if (IS_INST(ABCDD,opc)) {
 		addstr(dbuf, abcd\t);
 		PRINT_DREG(dbuf,BITFIELD(opc,2,0));
 		addchar(',');



CVS commit: src/sys/arch/m68k/m68k

2014-03-29 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Sat Mar 29 11:34:13 UTC 2014

Modified Files:
src/sys/arch/m68k/m68k: procfs_machdep.c

Log Message:
procfs_getcpuinfstr's len argument contains the buffer size on entry,
and the number of bytes used on return.  Use the actual buffer size in a
snprintf call, instead of sizeof(*buf), which is always 1.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/m68k/procfs_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/m68k/m68k/procfs_machdep.c
diff -u src/sys/arch/m68k/m68k/procfs_machdep.c:1.5 src/sys/arch/m68k/m68k/procfs_machdep.c:1.6
--- src/sys/arch/m68k/m68k/procfs_machdep.c:1.5	Sat Jul 22 06:58:17 2006
+++ src/sys/arch/m68k/m68k/procfs_machdep.c	Sat Mar 29 11:34:13 2014
@@ -1,7 +1,7 @@
-/*	$NetBSD: procfs_machdep.c,v 1.5 2006/07/22 06:58:17 tsutsui Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.6 2014/03/29 11:34:13 apb Exp $ */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: procfs_machdep.c,v 1.5 2006/07/22 06:58:17 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: procfs_machdep.c,v 1.6 2014/03/29 11:34:13 apb Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -19,8 +19,7 @@ int
 procfs_getcpuinfstr(char *buf, int *len)
 {
 	const char *cpu, *mmu, *fpu;
-
-	*len = 0;
+	int maxlen = *len;
 
 	switch (cputype) {
 	case CPU_68020:
@@ -79,7 +78,7 @@ procfs_getcpuinfstr(char *buf, int *len)
 		break;
 	}
 
-	*len = snprintf(buf, sizeof(buf),
+	*len = snprintf(buf, maxlen,
 	/* as seen in Linux 2.4.27 */
 	CPU:\t\t%s\n
 	MMU:\t\t%s\n



CVS commit: src/sys/arch/m68k/m68k

2014-03-15 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Mar 15 09:22:37 UTC 2014

Added Files:
src/sys/arch/m68k/m68k: busaddrerr.s

Log Message:
Add a common source of m68k bus error and address error handlers.

This will be included from each MD locore.s as other common m68k
asm files like trap_subr.s and support.s etc.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/m68k/m68k/busaddrerr.s

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

Added files:

Index: src/sys/arch/m68k/m68k/busaddrerr.s
diff -u /dev/null src/sys/arch/m68k/m68k/busaddrerr.s:1.1
--- /dev/null	Sat Mar 15 09:22:37 2014
+++ src/sys/arch/m68k/m68k/busaddrerr.s	Sat Mar 15 09:22:36 2014
@@ -0,0 +1,272 @@
+/*	$NetBSD: busaddrerr.s,v 1.1 2014/03/15 09:22:36 tsutsui Exp $	*/
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1980, 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * from: Utah $Hdr: locore.s 1.66 92/12/22$
+ *
+ *	@(#)locore.s	8.6 (Berkeley) 5/27/94
+ */
+
+/*
+ * bus error and address error handler routines common to all m68k ports.
+ */
+
+/*
+ * NOTICE: This is not a standalone file.  To use it, #include it in
+ * your port's locore.s, like so:
+ *
+ *	#include m68k/m68k/busaddrerr.s
+ */
+
+/* assume M68K_MMU_MOTOROLA is default if none is defined */
+#if !defined(M68K_MMU_MOTOROLA)  !defined(M68K_MMU_HP)
+#define M68K_MMU_MOTOROLA
+#endif
+
+/*
+ * address error handler for 68040/68060
+ */
+#if defined(M68040) || defined(M68060)
+ENTRY_NOPROFILE(addrerr4060)
+	clrl	%sp@-			| stack adjust count
+	moveml	%d0-%d7/%a0-%a7,%sp@-	| save user registers
+	movl	%usp,%a0		| save the user SP
+	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
+
+/*
+ * bus error handler for 68060
+ */
+#if defined(M68060)
+ENTRY_NOPROFILE(buserr60)
+	clrl	%sp@-			| stack adjust count
+	moveml	%d0-%d7/%a0-%a7,%sp@-	| save user registers
+	movl	%usp,%a0		| save the user SP
+	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
+#if defined(amiga) || defined(atari)
+	addql	#1,L60bpe
+#endif
+	andl	#0x7ffd,%d1		| check other faults
+	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
+	| XXX instr. case not done yet
+	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
+#ifdef mac68k
+	movl	%a2,_C_LABEL(mac68k_a2_fromfault) | save %a2
+	movl	%sp@(FR_HW+8+8),_C_LABEL(m68k_fault_addr) 

CVS commit: src/sys/arch/m68k/m68k

2013-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov  7 01:49:46 UTC 2013

Modified Files:
src/sys/arch/m68k/m68k: db_trace.c

Log Message:
add ifdefs for kernel only variable


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/m68k/m68k/db_trace.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/m68k/m68k/db_trace.c
diff -u src/sys/arch/m68k/m68k/db_trace.c:1.57 src/sys/arch/m68k/m68k/db_trace.c:1.58
--- src/sys/arch/m68k/m68k/db_trace.c:1.57	Tue Jan 31 16:17:57 2012
+++ src/sys/arch/m68k/m68k/db_trace.c	Wed Nov  6 20:49:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.57 2012/01/31 21:17:57 mlelstv Exp $	*/
+/*	$NetBSD: db_trace.c,v 1.58 2013/11/07 01:49:46 christos Exp $	*/
 
 /* 
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_trace.c,v 1.57 2012/01/31 21:17:57 mlelstv Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_trace.c,v 1.58 2013/11/07 01:49:46 christos Exp $);
 
 #include sys/param.h
 #include sys/proc.h
@@ -393,7 +393,9 @@ db_stack_trace_print(db_expr_t addr, boo
 	const char *	name;
 	struct stackpos pos;
 	struct pcb	*pcb;
+#ifdef _KERNEL
 	bool		kernel_only = true;
+#endif
 	bool		trace_thread = false;
 	bool		lwpaddr = false;
 	int		fault_pc = 0;
@@ -408,8 +410,10 @@ db_stack_trace_print(db_expr_t addr, boo
 trace_thread = true;
 			} else if (c == 't')
 trace_thread = true;
+#ifdef _KERNEL
 			else if (c == 'u')
 kernel_only = false;
+#endif
 	}
 
 	if (!have_addr)



CVS commit: src/sys/arch/m68k/m68k

2013-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 25 20:45:35 UTC 2013

Modified Files:
src/sys/arch/m68k/m68k: m68k_syscall.c

Log Message:
Mark a diagnostic-only variable


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/m68k/m68k/m68k_syscall.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/m68k/m68k/m68k_syscall.c
diff -u src/sys/arch/m68k/m68k/m68k_syscall.c:1.48 src/sys/arch/m68k/m68k/m68k_syscall.c:1.49
--- src/sys/arch/m68k/m68k/m68k_syscall.c:1.48	Sun Feb 19 21:06:14 2012
+++ src/sys/arch/m68k/m68k/m68k_syscall.c	Fri Oct 25 20:45:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: m68k_syscall.c,v 1.48 2012/02/19 21:06:14 rmind Exp $	*/
+/*	$NetBSD: m68k_syscall.c,v 1.49 2013/10/25 20:45:35 martin Exp $	*/
 
 /*-
  * Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: m68k_syscall.c,v 1.48 2012/02/19 21:06:14 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: m68k_syscall.c,v 1.49 2013/10/25 20:45:35 martin Exp $);
 
 #include opt_execfmt.h
 #include opt_compat_netbsd.h
@@ -414,7 +414,7 @@ startlwp(void *arg)
 	ucontext_t *uc = arg;
 	lwp_t *l = curlwp;
 	struct frame *f = (struct frame *)l-l_md.md_regs;
-	int error;
+	int error __diagused;
 
 	f-f_regs[D0] = 0;
 	f-f_sr = ~PSL_C;



CVS commit: src/sys/arch/m68k/m68k

2013-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 25 20:51:14 UTC 2013

Modified Files:
src/sys/arch/m68k/m68k: pmap_motorola.c

Log Message:
Mark a potentialy unused variable


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/m68k/m68k/pmap_motorola.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/m68k/m68k/pmap_motorola.c
diff -u src/sys/arch/m68k/m68k/pmap_motorola.c:1.66 src/sys/arch/m68k/m68k/pmap_motorola.c:1.67
--- src/sys/arch/m68k/m68k/pmap_motorola.c:1.66	Mon Jul  9 19:23:45 2012
+++ src/sys/arch/m68k/m68k/pmap_motorola.c	Fri Oct 25 20:51:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_motorola.c,v 1.66 2012/07/09 19:23:45 rkujawa Exp $*/
+/*	$NetBSD: pmap_motorola.c,v 1.67 2013/10/25 20:51:14 martin Exp $*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -119,7 +119,7 @@
 #include opt_m68k_arch.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap_motorola.c,v 1.66 2012/07/09 19:23:45 rkujawa Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap_motorola.c,v 1.67 2013/10/25 20:51:14 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -939,7 +939,7 @@ pmap_protect(pmap_t pmap, vaddr_t sva, v
 {
 	vaddr_t nssva;
 	pt_entry_t *pte;
-	bool firstpage, needtflush;
+	bool firstpage __unused, needtflush;
 	int isro;
 
 	PMAP_DPRINTF(PDB_FOLLOW|PDB_PROTECT,



CVS commit: src/sys/arch/m68k/m68k

2013-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 25 20:53:02 UTC 2013

Modified Files:
src/sys/arch/m68k/m68k: vm_machdep.c

Log Message:
Mark a potentially unused variable


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/m68k/m68k/vm_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/m68k/m68k/vm_machdep.c
diff -u src/sys/arch/m68k/m68k/vm_machdep.c:1.38 src/sys/arch/m68k/m68k/vm_machdep.c:1.39
--- src/sys/arch/m68k/m68k/vm_machdep.c:1.38	Sun Feb 19 21:06:15 2012
+++ src/sys/arch/m68k/m68k/vm_machdep.c	Fri Oct 25 20:53:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.38 2012/02/19 21:06:15 rmind Exp $	*/
+/*	$NetBSD: vm_machdep.c,v 1.39 2013/10/25 20:53:02 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vm_machdep.c,v 1.38 2012/02/19 21:06:15 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: vm_machdep.c,v 1.39 2013/10/25 20:53:02 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -149,7 +149,7 @@ cpu_lwp_free2(struct lwp *l)
 int
 vmapbuf(struct buf *bp, vsize_t len)
 {
-	struct pmap *upmap, *kpmap;
+	struct pmap *upmap, *kpmap __unused;
 	vaddr_t uva;		/* User VA (map from) */
 	vaddr_t kva;		/* Kernel VA (new to) */
 	paddr_t pa; 		/* physical address */



CVS commit: src/sys/arch/m68k/m68k

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

Modified Files:
src/sys/arch/m68k/m68k: bus_dma.c

Log Message:
Mark a variable that is only tested in DIAGNOSTIC kernels as potentially
unused.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/m68k/m68k/bus_dma.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/m68k/m68k/bus_dma.c
diff -u src/sys/arch/m68k/m68k/bus_dma.c:1.33 src/sys/arch/m68k/m68k/bus_dma.c:1.34
--- src/sys/arch/m68k/m68k/bus_dma.c:1.33	Wed Jul 11 17:13:30 2012
+++ src/sys/arch/m68k/m68k/bus_dma.c	Sat Oct 19 19:03:30 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.33 2012/07/11 17:13:30 rkujawa Exp $ */
+/* $NetBSD: bus_dma.c,v 1.34 2013/10/19 19:03:30 martin Exp $ */
 
 /*
  * This file was taken from from alpha/common/bus_dma.c
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h			/* RCS ID  Copyright macro defns */
 
-__KERNEL_RCSID(0, $NetBSD: bus_dma.c,v 1.33 2012/07/11 17:13:30 rkujawa Exp $);
+__KERNEL_RCSID(0, $NetBSD: bus_dma.c,v 1.34 2013/10/19 19:03:30 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -138,7 +138,7 @@ _bus_dmamap_load_buffer_direct_common(bu
 	vaddr_t vaddr = (vaddr_t)buf;
 	int seg, cacheable, coherent;
 	pmap_t pmap;
-	bool rv;
+	bool rv __unused;
 
 	coherent = BUS_DMA_COHERENT;
 	lastaddr = *lastaddrp;



CVS commit: src/sys/arch/m68k/m68k

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

Modified Files:
src/sys/arch/m68k/m68k: db_disasm.c

Log Message:
Remove unused variable


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/m68k/m68k/db_disasm.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/m68k/m68k/db_disasm.c
diff -u src/sys/arch/m68k/m68k/db_disasm.c:1.39 src/sys/arch/m68k/m68k/db_disasm.c:1.40
--- src/sys/arch/m68k/m68k/db_disasm.c:1.39	Tue Jan 31 21:17:57 2012
+++ src/sys/arch/m68k/m68k/db_disasm.c	Sat Oct 19 19:13:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.39 2012/01/31 21:17:57 mlelstv Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.40 2013/10/19 19:13:51 martin Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -63,7 +63,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_disasm.c,v 1.39 2012/01/31 21:17:57 mlelstv Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_disasm.c,v 1.40 2013/10/19 19:13:51 martin Exp $);
 
 #include sys/param.h
 #ifdef _KERNEL
@@ -849,7 +849,7 @@ opcode_0101(dis_buffer_t *dbuf, u_short 
 static void
 opcode_branch(dis_buffer_t *dbuf, u_short opc)
 {
-	int disp, sz;
+	int disp;
 
 	if (IS_INST(BRA,opc))
 		addstr(dbuf, bra);
@@ -863,20 +863,17 @@ opcode_branch(dis_buffer_t *dbuf, u_shor
 		/* 16-bit signed displacement */
 		disp = *(dbuf-val + 1);
 		dbuf-used++;
-		sz = SIZE_WORD;
 		addchar('w');
 	} else if (disp == 0xff) {
 		/* 32-bit signed displacement */
 		disp = *(long *)(dbuf-val + 1);
 		dbuf-used += 2;
-		sz = SIZE_LONG;
 		addchar('l');
 	} else {
 		/* 8-bit signed displacement in opcode. */
 		/* Needs to be sign-extended... */
 		if (ISBITSET(disp,7))
 			disp -= 256;
-		sz = SIZE_BYTE;
 		addchar('b');
 	}
 	addchar('\t');



CVS commit: src/sys/arch/m68k/m68k

2013-10-14 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Mon Oct 14 12:20:05 UTC 2013

Modified Files:
src/sys/arch/m68k/m68k: switch_subr.s

Log Message:
Check whether we have an FPU regardless of FPU_EMULATE option.
It prevents a kernel panic when we don't have an FPU and FPU_EMULATE
option is not set.
Thanks tsutsui@ for advice.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/m68k/m68k/switch_subr.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/m68k/m68k/switch_subr.s
diff -u src/sys/arch/m68k/m68k/switch_subr.s:1.31 src/sys/arch/m68k/m68k/switch_subr.s:1.32
--- src/sys/arch/m68k/m68k/switch_subr.s:1.31	Sat Sep  7 19:06:29 2013
+++ src/sys/arch/m68k/m68k/switch_subr.s	Mon Oct 14 12:20:05 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: switch_subr.s,v 1.31 2013/09/07 19:06:29 chs Exp $	*/
+/*	$NetBSD: switch_subr.s,v 1.32 2013/10/14 12:20:05 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation.
@@ -109,10 +109,9 @@ ENTRY(cpu_switchto)
 	jbsr	_ASM_LABEL(m68k_fpuctx_save)
 #else
 #ifdef FPCOPROC
-#ifdef FPU_EMULATE
 	tstl	_C_LABEL(fputype)	| Do we have an FPU?
 	jeq	.Lcpu_switch_nofpsave	| No  Then don't attempt save.
-#endif
+
 	lea	PCB_FPCTX(%a1),%a2	| pointer to FP save area
 	fsave	(%a2)			| save FP state
 #if defined(M68020) || defined(M68030) || defined(M68040)
@@ -222,10 +221,9 @@ ENTRY(cpu_switchto)
 	moveml	(%sp)+,%d0/%d1
 #else
 #ifdef FPCOPROC
-#ifdef FPU_EMULATE
 	tstl	_C_LABEL(fputype)	| Do we have an FPU?
 	jeq	.Lcpu_switch_nofprest	| No  Then don't attempt restore.
-#endif
+
 	lea	PCB_FPCTX(%a1),%a0	| pointer to FP save area
 #if defined(M68020) || defined(M68030) || defined(M68040)
 #if defined(M68060)
@@ -279,10 +277,9 @@ ENTRY(savectx)
 	jbsr	_ASM_LABEL(m68k_fpuctx_save)
 #else
 #ifdef FPCOPROC
-#ifdef FPU_EMULATE
 	tstl	_C_LABEL(fputype)	| Do we have FPU?
 	jeq	.Lsavectx_nofpsave	| No?  Then don't save state.
-#endif
+
 	lea	PCB_FPCTX(%a1),%a0	| pointer to FP save area
 	fsave	(%a0)			| save FP state
 #if defined(M68020) || defined(M68030) || defined(M68040)



CVS commit: src/sys/arch/m68k/m68k

2013-08-01 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Aug  1 13:42:52 UTC 2013

Modified Files:
src/sys/arch/m68k/m68k: compat_13_sigreturn13.s compat_16_sigreturn14.s
copypage.s lock_stubs.s reenter_syscall.s sigcode.s sunos_sigcode.s
support.s svr4_sigcode.s switch_subr.s trap_subr.s w16copy.s

Log Message:
Convert to motorola style.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/m68k/compat_13_sigreturn13.s \
src/sys/arch/m68k/m68k/sunos_sigcode.s
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/m68k/m68k/compat_16_sigreturn14.s
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/m68k/m68k/copypage.s \
src/sys/arch/m68k/m68k/sigcode.s src/sys/arch/m68k/m68k/trap_subr.s
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/m68k/lock_stubs.s
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/m68k/m68k/reenter_syscall.s \
src/sys/arch/m68k/m68k/w16copy.s
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/m68k/support.s \
src/sys/arch/m68k/m68k/svr4_sigcode.s
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/m68k/m68k/switch_subr.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/m68k/m68k/compat_13_sigreturn13.s
diff -u src/sys/arch/m68k/m68k/compat_13_sigreturn13.s:1.5 src/sys/arch/m68k/m68k/compat_13_sigreturn13.s:1.6
--- src/sys/arch/m68k/m68k/compat_13_sigreturn13.s:1.5	Tue Feb  8 20:20:16 2011
+++ src/sys/arch/m68k/m68k/compat_13_sigreturn13.s	Thu Aug  1 13:42:52 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_13_sigreturn13.s,v 1.5 2011/02/08 20:20:16 rmind Exp $	*/
+/*	$NetBSD: compat_13_sigreturn13.s,v 1.6 2013/08/01 13:42:52 matt Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -48,33 +48,33 @@
  * (possibly much larger) original stack frame.
  */
 ENTRY_NOPROFILE(m68k_compat_13_sigreturn13_stub)
-	lea	%sp@(-84),%sp		| leave enough space for largest frame
-	movl	%sp@(84),%sp@		| move up current 8 byte frame
-	movl	%sp@(88),%sp@(4)
-	movl	#84,%sp@-		| default: adjust by 84 bytes
-	moveml	#0x,%sp@-		| save user registers
+	lea	-84(%sp),%sp		| leave enough space for largest frame
+	movl	84(%sp),(%sp)		| move up current 8 byte frame
+	movl	88(%sp),4(%sp)
+	movl	#84,-(%sp)		| default: adjust by 84 bytes
+	moveml	#0x,-(%sp)		| save user registers
 	movl	%usp,%a0		| save the user SP
-	movl	%a0,%sp@(FR_SP)		|   in the savearea
-	movl	#SYS_compat_13_sigreturn13,%sp@-	| push syscall number
+	movl	%a0,FR_SP(%sp)		|   in the savearea
+	movl	#SYS_compat_13_sigreturn13,-(%sp)	| push syscall number
 	jbsr	_C_LABEL(syscall)	| handle it
 	addql	#4,%sp			| pop syscall#
-	movl	%sp@(FR_SP),%a0		| grab and restore
+	movl	FR_SP(%sp),%a0		| grab and restore
 	movl	%a0,%usp		|   user SP
-	lea	%sp@(FR_HW),%a1		| pointer to HW frame
-	movw	%sp@(FR_ADJ),%d0	| do we need to adjust the stack?
+	lea	FR_HW(%sp),%a1		| pointer to HW frame
+	movw	FR_ADJ(%sp),%d0	| do we need to adjust the stack?
 	jeq	Lc13sigr1		| no, just continue
 	moveq	#92,%d1			| total size
 	subw	%d0,%d1			|  - hole size = frame size
-	lea	%a1@(92),%a0		| destination
+	lea	92(%a1),%a0		| destination
 	addw	%d1,%a1			| source
 	lsrw	#1,%d1			| convert to word count
 	subqw	#1,%d1			| minus 1 for dbf
 Lc13sigrlp:
-	movw	%a1@-,%a0@-		| copy a word
+	movw	-(%a1),-(%a0)		| copy a word
 	dbf	%d1,Lc13sigrlp		| continue
 	movl	%a0,%a1			| new HW frame base
 Lc13sigr1:
-	movl	%a1,%sp@(FR_SP)		| new SP value
-	moveml	%sp@+,#0x7FFF		| restore user registers
-	movl	%sp@,%sp		| and our SP
+	movl	%a1,FR_SP(%sp)		| new SP value
+	moveml	(%sp)+,#0x7FFF		| restore user registers
+	movl	(%sp),%sp		| and our SP
 	jra	_ASM_LABEL(rei)		| all done
Index: src/sys/arch/m68k/m68k/sunos_sigcode.s
diff -u src/sys/arch/m68k/m68k/sunos_sigcode.s:1.5 src/sys/arch/m68k/m68k/sunos_sigcode.s:1.6
--- src/sys/arch/m68k/m68k/sunos_sigcode.s:1.5	Tue Feb  8 20:20:16 2011
+++ src/sys/arch/m68k/m68k/sunos_sigcode.s	Thu Aug  1 13:42:52 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sunos_sigcode.s,v 1.5 2011/02/08 20:20:16 rmind Exp $	*/
+/*	$NetBSD: sunos_sigcode.s,v 1.6 2013/08/01 13:42:52 matt Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -51,11 +51,11 @@
  	.data
  	.align	2
 GLOBAL(sunos_sigcode)
-	movl	%sp@(12),%a0	| signal handler addr	(4 bytes)
-	jsr	%a0@		| call signal handler	(2 bytes)
+	movl	12(%sp),%a0	| signal handler addr	(4 bytes)
+	jsr	(%a0)		| call signal handler	(2 bytes)
 	addql	#4,%sp		| pop signal number	(2 bytes)
 	trap	#1		| special syscall entry	(2 bytes)
-	movl	%d0,%sp@(4)	| save errno		(4 bytes)
+	movl	%d0,4(%sp)	| save errno		(4 bytes)
 	moveq	#1,%d0		| syscall == exit	(2 bytes)
 	trap	#0		| exit(errno)		(2 bytes)
 	.align	2

Index: src/sys/arch/m68k/m68k/compat_16_sigreturn14.s
diff -u src/sys/arch/m68k/m68k/compat_16_sigreturn14.s:1.3 src/sys/arch/m68k/m68k/compat_16_sigreturn14.s:1.4
--- src/sys/arch/m68k/m68k/compat_16_sigreturn14.s:1.3	Tue Feb  8 20:20:16 2011
+++ src/sys/arch/m68k/m68k/compat_16_sigreturn14.s	Thu Aug  1 

CVS commit: src/sys/arch/m68k/m68k

2013-07-22 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Jul 22 17:52:21 UTC 2013

Modified Files:
src/sys/arch/m68k/m68k: copy.s

Log Message:
Move to motorola syntax
Change all branches to use j.. instead of b.. (branches now use byte offsets)
(this causes it to go from 932 to 848 bytes of text)
Add GETCURPCB macro.
(binary identical before the b - j changes)


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/m68k/m68k/copy.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/m68k/m68k/copy.s
diff -u src/sys/arch/m68k/m68k/copy.s:1.43 src/sys/arch/m68k/m68k/copy.s:1.44
--- src/sys/arch/m68k/m68k/copy.s:1.43	Wed Jul  7 01:16:25 2010
+++ src/sys/arch/m68k/m68k/copy.s	Mon Jul 22 17:52:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: copy.s,v 1.43 2010/07/07 01:16:25 chs Exp $	*/
+/*	$NetBSD: copy.s,v 1.44 2013/07/22 17:52:21 matt Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -80,6 +80,12 @@
 	.file	copy.s
 	.text
 
+#ifdef CI_CURPCB
+#define	GETCURPCB(r)	movl	_C_LABEL(cpu_info_store)+CI_CURPCB,r
+#else
+#define	GETCURPCB(r)	movl	_C_LABEL(curpcb),r
+#endif
+
 #ifdef	DIAGNOSTIC
 /*
  * The following routines all use the moves instruction to access
@@ -93,7 +99,7 @@
  */
 Lbadfc:
 	PANIC(copy.s: bad sfc or dfc)
-	bra	Lbadfc
+	jra	Lbadfc
 #define	CHECK_SFC	movec %sfc,%d0; subql #FC_USERD,%d0; bne Lbadfc
 #define	CHECK_DFC	movec %dfc,%d0; subql #FC_USERD,%d0; bne Lbadfc
 #else	/* DIAGNOSTIC */
@@ -114,57 +120,57 @@ Lbadfc:
  */
 ENTRY(copyin)
 	CHECK_SFC
-	movl	%sp@(12),%d0		| check count
-	beq	Lciret			| == 0, don't do anything
+	movl	12(%sp),%d0		| check count
+	jeq	Lciret			| == 0, don't do anything
 #ifdef MAPPEDCOPY
 	cmpl	_C_LABEL(mappedcopysize),%d0 | size = mappedcopysize
-	bcc	_C_LABEL(mappedcopyin)	| yes, go do it the new way
+	jcc	_C_LABEL(mappedcopyin)	| yes, go do it the new way
 #endif
-	movl	%d2,%sp@-		| save scratch register
-	movl	_C_LABEL(curpcb),%a0	| set fault handler
-	movl	#Lcifault,%a0@(PCB_ONFAULT)
-	movl	%sp@(8),%a0		| src address
-	movl	%sp@(12),%a1		| dest address
+	movl	%d2,-(%sp)		| save scratch register
+	GETCURPCB(%a0)			| set fault handler
+	movl	#Lcifault,PCB_ONFAULT(%a0)
+	movl	8(%sp),%a0		| src address
+	movl	12(%sp),%a1		| dest address
 	movl	%a0,%d1
 	btst	#0,%d1			| src address odd?
-	beq	Lcieven			| no, skip alignment
-	movsb	%a0@+,%d2		| yes, copy a byte
-	movb	%d2,%a1@+
+	jeq	Lcieven			| no, skip alignment
+	movsb	(%a0)+,%d2		| yes, copy a byte
+	movb	%d2,(%a1)+
 	subql	#1,%d0			| adjust count
-	beq	Lcidone			| count 0, all done
+	jeq	Lcidone			| count 0, all done
 Lcieven:
 	movl	%a1,%d1
 	btst	#0,%d1			| dest address odd?
-	bne	Lcibytes		| yes, must copy bytes
+	jne	Lcibytes		| yes, must copy bytes
 	movl	%d0,%d1			| OK, both even.  Get count
 	lsrl	#2,%d1			|   and convert to longwords
-	beq	Lcibytes		| count 0, skip longword loop
+	jeq	Lcibytes		| count 0, skip longword loop
 	subql	#1,%d1			| predecrement for dbf
 Lcilloop:
-	movsl	%a0@+,%d2		| copy a longword
-	movl	%d2,%a1@+
+	movsl	(%a0)+,%d2		| copy a longword
+	movl	%d2,(%a1)+
 	dbf	%d1,Lcilloop		| decrement low word of count
 	subil	#0x1,%d1		| decrement high word of count
-	bcc	Lcilloop
+	jcc	Lcilloop
 	andl	#3,%d0			| what remains
-	beq	Lcidone			| nothing, all done
+	jeq	Lcidone			| nothing, all done
 Lcibytes:
 	subql	#1,%d0			| predecrement for dbf
 Lcibloop:
-	movsb	%a0@+,%d2		| copy a byte
-	movb	%d2,%a1@+
+	movsb	(%a0)+,%d2		| copy a byte
+	movb	%d2,(%a1)+
 	dbf	%d0,Lcibloop		| decrement low word of count
 	subil	#0x1,%d0		| decrement high word of count
-	bcc	Lcibloop
+	jcc	Lcibloop
 	clrl	%d0			| no error
 Lcidone:
-	movl	_C_LABEL(curpcb),%a0	| clear fault handler
-	clrl	%a0@(PCB_ONFAULT)
-	movl	%sp@+,%d2		| restore scratch register
+	GETCURPCB(%a0)			| clear fault handler
+	clrl	PCB_ONFAULT(%a0)
+	movl	(%sp)+,%d2		| restore scratch register
 Lciret:
 	rts
 Lcifault:
-	bra	Lcidone
+	jra	Lcidone
 
 /*
  * copyout(void *from, void *to, size_t len);
@@ -179,57 +185,57 @@ Lcifault:
  */
 ENTRY(copyout)
 	CHECK_DFC
-	movl	%sp@(12),%d0		| check count
-	beq	Lcoret			| == 0, don't do anything
+	movl	12(%sp),%d0		| check count
+	jeq	Lcoret			| == 0, don't do anything
 #ifdef MAPPEDCOPY
 	cmpl	_C_LABEL(mappedcopysize),%d0 | size = mappedcopysize
-	bcc	_C_LABEL(mappedcopyout)	| yes, go do it the new way
+	jcc	_C_LABEL(mappedcopyout)	| yes, go do it the new way
 #endif
-	movl	%d2,%sp@-		| save scratch register
-	movl	_C_LABEL(curpcb),%a0	| set fault handler
-	movl	#Lcofault,%a0@(PCB_ONFAULT)
-	movl	%sp@(8),%a0		| src address
-	movl	%sp@(12),%a1		| dest address
+	movl	%d2,-(%sp)		| save scratch register
+	GETCURPCB(%a0)			| set fault handler
+	movl	#Lcofault,PCB_ONFAULT(%a0)
+	movl	8(%sp),%a0		| src address
+	movl	12(%sp),%a1		| dest address
 	movl	%a0,%d1
 	btst	#0,%d1			| src address odd?
-	beq	Lcoeven			| no, skip alignment
-	movb	%a0@+,%d2		| yes, copy a 

CVS commit: src/sys/arch/m68k/m68k

2013-07-21 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Jul 22 03:30:38 UTC 2013

Modified Files:
src/sys/arch/m68k/m68k: oc_cksum.s

Log Message:
Use motorola syntax
Adjust for coldfire
(no binary difference for non-coldfire


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/m68k/m68k/oc_cksum.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/m68k/m68k/oc_cksum.s
diff -u src/sys/arch/m68k/m68k/oc_cksum.s:1.6 src/sys/arch/m68k/m68k/oc_cksum.s:1.7
--- src/sys/arch/m68k/m68k/oc_cksum.s:1.6	Fri Dec 23 05:06:19 2011
+++ src/sys/arch/m68k/m68k/oc_cksum.s	Mon Jul 22 03:30:38 2013
@@ -1,4 +1,4 @@
-|	$NetBSD: oc_cksum.s,v 1.6 2011/12/23 05:06:19 tsutsui Exp $
+|	$NetBSD: oc_cksum.s,v 1.7 2013/07/22 03:30:38 matt Exp $
 
 | Copyright (c) 1988 Regents of the University of California.
 | All rights reserved.
@@ -91,10 +91,10 @@
 	.text
 
 ENTRY(oc_cksum)
-	movl	%sp@(4),%a0	| get buffer ptr
-	movl	%sp@(8),%d1	| get byte count
-	movl	%sp@(12),%d0	| get starting value
-	movl	%d2,%sp@-	| free a reg
+	movl	4(%sp),%a0	| get buffer ptr
+	movl	8(%sp),%d1	| get byte count
+	movl	12(%sp),%d0	| get starting value
+	movl	%d2,-(%sp)	| free a reg
 
 	| test for possible 1, 2 or 3 bytes of excess at end
 	| of buffer.  The usual case is no excess (the usual
@@ -108,56 +108,85 @@ ENTRY(oc_cksum)
 	btst	#1,%d1
 	jne	L7		| if two bytes excess
 L1:
-	movl	%d1,%d2
+#ifdef __mcoldfire__
+	movq	#-4,%d2		| mask to clear bottom two bits
+	andl	%d2,%d1		| longword truncate length
+	movl	%d1,%d2		| move length to d2
+	movl	%d1,%a1		| move length to a1
+	addl	%a0,%a1		| add start so a1 now points to end
+	movq	#0x3c,%d1	| then find fractions of a chunk
+	andl	%d1,%d2
+	negl	%d2
+	subl	%d1,%d1		| this can never carry so X is cleared
+#else
+	movl	%d1,%d2		| move to d2
 	lsrl	#6,%d1		| make cnt into # of 64 byte chunks
 	andl	#0x3c,%d2	| then find fractions of a chunk
 	negl	%d2
 	andb	#0xf,%cc	| clear X
-	jmp	%pc@(L3-.-2:b,%d2)
+#endif
+	jmp	(L3-.-2:b,%pc,%d2)
 L2:
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
-	movl	%a0@+,%d2
+	movl	(%a0)+,%d2
 	addxl	%d2,%d0
 L3:
+#ifdef __mcoldfire__
+	cmpal	%a0,%a1		| cmpa doesn't affect X
+	bne	L2		| loop until reached
+#else
 	dbra	%d1,L2		| (NB- dbra doesn't affect X)
+#endif
 
 	movl	%d0,%d1		| fold 32 bit sum to 16 bits
 	swap	%d1		| (NB- swap doesn't affect X)
+#ifdef __mcoldfire__
+	mvzw	%d1,%d1		| zero extend %d1 (doesn't affect X)
+	mvzw	%d0,%d0		| zero extend %d0 (doesn't affect X)
+	addxl	%d1,%d0		| 
+	jcc	L4
+	addql	#1,%d0
+#else
 	addxw	%d1,%d0
 	jcc	L4
 	addw	#1,%d0
+#endif
 L4:
+#ifdef __mcoldfire__
+	mvzw	%d0,%d0
+#else
 	andl	#0x,%d0
-	movl	%sp@+,%d2
+#endif
+	movl	(%sp)+,%d2
 	rts
 
 L5:	| deal with 1 or 3 excess bytes at the end of the buffer.
@@ -166,18 +195,18 @@ L5:	| deal with 1 or 3 excess bytes at t
 
 	| 3 bytes excess
 	clrl	%d2
-	movw	%a0@(-3,%d1:l),%d2	| add in last full word then drop
+	movw	(-3,%a0,%d1:l),%d2	| add in last full word then drop
 	addl	%d2,%d0		|  through to pick up last byte
 
 L6:	| 1 byte excess
 	clrl	%d2
-	movb	%a0@(-1,%d1:l),%d2
+	movb	(-1,%a0,%d1:l),%d2
 	lsll	#8,%d2
 	addl	%d2,%d0
 	jra	L1
 
 L7:	| 2 bytes excess
 	clrl	%d2
-	movw	%a0@(-2,%d1:l),%d2
+	movw	(-2,%a0,%d1:l),%d2
 	addl	%d2,%d0
 	jra	L1



CVS commit: src/sys/arch/m68k/m68k

2013-07-21 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Mon Jul 22 03:37:17 UTC 2013

Modified Files:
src/sys/arch/m68k/m68k: oc_cksum.s

Log Message:
use mvz[wb] when possible


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/m68k/oc_cksum.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/m68k/m68k/oc_cksum.s
diff -u src/sys/arch/m68k/m68k/oc_cksum.s:1.7 src/sys/arch/m68k/m68k/oc_cksum.s:1.8
--- src/sys/arch/m68k/m68k/oc_cksum.s:1.7	Mon Jul 22 03:30:38 2013
+++ src/sys/arch/m68k/m68k/oc_cksum.s	Mon Jul 22 03:37:17 2013
@@ -1,4 +1,4 @@
-|	$NetBSD: oc_cksum.s,v 1.7 2013/07/22 03:30:38 matt Exp $
+|	$NetBSD: oc_cksum.s,v 1.8 2013/07/22 03:37:17 matt Exp $
 
 | Copyright (c) 1988 Regents of the University of California.
 | All rights reserved.
@@ -194,19 +194,31 @@ L5:	| deal with 1 or 3 excess bytes at t
 	jeq	L6		| if 1 excess
 
 	| 3 bytes excess
+#ifdef __mcoldfire__
+	mvzw	(-3,%a0,%d1:l),%d2	| add in last full word then drop
+#else
 	clrl	%d2
 	movw	(-3,%a0,%d1:l),%d2	| add in last full word then drop
+#endif
 	addl	%d2,%d0		|  through to pick up last byte
 
 L6:	| 1 byte excess
+#ifdef __mcoldfire__
+	mvzb	(-1,%a0,%d1:l),%d2
+#else
 	clrl	%d2
 	movb	(-1,%a0,%d1:l),%d2
+#endif
 	lsll	#8,%d2
 	addl	%d2,%d0
 	jra	L1
 
 L7:	| 2 bytes excess
+#ifdef __mcoldfire__
+	mvzw	(-2,%a0,%d1:l),%d2
+#else
 	clrl	%d2
 	movw	(-2,%a0,%d1:l),%d2
+#endif
 	addl	%d2,%d0
 	jra	L1



CVS commit: src/sys/arch/m68k/m68k

2011-12-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Dec 22 15:47:15 UTC 2011

Modified Files:
src/sys/arch/m68k/m68k: compat_16_machdep.c sig_machdep.c
svr4_machdep.c

Log Message:
Remove fuction declarations of m68881_restore() and m68881_save().
They are in m68k/m68k.h.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/m68k/compat_16_machdep.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/m68k/m68k/sig_machdep.c
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/m68k/m68k/svr4_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/m68k/m68k/compat_16_machdep.c
diff -u src/sys/arch/m68k/m68k/compat_16_machdep.c:1.15 src/sys/arch/m68k/m68k/compat_16_machdep.c:1.16
--- src/sys/arch/m68k/m68k/compat_16_machdep.c:1.15	Tue Feb  8 20:20:16 2011
+++ src/sys/arch/m68k/m68k/compat_16_machdep.c	Thu Dec 22 15:47:15 2011
@@ -1,4 +1,4 @@
-/*$NetBSD: compat_16_machdep.c,v 1.15 2011/02/08 20:20:16 rmind Exp $   */
+/*$NetBSD: compat_16_machdep.c,v 1.16 2011/12/22 15:47:15 tsutsui Exp $   */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -38,7 +38,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: compat_16_machdep.c,v 1.15 2011/02/08 20:20:16 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: compat_16_machdep.c,v 1.16 2011/12/22 15:47:15 tsutsui Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_compat_netbsd.h
@@ -68,8 +68,6 @@ __KERNEL_RCSID(0, $NetBSD: compat_16_ma
 #include machine/frame.h
 
 extern  short exframesize[];
-void	m68881_save(struct fpframe *);
-void	m68881_restore(struct fpframe *);
 
 #ifdef DEBUG
 extern int sigdebug;

Index: src/sys/arch/m68k/m68k/sig_machdep.c
diff -u src/sys/arch/m68k/m68k/sig_machdep.c:1.46 src/sys/arch/m68k/m68k/sig_machdep.c:1.47
--- src/sys/arch/m68k/m68k/sig_machdep.c:1.46	Thu Feb 24 04:28:46 2011
+++ src/sys/arch/m68k/m68k/sig_machdep.c	Thu Dec 22 15:47:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sig_machdep.c,v 1.46 2011/02/24 04:28:46 joerg Exp $	*/
+/*	$NetBSD: sig_machdep.c,v 1.47 2011/12/22 15:47:15 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -40,7 +40,7 @@
 #include opt_m68k_arch.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: sig_machdep.c,v 1.46 2011/02/24 04:28:46 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: sig_machdep.c,v 1.47 2011/12/22 15:47:15 tsutsui Exp $);
 
 #define __M68K_SIGNAL_PRIVATE
 
@@ -69,8 +69,6 @@ __KERNEL_RCSID(0, $NetBSD: sig_machdep.
 
 extern short exframesize[];
 struct fpframe m68k_cached_fpu_idle_frame;
-void	m68881_save(struct fpframe *);
-void	m68881_restore(struct fpframe *);
 
 #ifdef DEBUG
 int sigdebug = 0;

Index: src/sys/arch/m68k/m68k/svr4_machdep.c
diff -u src/sys/arch/m68k/m68k/svr4_machdep.c:1.32 src/sys/arch/m68k/m68k/svr4_machdep.c:1.33
--- src/sys/arch/m68k/m68k/svr4_machdep.c:1.32	Thu Dec 10 14:13:50 2009
+++ src/sys/arch/m68k/m68k/svr4_machdep.c	Thu Dec 22 15:47:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: svr4_machdep.c,v 1.32 2009/12/10 14:13:50 matt Exp $	*/
+/*	$NetBSD: svr4_machdep.c,v 1.33 2011/12/22 15:47:15 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: svr4_machdep.c,v 1.32 2009/12/10 14:13:50 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: svr4_machdep.c,v 1.33 2011/12/22 15:47:15 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -60,8 +60,6 @@ __KERNEL_RCSID(0, $NetBSD: svr4_machdep
 #include machine/vmparam.h
 
 extern short exframesize[];
-extern void	m68881_restore(struct fpframe *);
-extern void	m68881_save(struct fpframe *);
 static void	svr4_getsiginfo(union svr4_siginfo *, int, unsigned long,
 		void *);
 



CVS commit: src/sys/arch/m68k/m68k

2011-11-03 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Nov  3 14:39:05 UTC 2011

Modified Files:
src/sys/arch/m68k/m68k: pmap_motorola.c

Log Message:
Use pool_allocator_meta rather than pool_allocator_nointr to allocate
struct pv_entry pool in the previous fix for PR port-m68k/45519.
Per comment from yamt@ on source-changes-d@:
http://mail-index.NetBSD.org/source-changes-d/2011/10/31/msg004211.html


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/m68k/m68k/pmap_motorola.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/m68k/m68k/pmap_motorola.c
diff -u src/sys/arch/m68k/m68k/pmap_motorola.c:1.63 src/sys/arch/m68k/m68k/pmap_motorola.c:1.64
--- src/sys/arch/m68k/m68k/pmap_motorola.c:1.63	Sat Oct 29 18:26:19 2011
+++ src/sys/arch/m68k/m68k/pmap_motorola.c	Thu Nov  3 14:39:05 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_motorola.c,v 1.63 2011/10/29 18:26:19 tsutsui Exp $*/
+/*	$NetBSD: pmap_motorola.c,v 1.64 2011/11/03 14:39:05 tsutsui Exp $*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -119,7 +119,7 @@
 #include opt_m68k_arch.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap_motorola.c,v 1.63 2011/10/29 18:26:19 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap_motorola.c,v 1.64 2011/11/03 14:39:05 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -547,7 +547,7 @@ pmap_init(void)
 	 * Initialize the pv_entry pools.
 	 */
 	pool_init(pmap_pv_pool, sizeof(struct pv_entry), 0, 0, 0, pvpl,
-	pool_allocator_nointr, IPL_NONE);
+	pool_allocator_meta, IPL_NONE);
 
 	/*
 	 * Now that this is done, mark the pages shared with the



CVS commit: src/sys/arch/m68k/m68k

2010-10-15 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Oct 15 10:20:10 UTC 2010

Modified Files:
src/sys/arch/m68k/m68k: m68k_syscall.c

Log Message:
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/m68k/m68k/m68k_syscall.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/m68k/m68k/m68k_syscall.c
diff -u src/sys/arch/m68k/m68k/m68k_syscall.c:1.42 src/sys/arch/m68k/m68k/m68k_syscall.c:1.43
--- src/sys/arch/m68k/m68k/m68k_syscall.c:1.42	Thu Oct 14 16:34:29 2010
+++ src/sys/arch/m68k/m68k/m68k_syscall.c	Fri Oct 15 10:20:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: m68k_syscall.c,v 1.42 2010/10/14 16:34:29 tsutsui Exp $	*/
+/*	$NetBSD: m68k_syscall.c,v 1.43 2010/10/15 10:20:09 tsutsui Exp $	*/
 
 /*-
  * Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -110,7 +110,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: m68k_syscall.c,v 1.42 2010/10/14 16:34:29 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: m68k_syscall.c,v 1.43 2010/10/15 10:20:09 tsutsui Exp $);
 
 #include opt_execfmt.h
 #include opt_compat_netbsd.h
@@ -290,7 +290,7 @@
 		 * value there. However, -current binaries post 4.0
 		 * but pre-5.0 might still require this copy, so we
 		 * select this behaviour based on COMPAT_50 as we have
-		 * no equivvalent for the exact in-between version.
+		 * no equivalent for the exact in-between version.
 		 */
 #ifdef COMPAT_AOUT_M68K
 		{



CVS commit: src/sys/arch/m68k/m68k

2010-10-15 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Oct 15 10:40:53 UTC 2010

Modified Files:
src/sys/arch/m68k/m68k: m68k_syscall.c

Log Message:
Get rid of more #ifdef COMPAT_AOUT_M68K dependent part.
Now compat_aoutm68k can be a module.

XXX: linux/svr4 ELF binaries also require a syscall return value in %a0?


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/m68k/m68k/m68k_syscall.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/m68k/m68k/m68k_syscall.c
diff -u src/sys/arch/m68k/m68k/m68k_syscall.c:1.43 src/sys/arch/m68k/m68k/m68k_syscall.c:1.44
--- src/sys/arch/m68k/m68k/m68k_syscall.c:1.43	Fri Oct 15 10:20:09 2010
+++ src/sys/arch/m68k/m68k/m68k_syscall.c	Fri Oct 15 10:40:52 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: m68k_syscall.c,v 1.43 2010/10/15 10:20:09 tsutsui Exp $	*/
+/*	$NetBSD: m68k_syscall.c,v 1.44 2010/10/15 10:40:52 tsutsui Exp $	*/
 
 /*-
  * Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -110,7 +110,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: m68k_syscall.c,v 1.43 2010/10/15 10:20:09 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: m68k_syscall.c,v 1.44 2010/10/15 10:40:52 tsutsui Exp $);
 
 #include opt_execfmt.h
 #include opt_compat_netbsd.h
@@ -292,20 +292,13 @@
 		 * select this behaviour based on COMPAT_50 as we have
 		 * no equivalent for the exact in-between version.
 		 */
-#ifdef COMPAT_AOUT_M68K
-		{
-			extern struct emul emul_netbsd_aoutm68k;
-
-			/*
-			 * Some pre-m68k ELF libc assembler stubs assume
-			 * %a0 is preserved across system calls...
-			 */
-			if (p-p_emul != emul_netbsd_aoutm68k)
-frame-f_regs[A0] = rval[0];
-		}
-#else
-		frame-f_regs[A0] = rval[0];
-#endif
+
+		/*
+		 * Some pre-m68k ELF libc assembler stubs assume
+		 * %a0 is preserved across system calls...
+		 */
+		if (p-p_emul == emul_netbsd)
+			frame-f_regs[A0] = rval[0];
 #endif
 		break;
 	case ERESTART:
@@ -416,20 +409,13 @@
 		frame-f_sr = ~PSL_C;	/* carry bit */
 #ifdef COMPAT_50
 		/* see syscall_plain for a comment explaining this */
-#ifdef COMPAT_AOUT_M68K
-		{
-			extern struct emul emul_netbsd_aoutm68k;
-
-			/*
-			 * Some pre-m68k ELF libc assembler stubs assume
-			 * %a0 is preserved across system calls...
-			 */
-			if (p-p_emul != emul_netbsd_aoutm68k)
-frame-f_regs[A0] = rval[0];
-		}
-#else
-		frame-f_regs[A0] = rval[0];
-#endif
+
+		/*
+		 * Some pre-m68k ELF libc assembler stubs assume
+		 * %a0 is preserved across system calls...
+		 */
+		if (p-p_emul == emul_netbsd)
+			frame-f_regs[A0] = rval[0];
 #endif
 		break;
 	case ERESTART:



CVS commit: src/sys/arch/m68k/m68k

2010-10-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Oct 14 16:33:50 UTC 2010

Modified Files:
src/sys/arch/m68k/m68k: kobj_machdep.c

Log Message:
Fix reloc calcurations (mechanically pulled from working i386 and sh3).
Now options MODULAR works at least on news68k:

# uname -mrs
NetBSD 5.99.39 news68k
# modstat|grep filesys
coredump misc   filesys2 2790 -
exec_aoutmisc   filesys0 1866 coredump
exec_elf32   misc   filesys0 6072 coredump
exec_script  misc   filesys0 972  -
kernfs   vfsfilesys0 9734 -
mfs  vfsfilesys0 3656 ffs
procfs   vfsfilesys0 23924-
#


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/m68k/m68k/kobj_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/m68k/m68k/kobj_machdep.c
diff -u src/sys/arch/m68k/m68k/kobj_machdep.c:1.2 src/sys/arch/m68k/m68k/kobj_machdep.c:1.3
--- src/sys/arch/m68k/m68k/kobj_machdep.c:1.2	Mon Apr 28 20:23:27 2008
+++ src/sys/arch/m68k/m68k/kobj_machdep.c	Thu Oct 14 16:33:50 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: kobj_machdep.c,v 1.2 2008/04/28 20:23:27 martin Exp $	*/
+/*	$NetBSD: kobj_machdep.c,v 1.3 2010/10/14 16:33:50 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kobj_machdep.c,v 1.2 2008/04/28 20:23:27 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: kobj_machdep.c,v 1.3 2010/10/14 16:33:50 tsutsui Exp $);
 
 #define	ELFSIZE		ARCH_ELFSIZE
 
@@ -64,8 +64,7 @@
 		addr = kobj_sym_lookup(ko, symnum);
 		if (addr == 0)
 			return -1;
-		tmp = (Elf_Addr)(relocbase + addr +
-		rela-r_addend) - (Elf_Addr)where;
+		tmp = (Elf_Addr)(addr + rela-r_addend) - (Elf_Addr)where;
 		if (*where != tmp)
 			*where = tmp;
 		break;
@@ -75,14 +74,12 @@
 		addr = kobj_sym_lookup(ko, symnum);
 		if (addr == 0)
 			return -1;
-		tmp = (Elf_Addr)(relocbase + addr +
-		rela-r_addend);
-		if (*where != tmp)
-			*where = tmp;
+		tmp = (Elf_Addr)(addr + *where + rela-r_addend);
+		*where = tmp;
 		break;
 
 	case R_TYPE(RELATIVE):
-		*where += (Elf_Addr)relocbase;
+		*where += (Elf_Addr)(relocbase + rela-r_addend);
 		break;
 
 	default:



CVS commit: src/sys/arch/m68k/m68k

2010-10-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Oct 14 16:34:29 UTC 2010

Modified Files:
src/sys/arch/m68k/m68k: m68k_syscall.c

Log Message:
Un-ifdef COMPAT_AOUT_M68K for MODULAR kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/m68k/m68k/m68k_syscall.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/m68k/m68k/m68k_syscall.c
diff -u src/sys/arch/m68k/m68k/m68k_syscall.c:1.41 src/sys/arch/m68k/m68k/m68k_syscall.c:1.42
--- src/sys/arch/m68k/m68k/m68k_syscall.c:1.41	Mon Apr 26 15:07:01 2010
+++ src/sys/arch/m68k/m68k/m68k_syscall.c	Thu Oct 14 16:34:29 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: m68k_syscall.c,v 1.41 2010/04/26 15:07:01 tsutsui Exp $	*/
+/*	$NetBSD: m68k_syscall.c,v 1.42 2010/10/14 16:34:29 tsutsui Exp $	*/
 
 /*-
  * Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -110,7 +110,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: m68k_syscall.c,v 1.41 2010/04/26 15:07:01 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: m68k_syscall.c,v 1.42 2010/10/14 16:34:29 tsutsui Exp $);
 
 #include opt_execfmt.h
 #include opt_compat_netbsd.h
@@ -144,9 +144,7 @@
 
 void syscall(register_t, struct frame);
 
-#ifdef COMPAT_AOUT_M68K
 void	aoutm68k_syscall_intern(struct proc *);
-#endif
 static void syscall_plain(register_t, struct lwp *, struct frame *);
 static void syscall_fancy(register_t, struct lwp *, struct frame *);
 
@@ -192,7 +190,6 @@
 		p-p_md.md_syscall = syscall_plain;
 }
 
-#ifdef COMPAT_AOUT_M68K
 /*
  * Not worth the effort of a whole new set of syscall_{plain,fancy} functions
  */
@@ -205,7 +202,6 @@
 	else
 		p-p_md.md_syscall = syscall_plain;
 }
-#endif
 
 static void
 syscall_plain(register_t code, struct lwp *l, struct frame *frame)



CVS commit: src/sys/arch/m68k/m68k

2009-12-19 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Dec 19 12:31:35 UTC 2009

Modified Files:
src/sys/arch/m68k/m68k: vm_machdep.c

Log Message:
Remove extern struct pcb *curpcb declaration. Now it's in m68k/pcb.h.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/m68k/m68k/vm_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/m68k/m68k/vm_machdep.c
diff -u src/sys/arch/m68k/m68k/vm_machdep.c:1.31 src/sys/arch/m68k/m68k/vm_machdep.c:1.32
--- src/sys/arch/m68k/m68k/vm_machdep.c:1.31	Sun Nov 29 04:15:43 2009
+++ src/sys/arch/m68k/m68k/vm_machdep.c	Sat Dec 19 12:31:34 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.31 2009/11/29 04:15:43 rmind Exp $	*/
+/*	$NetBSD: vm_machdep.c,v 1.32 2009/12/19 12:31:34 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vm_machdep.c,v 1.31 2009/11/29 04:15:43 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: vm_machdep.c,v 1.32 2009/12/19 12:31:34 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -127,7 +127,6 @@
 	struct pcb *pcb1, *pcb2;
 	struct trapframe *tf;
 	struct switchframe *sf;
-	extern struct pcb *curpcb;
 	extern void lwp_trampoline(void);
 
 	pcb1 = lwp_getpcb(l1);



CVS commit: src/sys/arch/m68k/m68k

2009-11-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Nov 11 11:25:53 UTC 2009

Modified Files:
src/sys/arch/m68k/m68k: lock_stubs.s

Log Message:
Remove unnecessary and incorrect STRONG_ALIAS.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/m68k/lock_stubs.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/m68k/m68k/lock_stubs.s
diff -u src/sys/arch/m68k/m68k/lock_stubs.s:1.7 src/sys/arch/m68k/m68k/lock_stubs.s:1.8
--- src/sys/arch/m68k/m68k/lock_stubs.s:1.7	Sun May 25 15:56:12 2008
+++ src/sys/arch/m68k/m68k/lock_stubs.s	Wed Nov 11 11:25:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.s,v 1.7 2008/05/25 15:56:12 chs Exp $	*/
+/*	$NetBSD: lock_stubs.s,v 1.8 2009/11/11 11:25:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -69,7 +69,6 @@
 STRONG_ALIAS(atomic_cas_ulong,_atomic_cas_32)
 STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
 STRONG_ALIAS(atomic_cas_32,_atomic_cas_32)
-STRONG_ALIAS(_atomic_cas_32,_atomic_cas_32)
 
 STRONG_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
 STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)



CVS commit: src/sys/arch/m68k/m68k

2009-10-11 Thread Michael L. Hitch
Module Name:src
Committed By:   mhitch
Date:   Sun Oct 11 20:37:47 UTC 2009

Modified Files:
src/sys/arch/m68k/m68k: pmap_motorola.c

Log Message:
Fix DEBUG build - pv_flags does not exist anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/m68k/m68k/pmap_motorola.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/m68k/m68k/pmap_motorola.c
diff -u src/sys/arch/m68k/m68k/pmap_motorola.c:1.46 src/sys/arch/m68k/m68k/pmap_motorola.c:1.47
--- src/sys/arch/m68k/m68k/pmap_motorola.c:1.46	Wed Aug 26 00:30:02 2009
+++ src/sys/arch/m68k/m68k/pmap_motorola.c	Sun Oct 11 20:37:47 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_motorola.c,v 1.46 2009/08/26 00:30:02 thorpej Exp $*/
+/*	$NetBSD: pmap_motorola.c,v 1.47 2009/10/11 20:37:47 mhitch Exp $*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -117,7 +117,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap_motorola.c,v 1.46 2009/08/26 00:30:02 thorpej Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap_motorola.c,v 1.47 2009/10/11 20:37:47 mhitch Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -2885,9 +2885,8 @@
 	printf(pa %lx, pa);
 	pvh = pa_to_pvh(pa);
 	for (pv = pvh-pvh_first; pv; pv = pv-pv_next)
-		printf( - pmap %p, va %lx, ptste %p, ptpmap %p, flags %x,
-		pv-pv_pmap, pv-pv_va, pv-pv_ptste, pv-pv_ptpmap,
-		pv-pv_flags);
+		printf( - pmap %p, va %lx, ptste %p, ptpmap %p,
+		pv-pv_pmap, pv-pv_va, pv-pv_ptste, pv-pv_ptpmap);
 	printf(\n);
 }