xref: /openbsd/sys/arch/sh/include/mmu_sh3.h (revision 3cab2bb3)
1 /*	$OpenBSD: mmu_sh3.h,v 1.2 2008/06/26 05:42:12 ray Exp $	*/
2 /*	$NetBSD: mmu_sh3.h,v 1.6 2006/03/04 01:55:03 uwe Exp $	*/
3 
4 /*-
5  * Copyright (c) 2002 The NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to The NetBSD Foundation
9  * by UCHIYAMA Yasushi.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _SH_MMU_SH3_H_
34 #define	_SH_MMU_SH3_H_
35 #include <sh/devreg.h>
36 
37 /* 128-entry 4-way set-associative */
38 #define	SH3_MMU_WAY			4
39 #define	SH3_MMU_ENTRY			32
40 
41 #define	SH3_PTEH			0xfffffff0
42 #define	  SH3_PTEH_ASID_MASK		  0x000000ff
43 #define	  SH3_PTEH_VPN_MASK		  0xfffffc00
44 #define	SH3_PTEL			0xfffffff4
45 #define	  SH3_PTEL_HWBITS		  0x1ffff17e /* [28:12][8][6:1] */
46 #define	SH3_TTB				0xfffffff8
47 #define	SH3_TEA				0xfffffffc
48 #define	SH3_MMUCR			0xffffffe0
49 #define	  SH3_MMUCR_AT			  0x00000001
50 #define	  SH3_MMUCR_IX			  0x00000002
51 #define	  SH3_MMUCR_TF			  0x00000004
52 #define	  SH3_MMUCR_RC			  0x00000030
53 #define	  SH3_MMUCR_SV			  0x00000100
54 
55 /*
56  * memory-mapped TLB
57  */
58 /* Address array */
59 #define	SH3_MMUAA			0xf2000000
60 /* address specification */
61 #define	  SH3_MMU_VPN_SHIFT		  12
62 #define	  SH3_MMU_VPN_MASK		  0x0001f000	/* [16:12] */
63 #define	  SH3_MMU_WAY_SHIFT		  8
64 #define	  SH3_MMU_WAY_MASK		  0x00000300	/* [9:8] */
65 /* data specification */
66 #define	  SH3_MMU_D_VALID		  0x00000100
67 #define	  SH3_MMUAA_D_VPN_MASK_1K	  0xfffe0c00	/* [31:17][11:10] */
68 #define	  SH3_MMUAA_D_VPN_MASK_4K	  0xfffe0000	/* [31:17] */
69 #define	  SH3_MMUAA_D_ASID_MASK		  0x000000ff
70 
71 /* Data array */
72 #define	SH3_MMUDA			0xf3000000
73 #define	  SH3_MMUDA_D_PPN_MASK		  0xfffffc00
74 #define	  SH3_MMUDA_D_V			  0x00000100
75 #define	  SH3_MMUDA_D_PR_SHIFT		  5
76 #define	  SH3_MMUDA_D_PR_MASK		  0x00000060	/* [6:5] */
77 #define	  SH3_MMUDA_D_SZ		  0x00000010
78 #define	  SH3_MMUDA_D_C			  0x00000008
79 #define	  SH3_MMUDA_D_D			  0x00000004
80 #define	  SH3_MMUDA_D_SH		  0x00000002
81 
82 #define	SH3_TLB_DISABLE	*(volatile uint32_t *)SH3_MMUCR = SH3_MMUCR_TF
83 #endif /* !_SH_MMU_SH3_H_ */
84