Module Name:    src
Committed By:   tsutsui
Date:           Fri Dec 11 13:52:58 UTC 2009

Modified Files:
        src/sys/arch/sun3/include: param3.h param3x.h pmap3.h pmap3x.h
        src/sys/arch/sun3/sun3: dvma.c pmap.c

Log Message:
Refactoring MD segment related definitions on m68k ports:
- move macro SEGSHIFT, NBSG, and SEGOFFSET from <machine/param.h>
  to <machine/pmap.h> where they should belong
- don't use m68k_round_seg() and m68k_trunc_seg() in sun3 pmap sources
  and instead define and use sun3_round_seg() and sun3_trunc_seg()
  since they are quite pmap implementation dependent


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/sun3/include/param3.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sun3/include/param3x.h
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/sun3/include/pmap3.h
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/sun3/include/pmap3x.h
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/sun3/sun3/dvma.c
cvs rdiff -u -r1.163 -r1.164 src/sys/arch/sun3/sun3/pmap.c

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

Modified files:

Index: src/sys/arch/sun3/include/param3.h
diff -u src/sys/arch/sun3/include/param3.h:1.51 src/sys/arch/sun3/include/param3.h:1.52
--- src/sys/arch/sun3/include/param3.h:1.51	Sun Dec 11 12:19:21 2005
+++ src/sys/arch/sun3/include/param3.h	Fri Dec 11 13:52:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param3.h,v 1.51 2005/12/11 12:19:21 christos Exp $	*/
+/*	$NetBSD: param3.h,v 1.52 2009/12/11 13:52:57 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -82,9 +82,5 @@
 #define	KERNTEXTOFF	0x0E004000	/* start of kernel text */
 #define	KERN_END	0x0FE00000	/* end of kernel virtual */
 
-#define SEGSHIFT	17	        /* LOG2(NBSG) */
-#define NBSG		(1 << SEGSHIFT)	/* bytes/segment */
-#define	SEGOFSET	(NBSG-1)	/* byte offset into segment */
-
 #define	MAXBSIZE	0x8000		/* max FS block size */
 #define	MAXPHYS		0xe000

Index: src/sys/arch/sun3/include/param3x.h
diff -u src/sys/arch/sun3/include/param3x.h:1.14 src/sys/arch/sun3/include/param3x.h:1.15
--- src/sys/arch/sun3/include/param3x.h:1.14	Sun Dec 11 12:19:21 2005
+++ src/sys/arch/sun3/include/param3x.h	Fri Dec 11 13:52:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param3x.h,v 1.14 2005/12/11 12:19:21 christos Exp $	*/
+/*	$NetBSD: param3x.h,v 1.15 2009/12/11 13:52:57 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -82,9 +82,5 @@
 #define	KERNTEXTOFF	0xF8004000	/* start of kernel text */
 #define	KERN_END	0xFE000000	/* end of kernel virtual */
 
-#define SEGSHIFT	19	        /* LOG2(NBSG) */
-#define NBSG		(1 << SEGSHIFT)	/* bytes/segment */
-#define	SEGOFSET	(NBSG-1)	/* byte offset into segment */
-
 #define	MAXBSIZE	0x8000		/* max FS block size */
 

Index: src/sys/arch/sun3/include/pmap3.h
diff -u src/sys/arch/sun3/include/pmap3.h:1.45 src/sys/arch/sun3/include/pmap3.h:1.46
--- src/sys/arch/sun3/include/pmap3.h:1.45	Tue Dec  9 20:45:45 2008
+++ src/sys/arch/sun3/include/pmap3.h	Fri Dec 11 13:52:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap3.h,v 1.45 2008/12/09 20:45:45 pooka Exp $	*/
+/*	$NetBSD: pmap3.h,v 1.46 2009/12/11 13:52:57 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -95,4 +95,13 @@
 #define	PMAP_NC		0x10	/* tells pmap_enter to set PG_NC */
 #define	PMAP_SPEC	0x1C	/* mask to get all above. */
 
+/* MMU specific segment size */
+#define	SEGSHIFT	17	        /* LOG2(NBSG) */
+#define	NBSG		(1 << SEGSHIFT)	/* bytes/segment */
+#define	SEGOFSET	(NBSG - 1)	/* byte offset into segment */
+
+#define	sun3_round_seg(x)	((((vaddr_t)(x)) + SEGOFSET) & ~SEGOFSET)
+#define	sun3_trunc_seg(x)	((vaddr_t)(x) & ~SEGOFSET)
+#define	sun3_seg_offset(x)	((vaddr_t)(x) & SEGOFSET)
+
 #endif	/* _KERNEL */

