xref: /titanic_41/usr/src/uts/sun4u/sys/mmu.h (revision 1426d65aa9264a283c76d271972aeb7f6a070be3)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5e98fafb9Sjl139090  * Common Development and Distribution License (the "License").
6e98fafb9Sjl139090  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*1426d65aSsm142603  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_MMU_H
277c478bd9Sstevel@tonic-gate #define	_SYS_MMU_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * Definitions for the SOFT MMU
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	FAST_IMMU_MISS_TT	0x64
407c478bd9Sstevel@tonic-gate #define	FAST_DMMU_MISS_TT	0x68
417c478bd9Sstevel@tonic-gate #define	FAST_PROT_TT		0x6c
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate  * Constants defining alternate spaces
457c478bd9Sstevel@tonic-gate  * and register layouts within them,
467c478bd9Sstevel@tonic-gate  * and a few other interesting assembly constants.
477c478bd9Sstevel@tonic-gate  */
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * vaddr offsets of various registers
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate #define	MMU_TTARGET		0x00 /* TSB tag target */
537c478bd9Sstevel@tonic-gate #define	MMU_PCONTEXT		0x08 /* primary context number */
547c478bd9Sstevel@tonic-gate #define	MMU_SCONTEXT		0x10 /* secondary context number */
557c478bd9Sstevel@tonic-gate #define	MMU_SFSR		0x18 /* sync fault status reg */
567c478bd9Sstevel@tonic-gate #define	MMU_SFAR		0x20 /* sync fault addr reg */
577c478bd9Sstevel@tonic-gate #define	MMU_TSB			0x28 /* tsb base and config */
587c478bd9Sstevel@tonic-gate #define	MMU_TAG_ACCESS		0x30 /* tlb tag access */
597c478bd9Sstevel@tonic-gate #define	MMU_VAW			0x38 /* virtual watchpoint */
607c478bd9Sstevel@tonic-gate #define	MMU_PAW			0x40 /* physical watchpoint */
617c478bd9Sstevel@tonic-gate #define	MMU_TSB_PX		0x48 /* i/d tsb primary extension reg */
627c478bd9Sstevel@tonic-gate #define	MMU_TSB_SX		0x50 /* d tsb secondary extension reg */
637c478bd9Sstevel@tonic-gate #define	MMU_TSB_NX		0x58 /* i/d tsb nucleus extension reg */
647c478bd9Sstevel@tonic-gate #define	MMU_TAG_ACCESS_EXT	0x60 /* tlb tag access extension reg */
65e98fafb9Sjl139090 #define	MMU_SHARED_CONTEXT	0x68 /* SPARC64-VII shared context */
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /*
707c478bd9Sstevel@tonic-gate  * Synchronous Fault Status Register Layout
717c478bd9Sstevel@tonic-gate  *
727c478bd9Sstevel@tonic-gate  * IMMU and DMMU maintain their own SFSR Register
737c478bd9Sstevel@tonic-gate  * ______________________________________________________________________
747c478bd9Sstevel@tonic-gate  * |   Reserved   |  ASI | Reserved | FT | E | Cntx | PRIV | W | OW | FV|
757c478bd9Sstevel@tonic-gate  * |--------------|------|----------|----|---|------|------|---|----|---|
767c478bd9Sstevel@tonic-gate  *  63		24 23  16 15	  14 13 7  6  5	   4	3    2	  1   0
777c478bd9Sstevel@tonic-gate  *
787c478bd9Sstevel@tonic-gate  */
797c478bd9Sstevel@tonic-gate #define	SFSR_FV		0x00000001	/* fault valid */
807c478bd9Sstevel@tonic-gate #define	SFSR_OW		0x00000002	/* overwrite */
817c478bd9Sstevel@tonic-gate #define	SFSR_W		0x00000004	/* data write */
827c478bd9Sstevel@tonic-gate #define	SFSR_PR		0x00000008	/* privilege mode */
837c478bd9Sstevel@tonic-gate #define	SFSR_CTX	0x00000030	/* context id */
847c478bd9Sstevel@tonic-gate #define	SFSR_E		0x00000040	/* side-effect */
857c478bd9Sstevel@tonic-gate #define	SFSR_FT		0x00003F80	/* fault type mask */
867c478bd9Sstevel@tonic-gate #define	SFSR_ASI	0x00FF0000	/* ASI */
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /*
897c478bd9Sstevel@tonic-gate  * Definition of FT (Fault Type) bit field of sfsr.
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate #define	FT_NONE		0x00
927c478bd9Sstevel@tonic-gate #define	FT_PRIV		0x01		/* privilege violation */
937c478bd9Sstevel@tonic-gate #define	FT_SPEC_LD	0x02		/* speculative ld to e page */
947c478bd9Sstevel@tonic-gate #define	FT_ATOMIC_NC	0x04		/* atomic to nc page */
957c478bd9Sstevel@tonic-gate #define	FT_ILL_ALT	0x08		/* illegal lda/sta */
967c478bd9Sstevel@tonic-gate #define	FT_NFO		0x10		/* normal access to nfo page */
977c478bd9Sstevel@tonic-gate #define	FT_RANGE	0x20		/* dmmu or immu address out of range */
987c478bd9Sstevel@tonic-gate #define	FT_RANGE_REG	0x40		/* jump to reg out of range */
997c478bd9Sstevel@tonic-gate #define	SFSR_FT_SHIFT	7	/* amt. to shift right to get flt type */
1007c478bd9Sstevel@tonic-gate #define	X_FAULT_TYPE(x)	(((x) & SFSR_FT) >> SFSR_FT_SHIFT)
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * Defines for CT (ConText id) bit field of sfsr.
1047c478bd9Sstevel@tonic-gate  */
1057c478bd9Sstevel@tonic-gate #define	CT_PRIMARY	0x0	/* primary */
1067c478bd9Sstevel@tonic-gate #define	CT_SECONDARY	0x1	/* secondary */
1077c478bd9Sstevel@tonic-gate #define	CT_NUCLEUS	0x2	/* nucleus */
1087c478bd9Sstevel@tonic-gate #define	SFSR_CT_SHIFT	4
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #define	SFSR_ASI_SHIFT	16
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate /*
1137c478bd9Sstevel@tonic-gate  * MMU TAG TARGET register Layout
1147c478bd9Sstevel@tonic-gate  *
1157c478bd9Sstevel@tonic-gate  * +-----+---------+------+-------------------------+
1167c478bd9Sstevel@tonic-gate  * | 000 | context |  --  | virtual address [63:22] |
1177c478bd9Sstevel@tonic-gate  * +-----+---------+------+-------------------------+
1187c478bd9Sstevel@tonic-gate  *  63 61 60	 48 47	42 41			   0
1197c478bd9Sstevel@tonic-gate  */
1207c478bd9Sstevel@tonic-gate #define	TTARGET_CTX_SHIFT	48
1217c478bd9Sstevel@tonic-gate #define	TTARGET_VA_SHIFT	22
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate /*
1247c478bd9Sstevel@tonic-gate  * MMU TAG ACCESS register Layout
1257c478bd9Sstevel@tonic-gate  *
1267c478bd9Sstevel@tonic-gate  * +-------------------------+------------------+
1277c478bd9Sstevel@tonic-gate  * | virtual address [63:13] |  context [12:0]  |
1287c478bd9Sstevel@tonic-gate  * +-------------------------+------------------+
1297c478bd9Sstevel@tonic-gate  *  63			  13	12		0
1307c478bd9Sstevel@tonic-gate  */
1317c478bd9Sstevel@tonic-gate #define	TAGACC_CTX_MASK		0x1FFF
1327c478bd9Sstevel@tonic-gate #define	TAGACC_SHIFT		13
1337c478bd9Sstevel@tonic-gate #define	TAGACC_VADDR_MASK	(~TAGACC_CTX_MASK)
1347c478bd9Sstevel@tonic-gate #define	TAGACC_CTX_LSHIFT	(64 - TAGACC_SHIFT)
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate /*
1377c478bd9Sstevel@tonic-gate  * MMU DEMAP Register Layout
1387c478bd9Sstevel@tonic-gate  *
1397c478bd9Sstevel@tonic-gate  * +-------------------------+------+------+---------+-----+
1407c478bd9Sstevel@tonic-gate  * | virtual address [63:13] | rsvd | type | context |  0  |
1417c478bd9Sstevel@tonic-gate  * +-------------------------+------+------+---------+-----+
1427c478bd9Sstevel@tonic-gate  *  63			   13 12   8  7   6   5	    4 3   0
1437c478bd9Sstevel@tonic-gate  */
1447c478bd9Sstevel@tonic-gate #define	DEMAP_PRIMARY		(CT_PRIMARY << SFSR_CT_SHIFT)
1457c478bd9Sstevel@tonic-gate #define	DEMAP_SECOND		(CT_SECONDARY << SFSR_CT_SHIFT)
1467c478bd9Sstevel@tonic-gate #define	DEMAP_NUCLEUS		(CT_NUCLEUS << SFSR_CT_SHIFT)
1477c478bd9Sstevel@tonic-gate #define	DEMAP_TYPE_SHIFT	6
1487c478bd9Sstevel@tonic-gate #define	DEMAP_PAGE_TYPE		(0 << DEMAP_TYPE_SHIFT)
1497c478bd9Sstevel@tonic-gate #define	DEMAP_CTX_TYPE		(1 << DEMAP_TYPE_SHIFT)
1507c478bd9Sstevel@tonic-gate #define	DEMAP_ALL_TYPE		(2 << DEMAP_TYPE_SHIFT)
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate  * TLB DATA ACCESS Address Layout
1547c478bd9Sstevel@tonic-gate  *
1557c478bd9Sstevel@tonic-gate  * +-------------+---------------+---+
1567c478bd9Sstevel@tonic-gate  * +   Not used	 |   tlb entry	 | 0 |
1577c478bd9Sstevel@tonic-gate  * +-------------+---------------+---+
1587c478bd9Sstevel@tonic-gate  *  63		9 8		3 2  0
1597c478bd9Sstevel@tonic-gate  */
1607c478bd9Sstevel@tonic-gate #define	DTACC_SHIFT	0x3
1617c478bd9Sstevel@tonic-gate #define	DTACC_INC	0x8
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate  * TSB Register Layout
1657c478bd9Sstevel@tonic-gate  *
1667c478bd9Sstevel@tonic-gate  * split will always be 0.  It will not be supported by software.
1677c478bd9Sstevel@tonic-gate  *
1687c478bd9Sstevel@tonic-gate  * +----------------------+-------+-----+-------+
1697c478bd9Sstevel@tonic-gate  * +  tsb_base va [63:13] | split |  -  |  size |
1707c478bd9Sstevel@tonic-gate  * +----------------------+-------+-----+-------+
1717c478bd9Sstevel@tonic-gate  *  63			13   12	    11 3 2	0
1727c478bd9Sstevel@tonic-gate  */
1737c478bd9Sstevel@tonic-gate #define	TSBBASE_SHIFT		13
1747c478bd9Sstevel@tonic-gate #define	TSB_SZ_MASK		0x7
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate /*
1777c478bd9Sstevel@tonic-gate  * MMU TAG READ register Layout
1787c478bd9Sstevel@tonic-gate  *
1797c478bd9Sstevel@tonic-gate  * +-------------------------+------------------+
1807c478bd9Sstevel@tonic-gate  * | virtual address [63:13] |  context [12:0]  |
1817c478bd9Sstevel@tonic-gate  * +-------------------------+------------------+
1827c478bd9Sstevel@tonic-gate  *  63			  13	12		0
1837c478bd9Sstevel@tonic-gate  */
1847c478bd9Sstevel@tonic-gate #define	TAGREAD_CTX_MASK	0x1FFF
1857c478bd9Sstevel@tonic-gate #define	TAGREAD_SHIFT		13
1867c478bd9Sstevel@tonic-gate #define	TAGREAD_VADDR_MASK	(~TAGREAD_CTX_MASK)
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate /*
1897c478bd9Sstevel@tonic-gate  * MMU TAG ACCESS EXTENSION register Layout
1907c478bd9Sstevel@tonic-gate  *
1917c478bd9Sstevel@tonic-gate  * DTLB only
1927c478bd9Sstevel@tonic-gate  * +-----+-------+-------+-----+
1937c478bd9Sstevel@tonic-gate  * |  -  | pgsz1 | pgsz0 |  -  |
1947c478bd9Sstevel@tonic-gate  * +-----+-------+-------+-----+
1957c478bd9Sstevel@tonic-gate  *  63    21   19 18   16 15  0
1967c478bd9Sstevel@tonic-gate  */
1977c478bd9Sstevel@tonic-gate #define	TAGACCEXT_SHIFT		16
1987c478bd9Sstevel@tonic-gate #define	TAGACCEXT_MKSZPAIR(SZ1, SZ0)	(((SZ1) << 3) | (SZ0))
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate /*
201e98fafb9Sjl139090  * SPARC64-VII tsb prefetch register layout and VAs
202e98fafb9Sjl139090  *
203e98fafb9Sjl139090  * +-------------------------+-+---------+-+--+------+
204e98fafb9Sjl139090  * | virtual address [63:13] | | page_sz |V|  |TSB_sz|
205e98fafb9Sjl139090  * +-------------------------+-+---------+-+--+------+
206e98fafb9Sjl139090  *  63			  13	11	9 8    5    0
207e98fafb9Sjl139090  */
208e98fafb9Sjl139090 #define	VA_UTSBPREF_8K		0x00
209e98fafb9Sjl139090 #define	VA_UTSBPREF_4M		0x08
210e98fafb9Sjl139090 #define	VA_KTSBPREF_8K		0x40
211e98fafb9Sjl139090 #define	VA_KTSBPREF_4M		0x48
212e98fafb9Sjl139090 
213e98fafb9Sjl139090 /*
2147c478bd9Sstevel@tonic-gate  * MMU PRIMARY/SECONDARY CONTEXT register
2157c478bd9Sstevel@tonic-gate  */
2167c478bd9Sstevel@tonic-gate #define	CTXREG_CTX_MASK		0x1FFF
2178f230a59Sbs21162 #define	CTXREG_CTX_SHIFT	51
2187c478bd9Sstevel@tonic-gate #define	CTXREG_EXT_SHIFT	16
2197c478bd9Sstevel@tonic-gate #define	CTXREG_NEXT_SHIFT	58
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate /*
222*1426d65aSsm142603  * SPARC64-VII MMU SHARED CONTEXT register Layout
223*1426d65aSsm142603  *
224*1426d65aSsm142603  * +-----+----+-----+--------------------+-----+----+----+-------------------+
225*1426d65aSsm142603  * | --- | IV |  -- | Ishared ctx[44:32] | --- | DV | -- | Dshared ctx[12:0] |
226*1426d65aSsm142603  * +-----+----+-----+--------------------+-----+----+----+-------------------+
227*1426d65aSsm142603  * 63  48 47   46 45 44               32  31 16  15  14 13 12                0
228*1426d65aSsm142603  */
229*1426d65aSsm142603 #define	SHCTXREG_VALID_BIT	0x8000
230*1426d65aSsm142603 #define	SHCTXREG_CTX_LSHIFT	51
231*1426d65aSsm142603 
232*1426d65aSsm142603 /*
2337c478bd9Sstevel@tonic-gate  * The kernel always runs in KCONTEXT, and no user mappings
2347c478bd9Sstevel@tonic-gate  * are ever valid in it (so any user access pagefaults).
2357c478bd9Sstevel@tonic-gate  */
2367c478bd9Sstevel@tonic-gate #define	KCONTEXT	0
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate /*
2397c478bd9Sstevel@tonic-gate  * FLUSH_ADDR is used in the flush instruction to guarantee stores to mmu
2407c478bd9Sstevel@tonic-gate  * registers complete.  It is selected so it won't miss in the tlb.
2417c478bd9Sstevel@tonic-gate  */
2427c478bd9Sstevel@tonic-gate #define	FLUSH_ADDR	(KERNELBASE + 2 * MMU_PAGESIZE4M)
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2457c478bd9Sstevel@tonic-gate }
2467c478bd9Sstevel@tonic-gate #endif
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate #endif /* _SYS_MMU_H */
249