Module Name:    src
Committed By:   tsutsui
Date:           Fri Dec 11 17:53:23 UTC 2009

Modified Files:
        src/sys/arch/amiga/include: param.h
        src/sys/arch/atari/include: param.h
        src/sys/arch/cesfic/include: param.h
        src/sys/arch/hp300/include: param.h
        src/sys/arch/luna68k/include: param.h
        src/sys/arch/m68k/include: param.h pmap_motorola.h
        src/sys/arch/mac68k/include: param.h
        src/sys/arch/mvme68k/include: param.h
        src/sys/arch/news68k/include: param.h
        src/sys/arch/next68k/include: param.h
        src/sys/arch/x68k/include: param.h

Log Message:
Refactoring MD segment related definitions on m68k ports:
- move macro SEGSHIFT, NBSEG, and SEGOFSET from <machine/param.h>
  to <m68k/pmap_motorola.h> where they should belong
- also simplify NBSEG macro for both 020/030 and 040/060 cases
- also move m68k_trunc_seg(), m68k_round_seg(), and m68k_seg_offset()
  (that use SEGOFSET) from <m68k/param.h> to <m68k/pmap_motorola.h>
- add comments about each segment size value used on pmap_motorola
  implementation
- add TIA_SIZE, TIA_SHIFT, TIB_SIZE, and TIB_SHIFT macro which can be
  used for ste/pte index sizes
- use proper vaddr_t cast instead of unsigned for SEGOFSET/PGOFSET macro

Tested on atari, hp300, and news68k.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/amiga/include/param.h
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/atari/include/param.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/cesfic/include/param.h
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/hp300/include/param.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/luna68k/include/param.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/include/param.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/m68k/include/pmap_motorola.h
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/mac68k/include/param.h
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/mvme68k/include/param.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/news68k/include/param.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/next68k/include/param.h
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/x68k/include/param.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/amiga/include/param.h
diff -u src/sys/arch/amiga/include/param.h:1.46 src/sys/arch/amiga/include/param.h:1.47
--- src/sys/arch/amiga/include/param.h:1.46	Wed Dec  9 12:21:58 2009
+++ src/sys/arch/amiga/include/param.h	Fri Dec 11 17:53:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.46 2009/12/09 12:21:58 tsutsui Exp $	*/
+/*	$NetBSD: param.h,v 1.47 2009/12/11 17:53:22 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -88,13 +88,6 @@
 #define	PGSHIFT		13		/* LOG2(NBPG) */
 #define	KERNBASE	0x00000000	/* start of kernel virtual */
 
-#define	SEGSHIFT	24		/* LOG2(NBSEG) [68030 value] */
-
-#define NBSEG		((mmutype == MMU_68040) ? \
-			    (1 << 18 /* SG4_SHIFT2 */) : (1 << SEGSHIFT))
-					/* bytes/segment */
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
-
 #define	UPAGES		2		/* pages of u-area */
 
 #include <m68k/param.h>

Index: src/sys/arch/atari/include/param.h
diff -u src/sys/arch/atari/include/param.h:1.32 src/sys/arch/atari/include/param.h:1.33
--- src/sys/arch/atari/include/param.h:1.32	Wed Dec  9 12:21:58 2009
+++ src/sys/arch/atari/include/param.h	Fri Dec 11 17:53:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.32 2009/12/09 12:21:58 tsutsui Exp $	*/
+/*	$NetBSD: param.h,v 1.33 2009/12/11 17:53:22 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -88,13 +88,6 @@
 #define	PGSHIFT		13		/* LOG2(NBPG) */
 #define	KERNBASE	0x00000000	/* start of kernel virtual */
 
-#define	SEGSHIFT	24		/* LOG2(NBSEG) [68030 value] */
-
-#define	NBSEG		((mmutype == MMU_68040) \
-			    ? (1 << 18 /* SG4_SHIFT2 */) : (1 << SEGSHIFT))
-					/* bytes/segment */
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
-
 #define	UPAGES		2		/* pages of u-area */
 
 #include <m68k/param.h>

