/*-1* SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause2*3* Copyright (c) 1999 The NetBSD Foundation, Inc.4* All rights reserved.5*6* This code is derived from software contributed to The NetBSD Foundation7* by Jason R. Thorpe.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions and the following disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17*18* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS19* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED20* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR21* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS22* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR23* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF24* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS25* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN26* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)27* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE28* POSSIBILITY OF SUCH DAMAGE.29*/3031/*-32* Copyright (C) 1995, 1996 Wolfgang Solfrank.33* Copyright (C) 1995, 1996 TooLs GmbH.34* All rights reserved.35*36* Redistribution and use in source and binary forms, with or without37* modification, are permitted provided that the following conditions38* are met:39* 1. Redistributions of source code must retain the above copyright40* notice, this list of conditions and the following disclaimer.41* 2. Redistributions in binary form must reproduce the above copyright42* notice, this list of conditions and the following disclaimer in the43* documentation and/or other materials provided with the distribution.44* 3. All advertising materials mentioning features or use of this software45* must display the following acknowledgement:46* This product includes software developed by TooLs GmbH.47* 4. The name of TooLs GmbH may not be used to endorse or promote products48* derived from this software without specific prior written permission.49*50* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR51* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES52* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.53* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,54* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,55* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;56* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,57* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR58* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF59* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.60*61* $NetBSD: bat.h,v 1.2 1999/12/18 01:36:06 thorpej Exp $62*/6364#ifndef _MACHINE_BAT_H_65#define _MACHINE_BAT_H_6667#ifndef LOCORE68struct bat {69u_int32_t batu;70u_int32_t batl;71};72#endif7374/* Lower BAT bits (all but PowerPC 601): */75#define BAT_PBS 0xfffe0000 /* physical block start */76#define BAT_W 0x00000040 /* 1 = write-through, 0 = write-back */77#define BAT_I 0x00000020 /* cache inhibit */78#define BAT_M 0x00000010 /* memory coherency enable */79#define BAT_G 0x00000008 /* guarded region */8081#define BAT_PP_NONE 0x00000000 /* no access permission */82#define BAT_PP_RO_S 0x00000001 /* read-only (soft) */83#define BAT_PP_RW 0x00000002 /* read/write */84#define BAT_PP_RO 0x00000003 /* read-only */8586/* Upper BAT bits (all but PowerPC 601): */87#define BAT_EBS 0xfffe0000 /* effective block start */88#define BAT_BL 0x00001ffc /* block length */89#define BAT_Vs 0x00000002 /* valid in supervisor mode */90#define BAT_Vu 0x00000001 /* valid in user mode */9192#define BAT_V (BAT_Vs|BAT_Vu)9394/* Block Length encoding (all but PowerPC 601): */95#define BAT_BL_128K 0x0000000096#define BAT_BL_256K 0x0000000497#define BAT_BL_512K 0x0000000c98#define BAT_BL_1M 0x0000001c99#define BAT_BL_2M 0x0000003c100#define BAT_BL_4M 0x0000007c101#define BAT_BL_8M 0x000000fc102#define BAT_BL_16M 0x000001fc103#define BAT_BL_32M 0x000003fc104#define BAT_BL_64M 0x000007fc105#define BAT_BL_128M 0x00000ffc106#define BAT_BL_256M 0x00001ffc107108#define BATU(va, len, v) \109(((va) & BAT_EBS) | ((len) & BAT_BL) | ((v) & BAT_V))110111#define BATL(pa, wimg, pp) \112(((pa) & BAT_PBS) | (wimg) | (pp))113114/* Lower BAT bits (PowerPC 601): */115#define BAT601_PBN 0xfffe0000 /* physical block number */116#define BAT601_V 0x00000040 /* valid */117#define BAT601_BSM 0x0000003f /* block size mask */118119/* Upper BAT bits (PowerPC 601): */120#define BAT601_BLPI 0xfffe0000 /* block logical page index */121#define BAT601_W 0x00000040 /* 1 = write-through, 0 = write-back */122#define BAT601_I 0x00000020 /* cache inhibit */123#define BAT601_M 0x00000010 /* memory coherency enable */124#define BAT601_Ks 0x00000008 /* key-supervisor */125#define BAT601_Ku 0x00000004 /* key-user */126127/*128* Permission bits on the PowerPC 601 are modified by the appropriate129* Key bit:130*131* Key PP Access132* 0 NONE read/write133* 0 RO_S read/write134* 0 RW read/write135* 0 RO read-only136*137* 1 NONE none138* 1 RO_S read-only139* 1 RW read/write140* 1 RO read-only141*/142#define BAT601_PP_NONE 0x00000000 /* no access permission */143#define BAT601_PP_RO_S 0x00000001 /* read-only (soft) */144#define BAT601_PP_RW 0x00000002 /* read/write */145#define BAT601_PP_RO 0x00000003 /* read-only */146147/* Block Size Mask encoding (PowerPC 601): */148#define BAT601_BSM_128K 0x00000000149#define BAT601_BSM_256K 0x00000001150#define BAT601_BSM_512K 0x00000003151#define BAT601_BSM_1M 0x00000007152#define BAT601_BSM_2M 0x0000000f153#define BAT601_BSM_4M 0x0000001f154#define BAT601_BSM_8M 0x0000003f155156#define BATU601(va, wim, key, pp) \157(((va) & BAT601_BLPI) | (wim) | (key) | (pp))158159#define BATL601(pa, size, v) \160(((pa) & BAT601_PBN) | (v) | (size))161162#if defined(_KERNEL) && !defined(LOCORE)163extern struct bat battable[16];164#endif165166#endif /* _MACHINE_BAT_H_ */167168169