xref: /netbsd-src/sys/arch/sh3/include/pmb.h (revision 8a6032cf1b4bbbc0400a91107b70f85e9a47fe1e)
1*8a6032cfSuwe /* $NetBSD: pmb.h,v 1.4 2020/07/30 21:25:43 uwe Exp $ */
2a9db0369Suwe /*
3a9db0369Suwe  * Copyright (c) 2020 Valery Ushakov
4a9db0369Suwe  * All rights reserved.
5a9db0369Suwe  *
6a9db0369Suwe  * Redistribution and use in source and binary forms, with or without
7a9db0369Suwe  * modification, are permitted provided that the following conditions
8a9db0369Suwe  * are met:
9a9db0369Suwe  * 1. Redistributions of source code must retain the above copyright
10a9db0369Suwe  *    notice, this list of conditions and the following disclaimer.
11a9db0369Suwe  * 2. Redistributions in binary form must reproduce the above copyright
12a9db0369Suwe  *    notice, this list of conditions and the following disclaimer in the
13a9db0369Suwe  *    documentation and/or other materials provided with the distribution.
14a9db0369Suwe  *
15a9db0369Suwe  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16a9db0369Suwe  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17a9db0369Suwe  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18a9db0369Suwe  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19a9db0369Suwe  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20a9db0369Suwe  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21a9db0369Suwe  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22a9db0369Suwe  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23a9db0369Suwe  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24a9db0369Suwe  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25a9db0369Suwe  */
26a9db0369Suwe 
27a9db0369Suwe #ifndef _SH3_PMB_H_
28a9db0369Suwe #define	_SH3_PMB_H_
29a9db0369Suwe /*
30a9db0369Suwe  * ST40 Privileged Mapping Buffer (PMB)
31a9db0369Suwe  *
32a9db0369Suwe  * Original SuperH can handle only 29-bit external memory space.
33a9db0369Suwe  * "The physical address space is permanently mapped onto 29-bit
34a9db0369Suwe  * external memory space."  See <sh3/cpu.h>.
35a9db0369Suwe  *
36a9db0369Suwe  * ST40-200, ST40-300 and ST40-500 have "space enhanced" SE mode where
37a9db0369Suwe  * the mapping from the physical address space P1 and P2 segments to
38a9db0369Suwe  * the 32-bit external memory space is defined via 16-entry PMB.
39a9db0369Suwe  */
40a9db0369Suwe 
41a9db0369Suwe 
42a9db0369Suwe /* on ST40-200 and ST40-500 SE bit is in MMUCR */
43a9db0369Suwe #define ST40_MMUCR_SE			0x00000010
44a9db0369Suwe 
45a9db0369Suwe 
46a9db0369Suwe /* Physical address space control register (ST4-300) */
47bae4d750Suwe #define ST40_PASCR			0xff000070
48a9db0369Suwe #define   ST40_PASCR_UB_MASK		  0x0000000f
49a9db0369Suwe #define   ST40_PASCR_SE			  0x80000000
50a9db0369Suwe 
51bae4d750Suwe #define   ST40_PASCR_BITS			\
52bae4d750Suwe 		"\177\020"			\
53bae4d750Suwe 		"b\037"  "SE\0"			\
54bae4d750Suwe 		"f\0\04" "UB\0"
55bae4d750Suwe 
56a9db0369Suwe 
57a9db0369Suwe /* Memory-mapped PMB */
58a9db0369Suwe #define ST40_PMB_ENTRY			16
59a9db0369Suwe 
60a9db0369Suwe #define ST40_PMB_E_MASK			0x00000f00
61a9db0369Suwe #define ST40_PMB_E_SHIFT		8
62a9db0369Suwe 
63a9db0369Suwe 
64a9db0369Suwe /* PMB Address Array */
65a9db0369Suwe #define ST40_PMB_AA			0xf6100000
66a9db0369Suwe #define   ST40_PMB_AA_V			  0x00000100
67a9db0369Suwe #define   ST40_PMB_AA_VPN_MASK		  0xff000000
68a9db0369Suwe #define   ST40_PMB_AA_VPN_SHIFT		  24
69a9db0369Suwe 
70bae4d750Suwe #define   ST40_PMB_AA_BITS			\
71bae4d750Suwe 	  "\177\020"				\
72bae4d750Suwe 	  "f\030\010" "VPN\0"			\
73bae4d750Suwe 	  "b\010"     "V\0"
74bae4d750Suwe 
75a9db0369Suwe 
76a9db0369Suwe /* PMB Data Array */
77a9db0369Suwe #define   ST40_PMB_DA			0xf7100000
78a9db0369Suwe #define   ST40_PMB_DA_WT		0x00000001
79a9db0369Suwe #define   ST40_PMB_DA_C			0x00000008
80a9db0369Suwe #define   ST40_PMB_DA_UB		0x00000200
81a9db0369Suwe #define   ST40_PMB_DA_SZ_MASK		0x00000090
82a9db0369Suwe #define     ST40_PMB_DA_SZ_16M		0x00000000
83a9db0369Suwe #define     ST40_PMB_DA_SZ_64M		0x00000010
84a9db0369Suwe #define     ST40_PMB_DA_SZ_128M		0x00000080
85a9db0369Suwe #define     ST40_PMB_DA_SZ_512M		0x00000090
86a9db0369Suwe #define   ST40_PMB_DA_V			0x00000100
87a9db0369Suwe #define   ST40_PMB_DA_PPN_MASK		0xff000000
88a9db0369Suwe #define   ST40_PMB_DA_PPN_SHIFT		24
89a9db0369Suwe 
908f50f682Suwe /*
918f50f682Suwe  * size field is not continuous hence the kludgy list with all the
928f50f682Suwe  * possible junk bits in the middle.
938f50f682Suwe  */
94bae4d750Suwe #define   ST40_PMB_DA_BITS			\
95bae4d750Suwe 	  "\177\020"				\
96bae4d750Suwe 	  "f\030\010" "PPN\0"			\
97bae4d750Suwe 	  "b\010"     "V\0"			\
98bae4d750Suwe 	  "F\04\04"   "\0"			\
998f50f682Suwe 	    ":\017"   "512M\0"			\
1008f50f682Suwe 	    ":\016"   "128M\0"			\
1018f50f682Suwe 	    ":\015"   "512M\0"			\
1028f50f682Suwe 	    ":\014"   "128M\0"			\
1038f50f682Suwe 	    ":\013"   "512M\0"			\
1048f50f682Suwe 	    ":\012"   "128M\0"			\
105bae4d750Suwe 	    ":\011"   "512M\0"			\
106bae4d750Suwe 	    ":\010"   "128M\0"			\
1078f50f682Suwe 	    ":\007"    "64M\0"			\
1088f50f682Suwe 	    ":\006"    "16M\0"			\
1098f50f682Suwe 	    ":\005"    "64M\0"			\
1108f50f682Suwe 	    ":\004"    "16M\0"			\
1118f50f682Suwe 	    ":\003"    "64M\0"			\
1128f50f682Suwe 	    ":\002"    "16M\0"			\
1138f50f682Suwe 	    ":\001"    "64M\0"			\
1148f50f682Suwe 	    ":\000"    "16M\0"			\
115bae4d750Suwe 	  "b\011"     "UB\0"			\
116bae4d750Suwe 	  "b\03"      "C\0"			\
117bae4d750Suwe 	  "F\0\01"    "\0"			\
118bae4d750Suwe 	    ":\01"    "WT\0"			\
119bae4d750Suwe 	    ":\0"     "CB\0"
120bae4d750Suwe 
121*8a6032cfSuwe 
122*8a6032cfSuwe #ifndef _LOCORE
123*8a6032cfSuwe void st40_pmb_init(int);
124*8a6032cfSuwe #endif	/* !_LOCORE */
125*8a6032cfSuwe 
126a9db0369Suwe #endif	/* !_SH3_PMB_H_ */
127