Index: src/sys/arch/cesfic/include/param.h
diff -u src/sys/arch/cesfic/include/param.h:1.9 src/sys/arch/cesfic/include/param.h:1.10
--- src/sys/arch/cesfic/include/param.h:1.9	Wed Dec  9 12:21:58 2009
+++ src/sys/arch/cesfic/include/param.h	Fri Dec 11 17:53:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.9 2009/12/09 12:21:58 tsutsui Exp $	*/
+/*	$NetBSD: param.h,v 1.10 2009/12/11 17:53:22 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -97,17 +97,6 @@
 #define	PGSHIFT		12		/* LOG2(NBPG) */
 #define	NPTEPG		(NBPG/(sizeof (pt_entry_t)))
 
-#define	SEGSHIFT	22		/* LOG2(NBSEG) */
-#if defined(M68030) && !defined(M68040) && !defined(M68060)
-#define NBSEG		(1 << SEGSHIFT)	/* bytes/segment */
-#elif (defined(M68040) || defined(M68060)) && !defined(M68030)
-#define	NBSEG		(1 << 18 /* SG4_SHIFT2 */)
-#else
-#define	NBSEG		((mmutype == MMU_68040) ? \
-			    (1 << 18 /* SG4_SHIFT2 */) : (1 << SEGSHIFT))
-#endif
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
-
 #define	KERNBASE	0x00002000	/* start of kernel virtual */
 
 #define	UPAGES		2		/* pages of u-area */

Index: src/sys/arch/hp300/include/param.h
diff -u src/sys/arch/hp300/include/param.h:1.50 src/sys/arch/hp300/include/param.h:1.51
--- src/sys/arch/hp300/include/param.h:1.50	Wed Dec  9 12:21:58 2009
+++ src/sys/arch/hp300/include/param.h	Fri Dec 11 17:53:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.50 2009/12/09 12:21:58 tsutsui Exp $	*/
+/*	$NetBSD: param.h,v 1.51 2009/12/11 17:53:22 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -88,17 +88,6 @@
 #define	PGSHIFT		12		/* LOG2(NBPG) */
 #define	KERNBASE	0x00000000	/* start of kernel virtual */
 
-#define	SEGSHIFT	22		/* LOG2(NBSEG) */
-#if defined(M68030) && !defined(M68040) && !defined(M68060)
-#define NBSEG		(1 << SEGSHIFT)	/* bytes/segment */
-#elif (defined(M68040) || defined(M68060)) && !defined(M68030)
-#define	NBSEG		(1 << 18 /* SG4_SHIFT2 */)
-#else
-#define	NBSEG		((mmutype == MMU_68040) ? \
-			    (1 << 18 /* SG4_SHIFT2 */) : (1 << SEGSHIFT))
-#endif
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
-
 #define	UPAGES		2		/* pages of u-area */
 
 #include <m68k/param.h>

Index: src/sys/arch/luna68k/include/param.h
diff -u src/sys/arch/luna68k/include/param.h:1.9 src/sys/arch/luna68k/include/param.h:1.10
--- src/sys/arch/luna68k/include/param.h:1.9	Wed Dec  9 12:21:58 2009
+++ src/sys/arch/luna68k/include/param.h	Fri Dec 11 17:53:22 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.9 2009/12/09 12:21:58 tsutsui Exp $ */
+/* $NetBSD: param.h,v 1.10 2009/12/11 17:53:22 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -85,17 +85,6 @@
 #define PGSHIFT		12		/* LOG2(NBPG) */
 #define KERNBASE	0x00000000	/* start of kernel virtual */
 
-#define SEGSHIFT	22		/* LOG2(NBSEG) */
-#if defined(M68030) && !defined(M68040) && !defined(M68060)
-#define NBSEG		(1 << SEGSHIFT)	/* bytes/segment */
-#elif (defined(M68040) || defined(M68060)) && !defined(M68030)
-#define	NBSEG		(1 << 18 /* SG4_SHIFT2 */)
-#else
-#define	NBSEG		((mmutype == MMU_68040) ? \
-			    (1 << 18 /* SG4_SHIFT2 */) : (1 << SEGSHIFT))
-#endif
-#define SEGOFSET	(NBSEG-1)	/* byte offset into segment */
-
 #define UPAGES		2		/* pages of u-area */
 
 #include <m68k/param.h>

