Tue Jul 21 07:08:57 2009 UTC ()
protect C constructs from assembler source inclusion.


(nisimura)
diff -r1.12 -r1.13 src/sys/arch/powerpc/include/oea/bat.h

cvs diff -r1.12 -r1.13 src/sys/arch/powerpc/include/oea/bat.h (switch to unified diff)

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