Index: src/sys/arch/sun3/include/pmap3x.h
diff -u src/sys/arch/sun3/include/pmap3x.h:1.26 src/sys/arch/sun3/include/pmap3x.h:1.27
--- src/sys/arch/sun3/include/pmap3x.h:1.26	Tue Dec  9 20:45:45 2008
+++ src/sys/arch/sun3/include/pmap3x.h	Fri Dec 11 13:52:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap3x.h,v 1.26 2008/12/09 20:45:45 pooka Exp $	*/
+/*	$NetBSD: pmap3x.h,v 1.27 2009/12/11 13:52:57 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -80,4 +80,13 @@
 #define	PMAP_NC		0x40	/* tells pmap_enter to set PTE_CI */
 #define	PMAP_SPEC	0xFF	/* mask to get all above. */
 
+/* MMU specific segment size */
+#define	SEGSHIFT	19	        /* LOG2(NBSG) */
+#define	NBSG		(1 << SEGSHIFT)	/* bytes/segment */
+#define	SEGOFSET	(NBSG - 1)	/* byte offset into segment */
+
+#define	sun3x_round_seg(x)	((((vaddr_t)(x)) + SEGOFSET) & ~SEGOFSET)
+#define	sun3x_trunc_seg(x)	((vaddr_t)(x) & ~SEGOFSET)
+#define	sun3x_seg_offset(x)	((vaddr_t)(x) & SEGOFSET)
+ 
 #endif	/* _KERNEL */

Index: src/sys/arch/sun3/sun3/dvma.c
diff -u src/sys/arch/sun3/sun3/dvma.c:1.35 src/sys/arch/sun3/sun3/dvma.c:1.36
--- src/sys/arch/sun3/sun3/dvma.c:1.35	Sat Nov 21 04:16:52 2009
+++ src/sys/arch/sun3/sun3/dvma.c	Fri Dec 11 13:52:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: dvma.c,v 1.35 2009/11/21 04:16:52 rmind Exp $	*/
+/*	$NetBSD: dvma.c,v 1.36 2009/12/11 13:52:57 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dvma.c,v 1.35 2009/11/21 04:16:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dvma.c,v 1.36 2009/12/11 13:52:57 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -183,7 +183,7 @@
 	seg_len = (vsize_t)len;
 	seg_off = seg_kva & SEGOFSET;
 	seg_kva -= seg_off;
-	seg_len = m68k_round_seg(seg_len + seg_off);
+	seg_len = sun3_round_seg(seg_len + seg_off);
 
 	s = splvm();
 
@@ -245,7 +245,7 @@
 	seg_len = (vsize_t)len;
 	seg_off = seg_dma & SEGOFSET;
 	seg_dma -= seg_off;
-	seg_len = m68k_round_seg(seg_len + seg_off);
+	seg_len = sun3_round_seg(seg_len + seg_off);
 
 	s = splvm();
 

Index: src/sys/arch/sun3/sun3/pmap.c
diff -u src/sys/arch/sun3/sun3/pmap.c:1.163 src/sys/arch/sun3/sun3/pmap.c:1.164
--- src/sys/arch/sun3/sun3/pmap.c:1.163	Sat Nov 21 04:16:53 2009
+++ src/sys/arch/sun3/sun3/pmap.c	Fri Dec 11 13:52:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.163 2009/11/21 04:16:53 rmind Exp $	*/
+/*	$NetBSD: pmap.c,v 1.164 2009/12/11 13:52:57 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.163 2009/11/21 04:16:53 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.164 2009/12/11 13:52:57 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_pmap_debug.h"
@@ -1516,7 +1516,7 @@
 	 * Determine the range of kernel virtual space available.
 	 * It is segment-aligned to simplify PMEG management.
 	 */
-	virtual_avail = m68k_round_seg(nextva);
+	virtual_avail = sun3_round_seg(nextva);
 	virtual_end = VM_MAX_KERNEL_ADDRESS;
 
 	/*
@@ -2056,7 +2056,7 @@
 		new_pte |= PG_NC;
 	}
 
-	segva = m68k_trunc_seg(pgva);
+	segva = sun3_trunc_seg(pgva);
 	do_pv = true;
 
 	/* Do we have a PMEG? */
