Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Refactoring MD segment related definitions on m68k ...
details: https://anonhg.NetBSD.org/src/rev/d04eb3c997e5
branches: trunk
changeset: 749868:d04eb3c997e5
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Fri Dec 11 17:53:22 2009 +0000
description:
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.
diffstat:
sys/arch/amiga/include/param.h | 9 +-----
sys/arch/atari/include/param.h | 9 +-----
sys/arch/cesfic/include/param.h | 13 +-------
sys/arch/hp300/include/param.h | 13 +-------
sys/arch/luna68k/include/param.h | 13 +-------
sys/arch/m68k/include/param.h | 15 +++-----
sys/arch/m68k/include/pmap_motorola.h | 53 ++++++++++++++++++++++++++++++++++-
sys/arch/mac68k/include/param.h | 13 +-------
sys/arch/mvme68k/include/param.h | 13 +-------
sys/arch/news68k/include/param.h | 14 +--------
sys/arch/next68k/include/param.h | 13 +-------
sys/arch/x68k/include/param.h | 13 +-------
12 files changed, 68 insertions(+), 123 deletions(-)
diffs (truncated from 358 to 300 lines):
diff -r 97d530d259a2 -r d04eb3c997e5 sys/arch/amiga/include/param.h
--- a/sys/arch/amiga/include/param.h Fri Dec 11 17:00:49 2009 +0000
+++ b/sys/arch/amiga/include/param.h Fri Dec 11 17:53:22 2009 +0000
@@ -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>
diff -r 97d530d259a2 -r d04eb3c997e5 sys/arch/atari/include/param.h
--- a/sys/arch/atari/include/param.h Fri Dec 11 17:00:49 2009 +0000
+++ b/sys/arch/atari/include/param.h Fri Dec 11 17:53:22 2009 +0000
@@ -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>
diff -r 97d530d259a2 -r d04eb3c997e5 sys/arch/cesfic/include/param.h
--- a/sys/arch/cesfic/include/param.h Fri Dec 11 17:00:49 2009 +0000
+++ b/sys/arch/cesfic/include/param.h Fri Dec 11 17:53:22 2009 +0000
@@ -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 */
diff -r 97d530d259a2 -r d04eb3c997e5 sys/arch/hp300/include/param.h
--- a/sys/arch/hp300/include/param.h Fri Dec 11 17:00:49 2009 +0000
+++ b/sys/arch/hp300/include/param.h Fri Dec 11 17:53:22 2009 +0000
@@ -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>
diff -r 97d530d259a2 -r d04eb3c997e5 sys/arch/luna68k/include/param.h
--- a/sys/arch/luna68k/include/param.h Fri Dec 11 17:00:49 2009 +0000
+++ b/sys/arch/luna68k/include/param.h Fri Dec 11 17:53:22 2009 +0000
@@ -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>
diff -r 97d530d259a2 -r d04eb3c997e5 sys/arch/m68k/include/param.h
--- a/sys/arch/m68k/include/param.h Fri Dec 11 17:00:49 2009 +0000
+++ b/sys/arch/m68k/include/param.h Fri Dec 11 17:53:22 2009 +0000
@@ -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_ */
diff -r 97d530d259a2 -r d04eb3c997e5 sys/arch/m68k/include/pmap_motorola.h
--- a/sys/arch/m68k/include/pmap_motorola.h Fri Dec 11 17:00:49 2009 +0000
+++ b/sys/arch/m68k/include/pmap_motorola.h Fri Dec 11 17:53:22 2009 +0000
@@ -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
diff -r 97d530d259a2 -r d04eb3c997e5 sys/arch/mac68k/include/param.h
--- a/sys/arch/mac68k/include/param.h Fri Dec 11 17:00:49 2009 +0000
+++ b/sys/arch/mac68k/include/param.h Fri Dec 11 17:53:22 2009 +0000
@@ -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>
diff -r 97d530d259a2 -r d04eb3c997e5 sys/arch/mvme68k/include/param.h
--- a/sys/arch/mvme68k/include/param.h Fri Dec 11 17:00:49 2009 +0000
+++ b/sys/arch/mvme68k/include/param.h Fri Dec 11 17:53:22 2009 +0000
@@ -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>
diff -r 97d530d259a2 -r d04eb3c997e5 sys/arch/news68k/include/param.h
--- a/sys/arch/news68k/include/param.h Fri Dec 11 17:00:49 2009 +0000
+++ b/sys/arch/news68k/include/param.h Fri Dec 11 17:53:22 2009 +0000
@@ -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 */
Home |
Main Index |
Thread Index |
Old Index