/*-
* 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
* descriptor 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
*/
/*
* 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 */
/*
* 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.
*/