Index: src/sys/arch/m68k/include/param.h
diff -u src/sys/arch/m68k/include/param.h:1.15 src/sys/arch/m68k/include/param.h:1.16
--- src/sys/arch/m68k/include/param.h:1.15	Mon Aug 28 13:43:35 2006
+++ src/sys/arch/m68k/include/param.h	Fri Dec 11 17:53:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.15 2006/08/28 13:43:35 yamt Exp $	*/
+/*	$NetBSD: param.h,v 1.16 2009/12/11 17:53:22 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -156,13 +156,10 @@
 /*
  * Mach-derived conversion macros
  */
-#define	m68k_round_seg(x)	((((unsigned)(x)) + SEGOFSET) & ~SEGOFSET)
-#define	m68k_trunc_seg(x)	((unsigned)(x) & ~SEGOFSET)
-#define	m68k_seg_offset(x)	((unsigned)(x) & SEGOFSET)
-#define	m68k_round_page(x)	((((unsigned)(x)) + PGOFSET) & ~PGOFSET)
-#define	m68k_trunc_page(x)	((unsigned)(x) & ~PGOFSET)
-#define	m68k_page_offset(x)	((unsigned)(x) & PGOFSET)
-#define	m68k_btop(x)		((unsigned)(x) >> PGSHIFT)
-#define	m68k_ptob(x)		((unsigned)(x) << PGSHIFT)
+#define	m68k_round_page(x)	((((vaddr_t)(x)) + PGOFSET) & ~PGOFSET)
+#define	m68k_trunc_page(x)	((vaddr_t)(x) & ~PGOFSET)
+#define	m68k_page_offset(x)	((vaddr_t)(x) & PGOFSET)
+#define	m68k_btop(x)		((vaddr_t)(x) >> PGSHIFT)
+#define	m68k_ptob(x)		((vaddr_t)(x) << PGSHIFT)
 
 #endif	/* !_M68K_PARAM_H_ */

Index: src/sys/arch/m68k/include/pmap_motorola.h
diff -u src/sys/arch/m68k/include/pmap_motorola.h:1.25 src/sys/arch/m68k/include/pmap_motorola.h:1.26
--- src/sys/arch/m68k/include/pmap_motorola.h:1.25	Tue Dec  8 15:32:01 2009
+++ src/sys/arch/m68k/include/pmap_motorola.h	Fri Dec 11 17:53:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_motorola.h,v 1.25 2009/12/08 15:32:01 tsutsui Exp $	*/
+/*	$NetBSD: pmap_motorola.h,v 1.26 2009/12/11 17:53:22 tsutsui Exp $	*/
 
 /* 
  * Copyright (c) 1991, 1993
@@ -96,6 +96,57 @@
 };
 
 /*
+ * MMU specific segment values
+ *
+ * We are using following segment layout in m68k pmap_motorola.c:
+ * 68020/030 4KB/page: l1,l2,page    == 10,10,12	(%tc = 0x82c0aa00)
+ * 68020/030 8KB/page: l1,l2,page    ==  8,11,13	(%tc = 0x82d08b00)
+ * 68040/060 4KB/page: l1,l2,l3,page == 7,7,6,12
+ * 68040/060 8KB/page: l1,l2,l3,page == 7,7,5,13
+ *
+ * 68020/030 l2 size is chosen per NPTEPG, a number of page table entries
+ * per page, to use one whole page for PTEs per one segment table entry,
+ * and maybe also because 68020 HP MMU machines use simlar structures.
+ *
+ * 68040/060 layout is defined by hardware design and not configurable,
+ * as defined in <m68k/pte_motorola.h>.
+ *
+ * Even on 68040/060, we still appropriate 2-level ste-pte pmap structures
+ * for 68020/030 (derived from 4.4BSD/hp300) to handle 040's 3-level MMU.
+ * TIA_SIZE and TIB_SIZE are used to represent such pmap structures and
+ * they are also refered on 040/060.
+ *
+ * NBSEG and SEGOFSET are used to check l2 STE of the specified VA,
+ * so they have different values between 020/030 and 040/060.
+ */
+							/*  8KB /  4KB	*/
+#define TIB_SHIFT	(PG_SHIFT - 2)			/*   11 /   10	*/
+#define TIB_SIZE	(1U << TIB_SHIFT)		/* 2048 / 1024	*/
+#define TIA_SHIFT	(32 - TIB_SHIFT - PG_SHIFT)	/*    8 /   10	*/
+#define TIA_SIZE	(1U << TIA_SHIFT)		/*  256 / 1024	*/
+
+#define SEGSHIFT	(TIB_SHIFT + PG_SHIFT)		/*   24 /   22	*/
+
+#define NBSEG30		(1U << SEGSHIFT)
+#define NBSEG40		(1U << SG4_SHIFT2)
+
+#if   ( defined(M68020) ||  defined(M68030)) &&	\
+      (!defined(M68040) && !defined(M68060))
+#define NBSEG		NBSEG30
+#elif ( defined(M68040) ||  defined(M68060)) &&	\
+      (!defined(M68020) && !defined(M68030))
+#define NBSEG		NBSEG40
+#else
+#define NBSEG		((mmutype == MMU_68040) ? NBSEG40 : NBSEG30)
+#endif
+
+#define SEGOFSET	(NBSEG - 1)	/* byte offset into segment */ 
+
+#define	m68k_round_seg(x)	((((vaddr_t)(x)) + SEGOFSET) & ~SEGOFSET)
+#define	m68k_trunc_seg(x)	((vaddr_t)(x) & ~SEGOFSET)
+#define	m68k_seg_offset(x)	((vaddr_t)(x) & SEGOFSET)
+
+/*
  * On the 040, we keep track of which level 2 blocks are already in use
  * with the pm_stfree mask.  Bits are arranged from LSB (block 0) to MSB
  * (block 31).  For convenience, the level 1 table is considered to be

Index: src/sys/arch/mac68k/include/param.h
diff -u src/sys/arch/mac68k/include/param.h:1.42 src/sys/arch/mac68k/include/param.h:1.43
--- src/sys/arch/mac68k/include/param.h:1.42	Wed Dec  9 12:21:58 2009
+++ src/sys/arch/mac68k/include/param.h	Fri Dec 11 17:53:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.42 2009/12/09 12:21:58 tsutsui Exp $	*/
+/*	$NetBSD: param.h,v 1.43 2009/12/11 17:53:22 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -123,17 +123,6 @@
 #define	PGSHIFT		12		/* LOG2(NBPG) */
 #define	KERNBASE	0x00000000	/* start of kernel virtual */
 
