mmu.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SUN4_MMU_H
#define _SUN4_MMU_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Sun-4 memory management unit.
* All sun-4 implementations use 32 bits of address.
* A particular implementation may implement a smaller MMU.
* If so, the missing addresses are in the "middle" of the
* 32 bit address space. All accesses in this range behave
* as if there was an invalid page map entry correspronding
* to the address.
*
* There are two types of MMUs a 2 level MMU and a 3 level MMU.
* Three level MMUs do not have holes.
*/
/*
* Hardware context and segment information
* Mnemonic decoding:
* PMENT - Page Map ENTry
* PMGRP - Group of PMENTs (aka "segment")
* SMENT - Segment Map ENTry - 3 level MMU only
* SMGRP - Group of SMENTs (aka "region") - 3 level MMU only
*/
/* fixed SUN4 constants */
#define NPMENTPERPMGRP 32
#define PMGRPMASK (~PMGRPOFFSET)
#define NSMENTPERSMGRP 64
#define SMGRPMASK (~SMGRPOFFSET)
#define NSMGRPPERCTX 256
/*
* Useful defines for hat constants,
* Every implementation seems to have its own set
* they are set at boot time by setcputype()
*/
/*
* Variables set at boot time to reflect cpu type.
*/
#ifndef LOCORE
#ifdef MMU_3LEVEL
#endif /* MMU_3LEVEL */
#ifdef MMU_3LEVEL
extern int mmu_3level; /* indicates 3 level MMU can exist */
#endif /* MMU_3LEVEL */
/*
* Macro to determine whether an address is within the range of the MMU.
*/
#ifdef MMU_3LEVEL
#define good_addr(a) \
#else
#define good_addr(a) \
#endif /* MMU_3LEVEL */
#endif /* !LOCORE */
/*
* Address space identifiers.
*/
/*
* ASI_CTL addresses
*/
#define ID_PROM 0x00000000
#define CONTEXT_REG 0x30000000
#define SYSTEM_ENABLE 0x40000000
#define BUS_ERROR_REG 0x60000000
#define DIAGNOSTIC_REG 0x70000000
#define CACHE_TAGS 0x80000000
#define VME_INT_VEC 0xE0000000
#define UART_BYPASS 0xF0000000
/*
* Constants for cache operations.
* XXX - should be deleted but the standalones (boot) use them.
*/
#define NPMGRPPERCTX_110 4096
#define NPMGRPPERCTX_260 4096
#define NPMGRPPERCTX_330 4096
#define NPMGRPS_110 256
#define NPMGRPS_260 512
#define NPMGRPS_330 256
#define NPMGRPS_470 1024
/*
* Various I/O space related constants
*/
#define VME16_BASE 0xFFFF0000
#define VME24_BASE 0xFF000000
/*
* Virtual address where dvma starts.
*/
/*
* Context for kernel. On a Sun-4 the kernel is in every address space,
* but KCONTEXT is magic in that there is never any user context there.
*/
#define KCONTEXT 0
/*
* MDEVBASE is a virtual segment reserved for mapping misc. obio devices.
* The base address and the number of devices mapped should not cause the
* device mappings to cross a segment boundary. We use the segment
* immediately before SYSBASE
*/
/*
* SEGTEMP & SEGTEMP2 are virtual segments reserved for temporary operations.
* We use the segments immediately before the start of debugger area.
*/
/*
* REGTEMP is only during intialization, we use the
* REGION immediately before KERNELBASE, it is invalidated
* after use
*/
#ifdef VAC
void vac_dontcache();
/*
* cache related constants set at boot time
*/
extern int vac_size; /* size of cache in bytes */
extern int vac_linesize; /* cache linesize */
extern int vac_nlines; /* number of lines in cache */
extern int vac_pglines; /* number of cache lines in a page */
#endif /* VAC */
/*
* Low level mmu-specific functions
*/
struct ctx *mmu_getctx();
void mmu_setctx(/* ctx */);
void mmu_setpmg(/* base, pmg */);
void mmu_settpmg(/* base, pmg */);
void mmu_setpte(/* base, pte */);
void mmu_getpte(/* base, ppte */);
void mmu_getkpte(/* base, ppte */);
void mmu_pmginval(/* pmg */);
#ifdef MMU_3LEVEL
void mmu_setsmg(/* base, smg */);
void mmu_settsmg(/* base, smg */);
void mmu_smginval(/* smg */);
#endif /* MMU_3LEVEL */
/*
* Cache specific routines - ifdef'ed out if there is no chance
* of running on a machine with a virtual address cache.
*/
#ifdef VAC
void vac_init();
void vac_tagsinit();
void vac_flushall();
void vac_ctxflush();
#ifdef MMU_3LEVEL
void vac_usrflush();
void vac_rgnflush(/* base */);
#endif /* MMU_3LEVEL */
void vac_segflush(/* base */);
void vac_pageflush(/* base */);
void vac_flush(/* base, len */);
int bp_alloc(/* map, bp, size */);
#else /* VAC */
#define vac_init()
#define vac_tagsinit()
#define vac_flushall()
#define vac_usrflush()
#define vac_ctxflush()
#define vac_rgnflush(base)
#define vac_segflush(base)
#define vac_pageflush(base)
#endif /* VAC */
int valid_va_range(/* basep, lenp, minlen, dir */);
#endif /* defined(KERNEL) && !defined(LOCORE) */
#ifdef __cplusplus
}
#endif
#endif /* !_SUN4_MMU_H */