11.4Suwe/* $NetBSD: pmb.h,v 1.4 2020/07/30 21:25:43 uwe Exp $ */
21.1Suwe/*
31.1Suwe * Copyright (c) 2020 Valery Ushakov
41.1Suwe * All rights reserved.
51.1Suwe *
61.1Suwe * Redistribution and use in source and binary forms, with or without
71.1Suwe * modification, are permitted provided that the following conditions
81.1Suwe * are met:
91.1Suwe * 1. Redistributions of source code must retain the above copyright
101.1Suwe *    notice, this list of conditions and the following disclaimer.
111.1Suwe * 2. Redistributions in binary form must reproduce the above copyright
121.1Suwe *    notice, this list of conditions and the following disclaimer in the
131.1Suwe *    documentation and/or other materials provided with the distribution.
141.1Suwe *
151.1Suwe * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
161.1Suwe * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
171.1Suwe * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
181.1Suwe * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
191.1Suwe * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
201.1Suwe * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
211.1Suwe * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
221.1Suwe * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231.1Suwe * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
241.1Suwe * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
251.1Suwe */
261.1Suwe
271.1Suwe#ifndef _SH3_PMB_H_
281.1Suwe#define	_SH3_PMB_H_
291.1Suwe/*
301.1Suwe * ST40 Privileged Mapping Buffer (PMB)
311.1Suwe *
321.1Suwe * Original SuperH can handle only 29-bit external memory space.
331.1Suwe * "The physical address space is permanently mapped onto 29-bit
341.1Suwe * external memory space."  See <sh3/cpu.h>.
351.1Suwe *
361.1Suwe * ST40-200, ST40-300 and ST40-500 have "space enhanced" SE mode where
371.1Suwe * the mapping from the physical address space P1 and P2 segments to
381.1Suwe * the 32-bit external memory space is defined via 16-entry PMB.
391.1Suwe */
401.1Suwe
411.1Suwe
421.1Suwe/* on ST40-200 and ST40-500 SE bit is in MMUCR */
431.1Suwe#define ST40_MMUCR_SE			0x00000010
441.1Suwe
451.1Suwe
461.1Suwe/* Physical address space control register (ST4-300) */
471.2Suwe#define ST40_PASCR			0xff000070
481.1Suwe#define   ST40_PASCR_UB_MASK		  0x0000000f
491.1Suwe#define   ST40_PASCR_SE			  0x80000000
501.1Suwe
511.2Suwe#define   ST40_PASCR_BITS			\
521.2Suwe		"\177\020"			\
531.2Suwe		"b\037"  "SE\0"			\
541.2Suwe		"f\0\04" "UB\0"
551.2Suwe
561.1Suwe
571.1Suwe/* Memory-mapped PMB */
581.1Suwe#define ST40_PMB_ENTRY			16
591.1Suwe
601.1Suwe#define ST40_PMB_E_MASK			0x00000f00
611.1Suwe#define ST40_PMB_E_SHIFT		8
621.1Suwe
631.1Suwe
641.1Suwe/* PMB Address Array */
651.1Suwe#define ST40_PMB_AA			0xf6100000
661.1Suwe#define   ST40_PMB_AA_V			  0x00000100
671.1Suwe#define   ST40_PMB_AA_VPN_MASK		  0xff000000
681.1Suwe#define   ST40_PMB_AA_VPN_SHIFT		  24
691.1Suwe
701.2Suwe#define   ST40_PMB_AA_BITS			\
711.2Suwe	  "\177\020"				\
721.2Suwe	  "f\030\010" "VPN\0"			\
731.2Suwe	  "b\010"     "V\0"
741.2Suwe
751.1Suwe
761.1Suwe/* PMB Data Array */
771.1Suwe#define   ST40_PMB_DA			0xf7100000
781.1Suwe#define   ST40_PMB_DA_WT		0x00000001
791.1Suwe#define   ST40_PMB_DA_C			0x00000008
801.1Suwe#define   ST40_PMB_DA_UB		0x00000200
811.1Suwe#define   ST40_PMB_DA_SZ_MASK		0x00000090
821.1Suwe#define     ST40_PMB_DA_SZ_16M		0x00000000
831.1Suwe#define     ST40_PMB_DA_SZ_64M		0x00000010
841.1Suwe#define     ST40_PMB_DA_SZ_128M		0x00000080
851.1Suwe#define     ST40_PMB_DA_SZ_512M		0x00000090
861.1Suwe#define   ST40_PMB_DA_V			0x00000100
871.1Suwe#define   ST40_PMB_DA_PPN_MASK		0xff000000
881.1Suwe#define   ST40_PMB_DA_PPN_SHIFT		24
891.1Suwe
901.3Suwe/*
911.3Suwe * size field is not continuous hence the kludgy list with all the
921.3Suwe * possible junk bits in the middle.
931.3Suwe */
941.2Suwe#define   ST40_PMB_DA_BITS			\
951.2Suwe	  "\177\020"				\
961.2Suwe	  "f\030\010" "PPN\0"			\
971.2Suwe	  "b\010"     "V\0"			\
981.2Suwe	  "F\04\04"   "\0"			\
991.3Suwe	    ":\017"   "512M\0"			\
1001.3Suwe	    ":\016"   "128M\0"			\
1011.3Suwe	    ":\015"   "512M\0"			\
1021.3Suwe	    ":\014"   "128M\0"			\
1031.3Suwe	    ":\013"   "512M\0"			\
1041.3Suwe	    ":\012"   "128M\0"			\
1051.2Suwe	    ":\011"   "512M\0"			\
1061.2Suwe	    ":\010"   "128M\0"			\
1071.3Suwe	    ":\007"    "64M\0"			\
1081.3Suwe	    ":\006"    "16M\0"			\
1091.3Suwe	    ":\005"    "64M\0"			\
1101.3Suwe	    ":\004"    "16M\0"			\
1111.3Suwe	    ":\003"    "64M\0"			\
1121.3Suwe	    ":\002"    "16M\0"			\
1131.3Suwe	    ":\001"    "64M\0"			\
1141.3Suwe	    ":\000"    "16M\0"			\
1151.2Suwe	  "b\011"     "UB\0"			\
1161.2Suwe	  "b\03"      "C\0"			\
1171.2Suwe	  "F\0\01"    "\0"			\
1181.2Suwe	    ":\01"    "WT\0"			\
1191.2Suwe	    ":\0"     "CB\0"
1201.2Suwe
1211.4Suwe
1221.4Suwe#ifndef _LOCORE
1231.4Suwevoid st40_pmb_init(int);
1241.4Suwe#endif	/* !_LOCORE */
1251.4Suwe
1261.1Suwe#endif	/* !_SH3_PMB_H_ */
127