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.
This commit is contained in:
parent
a2c6d1c59d
commit
465857f028
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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
|
||||
|
@ -95,6 +95,57 @@ struct pmap {
|
|||
int pm_ptpages; /* more stats: PT pages */
|
||||
};
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue