Module Name:    src
Committed By:   thorpej
Date:           Wed Dec 27 02:40:32 UTC 2023

Modified Files:
        src/distrib/sets/lists/comp: ad.m68k
        src/sys/arch/m68k/include: Makefile
Added Files:
        src/sys/arch/m68k/include: mmu_40.h mmu_51.h

Log Message:
Add new headers that describe the 68851 (and 68030) MMU and
68040 (and 68060) MMU structures using names that more closely
align with Motorola's documentation.

The definitions here automagically adapt to 4K or 8K pages, based
on the value of PGSHIFT, which must be a compile-time constant.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/distrib/sets/lists/comp/ad.m68k
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/m68k/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/m68k/include/mmu_40.h \
    src/sys/arch/m68k/include/mmu_51.h

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

Modified files:

Index: src/distrib/sets/lists/comp/ad.m68k
diff -u src/distrib/sets/lists/comp/ad.m68k:1.68 src/distrib/sets/lists/comp/ad.m68k:1.69
--- src/distrib/sets/lists/comp/ad.m68k:1.68	Tue Aug 29 04:35:26 2023
+++ src/distrib/sets/lists/comp/ad.m68k	Wed Dec 27 02:40:31 2023
@@ -1,4 +1,4 @@
-# $NetBSD: ad.m68k,v 1.68 2023/08/29 04:35:26 mrg Exp $
+# $NetBSD: ad.m68k,v 1.69 2023/12/27 02:40:31 thorpej Exp $
 ./usr/bin/elf2aout				comp-sysutil-bin
 ./usr/include/gcc-4.5/math-68881.h		comp-obsolete		obsolete
 ./usr/include/gcc-4.5/tgmath.h			comp-obsolete		obsolete
@@ -54,6 +54,8 @@
 ./usr/include/m68k/m68k.h			comp-c-include
 ./usr/include/m68k/math.h			comp-c-include
 ./usr/include/m68k/mcontext.h			comp-c-include
+./usr/include/m68k/mmu_40.h			comp-c-include
+./usr/include/m68k/mmu_51.h			comp-c-include
 ./usr/include/m68k/mutex.h			comp-c-include
 ./usr/include/m68k/param.h			comp-c-include
 ./usr/include/m68k/pcb.h			comp-c-include

Index: src/sys/arch/m68k/include/Makefile
diff -u src/sys/arch/m68k/include/Makefile:1.32 src/sys/arch/m68k/include/Makefile:1.33
--- src/sys/arch/m68k/include/Makefile:1.32	Sat Feb  1 19:41:48 2020
+++ src/sys/arch/m68k/include/Makefile	Wed Dec 27 02:40:31 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.32 2020/02/01 19:41:48 tsutsui Exp $
+#	$NetBSD: Makefile,v 1.33 2023/12/27 02:40:31 thorpej Exp $
 
 INCSDIR= /usr/include/m68k
 
@@ -12,7 +12,7 @@ INCS=	ansi.h aout_machdep.h asm.h asm_si
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	kcore.h \
 	limits.h lock.h \
-	m68k.h math.h mcontext.h mutex.h \
+	m68k.h math.h mcontext.h mmu_40.h mmu_51.h mutex.h \
 	param.h pmap_motorola.h pcb.h proc.h profile.h \
 	psl.h pte_motorola.h ptrace.h \
 	reg.h rwlock.h setjmp.h signal.h sync_icache.h \

Added files:

