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