Home | History | Annotate | Line # | Download | only in oea
bat.h revision 1.1
      1 /*	$NetBSD: bat.h,v 1.1 2003/02/03 17:10:05 matt Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the NetBSD
     21  *	Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
     41  * Copyright (C) 1995, 1996 TooLs GmbH.
     42  * All rights reserved.
     43  *
     44  * Redistribution and use in source and binary forms, with or without
     45  * modification, are permitted provided that the following conditions
     46  * are met:
     47  * 1. Redistributions of source code must retain the above copyright
     48  *    notice, this list of conditions and the following disclaimer.
     49  * 2. Redistributions in binary form must reproduce the above copyright
     50  *    notice, this list of conditions and the following disclaimer in the
     51  *    documentation and/or other materials provided with the distribution.
     52  * 3. All advertising materials mentioning features or use of this software
     53  *    must display the following acknowledgement:
     54  *	This product includes software developed by TooLs GmbH.
     55  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     56  *    derived from this software without specific prior written permission.
     57  *
     58  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     59  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     60  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     61  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     62  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     63  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     64  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     65  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     66  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     67  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     68  */
     69 
     70 #ifndef	_POWERPC_OEA_BAT_H_
     71 #define	_POWERPC_OEA_BAT_H_
     72 
     73 struct bat {
     74 	u_int32_t batu;
     75 	u_int32_t batl;
     76 };
     77 
     78 /* Lower BAT bits (all but PowerPC 601): */
     79 #define	BAT_PBS		0xfffe0000	/* physical block start */
     80 #define	BAT_W		0x00000040	/* 1 = write-through, 0 = write-back */
     81 #define	BAT_I		0x00000020	/* cache inhibit */
     82 #define	BAT_M		0x00000010	/* memory coherency enable */
     83 #define	BAT_G		0x00000008	/* guarded region (not on 601) */
     84 
     85 #define	BAT_PP      0x00000003	/* PP mask */
     86 #define	BAT_PP_NONE	0x00000000	/* no access permission */
     87 #define	BAT_PP_RO_S	0x00000001	/* read-only (soft) */
     88 #define	BAT_PP_RW	0x00000002	/* read/write */
     89 #define	BAT_PP_RO	0x00000003	/* read-only */
     90 
     91 /* Upper BAT bits (all but PowerPC 601): */
     92 #define	BAT_EBS		0xfffe0000	/* effective block start */
     93 #define	BAT_BL		0x00001ffc	/* block length */
     94 #define	BAT_Vs		0x00000002	/* valid in supervisor mode */
     95 #define	BAT_Vu		0x00000001	/* valid in user mode */
     96 
     97 #define	BAT_V		(BAT_Vs|BAT_Vu)
     98 
     99 /* Block Length encoding (all but PowerPC 601): */
    100 #define	BAT_BL_128K	0x00000000
    101 #define	BAT_BL_256K	0x00000004
    102 #define	BAT_BL_512K	0x0000000c
    103 #define	BAT_BL_1M	0x0000001c
    104 #define	BAT_BL_2M	0x0000003c
    105 #define	BAT_BL_4M	0x0000007c
    106 #define	BAT_BL_8M	0x000000fc
    107 #define	BAT_BL_16M	0x000001fc
    108 #define	BAT_BL_32M	0x000003fc
    109 #define	BAT_BL_64M	0x000007fc
    110 #define	BAT_BL_128M	0x00000ffc
    111 #define	BAT_BL_256M	0x00001ffc
    112 
    113 #define	BATU(va, len, v)						\
    114 	(((va) & BAT_EBS) | ((len) & BAT_BL) | ((v) & BAT_V))
    115 
    116 #define	BATL(pa, wimg, pp)						\
    117 	(((pa) & BAT_PBS) | (wimg) | (pp))
    118 
    119 #define BAT_VA_MATCH_P(batu,va) \
    120   (((~(((batu)&BAT_BL)<<15))&(va)&BAT_EBS)==((batu)&BAT_EBS))
    121 
    122 #define BAT_VALID_P(batu, msr) \
    123   (((msr)&PSL_PR)?(((batu)&BAT_Vu)==BAT_Vu):(((batu)&BAT_Vs)==BAT_Vs))
    124 
    125 /* Lower BAT bits (PowerPC 601): */
    126 #define	BAT601_PBN	0xfffe0000	/* physical block number */
    127 #define	BAT601_V	0x00000040	/* valid */
    128 #define	BAT601_BSM	0x0000003f	/* block size mask */
    129 
    130 /* Upper BAT bits (PowerPC 601): */
    131 #define	BAT601_BLPI	0xfffe0000	/* block logical page index */
    132 #define	BAT601_W	0x00000040	/* 1 = write-through, 0 = write-back */
    133 #define	BAT601_I	0x00000020	/* cache inhibit */
    134 #define	BAT601_M	0x00000010	/* memory coherency enable */
    135 #define	BAT601_Ks	0x00000008	/* key-supervisor */
    136 #define	BAT601_Ku	0x00000004	/* key-user */
    137 
    138 /*
    139  * Permission bits on the PowerPC 601 are modified by the appropriate
    140  * Key bit:
    141  *
    142  *	Key	PP	Access
    143  *	0	NONE	read/write
    144  *	0	RO_S	read/write
    145  *	0	RW	read/write
    146  *	0	RO	read-only
    147  *
    148  *	1	NONE	none
    149  *	1	RO_S	read-only
    150  *	1	RW	read/write
    151  *	1	RO	read-only
    152  */
    153 #define	BAT601_PP	0x00000003
    154 #define	BAT601_PP_NONE	0x00000000	/* no access permission */
    155 #define	BAT601_PP_RO_S	0x00000001	/* read-only (soft) */
    156 #define	BAT601_PP_RW	0x00000002	/* read/write */
    157 #define	BAT601_PP_RO	0x00000003	/* read-only */
    158 
    159 /* Block Size Mask encoding (PowerPC 601): */
    160 #define	BAT601_BSM_128K	0x00000000
    161 #define	BAT601_BSM_256K	0x00000001
    162 #define	BAT601_BSM_512K	0x00000003
    163 #define	BAT601_BSM_1M	0x00000007
    164 #define	BAT601_BSM_2M	0x0000000f
    165 #define	BAT601_BSM_4M	0x0000001f
    166 #define	BAT601_BSM_8M	0x0000003f
    167 
    168 #define	BATU601(va, wim, key, pp)					\
    169 	(((va) & BAT601_BLPI) | (wim) | (key) | (pp))
    170 
    171 #define	BATL601(pa, size, v)						\
    172 	(((pa) & BAT601_PBN) | (v) | (size))
    173 
    174 #define	BAT601_VA_MATCH_P(batu, batl, va)				\
    175 	(((~(((batl)&BAT601_BSM)<<17))&(va)&BAT601_BLPI)==((batu)&BAT601_BLPI))
    176 
    177 #define	BAT601_VALID_P(batl) \
    178 	((batl) & BAT601_V)
    179 
    180 #ifdef	_KERNEL
    181 void oea_batinit(paddr_t, ...);
    182 void oea_iobat_add(paddr_t, register_t);
    183 extern struct bat battable[];
    184 #endif
    185 
    186 #endif	/* _POWERPC_OEA_BAT_H_ */
    187