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