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