/*-
* 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 */
/*
* 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.
*/
/*
* 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 */
};