-#define	SEGSHIFT	22		/* LOG2(NBSEG) */
-#if defined(M68030) && !defined(M68040) && !defined(M68060)
-#define NBSEG		(1 << SEGSHIFT)	/* bytes/segment */
-#elif (defined(M68040) || defined(M68060)) && !defined(M68030)
-#define	NBSEG		(1 << 18 /* SG4_SHIFT2 */)
-#else
-#define	NBSEG		((mmutype == MMU_68040) ? \
-			    (1 << 18 /* SG4_SHIFT2 */) : (1 << SEGSHIFT))
-#endif
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
-
 #define	UPAGES		3  		/* pages of u-area */
 
 #include <m68k/param.h>

Index: src/sys/arch/mvme68k/include/param.h
diff -u src/sys/arch/mvme68k/include/param.h:1.30 src/sys/arch/mvme68k/include/param.h:1.31
--- src/sys/arch/mvme68k/include/param.h:1.30	Wed Dec  9 12:21:58 2009
+++ src/sys/arch/mvme68k/include/param.h	Fri Dec 11 17:53:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.30 2009/12/09 12:21:58 tsutsui Exp $	*/
+/*	$NetBSD: param.h,v 1.31 2009/12/11 17:53:22 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -95,17 +95,6 @@
 #define	PGSHIFT		12		/* LOG2(NBPG) */
 #define	KERNBASE	0x00000000	/* start of kernel virtual */
 
-#define	SEGSHIFT	22		/* LOG2(NBSEG) */
-#if defined(M68030) && !defined(M68040) && !defined(M68060)
-#define NBSEG		(1 << SEGSHIFT)	/* bytes/segment */
-#elif (defined(M68040) || defined(M68060)) && !defined(M68030)
-#define	NBSEG		(1 << 18 /* SG4_SHIFT2 */)
-#else
-#define	NBSEG		((mmutype == MMU_68040) ? \
-			    (1 << 18 /* SG4_SHIFT2 */) : (1 << SEGSHIFT))
-#endif
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
-
 #define	UPAGES		2		/* pages of u-area */
 
 #include <m68k/param.h>