Index: src/sys/arch/m68k/include/mmu_40.h
diff -u /dev/null src/sys/arch/m68k/include/mmu_40.h:1.1
--- /dev/null	Wed Dec 27 02:40:32 2023
+++ src/sys/arch/m68k/include/mmu_40.h	Wed Dec 27 02:40:31 2023
@@ -0,0 +1,214 @@
+/*	$NetBSD: mmu_40.h,v 1.1 2023/12/27 02:40:31 thorpej Exp $	*/
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _M68K_MMU_40_H_
+#define	_M68K_MMU_40_H_
+
+/*
+ * Translation table structures for the 68040 MMU.
+ *
+ * The 68040 MMU uses a 3-level tree structure.  The root (L1) and
+ * and pointer (L2) tables contain the base addresses of the tables
+ * at the lext level, and the page (L3) tables contain the addresses
+ * of the page descriptors, which may either contain the address of
+ * a physical page (4K or 8K) directly, or point to an indirect
+ * decriptor which points to the physical page.
+ *
+ * The L1 and L2 tables contain 128 4-byte descriptors, and are thus 512
+ * bytes in size.  Each of the 128 L1 descriptors corresponds to a 32MB
+ * region of address space.  Each of the 128 L2 descriptors corresponds
+ * to a 256KB region of address space.
+ *
+ * For 8K pages, the L3 tables contain 32 4-byte descriptors, and are
+ * thus 128 bytes in size.
+ *
+ *  31          25 24          18 17      13 12                       0
+ * |              |              |          |                          |
+ *  11111111111111 22222222222222 3333333333 ..........................
+ *       Root         Pointer        Page               Page
+ *       Index         Index         Index             Offset
+ *
+ * For 4K pages, the L3 tables contain 64 4-byte descriptors, and are
+ * thus 256 bytes in size.
+ *
+ *  31          25 24          18 17        12 11                     0
+ * |              |              |            |                        |
+ *  11111111111111 22222222222222 333333333333 ........................
+ *       Root         Pointer         Page              Page
+ *       Index         Index          Index            Offset
+ *
+ *                       Logical Address Format
+ */
+
+#define	LA40_L1_NBITS	7U
+#define	LA40_L1_SHIFT	25
+#define	LA40_L2_NBITS	7U
+#define	LA40_L2_SHIFT	18
+#define	LA40_L3_NBITS	(32U - LA40_L1_NBITS - LA40_L2_NBITS - PGSHIFT)
+#define	LA40_L3_SHIFT	PGSHIFT
+
+#define	LA40_L1_COUNT	__BIT(LA40_L1_NBITS)
+#define	LA40_L2_COUNT	__BIT(LA40_L2_NBITS)
+#define	LA40_L3_COUNT	__BIT(LA40_L3_NBITS)
+
+#define	LA40_L1_MASK	(__BITS(0,(LA40_L1_NBITS - 1)) << LA40_L1_SHIFT)
+#define	LA40_L2_MASK	(__BITS(0,(LA40_L2_NBITS - 1)) << LA40_L2_SHIFT)
+#define	LA40_L3_MASK	(__BITS(0,(LA40_L3_NBITS - 1)) << LA40_L3_SHIFT)
+
+/* N.B. all tables must be aligned to their size */
+#define	TBL40_L1_SIZE	(LA40_L1_COUNT * sizeof(uint32_t))
+#define	TBL40_L2_SIZE	(LA40_L2_COUNT * sizeof(uint32_t))
+#define	TBL40_L3_SIZE	(LA40_L3_COUNT * sizeof(uint32_t))
+
+#define	LA40_RI(va)	__SHIFTOUT((va), LA40_L1_MASK)	/* root index */
+#define	LA40_PI(va)	__SHIFTOUT((va), LA40_L2_MASK)	/* pointer index */
+#define	LA40_PGI(va)	__SHIFTOUT((va), LA40_L3_MASK)	/* page index */
+
+#define	LA40_TRUNC_L1(va) (((vaddr_t)(va)) & LA40_L1_MASK)
+#define	LA40_TRUNC_L2(va) (((vaddr_t)(va)) & (LA40_L1_MASK | LA40_L2_MASK))
+
+/*
+ * The PTE format for L1 and L2 tables (Upper Tables).
+ */
+#define	UTE40_PTA	__BITS(9,31)	/* Pointer Table Address (L1 PTE) */
+					/* Page Table Address (L2 PTE) */
+#define	UTE40_PGTA	__BITS(8 - (13 - PGSHIFT),31)
+#define	UTE40_U		__BIT(3)	/* Used (referenced) */
+#define	UTE40_W		__BIT(2)	/* Write Protected */
+#define	UTE40_UDT	__BITS(0,1)	/* Upper Descriptor Type */
+					/* 00 or 01 -- Invalid */
+					/* 10 or 11 -- Resident */
+
+#define	UTE40_INVALID	__SHIFTIN(0, UTE_UDT)
+#define	UTE40_RESIDENT	__SHIFTIN(2, UTE_UDT)
+
+/*
+ * The PTE format for L3 tables.
+ *
+ * Some notes:
+ *
+ * - PFLUSH variants that specify non-global entries do not invalidate
+ *   global entries.  If these PFLUSH variants are not used, then the G
+ *   bit can be used as a software-defined bit.
+ *
+ * - The UR bits are "reserved for use by the user", so can be
+ *   used as software-defined bits.
+ *
+ * - The U0 and U1 "User Page Attribute" bits should *not* be used
+ *   as software-defined bits; they are reflected on the UPA0 and UPA1
+ *   CPU signals if an external bus transfer results from the access,
+ *   meaning that they may have system-specific side-effects.
+ */
+#define	PTE40_PGA	__BITS(PGSHIFT,31) /* Page Physical Address */
+#define	PTE40_UR_x	__BIT(12)	/* User Reserved (extra avail if 8K) */
+#define	PTE40_UR	__BIT(11)	/* User Reserved */
+#define	PTE40_G		__BIT(10)	/* Global */
+#define	PTE40_U1	__BIT(9)	/* User Page Attribute 1 */
+#define	PTE40_U0	__BIT(8)	/* User Page Attribute 0 */
+#define	PTE40_S		__BIT(7)	/* Supervisor Protected */
+#define	PTE40_CM	__BITS(5,6)	/* Cache Mode */
+					/* 00 -- write-through */
+					/* 01 -- copy-back */
+					/* 10 -- non-cacheable, serialized */
+					/* 11 -- non-cacheable */
+#define	PTE40_M		__BIT(4)	/* Modified */
+#define	PTE40_U		__BIT(3)	/* Used (referenced) */
+#define	PTE40_W		__BIT(2)	/* Write Protected */
+#define	PTE40_PDT	__BITS(0,1)	/* Page Descriptor Type */
+					/* 00       -- Invalid */
+					/* 01 or 11 -- Resident */
+					/* 10       -- Indirect */
+
+#define	PTE40_CM_WT	__SHIFTIN(0, PTE40_CM)
+#define	PTE40_CM_CB	__SHIFTIN(1, PTE40_CM)
+#define	PTE40_CM_NC_SER	__SHIFTIN(2, PTE40_CM)
+#define	PTE40_CM_NC	__SHIFTIN(3, PTE40_CM)
+
+#define	PTE40_INVALID	__SHIFTIN(0, PTE40_PDT)
+#define	PTE40_RESIDENT	__SHIFTIN(1, PTE40_PDT)
+#define	PTE40_INDIRECT	__SHIFTIN(2, PTE40_PDT)
+
+/*
+ * MMU registers (and the sections in the 68040 manual that
+ * describe them).
+ */
+
+/*
+ * 3.1.1 -- User and Supervisor Root Pointer Registers (32-bit)
+ *
+ * URP and SRP contain the physical address of the L1 table for
+ * user and supervisor space, respectively.  Bits 8-0 of the address
+ * must be 0.
+ */
+
+/*
+ * 3.1.2 -- Translation Control Register (16-bit)
+ */
+#define	TCR40_E		__BIT(15)	/* enable translation */
+#define	TCR40_P		__BIT(14)	/* page size: 0=4K 1=8K */
+
+/*
+ * 3.1.3 -- Transparent Translation Registers (32-bit)
+ *
+ * There are 2 data translation registers (DTTR0, DTTR1) and 2
+ * instruction translation registers (ITTR0, ITTR1).
+ */
+#define	TTR40_LAB	__BITS(24,31)	/* logical address base */
+#define	TTR40_LAM	__BITS(16,23)	/* logical address mask */
+#define	TTR40_E		__BIT(15)	/* enable TTR */
+#define	TTR40_SFIELD	__BITS(13,14)	/* Supervisor Mode field (see below) */
+#define	TTR40_U1	PTE40_U1
+#define	TTR40_U0	PTE40_U0
+#define	TTR40_CM	PTE40_CM
+#define	TTR40_W		PTE40_W
+
+#define	TTR40_USER	__SHIFTIN(0, TTR40_SFIELD)
+#define	TTR40_SUPER	__SHIFTIN(1, TTR40_SFIELD)
+#define	TTR40_BOTH	__SHIFTIN(2, TTR40_SFIELD)
+
+/*
+ * 3.1.4 -- MMU Status Register
+ *
+ * N.B. If 8K pages are in use, bit 12 of the PA field is **undefined**.
+ */
+#define	MMUSR40_PA	PTE40_PGA
+#define	MMUSR40_B	__BIT(11)	/* bus error */
+#define	MMUSR40_G	PTE40_G
+#define	MMUSR40_U1	PTE40_U1
+#define	MMUSR40_U0	PTE40_U0
+#define	MMUSR40_S	PTE40_S
+#define	MMUSR40_CM	PTE40_CM
+#define	MMUSR40_M	PTE40_M
+#define	MMUSR40_W	PTE40_W
+#define	MMUSR40_T	__BIT(1)	/* Transparent Translation hit */
+#define	MMUSR40_R	PTE40_RESIDENT
+
+#endif /* _M68K_MMU_40_H_ */
Index: src/sys/arch/m68k/include/mmu_51.h
diff -u /dev/null src/sys/arch/m68k/include/mmu_51.h:1.1
--- /dev/null	Wed Dec 27 02:40:32 2023
+++ src/sys/arch/m68k/include/mmu_51.h	Wed Dec 27 02:40:32 2023
@@ -0,0 +1,266 @@
+/*	$NetBSD: mmu_51.h,v 1.1 2023/12/27 02:40:32 thorpej Exp $	*/
+
+/*-
+ * Copyright (c) 1997, 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jeremy Cooper and by Jason R. Thorpe.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _M68K_MMU_51_H_
+#define	_M68K_MMU_51_H_
+
+/*
+ * Translation table structures for the 68851 MMU.
+ *
+ * The 68851 MMU (as well as the 68030's built-in MMU) are pretty flexible and
+ * can use a 1, 2, 3, or 4-level tree structure and a number of page sizes.
+ *
+ * The logical address format is defined as:
+ *
+ *  31                                                                0
+ * |        |          |          |          |          |              |
+ *  SSSSSSSS AAAAAAAAAA BBBBBBBBBB CCCCCCCCCC DDDDDDDDDD PPPPPPPPPPPPPP
+ *  Initial   A Index    B Index    C Index    D Index    Page Offset
+ *   Shift
+ *
+ * The Initial Shift, and number of A, B, C, and D index bits are defined
+ * in the Translation Control register.  Once the MMU encounters a tree
+ * level where the number of index bits is 0, tree traversal stops.  The
+ * values of IS + TIA + TIB + TIC + TID + page offset must equal 32.  For
+ * example, for a 2-level arrangment using 4KB pages where all 32-bits of
+ * the address are significant:
+ *
+ *     IS  TIA  TIB  TIC  TID  page
+ *	0 + 10 + 10 +  0 +  0 +  12 == 32
+ */
+
+/*
+ * The 68851 has 3 descriptor formats:
+ *
+ *	Long Table Descriptors		(8 byte)
+ *	Short Table Descriptors		(4 byte)
+ *	Page Descriptors		(4 byte)
+ *
+ * These occupy the lower 2 bits of each descriptor and the root pointers.
+ */
+#define	DT51_INVALID	0
+#define	DT51_PAGE	1	/* points to a page */
+#define	DT51_SHORT	2	/* points to a short entry table */
+#define	DT51_LONG	3	/* points to a long entry table */
+
+/*
+ * Long Format Table Descriptor
+ *
+ *  63                                                             48
+ *  +---+---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
+ *  |L/U|                 LIMIT                                     |
+ *  +---+---.---+---.---.---+---+---+---+---+---+---+---+---+---.---+
+ *  |    RAL    |    WAL    |SG | S | 0 | 0 | 0 | 0 | U |WP |  DT   |
+ *  +---.---.---+---.---.---+---+---+---+---+---+---+---+---+---.---+
+ *  |              TABLE PHYSICAL ADDRESS (BITS 31-16)              |
+ *  +---.---.---.---.---.---.---.---.---.---.---.---+---.---.---.---+
+ *  |       TABLE PHYSICAL ADDRESS (15-4)           |     UNUSED    |
+ *  +---.---.---.---.---.---.---.---.---.---.---.---+---.---.---.---+
+ *  15                                                              0
+ *
+ * DT is either 2 or 3, depending on what next table descriptor format is.
+ */
+struct mmu51_ldte {		/* 'dte' stands for 'descriptor table entry' */
+	uint32_t	ldte_attr;
+	uint32_t	ldte_addr;
+};
+#define	DTE51_ADDR	__BITS(4,31)	/* table address mask */
+#define	DTE51_LOWER	__BIT(31)	/* L: Index limit is lower limit */
+#define	DTE51_LIMIT	__BITS(16,30)	/* L: Index limit */
+#define	DTE51_RAL	__BITS(13,15)	/* L: Read Access Level */
+#define	DTE51_WAL	__BITS(10,12)	/* L: Write Access Level */
+#define	DTE51_SG	__BIT(9)	/* L: Shared Globally */
+#define	DTE51_S		__BIT(8)	/* L: Supervisor protected */
+#define	DTE51_U		__BIT(3)	/* Used */
+#define	DTE51_WP	__BIT(2)	/* Write Protected */
+
+/*
+ * Short Format Table Descriptor
+ *
+ * 31                                                             16
+ * +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
+ * |           TABLE PHYSICAL BASE ADDRESS (BITS 31-16)            |
+ * +---.---.---.---.---.---.---.---.---.---.---.---+---+---+---.---+
+ * | TABLE PHYSICAL BASE ADDRESS (15-4)            | U |WP |  DT   |
+ * +---.---.---.---.---.---.---.---.---.---.---.---+---+---+---.---+
+ * 15                                                              0
+ *
+ * DT is either 2 or 3, depending on what next table descriptor format is.
+ */
+
+/*
+ * Long Format Page Descriptor (Level A table only)
+ *
+ *  63                                                             48
+ *  +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
+ *  |                          UNUSED                               |
+ *  +---.---.---+---.---.---+---+---+---+---+---+---+---+---+---.---+
+ *  |    RAL    |    WAL    |SG | S | G |CI | L | M | U |WP |DT (01)|
+ *  +---.---.---+---.---.---+---+---+---+---+---+---+---+---+---.---+
+ *  |               PAGE PHYSICAL ADDRESS (BITS 31-16)              |
+ *  +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
+ *  | PAGE PHYS. ADDRESS (15-8)     |            UNUSED             |
+ *  +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
+ *  15                                                              0
+ *
+ * N.B. Unused bits of the page address (if the page size is larger
+ * than 256 bytes) can be used as software-defined PTE bits.
+ */
+struct mmu51_lpte {		/* 'pte' stands for 'page table entry' */
+	uint32_t	lpte_attr;
+	uint32_t	lpte_addr;
+};
+#define	PTE51_ADDR	__BITS(8,31)	/* page address mask */
+#define	PTE51_RAL	__BITS(13,15)	/* L: Read Access Level */
+#define	PTE51_WAL	__BITS(10,12)	/* L: Write Access Level */
+#define	PTE51_SG	__BIT(9)	/* L: Shared Globally */
+#define	PTE51_S		__BIT(8)	/* L: Supervisor protected */
+#define	PTE51_G		__BIT(7)	/* Gate allowed */
+#define	PTE51_CI	__BIT(6)	/* Cache inhibit */
+#define	PTE51_L		__BIT(5)	/* Lock entry */
+#define	PTE51_M		__BIT(4)	/* Modified */
+#define	PTE51_U		__BIT(3)	/* Used */
+#define	PTE51_WP	__BIT(2)	/* Write Protected */
+
+/*
+ * Short Format Page Descriptor
+ *
+ * 31                                                             16
+ * +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---+
+ * |            PAGE PHYSICAL BASE ADDRESS (BITS 31-16)            |
+ * +---.---.---.---.---.---.---.---+---+---+---+---+---+---+---.---+
+ * | PAGE PHYS. BASE ADDRESS (15-8)| G |CI | L | M | U |WP |DT (01)|
+ * +---.---.---.---.---.---.---.---+---+---+---+---+---+---+---.---+
+ * 15                                                              0
+ *
+ * N.B. Unused bits of the page address (if the page size is larger
+ * than 256 bytes) can be used as software-defined PTE bits.
+ */
+
+/*
+ * MMU registers (and the sections in the 68851 manual that
+ * describe them).
+ */
+
+/*
+ * 5.1.4 -- Root Pointer
+ * (and also 6.1.1)
+ *
+ * This is a 64-bit register.  The upper 32 bits contain configuration
+ * information, and the lower 32 bits contain the A table address.
+ * Bits 3-0 of the address must be 0.  The root pointer is essentially
+ * a long format table descriptor with only the U/L, limit, and SG bits.
+ *
+ * The 68851 has 3 root pointers:
+ *
+ * CRP		CPU root pointer, for user accesses
+ * SRP		Supervisor root pointer
+ * DRP		DMA root pointer, for IOMMU functionality (not on '030)
+ *
+ * Selection of root pointer is as follows:
+ *
+ *	FC3	FC2	SRE		Root pointer used
+ *	 0	 0	 0		      CRP
+ *	 0	 0	 1		      CRP
+ *	 0	 1	 0		      CRP
+ *	 0	 1	 1		      SRP
+ *	 1	 x	 x		      DRP
+ */
+struct mmu51_rootptr {
+	unsigned long	rp_attr;	/* Lower/Upper Limit and access flags */
+	unsigned long	rp_addr;	/* Physical Base Address */
+};
+
+/*
+ * 6.1.2 -- PMMU Cache Status (PCSR) (16-bit)
+ */
+#define	PCSR51_F	__BIT(15)	/* Flush(ed) */
+#define	PCSR51_LW	__BIT(14)	/* Lock Warning */
+#define	PCSR51_TA	__BITS(0,2)	/* Task Alias (not '030) */
+
+/*
+ * 6.1.3 -- Translation Control (TCR) (32-bit)
+ */
+#define	TCR51_E		__BIT(31)	/* Enable translation */
+#define	TCR51_SRE	__BIT(25)	/* Supervisor Root Enable */
+#define	TCR51_FCL	__BIT(24)	/* Function Code Lookup */
+#define	TCR51_PS	__BITS(20,23)	/* Page Size (see below) */
+#define	TCR51_IS	__BITS(16,19)	/* Initial Shift */
+#define	TCR51_TIA	__BITS(12,15)	/* Table A Index bits */
+#define	TCR51_TIB	__BITS(8,11)	/* Table B Index bits */
+#define	TCR51_TIC	__BITS(4,7)	/* Table C Index bits */
+#define	TCR51_TID	__BITS(0,3)	/* Table D Index bits */
+
+/*
+ * Astute readers will note that the value in the PS field is
+ * log2(PAGE_SIZE).
+ */
+#define	TCR51_PS_256	__SHIFTIN(0x8, TCR51_PS)
+#define	TCR51_PS_512	__SHIFTIN(0x9, TCR51_PS)
+#define	TCR51_PS_1K	__SHIFTIN(0xa, TCR51_PS)
+#define	TCR51_PS_2K	__SHIFTIN(0xb, TCR51_PS)
+#define	TCR51_PS_4K	__SHIFTIN(0xc, TCR51_PS)
+#define	TCR51_PS_8K	__SHIFTIN(0xd, TCR51_PS)
+#define	TCR51_PS_16K	__SHIFTIN(0xe, TCR51_PS)
+#define	TCR51_PS_32K	__SHIFTIN(0xf, TCR51_PS)
+
+/*
+ * 6.1.4 -- Current Access Level (8-bit)
+ * 6.1.5 -- Validate Access Level
+ */
+#define	CAL51_AL	__BITS(5,7)
+
+/*
+ * 6.1.6 -- Stack Change Control (8-bit)
+ */
+
+/*
+ * 6.1.7 -- Access Control (16-bit)
+ */
+#define	AC51_MC		__BIT(7)	/* Module Control */
+#define	AC51_ALC	__BITS(4,5)	/* Access Level Control */
+#define	AC51_MDS	__BITS(0,1)	/* Module Descriptor Size */
+
+/*
+ * 6.1.8 -- PMMU Status Register (PSR) (16-bit)
+ */
+#define	PSR51_B		__BIT(15)	/* Bus Error */
+#define	PSR51_L		__BIT(14)	/* Limit Violation */
+#define	PSR51_S		__BIT(13)	/* Supervisor Violation */
+#define	PSR51_A		__BIT(12)	/* Access Level Violation */
+#define	PSR51_W		__BIT(11)	/* Write Protected */
+#define	PSR51_I		__BIT(10)	/* Invalid */
+#define	PSR51_M		__BIT(9)	/* Modified */
+#define	PSR51_G		__BIT(8)	/* Gate */
+#define	PSR51_C		__BIT(7)	/* Globally Sharable */
+#define	PSR51_N		__BITS(0,2)	/* Number of levels */
+
+#endif /* _M68K_MMU_51_H_ */

Reply via email to