@@ -2199,7 +2199,7 @@
 		return;
 	}
 
-	segva = m68k_trunc_seg(pgva);
+	segva = sun3_trunc_seg(pgva);
 	do_pv = true;
 
 	/*
@@ -2388,7 +2388,7 @@
 		new_pte |= PG_NC;
 	}
 
-	segva = m68k_trunc_seg(va);
+	segva = sun3_trunc_seg(va);
 
 	s = splvm();
 
@@ -2456,7 +2456,7 @@
 	s = splvm();
 	segnum = VA_SEGNUM(va);
 	for (eva = va + len; va < eva; va = neva, segnum++) {
-		neva = m68k_trunc_seg(va) + NBSG;
+		neva = sun3_trunc_seg(va) + NBSG;
 		if (neva > eva) {
 			neva = eva;
 		}
@@ -2464,7 +2464,7 @@
 			continue;
 		}
 
-		segva = m68k_trunc_seg(va);
+		segva = sun3_trunc_seg(va);
 		sme = get_segmap(segva);
 		pmegp = pmeg_p(sme);
 
@@ -2612,7 +2612,7 @@
 	if (pmap->pm_segmap[VA_SEGNUM(pgva)] == SEGINV)
 		return (0);
 
-	segva = m68k_trunc_seg(pgva);
+	segva = sun3_trunc_seg(pgva);
 	chkpte = PG_VALID;
 	if (ftype & VM_PROT_WRITE)
 		chkpte |= PG_WRITE;
@@ -2983,7 +2983,7 @@
 	va = sva;
 	segnum = VA_SEGNUM(va);
 	while (va < eva) {
-		neva = m68k_trunc_seg(va) + NBSG;
+		neva = sun3_trunc_seg(va) + NBSG;
 		if (neva > eva)
 			neva = eva;
 		if (pmap->pm_segmap[segnum] != SEGINV)
@@ -3007,7 +3007,7 @@
 	s = splvm();
 
 #ifdef	DIAGNOSTIC
-	if (m68k_trunc_seg(sva) != m68k_trunc_seg(eva-1))
+	if (sun3_trunc_seg(sva) != sun3_trunc_seg(eva-1))
 		panic("pmap_protect1: bad range!");
 #endif
 
@@ -3069,7 +3069,7 @@
 	}
 #endif
 
-	segva = m68k_trunc_seg(sva);
+	segva = sun3_trunc_seg(sva);
 	sme = get_segmap(segva);
 
 #ifdef	DIAGNOSTIC
@@ -3150,7 +3150,7 @@
 		panic("pmap_protect_noctx: null segmap");
 #endif
 
-	segva = m68k_trunc_seg(sva);
+	segva = sun3_trunc_seg(sva);
 	segnum = VA_SEGNUM(segva);
 	sme = pmap->pm_segmap[segnum];
 	if (sme == SEGINV)
@@ -3211,7 +3211,7 @@
 	va = sva;
 	segnum = VA_SEGNUM(va);
 	while (va < eva) {
-		neva = m68k_trunc_seg(va) + NBSG;
+		neva = sun3_trunc_seg(va) + NBSG;
 		if (neva > eva)
 			neva = eva;
 		if (pmap->pm_segmap[segnum] != SEGINV)
@@ -3233,7 +3233,7 @@
 	s = splvm();
 
 #ifdef	DIAGNOSTIC
-	if (m68k_trunc_seg(sva) != m68k_trunc_seg(eva-1))
+	if (sun3_trunc_seg(sva) != sun3_trunc_seg(eva-1))
 		panic("pmap_remove1: bad range!");
 #endif
 
@@ -3296,7 +3296,7 @@
 	}
 #endif
 
-	segva = m68k_trunc_seg(sva);
+	segva = sun3_trunc_seg(sva);
 	sme = get_segmap(segva);
 
 #ifdef	DIAGNOSTIC
@@ -3425,7 +3425,7 @@
 		panic("pmap_remove_noctx: null segmap");
 #endif
 
-	segva = m68k_trunc_seg(sva);
+	segva = sun3_trunc_seg(sva);
 	segnum = VA_SEGNUM(segva);
 	sme = pmap->pm_segmap[segnum];
 	if (sme == SEGINV)

Reply via email to