Index: src/sys/arch/news68k/include/param.h
diff -u src/sys/arch/news68k/include/param.h:1.13 src/sys/arch/news68k/include/param.h:1.14
--- src/sys/arch/news68k/include/param.h:1.13	Wed Dec  9 12:21:58 2009
+++ src/sys/arch/news68k/include/param.h	Fri Dec 11 17:53:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.13 2009/12/09 12:21:58 tsutsui Exp $	*/
+/*	$NetBSD: param.h,v 1.14 2009/12/11 17:53:22 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -89,18 +89,6 @@
 #define	PGSHIFT		12		/* LOG2(NBPG) */
 #define	KERNBASE	0x00000000	/* start of kernel virtual */
 
-#define	SEGSHIFT	22		/* LOG2(NBSEG) */
-
-#if defined(M68030) && !defined(M68040) && !defined(M68060)
-#define NBSEG		(1 << SEGSHIFT)	/* bytes/segment */
-#elif (defined(M68040) || defined(M68060)) && !defined(M68030)
-#define	NBSEG		(1 << 18 /* SG4_SHIFT2 */)
-#else
-#define	NBSEG		((mmutype == MMU_68040) ? \
-			    (1 << 18 /* SG4_SHIFT2 */) : (1 << SEGSHIFT))
-#endif
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
-
 #define	UPAGES		2		/* pages of u-area */
 
 #include <m68k/param.h>

Index: src/sys/arch/next68k/include/param.h
diff -u src/sys/arch/next68k/include/param.h:1.9 src/sys/arch/next68k/include/param.h:1.10
--- src/sys/arch/next68k/include/param.h:1.9	Wed Dec  9 12:21:59 2009
+++ src/sys/arch/next68k/include/param.h	Fri Dec 11 17:53:23 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.9 2009/12/09 12:21:59 tsutsui Exp $	*/
+/*	$NetBSD: param.h,v 1.10 2009/12/11 17:53:23 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -88,17 +88,6 @@
 #define	PGSHIFT		12		/* LOG2(NBPG) */
 #define	KERNBASE	0x00000000	/* start of kernel virtual */
 
-#define	SEGSHIFT	22		/* LOG2(NBSEG) */
-#if defined(M68030) && !defined(M68040) && !defined(M68060)
-#define NBSEG		(1 << SEGSHIFT)	/* bytes/segment */
-#elif (defined(M68040) || defined(M68060)) && !defined(M68030)
-#define	NBSEG		(1 << 18 /* SG4_SHIFT2 */)
-#else
-#define	NBSEG		((mmutype == MMU_68040) ? \
-			    (1 << 18 /* SG4_SHIFT2 */) : (1 << SEGSHIFT))
-#endif
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
-
 #define	UPAGES		3  		/* pages of u-area */
 
 #include <m68k/param.h>

Index: src/sys/arch/x68k/include/param.h
diff -u src/sys/arch/x68k/include/param.h:1.25 src/sys/arch/x68k/include/param.h:1.26
--- src/sys/arch/x68k/include/param.h:1.25	Wed Dec  9 12:21:59 2009
+++ src/sys/arch/x68k/include/param.h	Fri Dec 11 17:53:23 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.25 2009/12/09 12:21:59 tsutsui Exp $	*/
+/*	$NetBSD: param.h,v 1.26 2009/12/11 17:53:23 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -88,17 +88,6 @@
 #define	PGSHIFT		12		/* LOG2(NBPG) */
 #define	KERNBASE	0x00000000	/* start of kernel virtual */
 
-#define	SEGSHIFT	22		/* LOG2(NBSEG) */
-#if defined(M68030) && !defined(M68040) && !defined(M68060)
-#define NBSEG		(1 << SEGSHIFT)	/* bytes/segment */
-#elif (defined(M68040) || defined(M68060)) && !defined(M68030)
-#define	NBSEG		(1 << 18 /* SG4_SHIFT2 */)
-#else
-#define	NBSEG		((mmutype == MMU_68040) ? \
-			    (1 << 18 /* SG4_SHIFT2 */) : (1 << SEGSHIFT))
-#endif
-#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
-
 #define	UPAGES		2		/* pages of u-area */
 
 #include <m68k/param.h>

Reply via email to