Tue May 26 03:30:25 2009 UTC ()
do as phone suggested - remove sparc_bus_map_large() again and use a flag
instead ( BUS_SPACE_MAP_LARGE )


(macallan)
diff -r1.55 -r1.56 src/sys/arch/sparc/include/bus.h
diff -r1.293 -r1.294 src/sys/arch/sparc/sparc/machdep.c

cvs diff -r1.55 -r1.56 src/sys/arch/sparc/include/Attic/bus.h (switch to unified diff)

--- src/sys/arch/sparc/include/Attic/bus.h 2009/04/16 16:55:00 1.55
+++ src/sys/arch/sparc/include/Attic/bus.h 2009/05/26 03:30:25 1.56
@@ -1,1358 +1,1355 @@ @@ -1,1358 +1,1355 @@
1/* $NetBSD: bus.h,v 1.55 2009/04/16 16:55:00 macallan Exp $ */ 1/* $NetBSD: bus.h,v 1.56 2009/05/26 03:30:25 macallan Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998, 2001 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 of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer. 15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright 16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the 17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution. 18 * documentation and/or other materials provided with the distribution.
19 * 19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33/* 33/*
34 * Copyright (c) 1996 Charles M. Hannum. All rights reserved. 34 * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
35 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 35 * Copyright (c) 1996 Christopher G. Demetriou. 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 Christopher G. Demetriou 47 * This product includes software developed by Christopher G. Demetriou
48 * for the NetBSD Project. 48 * for the NetBSD Project.
49 * 4. The name of the author may not be used to endorse or promote products 49 * 4. The name of the author may not be used to endorse or promote products
50 * derived from this software without specific prior written permission 50 * derived from this software without specific prior written permission
51 * 51 *
52 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 52 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
53 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 53 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
54 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 54 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 */ 62 */
63 63
64#ifndef _SPARC_BUS_H_ 64#ifndef _SPARC_BUS_H_
65#define _SPARC_BUS_H_ 65#define _SPARC_BUS_H_
66 66
67#define SPARC_BUS_SPACE 0 67#define SPARC_BUS_SPACE 0
68 68
69/* 69/*
70 * Bus address and size types 70 * Bus address and size types
71 */ 71 */
72typedef u_long bus_space_handle_t; 72typedef u_long bus_space_handle_t;
73typedef uint64_t bus_addr_t; 73typedef uint64_t bus_addr_t;
74typedef u_long bus_size_t; 74typedef u_long bus_size_t;
75 75
76/* bus_addr_t is extended to 64-bits and has the iospace encoded in it */ 76/* bus_addr_t is extended to 64-bits and has the iospace encoded in it */
77#define BUS_ADDR_IOSPACE(x) ((x)>>32) 77#define BUS_ADDR_IOSPACE(x) ((x)>>32)
78#define BUS_ADDR_PADDR(x) ((x)&0xffffffff) 78#define BUS_ADDR_PADDR(x) ((x)&0xffffffff)
79#define BUS_ADDR(io, pa) \ 79#define BUS_ADDR(io, pa) \
80 ((((uint64_t)(uint32_t)(io))<<32) | (uint32_t)(pa)) 80 ((((uint64_t)(uint32_t)(io))<<32) | (uint32_t)(pa))
81 81
82#define __BUS_SPACE_HAS_STREAM_METHODS 1 82#define __BUS_SPACE_HAS_STREAM_METHODS 1
83 83
84/* 84/*
85 * Access methods for bus resources and address space. 85 * Access methods for bus resources and address space.
86 */ 86 */
87typedef struct sparc_bus_space_tag *bus_space_tag_t; 87typedef struct sparc_bus_space_tag *bus_space_tag_t;
88 88
89struct sparc_bus_space_tag { 89struct sparc_bus_space_tag {
90 void *cookie; 90 void *cookie;
91 bus_space_tag_t parent; 91 bus_space_tag_t parent;
92 92
93 /* 93 /*
94 * Windows onto the parent bus that this tag maps. If ranges 94 * Windows onto the parent bus that this tag maps. If ranges
95 * is non-NULL, the address will be translated, and recursively 95 * is non-NULL, the address will be translated, and recursively
96 * mapped via the parent tag. 96 * mapped via the parent tag.
97 */ 97 */
98 struct openprom_range *ranges; 98 struct openprom_range *ranges;
99 int nranges; 99 int nranges;
100 100
101 int (*sparc_bus_map)( 101 int (*sparc_bus_map)(
102 bus_space_tag_t, 102 bus_space_tag_t,
103 bus_addr_t, 103 bus_addr_t,
104 bus_size_t, 104 bus_size_t,
105 int, /*flags*/ 105 int, /*flags*/
106 vaddr_t, /*preferred vaddr*/ 106 vaddr_t, /*preferred vaddr*/
107 bus_space_handle_t *); 107 bus_space_handle_t *);
108 int (*sparc_bus_unmap)( 108 int (*sparc_bus_unmap)(
109 bus_space_tag_t, 109 bus_space_tag_t,
110 bus_space_handle_t, 110 bus_space_handle_t,
111 bus_size_t); 111 bus_size_t);
112 int (*sparc_bus_subregion)( 112 int (*sparc_bus_subregion)(
113 bus_space_tag_t, 113 bus_space_tag_t,
114 bus_space_handle_t, 114 bus_space_handle_t,
115 bus_size_t, /*offset*/ 115 bus_size_t, /*offset*/
116 bus_size_t, /*size*/ 116 bus_size_t, /*size*/
117 bus_space_handle_t *); 117 bus_space_handle_t *);
118 118
119 void (*sparc_bus_barrier)( 119 void (*sparc_bus_barrier)(
120 bus_space_tag_t, 120 bus_space_tag_t,
121 bus_space_handle_t, 121 bus_space_handle_t,
122 bus_size_t, /*offset*/ 122 bus_size_t, /*offset*/
123 bus_size_t, /*size*/ 123 bus_size_t, /*size*/
124 int); /*flags*/ 124 int); /*flags*/
125 125
126 paddr_t (*sparc_bus_mmap)( 126 paddr_t (*sparc_bus_mmap)(
127 bus_space_tag_t, 127 bus_space_tag_t,
128 bus_addr_t, 128 bus_addr_t,
129 off_t, 129 off_t,
130 int, /*prot*/ 130 int, /*prot*/
131 int); /*flags*/ 131 int); /*flags*/
132 132
133 void *(*sparc_intr_establish)( 133 void *(*sparc_intr_establish)(
134 bus_space_tag_t, 134 bus_space_tag_t,
135 int, /*bus-specific intr*/ 135 int, /*bus-specific intr*/
136 int, /*device class level, 136 int, /*device class level,
137 see machine/intr.h*/ 137 see machine/intr.h*/
138 int (*)(void *), /*handler*/ 138 int (*)(void *), /*handler*/
139 void *, /*handler arg*/ 139 void *, /*handler arg*/
140 void (*)(void)); /*optional fast vector*/ 140 void (*)(void)); /*optional fast vector*/
141 141
142 uint8_t (*sparc_read_1)( 142 uint8_t (*sparc_read_1)(
143 bus_space_tag_t space, 143 bus_space_tag_t space,
144 bus_space_handle_t handle, 144 bus_space_handle_t handle,
145 bus_size_t offset); 145 bus_size_t offset);
146 146
147 uint16_t (*sparc_read_2)( 147 uint16_t (*sparc_read_2)(
148 bus_space_tag_t space, 148 bus_space_tag_t space,
149 bus_space_handle_t handle, 149 bus_space_handle_t handle,
150 bus_size_t offset); 150 bus_size_t offset);
151 151
152 uint32_t (*sparc_read_4)( 152 uint32_t (*sparc_read_4)(
153 bus_space_tag_t space, 153 bus_space_tag_t space,
154 bus_space_handle_t handle, 154 bus_space_handle_t handle,
155 bus_size_t offset); 155 bus_size_t offset);
156 156
157 uint64_t (*sparc_read_8)( 157 uint64_t (*sparc_read_8)(
158 bus_space_tag_t space, 158 bus_space_tag_t space,
159 bus_space_handle_t handle, 159 bus_space_handle_t handle,
160 bus_size_t offset); 160 bus_size_t offset);
161 161
162 void (*sparc_write_1)( 162 void (*sparc_write_1)(
163 bus_space_tag_t space, 163 bus_space_tag_t space,
164 bus_space_handle_t handle, 164 bus_space_handle_t handle,
165 bus_size_t offset, 165 bus_size_t offset,
166 uint8_t value); 166 uint8_t value);
167 167
168 void (*sparc_write_2)( 168 void (*sparc_write_2)(
169 bus_space_tag_t space, 169 bus_space_tag_t space,
170 bus_space_handle_t handle, 170 bus_space_handle_t handle,
171 bus_size_t offset, 171 bus_size_t offset,
172 uint16_t value); 172 uint16_t value);
173 173
174 void (*sparc_write_4)( 174 void (*sparc_write_4)(
175 bus_space_tag_t space, 175 bus_space_tag_t space,
176 bus_space_handle_t handle, 176 bus_space_handle_t handle,
177 bus_size_t offset, 177 bus_size_t offset,
178 uint32_t value); 178 uint32_t value);
179 179
180 void (*sparc_write_8)( 180 void (*sparc_write_8)(
181 bus_space_tag_t space, 181 bus_space_tag_t space,
182 bus_space_handle_t handle, 182 bus_space_handle_t handle,
183 bus_size_t offset, 183 bus_size_t offset,
184 uint64_t value); 184 uint64_t value);
185}; 185};
186 186
187bus_space_tag_t bus_space_tag_alloc(bus_space_tag_t, void *); 187bus_space_tag_t bus_space_tag_alloc(bus_space_tag_t, void *);
188int bus_space_translate_address_generic(struct openprom_range *, 188int bus_space_translate_address_generic(struct openprom_range *,
189 int, bus_addr_t *); 189 int, bus_addr_t *);
190 190
191/* 191/*
192 * Bus space function prototypes. 192 * Bus space function prototypes.
193 * In bus_space_map2(), supply a special virtual address only if you 193 * In bus_space_map2(), supply a special virtual address only if you
194 * get it from ../sparc/vaddrs.h. 194 * get it from ../sparc/vaddrs.h.
195 */ 195 */
196static int bus_space_map( 196static int bus_space_map(
197 bus_space_tag_t, 197 bus_space_tag_t,
198 bus_addr_t, 198 bus_addr_t,
199 bus_size_t, 199 bus_size_t,
200 int, /*flags*/ 200 int, /*flags*/
201 bus_space_handle_t *); 201 bus_space_handle_t *);
202static int bus_space_map2( 202static int bus_space_map2(
203 bus_space_tag_t, 203 bus_space_tag_t,
204 bus_addr_t, 204 bus_addr_t,
205 bus_size_t, 205 bus_size_t,
206 int, /*flags*/ 206 int, /*flags*/
207 vaddr_t, /*preferred vaddr*/ 207 vaddr_t, /*preferred vaddr*/
208 bus_space_handle_t *); 208 bus_space_handle_t *);
209static int bus_space_unmap( 209static int bus_space_unmap(
210 bus_space_tag_t, 210 bus_space_tag_t,
211 bus_space_handle_t, 211 bus_space_handle_t,
212 bus_size_t); 212 bus_size_t);
213static int bus_space_subregion( 213static int bus_space_subregion(
214 bus_space_tag_t, 214 bus_space_tag_t,
215 bus_space_handle_t, 215 bus_space_handle_t,
216 bus_size_t, 216 bus_size_t,
217 bus_size_t, 217 bus_size_t,
218 bus_space_handle_t *); 218 bus_space_handle_t *);
219static void bus_space_barrier( 219static void bus_space_barrier(
220 bus_space_tag_t, 220 bus_space_tag_t,
221 bus_space_handle_t, 221 bus_space_handle_t,
222 bus_size_t, 222 bus_size_t,
223 bus_size_t, 223 bus_size_t,
224 int); 224 int);
225static paddr_t bus_space_mmap( 225static paddr_t bus_space_mmap(
226 bus_space_tag_t, 226 bus_space_tag_t,
227 bus_addr_t, /**/ 227 bus_addr_t, /**/
228 off_t, 228 off_t,
229 int, /*prot*/ 229 int, /*prot*/
230 int); /*flags*/ 230 int); /*flags*/
231static void *bus_intr_establish( 231static void *bus_intr_establish(
232 bus_space_tag_t, 232 bus_space_tag_t,
233 int, /*bus-specific intr*/ 233 int, /*bus-specific intr*/
234 int, /*device class level, 234 int, /*device class level,
235 see machine/intr.h*/ 235 see machine/intr.h*/
236 int (*)(void *), /*handler*/ 236 int (*)(void *), /*handler*/
237 void *); /*handler arg*/ 237 void *); /*handler arg*/
238static void *bus_intr_establish2( 238static void *bus_intr_establish2(
239 bus_space_tag_t, 239 bus_space_tag_t,
240 int, /*bus-specific intr*/ 240 int, /*bus-specific intr*/
241 int, /*device class level, 241 int, /*device class level,
242 see machine/intr.h*/ 242 see machine/intr.h*/
243 int (*)(void *), /*handler*/ 243 int (*)(void *), /*handler*/
244 void *, /*handler arg*/ 244 void *, /*handler arg*/
245 void (*)(void)); /*optional fast vector*/ 245 void (*)(void)); /*optional fast vector*/
246 246
247 247
248int sparc_bus_map_large(bus_space_tag_t, int, bus_size_t, bus_size_t, int,  
249 bus_space_handle_t *); 
250 
251 248
252static __inline int 249static __inline int
253bus_space_map(t, a, s, f, hp) 250bus_space_map(t, a, s, f, hp)
254 bus_space_tag_t t; 251 bus_space_tag_t t;
255 bus_addr_t a; 252 bus_addr_t a;
256 bus_size_t s; 253 bus_size_t s;
257 int f; 254 int f;
258 bus_space_handle_t *hp; 255 bus_space_handle_t *hp;
259{ 256{
260 return (*t->sparc_bus_map)(t, a, s, f, (vaddr_t)0, hp); 257 return (*t->sparc_bus_map)(t, a, s, f, (vaddr_t)0, hp);
261} 258}
262 259
263static __inline int 260static __inline int
264bus_space_map2(t, a, s, f, v, hp) 261bus_space_map2(t, a, s, f, v, hp)
265 bus_space_tag_t t; 262 bus_space_tag_t t;
266 bus_addr_t a; 263 bus_addr_t a;
267 bus_size_t s; 264 bus_size_t s;
268 int f; 265 int f;
269 vaddr_t v; 266 vaddr_t v;
270 bus_space_handle_t *hp; 267 bus_space_handle_t *hp;
271{ 268{
272 return (*t->sparc_bus_map)(t, a, s, f, v, hp); 269 return (*t->sparc_bus_map)(t, a, s, f, v, hp);
273} 270}
274 271
275static __inline int 272static __inline int
276bus_space_unmap(t, h, s) 273bus_space_unmap(t, h, s)
277 bus_space_tag_t t; 274 bus_space_tag_t t;
278 bus_space_handle_t h; 275 bus_space_handle_t h;
279 bus_size_t s; 276 bus_size_t s;
280{ 277{
281 return (*t->sparc_bus_unmap)(t, h, s); 278 return (*t->sparc_bus_unmap)(t, h, s);
282} 279}
283 280
284static __inline int 281static __inline int
285bus_space_subregion(t, h, o, s, hp) 282bus_space_subregion(t, h, o, s, hp)
286 bus_space_tag_t t; 283 bus_space_tag_t t;
287 bus_space_handle_t h; 284 bus_space_handle_t h;
288 bus_size_t o; 285 bus_size_t o;
289 bus_size_t s; 286 bus_size_t s;
290 bus_space_handle_t *hp; 287 bus_space_handle_t *hp;
291{ 288{
292 return (*t->sparc_bus_subregion)(t, h, o, s, hp); 289 return (*t->sparc_bus_subregion)(t, h, o, s, hp);
293} 290}
294 291
295static __inline paddr_t 292static __inline paddr_t
296bus_space_mmap(t, a, o, p, f) 293bus_space_mmap(t, a, o, p, f)
297 bus_space_tag_t t; 294 bus_space_tag_t t;
298 bus_addr_t a; 295 bus_addr_t a;
299 off_t o; 296 off_t o;
300 int p; 297 int p;
301 int f; 298 int f;
302{ 299{
303 return (*t->sparc_bus_mmap)(t, a, o, p, f); 300 return (*t->sparc_bus_mmap)(t, a, o, p, f);
304} 301}
305 302
306static __inline void * 303static __inline void *
307bus_intr_establish(t, p, l, h, a) 304bus_intr_establish(t, p, l, h, a)
308 bus_space_tag_t t; 305 bus_space_tag_t t;
309 int p; 306 int p;
310 int l; 307 int l;
311 int (*h)(void *); 308 int (*h)(void *);
312 void *a; 309 void *a;
313{ 310{
314 return (*t->sparc_intr_establish)(t, p, l, h, a, NULL); 311 return (*t->sparc_intr_establish)(t, p, l, h, a, NULL);
315} 312}
316 313
317static __inline void * 314static __inline void *
318bus_intr_establish2(t, p, l, h, a, v) 315bus_intr_establish2(t, p, l, h, a, v)
319 bus_space_tag_t t; 316 bus_space_tag_t t;
320 int p; 317 int p;
321 int l; 318 int l;
322 int (*h)(void *); 319 int (*h)(void *);
323 void *a; 320 void *a;
324 void (*v)(void); 321 void (*v)(void);
325{ 322{
326 return (*t->sparc_intr_establish)(t, p, l, h, a, v); 323 return (*t->sparc_intr_establish)(t, p, l, h, a, v);
327} 324}
328 325
329static __inline void 326static __inline void
330bus_space_barrier(t, h, o, s, f) 327bus_space_barrier(t, h, o, s, f)
331 bus_space_tag_t t; 328 bus_space_tag_t t;
332 bus_space_handle_t h; 329 bus_space_handle_t h;
333 bus_size_t o; 330 bus_size_t o;
334 bus_size_t s; 331 bus_size_t s;
335 int f; 332 int f;
336{ 333{
337 (*t->sparc_bus_barrier)(t, h, o, s, f); 334 (*t->sparc_bus_barrier)(t, h, o, s, f);
338} 335}
339 336
340 337
341#if 0 338#if 0
342int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, 339int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
343 bus_addr_t rend, bus_size_t size, bus_size_t align, 340 bus_addr_t rend, bus_size_t size, bus_size_t align,
344 bus_size_t boundary, int flags, bus_addr_t *addrp, 341 bus_size_t boundary, int flags, bus_addr_t *addrp,
345 bus_space_handle_t *bshp); 342 bus_space_handle_t *bshp);
346void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh, 343void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
347 bus_size_t size); 344 bus_size_t size);
348#endif 345#endif
349 346
350#define bus_space_vaddr(t, h) ((void)(t), (void *)(h)) 347#define bus_space_vaddr(t, h) ((void)(t), (void *)(h))
351 348
352/* flags for bus space map functions */ 349/* flags for bus space map functions */
353#define BUS_SPACE_MAP_CACHEABLE 0x0001 350#define BUS_SPACE_MAP_CACHEABLE 0x0001
354#define BUS_SPACE_MAP_LINEAR 0x0002 351#define BUS_SPACE_MAP_LINEAR 0x0002
355#define BUS_SPACE_MAP_PREFETCHABLE 0x0004 352#define BUS_SPACE_MAP_PREFETCHABLE 0x0004
356#define BUS_SPACE_MAP_BUS1 0x0100 /* placeholders for bus functions... */ 353#define BUS_SPACE_MAP_BUS1 0x0100 /* placeholders for bus functions... */
357#define BUS_SPACE_MAP_BUS2 0x0200 354#define BUS_SPACE_MAP_BUS2 0x0200
358#define BUS_SPACE_MAP_BUS3 0x0400 355#define BUS_SPACE_MAP_BUS3 0x0400
359#define BUS_SPACE_MAP_BUS4 0x0800 356#define BUS_SPACE_MAP_LARGE 0x0800 /* map outside IODEV range */
360 357
361 358
362/* flags for bus_space_barrier() */ 359/* flags for bus_space_barrier() */
363#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ 360#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
364#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ 361#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
365 362
366/* 363/*
367 * Device space probe assistant. 364 * Device space probe assistant.
368 * The optional callback function's arguments are: 365 * The optional callback function's arguments are:
369 * the temporary virtual address 366 * the temporary virtual address
370 * the passed `arg' argument 367 * the passed `arg' argument
371 */ 368 */
372int bus_space_probe( 369int bus_space_probe(
373 bus_space_tag_t, 370 bus_space_tag_t,
374 bus_addr_t, 371 bus_addr_t,
375 bus_size_t, /* probe size */ 372 bus_size_t, /* probe size */
376 size_t, /* offset */ 373 size_t, /* offset */
377 int, /* flags */ 374 int, /* flags */
378 int (*)(void *, void *), /* callback function */ 375 int (*)(void *, void *), /* callback function */
379 void *); /* callback arg */ 376 void *); /* callback arg */
380 377
381 378
382/* 379/*
383 * u_intN_t bus_space_read_N(bus_space_tag_t tag, 380 * u_intN_t bus_space_read_N(bus_space_tag_t tag,
384 * bus_space_handle_t bsh, bus_size_t offset); 381 * bus_space_handle_t bsh, bus_size_t offset);
385 * 382 *
386 * Read a 1, 2, 4, or 8 byte quantity from bus space 383 * Read a 1, 2, 4, or 8 byte quantity from bus space
387 * described by tag/handle/offset. 384 * described by tag/handle/offset.
388 */ 385 */
389 386
390#define bus_space_read_1_real(t, h, o) \ 387#define bus_space_read_1_real(t, h, o) \
391 ((void)(t), *(volatile uint8_t *)((h) + (o))) 388 ((void)(t), *(volatile uint8_t *)((h) + (o)))
392 389
393#define bus_space_read_2_real(t, h, o) \ 390#define bus_space_read_2_real(t, h, o) \
394 ((void)(t), *(volatile uint16_t *)((h) + (o))) 391 ((void)(t), *(volatile uint16_t *)((h) + (o)))
395 392
396#define bus_space_read_4_real(t, h, o) \ 393#define bus_space_read_4_real(t, h, o) \
397 ((void)(t), *(volatile uint32_t *)((h) + (o))) 394 ((void)(t), *(volatile uint32_t *)((h) + (o)))
398 395
399#define bus_space_read_8_real(t, h, o) \ 396#define bus_space_read_8_real(t, h, o) \
400 ((void)(t), *(volatile uint64_t *)((h) + (o))) 397 ((void)(t), *(volatile uint64_t *)((h) + (o)))
401 398
402 399
403 400
404static uint8_t bus_space_read_1(bus_space_tag_t, 401static uint8_t bus_space_read_1(bus_space_tag_t,
405 bus_space_handle_t, 402 bus_space_handle_t,
406 bus_size_t); 403 bus_size_t);
407static uint16_t bus_space_read_2(bus_space_tag_t, 404static uint16_t bus_space_read_2(bus_space_tag_t,
408 bus_space_handle_t, 405 bus_space_handle_t,
409 bus_size_t); 406 bus_size_t);
410static uint32_t bus_space_read_4(bus_space_tag_t, 407static uint32_t bus_space_read_4(bus_space_tag_t,
411 bus_space_handle_t, 408 bus_space_handle_t,
412 bus_size_t); 409 bus_size_t);
413static uint64_t bus_space_read_8(bus_space_tag_t, 410static uint64_t bus_space_read_8(bus_space_tag_t,
414 bus_space_handle_t, 411 bus_space_handle_t,
415 bus_size_t); 412 bus_size_t);
416 413
417static __inline uint8_t 414static __inline uint8_t
418bus_space_read_1(t, h, o) 415bus_space_read_1(t, h, o)
419 bus_space_tag_t t; 416 bus_space_tag_t t;
420 bus_space_handle_t h; 417 bus_space_handle_t h;
421 bus_size_t o; 418 bus_size_t o;
422{ 419{
423 return (*t->sparc_read_1)(t, h, o); 420 return (*t->sparc_read_1)(t, h, o);
424} 421}
425 422
426static __inline uint16_t 423static __inline uint16_t
427bus_space_read_2(t, h, o) 424bus_space_read_2(t, h, o)
428 bus_space_tag_t t; 425 bus_space_tag_t t;
429 bus_space_handle_t h; 426 bus_space_handle_t h;
430 bus_size_t o; 427 bus_size_t o;
431{ 428{
432 return (*t->sparc_read_2)(t, h, o); 429 return (*t->sparc_read_2)(t, h, o);
433} 430}
434 431
435static __inline uint32_t 432static __inline uint32_t
436bus_space_read_4(t, h, o) 433bus_space_read_4(t, h, o)
437 bus_space_tag_t t; 434 bus_space_tag_t t;
438 bus_space_handle_t h; 435 bus_space_handle_t h;
439 bus_size_t o; 436 bus_size_t o;
440{ 437{
441 return (*t->sparc_read_4)(t, h, o); 438 return (*t->sparc_read_4)(t, h, o);
442} 439}
443 440
444static __inline uint64_t 441static __inline uint64_t
445bus_space_read_8(t, h, o) 442bus_space_read_8(t, h, o)
446 bus_space_tag_t t; 443 bus_space_tag_t t;
447 bus_space_handle_t h; 444 bus_space_handle_t h;
448 bus_size_t o; 445 bus_size_t o;
449{ 446{
450 return (*t->sparc_read_8)(t, h, o); 447 return (*t->sparc_read_8)(t, h, o);
451} 448}
452 449
453#if __SLIM_SPARC_BUS_SPACE 450#if __SLIM_SPARC_BUS_SPACE
454static __inline uint8_t 451static __inline uint8_t
455bus_space_read_1(t, h, o) 452bus_space_read_1(t, h, o)
456 bus_space_tag_t t; 453 bus_space_tag_t t;
457 bus_space_handle_t h; 454 bus_space_handle_t h;
458 bus_size_t o; 455 bus_size_t o;
459{ 456{
460 __insn_barrier(); 457 __insn_barrier();
461 return bus_space_read_1_real(t, h, o); 458 return bus_space_read_1_real(t, h, o);
462} 459}
463 460
464static __inline uint16_t 461static __inline uint16_t
465bus_space_read_2(t, h, o) 462bus_space_read_2(t, h, o)
466 bus_space_tag_t t; 463 bus_space_tag_t t;
467 bus_space_handle_t h; 464 bus_space_handle_t h;
468 bus_size_t o; 465 bus_size_t o;
469{ 466{
470 __insn_barrier(); 467 __insn_barrier();
471 return bus_space_read_2_real(t, h, o); 468 return bus_space_read_2_real(t, h, o);
472} 469}
473 470
474static __inline uint32_t 471static __inline uint32_t
475bus_space_read_4(t, h, o) 472bus_space_read_4(t, h, o)
476 bus_space_tag_t t; 473 bus_space_tag_t t;
477 bus_space_handle_t h; 474 bus_space_handle_t h;
478 bus_size_t o; 475 bus_size_t o;
479{ 476{
480 __insn_barrier(); 477 __insn_barrier();
481 return bus_space_read_4_real(t, h, o); 478 return bus_space_read_4_real(t, h, o);
482} 479}
483 480
484static __inline uint64_t 481static __inline uint64_t
485bus_space_read_8(t, h, o) 482bus_space_read_8(t, h, o)
486 bus_space_tag_t t; 483 bus_space_tag_t t;
487 bus_space_handle_t h; 484 bus_space_handle_t h;
488 bus_size_t o; 485 bus_size_t o;
489{ 486{
490 __insn_barrier(); 487 __insn_barrier();
491 return bus_space_read_8_real(t, h, o); 488 return bus_space_read_8_real(t, h, o);
492} 489}
493 490
494#endif /* __SLIM_SPARC_BUS_SPACE */ 491#endif /* __SLIM_SPARC_BUS_SPACE */
495 492
496#define bus_space_read_stream_1 bus_space_read_1_real 493#define bus_space_read_stream_1 bus_space_read_1_real
497#define bus_space_read_stream_2 bus_space_read_2_real 494#define bus_space_read_stream_2 bus_space_read_2_real
498#define bus_space_read_stream_4 bus_space_read_4_real 495#define bus_space_read_stream_4 bus_space_read_4_real
499#define bus_space_read_stream_8 bus_space_read_8_real 496#define bus_space_read_stream_8 bus_space_read_8_real
500 497
501 498
502/* 499/*
503 * void bus_space_write_N(bus_space_tag_t tag, 500 * void bus_space_write_N(bus_space_tag_t tag,
504 * bus_space_handle_t bsh, bus_size_t offset, 501 * bus_space_handle_t bsh, bus_size_t offset,
505 * u_intN_t value); 502 * u_intN_t value);
506 * 503 *
507 * Write the 1, 2, 4, or 8 byte value `value' to bus space 504 * Write the 1, 2, 4, or 8 byte value `value' to bus space
508 * described by tag/handle/offset. 505 * described by tag/handle/offset.
509 */ 506 */
510 507
511#define bus_space_write_1_real(t, h, o, v) do { \ 508#define bus_space_write_1_real(t, h, o, v) do { \
512 ((void)(t), (void)(*(volatile uint8_t *)((h) + (o)) = (v))); \ 509 ((void)(t), (void)(*(volatile uint8_t *)((h) + (o)) = (v))); \
513} while (/* CONSTCOND */ 0) 510} while (/* CONSTCOND */ 0)
514 511
515#define bus_space_write_2_real(t, h, o, v) do { \ 512#define bus_space_write_2_real(t, h, o, v) do { \
516 ((void)(t), (void)(*(volatile uint16_t *)((h) + (o)) = (v))); \ 513 ((void)(t), (void)(*(volatile uint16_t *)((h) + (o)) = (v))); \
517} while (/* CONSTCOND */ 0) 514} while (/* CONSTCOND */ 0)
518 515
519#define bus_space_write_4_real(t, h, o, v) do { \ 516#define bus_space_write_4_real(t, h, o, v) do { \
520 ((void)(t), (void)(*(volatile uint32_t *)((h) + (o)) = (v))); \ 517 ((void)(t), (void)(*(volatile uint32_t *)((h) + (o)) = (v))); \
521} while (/* CONSTCOND */ 0) 518} while (/* CONSTCOND */ 0)
522 519
523#define bus_space_write_8_real(t, h, o, v) do { \ 520#define bus_space_write_8_real(t, h, o, v) do { \
524 ((void)(t), (void)(*(volatile uint64_t *)((h) + (o)) = (v))); \ 521 ((void)(t), (void)(*(volatile uint64_t *)((h) + (o)) = (v))); \
525} while (/* CONSTCOND */ 0) 522} while (/* CONSTCOND */ 0)
526 523
527 524
528 525
529static void bus_space_write_1(bus_space_tag_t, 526static void bus_space_write_1(bus_space_tag_t,
530 bus_space_handle_t, 527 bus_space_handle_t,
531 bus_size_t, 528 bus_size_t,
532 const uint8_t); 529 const uint8_t);
533static void bus_space_write_2(bus_space_tag_t, 530static void bus_space_write_2(bus_space_tag_t,
534 bus_space_handle_t, 531 bus_space_handle_t,
535 bus_size_t, 532 bus_size_t,
536 const uint16_t); 533 const uint16_t);
537static void bus_space_write_4(bus_space_tag_t, 534static void bus_space_write_4(bus_space_tag_t,
538 bus_space_handle_t, 535 bus_space_handle_t,
539 bus_size_t, 536 bus_size_t,
540 const uint32_t); 537 const uint32_t);
541static void bus_space_write_8(bus_space_tag_t, 538static void bus_space_write_8(bus_space_tag_t,
542 bus_space_handle_t, 539 bus_space_handle_t,
543 bus_size_t, 540 bus_size_t,
544 const uint64_t); 541 const uint64_t);
545 542
546static __inline void 543static __inline void
547bus_space_write_1(t, h, o, v) 544bus_space_write_1(t, h, o, v)
548 bus_space_tag_t t; 545 bus_space_tag_t t;
549 bus_space_handle_t h; 546 bus_space_handle_t h;
550 bus_size_t o; 547 bus_size_t o;
551 uint8_t v; 548 uint8_t v;
552{ 549{
553 (*t->sparc_write_1)(t, h, o, v); 550 (*t->sparc_write_1)(t, h, o, v);
554} 551}
555 552
556static __inline void 553static __inline void
557bus_space_write_2(t, h, o, v) 554bus_space_write_2(t, h, o, v)
558 bus_space_tag_t t; 555 bus_space_tag_t t;
559 bus_space_handle_t h; 556 bus_space_handle_t h;
560 bus_size_t o; 557 bus_size_t o;
561 uint16_t v; 558 uint16_t v;
562{ 559{
563 (*t->sparc_write_2)(t, h, o, v); 560 (*t->sparc_write_2)(t, h, o, v);
564} 561}
565 562
566static __inline void 563static __inline void
567bus_space_write_4(t, h, o, v) 564bus_space_write_4(t, h, o, v)
568 bus_space_tag_t t; 565 bus_space_tag_t t;
569 bus_space_handle_t h; 566 bus_space_handle_t h;
570 bus_size_t o; 567 bus_size_t o;
571 uint32_t v; 568 uint32_t v;
572{ 569{
573 (*t->sparc_write_4)(t, h, o, v); 570 (*t->sparc_write_4)(t, h, o, v);
574} 571}
575 572
576static __inline void 573static __inline void
577bus_space_write_8(t, h, o, v) 574bus_space_write_8(t, h, o, v)
578 bus_space_tag_t t; 575 bus_space_tag_t t;
579 bus_space_handle_t h; 576 bus_space_handle_t h;
580 bus_size_t o; 577 bus_size_t o;
581 uint64_t v; 578 uint64_t v;
582{ 579{
583 (*t->sparc_write_8)(t, h, o, v); 580 (*t->sparc_write_8)(t, h, o, v);
584} 581}
585 582
586#if __SLIM_SPARC_BUS_SPACE 583#if __SLIM_SPARC_BUS_SPACE
587 584
588static __inline void 585static __inline void
589bus_space_write_1(t, h, o, v) 586bus_space_write_1(t, h, o, v)
590 bus_space_tag_t t; 587 bus_space_tag_t t;
591 bus_space_handle_t h; 588 bus_space_handle_t h;
592 bus_size_t o; 589 bus_size_t o;
593 uint8_t v; 590 uint8_t v;
594{ 591{
595 __insn_barrier(); 592 __insn_barrier();
596 bus_space_write_1_real(t, h, o, v); 593 bus_space_write_1_real(t, h, o, v);
597} 594}
598 595
599static __inline void 596static __inline void
600bus_space_write_2(t, h, o, v) 597bus_space_write_2(t, h, o, v)
601 bus_space_tag_t t; 598 bus_space_tag_t t;
602 bus_space_handle_t h; 599 bus_space_handle_t h;
603 bus_size_t o; 600 bus_size_t o;
604 uint16_t v; 601 uint16_t v;
605{ 602{
606 __insn_barrier(); 603 __insn_barrier();
607 bus_space_write_2_real(t, h, o, v); 604 bus_space_write_2_real(t, h, o, v);
608} 605}
609 606
610static __inline void 607static __inline void
611bus_space_write_4(t, h, o, v) 608bus_space_write_4(t, h, o, v)
612 bus_space_tag_t t; 609 bus_space_tag_t t;
613 bus_space_handle_t h; 610 bus_space_handle_t h;
614 bus_size_t o; 611 bus_size_t o;
615 uint32_t v; 612 uint32_t v;
616{ 613{
617 __insn_barrier(); 614 __insn_barrier();
618 bus_space_write_4_real(t, h, o, v); 615 bus_space_write_4_real(t, h, o, v);
619} 616}
620 617
621static __inline void 618static __inline void
622bus_space_write_8(t, h, o, v) 619bus_space_write_8(t, h, o, v)
623 bus_space_tag_t t; 620 bus_space_tag_t t;
624 bus_space_handle_t h; 621 bus_space_handle_t h;
625 bus_size_t o; 622 bus_size_t o;
626 uint64_t v; 623 uint64_t v;
627{ 624{
628 __insn_barrier(); 625 __insn_barrier();
629 bus_space_write_8_real(t, h, o, v); 626 bus_space_write_8_real(t, h, o, v);
630} 627}
631 628
632#endif /* __SLIM_SPARC_BUS_SPACE */ 629#endif /* __SLIM_SPARC_BUS_SPACE */
633 630
634#define bus_space_write_stream_1 bus_space_write_1_real 631#define bus_space_write_stream_1 bus_space_write_1_real
635#define bus_space_write_stream_2 bus_space_write_2_real 632#define bus_space_write_stream_2 bus_space_write_2_real
636#define bus_space_write_stream_4 bus_space_write_4_real 633#define bus_space_write_stream_4 bus_space_write_4_real
637#define bus_space_write_stream_8 bus_space_write_8_real 634#define bus_space_write_stream_8 bus_space_write_8_real
638 635
639 636
640/* 637/*
641 * void bus_space_read_multi_N(bus_space_tag_t tag, 638 * void bus_space_read_multi_N(bus_space_tag_t tag,
642 * bus_space_handle_t bsh, bus_size_t offset, 639 * bus_space_handle_t bsh, bus_size_t offset,
643 * u_intN_t *addr, bus_size_t count); 640 * u_intN_t *addr, bus_size_t count);
644 * 641 *
645 * Read `count' 1, 2, 4, or 8 byte quantities from bus space 642 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
646 * described by tag/handle/offset and copy into buffer provided. 643 * described by tag/handle/offset and copy into buffer provided.
647 */ 644 */
648 645
649static void bus_space_read_multi_1(bus_space_tag_t, 646static void bus_space_read_multi_1(bus_space_tag_t,
650 bus_space_handle_t, 647 bus_space_handle_t,
651 bus_size_t, 648 bus_size_t,
652 uint8_t *, 649 uint8_t *,
653 bus_size_t); 650 bus_size_t);
654 651
655static void bus_space_read_multi_2(bus_space_tag_t, 652static void bus_space_read_multi_2(bus_space_tag_t,
656 bus_space_handle_t, 653 bus_space_handle_t,
657 bus_size_t, 654 bus_size_t,
658 uint16_t *, 655 uint16_t *,
659 bus_size_t); 656 bus_size_t);
660 657
661static void bus_space_read_multi_4(bus_space_tag_t, 658static void bus_space_read_multi_4(bus_space_tag_t,
662 bus_space_handle_t, 659 bus_space_handle_t,
663 bus_size_t, 660 bus_size_t,
664 uint32_t *, 661 uint32_t *,
665 bus_size_t); 662 bus_size_t);
666 663
667static void bus_space_read_multi_8(bus_space_tag_t, 664static void bus_space_read_multi_8(bus_space_tag_t,
668 bus_space_handle_t, 665 bus_space_handle_t,
669 bus_size_t, 666 bus_size_t,
670 uint64_t *, 667 uint64_t *,
671 bus_size_t); 668 bus_size_t);
672 669
673static __inline void 670static __inline void
674bus_space_read_multi_1(t, h, o, a, c) 671bus_space_read_multi_1(t, h, o, a, c)
675 bus_space_tag_t t; 672 bus_space_tag_t t;
676 bus_space_handle_t h; 673 bus_space_handle_t h;
677 bus_size_t o, c; 674 bus_size_t o, c;
678 uint8_t *a; 675 uint8_t *a;
679{ 676{
680 while (c-- > 0) 677 while (c-- > 0)
681 *a++ = bus_space_read_1(t, h, o); 678 *a++ = bus_space_read_1(t, h, o);
682} 679}
683 680
684static __inline void 681static __inline void
685bus_space_read_multi_2(t, h, o, a, c) 682bus_space_read_multi_2(t, h, o, a, c)
686 bus_space_tag_t t; 683 bus_space_tag_t t;
687 bus_space_handle_t h; 684 bus_space_handle_t h;
688 bus_size_t o, c; 685 bus_size_t o, c;
689 uint16_t *a; 686 uint16_t *a;
690{ 687{
691 while (c-- > 0) 688 while (c-- > 0)
692 *a++ = bus_space_read_2(t, h, o); 689 *a++ = bus_space_read_2(t, h, o);
693} 690}
694 691
695static __inline void 692static __inline void
696bus_space_read_multi_4(t, h, o, a, c) 693bus_space_read_multi_4(t, h, o, a, c)
697 bus_space_tag_t t; 694 bus_space_tag_t t;
698 bus_space_handle_t h; 695 bus_space_handle_t h;
699 bus_size_t o, c; 696 bus_size_t o, c;
700 uint32_t *a; 697 uint32_t *a;
701{ 698{
702 while (c-- > 0) 699 while (c-- > 0)
703 *a++ = bus_space_read_4(t, h, o); 700 *a++ = bus_space_read_4(t, h, o);
704} 701}
705 702
706static __inline void 703static __inline void
707bus_space_read_multi_8(t, h, o, a, c) 704bus_space_read_multi_8(t, h, o, a, c)
708 bus_space_tag_t t; 705 bus_space_tag_t t;
709 bus_space_handle_t h; 706 bus_space_handle_t h;
710 bus_size_t o, c; 707 bus_size_t o, c;
711 uint64_t *a; 708 uint64_t *a;
712{ 709{
713 while (c-- > 0) 710 while (c-- > 0)
714 *a++ = bus_space_read_8(t, h, o); 711 *a++ = bus_space_read_8(t, h, o);
715} 712}
716 713
717#define bus_space_read_multi_stream_1 bus_space_read_multi_1 714#define bus_space_read_multi_stream_1 bus_space_read_multi_1
718 715
719static void bus_space_read_multi_stream_2(bus_space_tag_t, 716static void bus_space_read_multi_stream_2(bus_space_tag_t,
720 bus_space_handle_t, 717 bus_space_handle_t,
721 bus_size_t, 718 bus_size_t,
722 uint16_t *, 719 uint16_t *,
723 bus_size_t); 720 bus_size_t);
724 721
725static void bus_space_read_multi_stream_4(bus_space_tag_t, 722static void bus_space_read_multi_stream_4(bus_space_tag_t,
726 bus_space_handle_t, 723 bus_space_handle_t,
727 bus_size_t, 724 bus_size_t,
728 uint32_t *, 725 uint32_t *,
729 bus_size_t); 726 bus_size_t);
730 727
731static void bus_space_read_multi_stream_8(bus_space_tag_t, 728static void bus_space_read_multi_stream_8(bus_space_tag_t,
732 bus_space_handle_t, 729 bus_space_handle_t,
733 bus_size_t, 730 bus_size_t,
734 uint64_t *, 731 uint64_t *,
735 bus_size_t); 732 bus_size_t);
736 733
737static __inline void 734static __inline void
738bus_space_read_multi_stream_2(t, h, o, a, c) 735bus_space_read_multi_stream_2(t, h, o, a, c)
739 bus_space_tag_t t; 736 bus_space_tag_t t;
740 bus_space_handle_t h; 737 bus_space_handle_t h;
741 bus_size_t o, c; 738 bus_size_t o, c;
742 uint16_t *a; 739 uint16_t *a;
743{ 740{
744 while (c-- > 0) 741 while (c-- > 0)
745 *a++ = bus_space_read_2_real(t, h, o); 742 *a++ = bus_space_read_2_real(t, h, o);
746} 743}
747 744
748static __inline void 745static __inline void
749bus_space_read_multi_stream_4(t, h, o, a, c) 746bus_space_read_multi_stream_4(t, h, o, a, c)
750 bus_space_tag_t t; 747 bus_space_tag_t t;
751 bus_space_handle_t h; 748 bus_space_handle_t h;
752 bus_size_t o, c; 749 bus_size_t o, c;
753 uint32_t *a; 750 uint32_t *a;
754{ 751{
755 while (c-- > 0) 752 while (c-- > 0)
756 *a++ = bus_space_read_4_real(t, h, o); 753 *a++ = bus_space_read_4_real(t, h, o);
757} 754}
758 755
759static __inline void 756static __inline void
760bus_space_read_multi_stream_8(t, h, o, a, c) 757bus_space_read_multi_stream_8(t, h, o, a, c)
761 bus_space_tag_t t; 758 bus_space_tag_t t;
762 bus_space_handle_t h; 759 bus_space_handle_t h;
763 bus_size_t o, c; 760 bus_size_t o, c;
764 uint64_t *a; 761 uint64_t *a;
765{ 762{
766 while (c-- > 0) 763 while (c-- > 0)
767 *a++ = bus_space_read_8_real(t, h, o); 764 *a++ = bus_space_read_8_real(t, h, o);
768} 765}
769 766
770/* 767/*
771 * void bus_space_write_multi_N(bus_space_tag_t tag, 768 * void bus_space_write_multi_N(bus_space_tag_t tag,
772 * bus_space_handle_t bsh, bus_size_t offset, 769 * bus_space_handle_t bsh, bus_size_t offset,
773 * const u_intN_t *addr, bus_size_t count); 770 * const u_intN_t *addr, bus_size_t count);
774 * 771 *
775 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer 772 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
776 * provided to bus space described by tag/handle/offset. 773 * provided to bus space described by tag/handle/offset.
777 */ 774 */
778static void bus_space_write_multi_1(bus_space_tag_t, 775static void bus_space_write_multi_1(bus_space_tag_t,
779 bus_space_handle_t, 776 bus_space_handle_t,
780 bus_size_t, 777 bus_size_t,
781 const uint8_t *, 778 const uint8_t *,
782 bus_size_t); 779 bus_size_t);
783static void bus_space_write_multi_2(bus_space_tag_t, 780static void bus_space_write_multi_2(bus_space_tag_t,
784 bus_space_handle_t, 781 bus_space_handle_t,
785 bus_size_t, 782 bus_size_t,
786 const uint16_t *, 783 const uint16_t *,
787 bus_size_t); 784 bus_size_t);
788static void bus_space_write_multi_4(bus_space_tag_t, 785static void bus_space_write_multi_4(bus_space_tag_t,
789 bus_space_handle_t, 786 bus_space_handle_t,
790 bus_size_t, 787 bus_size_t,
791 const uint32_t *, 788 const uint32_t *,
792 bus_size_t); 789 bus_size_t);
793static void bus_space_write_multi_8(bus_space_tag_t, 790static void bus_space_write_multi_8(bus_space_tag_t,
794 bus_space_handle_t, 791 bus_space_handle_t,
795 bus_size_t, 792 bus_size_t,
796 const uint64_t *, 793 const uint64_t *,
797 bus_size_t); 794 bus_size_t);
798static __inline void 795static __inline void
799bus_space_write_multi_1(t, h, o, a, c) 796bus_space_write_multi_1(t, h, o, a, c)
800 bus_space_tag_t t; 797 bus_space_tag_t t;
801 bus_space_handle_t h; 798 bus_space_handle_t h;
802 bus_size_t o, c; 799 bus_size_t o, c;
803 const uint8_t *a; 800 const uint8_t *a;
804{ 801{
805 while (c-- > 0) 802 while (c-- > 0)
806 bus_space_write_1(t, h, o, *a++); 803 bus_space_write_1(t, h, o, *a++);
807} 804}
808 805
809static __inline void 806static __inline void
810bus_space_write_multi_2(t, h, o, a, c) 807bus_space_write_multi_2(t, h, o, a, c)
811 bus_space_tag_t t; 808 bus_space_tag_t t;
812 bus_space_handle_t h; 809 bus_space_handle_t h;
813 bus_size_t o, c; 810 bus_size_t o, c;
814 const uint16_t *a; 811 const uint16_t *a;
815{ 812{
816 while (c-- > 0) 813 while (c-- > 0)
817 bus_space_write_2(t, h, o, *a++); 814 bus_space_write_2(t, h, o, *a++);
818} 815}
819 816
820static __inline void 817static __inline void
821bus_space_write_multi_4(t, h, o, a, c) 818bus_space_write_multi_4(t, h, o, a, c)
822 bus_space_tag_t t; 819 bus_space_tag_t t;
823 bus_space_handle_t h; 820 bus_space_handle_t h;
824 bus_size_t o, c; 821 bus_size_t o, c;
825 const uint32_t *a; 822 const uint32_t *a;
826{ 823{
827 while (c-- > 0) 824 while (c-- > 0)
828 bus_space_write_4(t, h, o, *a++); 825 bus_space_write_4(t, h, o, *a++);
829} 826}
830 827
831static __inline void 828static __inline void
832bus_space_write_multi_8(t, h, o, a, c) 829bus_space_write_multi_8(t, h, o, a, c)
833 bus_space_tag_t t; 830 bus_space_tag_t t;
834 bus_space_handle_t h; 831 bus_space_handle_t h;
835 bus_size_t o, c; 832 bus_size_t o, c;
836 const uint64_t *a; 833 const uint64_t *a;
837{ 834{
838 while (c-- > 0) 835 while (c-- > 0)
839 bus_space_write_8(t, h, o, *a++); 836 bus_space_write_8(t, h, o, *a++);
840} 837}
841 838
842#define bus_space_write_multi_stream_1 bus_space_write_multi_1 839#define bus_space_write_multi_stream_1 bus_space_write_multi_1
843 840
844static void bus_space_write_multi_stream_2(bus_space_tag_t, 841static void bus_space_write_multi_stream_2(bus_space_tag_t,
845 bus_space_handle_t, 842 bus_space_handle_t,
846 bus_size_t, 843 bus_size_t,
847 const uint16_t *, 844 const uint16_t *,
848 bus_size_t); 845 bus_size_t);
849static void bus_space_write_multi_stream_4(bus_space_tag_t, 846static void bus_space_write_multi_stream_4(bus_space_tag_t,
850 bus_space_handle_t, 847 bus_space_handle_t,
851 bus_size_t, 848 bus_size_t,
852 const uint32_t *, 849 const uint32_t *,
853 bus_size_t); 850 bus_size_t);
854static void bus_space_write_multi_stream_8(bus_space_tag_t, 851static void bus_space_write_multi_stream_8(bus_space_tag_t,
855 bus_space_handle_t, 852 bus_space_handle_t,
856 bus_size_t, 853 bus_size_t,
857 const uint64_t *, 854 const uint64_t *,
858 bus_size_t); 855 bus_size_t);
859 856
860static __inline void 857static __inline void
861bus_space_write_multi_stream_2(t, h, o, a, c) 858bus_space_write_multi_stream_2(t, h, o, a, c)
862 bus_space_tag_t t; 859 bus_space_tag_t t;
863 bus_space_handle_t h; 860 bus_space_handle_t h;
864 bus_size_t o, c; 861 bus_size_t o, c;
865 const uint16_t *a; 862 const uint16_t *a;
866{ 863{
867 while (c-- > 0) 864 while (c-- > 0)
868 bus_space_write_2_real(t, h, o, *a++); 865 bus_space_write_2_real(t, h, o, *a++);
869} 866}
870 867
871static __inline void 868static __inline void
872bus_space_write_multi_stream_4(t, h, o, a, c) 869bus_space_write_multi_stream_4(t, h, o, a, c)
873 bus_space_tag_t t; 870 bus_space_tag_t t;
874 bus_space_handle_t h; 871 bus_space_handle_t h;
875 bus_size_t o, c; 872 bus_size_t o, c;
876 const uint32_t *a; 873 const uint32_t *a;
877{ 874{
878 while (c-- > 0) 875 while (c-- > 0)
879 bus_space_write_4_real(t, h, o, *a++); 876 bus_space_write_4_real(t, h, o, *a++);
880} 877}
881 878
882static __inline void 879static __inline void
883bus_space_write_multi_stream_8(t, h, o, a, c) 880bus_space_write_multi_stream_8(t, h, o, a, c)
884 bus_space_tag_t t; 881 bus_space_tag_t t;
885 bus_space_handle_t h; 882 bus_space_handle_t h;
886 bus_size_t o, c; 883 bus_size_t o, c;
887 const uint64_t *a; 884 const uint64_t *a;
888{ 885{
889 while (c-- > 0) 886 while (c-- > 0)
890 bus_space_write_8_real(t, h, o, *a++); 887 bus_space_write_8_real(t, h, o, *a++);
891} 888}
892 889
893 890
894/* 891/*
895 * void bus_space_set_multi_N(bus_space_tag_t tag, 892 * void bus_space_set_multi_N(bus_space_tag_t tag,
896 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, 893 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
897 * bus_size_t count); 894 * bus_size_t count);
898 * 895 *
899 * Write the 1, 2, 4, or 8 byte value `val' to bus space described 896 * Write the 1, 2, 4, or 8 byte value `val' to bus space described
900 * by tag/handle/offset `count' times. 897 * by tag/handle/offset `count' times.
901 */ 898 */
902static void bus_space_set_multi_1(bus_space_tag_t, 899static void bus_space_set_multi_1(bus_space_tag_t,
903 bus_space_handle_t, 900 bus_space_handle_t,
904 bus_size_t, 901 bus_size_t,
905 const uint8_t, 902 const uint8_t,
906 bus_size_t); 903 bus_size_t);
907static void bus_space_set_multi_2(bus_space_tag_t, 904static void bus_space_set_multi_2(bus_space_tag_t,
908 bus_space_handle_t, 905 bus_space_handle_t,
909 bus_size_t, 906 bus_size_t,
910 const uint16_t, 907 const uint16_t,
911 bus_size_t); 908 bus_size_t);
912static void bus_space_set_multi_4(bus_space_tag_t, 909static void bus_space_set_multi_4(bus_space_tag_t,
913 bus_space_handle_t, 910 bus_space_handle_t,
914 bus_size_t, 911 bus_size_t,
915 const uint32_t, 912 const uint32_t,
916 bus_size_t); 913 bus_size_t);
917static void bus_space_set_multi_8(bus_space_tag_t, 914static void bus_space_set_multi_8(bus_space_tag_t,
918 bus_space_handle_t, 915 bus_space_handle_t,
919 bus_size_t, 916 bus_size_t,
920 const uint64_t, 917 const uint64_t,
921 bus_size_t); 918 bus_size_t);
922 919
923static __inline void 920static __inline void
924bus_space_set_multi_1(t, h, o, v, c) 921bus_space_set_multi_1(t, h, o, v, c)
925 bus_space_tag_t t; 922 bus_space_tag_t t;
926 bus_space_handle_t h; 923 bus_space_handle_t h;
927 bus_size_t o, c; 924 bus_size_t o, c;
928 const uint8_t v; 925 const uint8_t v;
929{ 926{
930 while (c-- > 0) 927 while (c-- > 0)
931 bus_space_write_1(t, h, o, v); 928 bus_space_write_1(t, h, o, v);
932} 929}
933 930
934static __inline void 931static __inline void
935bus_space_set_multi_2(t, h, o, v, c) 932bus_space_set_multi_2(t, h, o, v, c)
936 bus_space_tag_t t; 933 bus_space_tag_t t;
937 bus_space_handle_t h; 934 bus_space_handle_t h;
938 bus_size_t o, c; 935 bus_size_t o, c;
939 const uint16_t v; 936 const uint16_t v;
940{ 937{
941 while (c-- > 0) 938 while (c-- > 0)
942 bus_space_write_2(t, h, o, v); 939 bus_space_write_2(t, h, o, v);
943} 940}
944 941
945static __inline void 942static __inline void
946bus_space_set_multi_4(t, h, o, v, c) 943bus_space_set_multi_4(t, h, o, v, c)
947 bus_space_tag_t t; 944 bus_space_tag_t t;
948 bus_space_handle_t h; 945 bus_space_handle_t h;
949 bus_size_t o, c; 946 bus_size_t o, c;
950 const uint32_t v; 947 const uint32_t v;
951{ 948{
952 while (c-- > 0) 949 while (c-- > 0)
953 bus_space_write_4(t, h, o, v); 950 bus_space_write_4(t, h, o, v);
954} 951}
955 952
956static __inline void 953static __inline void
957bus_space_set_multi_8(t, h, o, v, c) 954bus_space_set_multi_8(t, h, o, v, c)
958 bus_space_tag_t t; 955 bus_space_tag_t t;
959 bus_space_handle_t h; 956 bus_space_handle_t h;
960 bus_size_t o, c; 957 bus_size_t o, c;
961 const uint64_t v; 958 const uint64_t v;
962{ 959{
963 while (c-- > 0) 960 while (c-- > 0)
964 bus_space_write_8(t, h, o, v); 961 bus_space_write_8(t, h, o, v);
965} 962}
966 963
967 964
968/* 965/*
969 * void bus_space_read_region_N(bus_space_tag_t tag, 966 * void bus_space_read_region_N(bus_space_tag_t tag,
970 * bus_space_handle_t bsh, bus_size_t off, 967 * bus_space_handle_t bsh, bus_size_t off,
971 * u_intN_t *addr, bus_size_t count); 968 * u_intN_t *addr, bus_size_t count);
972 * 969 *
973 */ 970 */
974static void bus_space_read_region_1(bus_space_tag_t, 971static void bus_space_read_region_1(bus_space_tag_t,
975 bus_space_handle_t, 972 bus_space_handle_t,
976 bus_size_t, 973 bus_size_t,
977 uint8_t *, 974 uint8_t *,
978 bus_size_t); 975 bus_size_t);
979static void bus_space_read_region_2(bus_space_tag_t, 976static void bus_space_read_region_2(bus_space_tag_t,
980 bus_space_handle_t, 977 bus_space_handle_t,
981 bus_size_t, 978 bus_size_t,
982 uint16_t *, 979 uint16_t *,
983 bus_size_t); 980 bus_size_t);
984static void bus_space_read_region_4(bus_space_tag_t, 981static void bus_space_read_region_4(bus_space_tag_t,
985 bus_space_handle_t, 982 bus_space_handle_t,
986 bus_size_t, 983 bus_size_t,
987 uint32_t *, 984 uint32_t *,
988 bus_size_t); 985 bus_size_t);
989static void bus_space_read_region_8(bus_space_tag_t, 986static void bus_space_read_region_8(bus_space_tag_t,
990 bus_space_handle_t, 987 bus_space_handle_t,
991 bus_size_t, 988 bus_size_t,
992 uint64_t *, 989 uint64_t *,
993 bus_size_t); 990 bus_size_t);
994 991
995static __inline void 992static __inline void
996bus_space_read_region_1(t, h, o, a, c) 993bus_space_read_region_1(t, h, o, a, c)
997 bus_space_tag_t t; 994 bus_space_tag_t t;
998 bus_space_handle_t h; 995 bus_space_handle_t h;
999 bus_size_t o, c; 996 bus_size_t o, c;
1000 uint8_t *a; 997 uint8_t *a;
1001{ 998{
1002 for (; c; a++, c--, o++) 999 for (; c; a++, c--, o++)
1003 *a = bus_space_read_1(t, h, o); 1000 *a = bus_space_read_1(t, h, o);
1004} 1001}
1005 1002
1006static __inline void 1003static __inline void
1007bus_space_read_region_2(t, h, o, a, c) 1004bus_space_read_region_2(t, h, o, a, c)
1008 bus_space_tag_t t; 1005 bus_space_tag_t t;
1009 bus_space_handle_t h; 1006 bus_space_handle_t h;
1010 bus_size_t o, c; 1007 bus_size_t o, c;
1011 uint16_t *a; 1008 uint16_t *a;
1012{ 1009{
1013 for (; c; a++, c--, o+=2) 1010 for (; c; a++, c--, o+=2)
1014 *a = bus_space_read_2(t, h, o); 1011 *a = bus_space_read_2(t, h, o);
1015} 1012}
1016 1013
1017static __inline void 1014static __inline void
1018bus_space_read_region_4(t, h, o, a, c) 1015bus_space_read_region_4(t, h, o, a, c)
1019 bus_space_tag_t t; 1016 bus_space_tag_t t;
1020 bus_space_handle_t h; 1017 bus_space_handle_t h;
1021 bus_size_t o, c; 1018 bus_size_t o, c;
1022 uint32_t *a; 1019 uint32_t *a;
1023{ 1020{
1024 for (; c; a++, c--, o+=4) 1021 for (; c; a++, c--, o+=4)
1025 *a = bus_space_read_4(t, h, o); 1022 *a = bus_space_read_4(t, h, o);
1026} 1023}
1027 1024
1028static __inline void 1025static __inline void
1029bus_space_read_region_8(t, h, o, a, c) 1026bus_space_read_region_8(t, h, o, a, c)
1030 bus_space_tag_t t; 1027 bus_space_tag_t t;
1031 bus_space_handle_t h; 1028 bus_space_handle_t h;
1032 bus_size_t o, c; 1029 bus_size_t o, c;
1033 uint64_t *a; 1030 uint64_t *a;
1034{ 1031{
1035 for (; c; a++, c--, o+=8) 1032 for (; c; a++, c--, o+=8)
1036 *a = bus_space_read_8(t, h, o); 1033 *a = bus_space_read_8(t, h, o);
1037} 1034}
1038 1035
1039/* 1036/*
1040 * void bus_space_write_region_N(bus_space_tag_t tag, 1037 * void bus_space_write_region_N(bus_space_tag_t tag,
1041 * bus_space_handle_t bsh, bus_size_t off, 1038 * bus_space_handle_t bsh, bus_size_t off,
1042 * u_intN_t *addr, bus_size_t count); 1039 * u_intN_t *addr, bus_size_t count);
1043 * 1040 *
1044 */ 1041 */
1045static void bus_space_write_region_1(bus_space_tag_t, 1042static void bus_space_write_region_1(bus_space_tag_t,
1046 bus_space_handle_t, 1043 bus_space_handle_t,
1047 bus_size_t, 1044 bus_size_t,
1048 const uint8_t *, 1045 const uint8_t *,
1049 bus_size_t); 1046 bus_size_t);
1050static void bus_space_write_region_2(bus_space_tag_t, 1047static void bus_space_write_region_2(bus_space_tag_t,
1051 bus_space_handle_t, 1048 bus_space_handle_t,
1052 bus_size_t, 1049 bus_size_t,
1053 const uint16_t *, 1050 const uint16_t *,
1054 bus_size_t); 1051 bus_size_t);
1055static void bus_space_write_region_4(bus_space_tag_t, 1052static void bus_space_write_region_4(bus_space_tag_t,
1056 bus_space_handle_t, 1053 bus_space_handle_t,
1057 bus_size_t, 1054 bus_size_t,
1058 const uint32_t *, 1055 const uint32_t *,
1059 bus_size_t); 1056 bus_size_t);
1060static void bus_space_write_region_8(bus_space_tag_t, 1057static void bus_space_write_region_8(bus_space_tag_t,
1061 bus_space_handle_t, 1058 bus_space_handle_t,
1062 bus_size_t, 1059 bus_size_t,
1063 const uint64_t *, 1060 const uint64_t *,
1064 bus_size_t); 1061 bus_size_t);
1065static __inline void 1062static __inline void
1066bus_space_write_region_1(t, h, o, a, c) 1063bus_space_write_region_1(t, h, o, a, c)
1067 bus_space_tag_t t; 1064 bus_space_tag_t t;
1068 bus_space_handle_t h; 1065 bus_space_handle_t h;
1069 bus_size_t o, c; 1066 bus_size_t o, c;
1070 const uint8_t *a; 1067 const uint8_t *a;
1071{ 1068{
1072 for (; c; a++, c--, o++) 1069 for (; c; a++, c--, o++)
1073 bus_space_write_1(t, h, o, *a); 1070 bus_space_write_1(t, h, o, *a);
1074} 1071}
1075 1072
1076static __inline void 1073static __inline void
1077bus_space_write_region_2(t, h, o, a, c) 1074bus_space_write_region_2(t, h, o, a, c)
1078 bus_space_tag_t t; 1075 bus_space_tag_t t;
1079 bus_space_handle_t h; 1076 bus_space_handle_t h;
1080 bus_size_t o, c; 1077 bus_size_t o, c;
1081 const uint16_t *a; 1078 const uint16_t *a;
1082{ 1079{
1083 for (; c; a++, c--, o+=2) 1080 for (; c; a++, c--, o+=2)
1084 bus_space_write_2(t, h, o, *a); 1081 bus_space_write_2(t, h, o, *a);
1085} 1082}
1086 1083
1087static __inline void 1084static __inline void
1088bus_space_write_region_4(t, h, o, a, c) 1085bus_space_write_region_4(t, h, o, a, c)
1089 bus_space_tag_t t; 1086 bus_space_tag_t t;
1090 bus_space_handle_t h; 1087 bus_space_handle_t h;
1091 bus_size_t o, c; 1088 bus_size_t o, c;
1092 const uint32_t *a; 1089 const uint32_t *a;
1093{ 1090{
1094 for (; c; a++, c--, o+=4) 1091 for (; c; a++, c--, o+=4)
1095 bus_space_write_4(t, h, o, *a); 1092 bus_space_write_4(t, h, o, *a);
1096} 1093}
1097 1094
1098static __inline void 1095static __inline void
1099bus_space_write_region_8(t, h, o, a, c) 1096bus_space_write_region_8(t, h, o, a, c)
1100 bus_space_tag_t t; 1097 bus_space_tag_t t;
1101 bus_space_handle_t h; 1098 bus_space_handle_t h;
1102 bus_size_t o, c; 1099 bus_size_t o, c;
1103 const uint64_t *a; 1100 const uint64_t *a;
1104{ 1101{
1105 for (; c; a++, c--, o+=8) 1102 for (; c; a++, c--, o+=8)
1106 bus_space_write_8(t, h, o, *a); 1103 bus_space_write_8(t, h, o, *a);
1107} 1104}
1108 1105
1109 1106
1110/* 1107/*
1111 * void bus_space_set_region_N(bus_space_tag_t tag, 1108 * void bus_space_set_region_N(bus_space_tag_t tag,
1112 * bus_space_handle_t bsh, bus_size_t off, 1109 * bus_space_handle_t bsh, bus_size_t off,
1113 * u_intN_t *addr, bus_size_t count); 1110 * u_intN_t *addr, bus_size_t count);
1114 * 1111 *
1115 */ 1112 */
1116static void bus_space_set_region_1(bus_space_tag_t, 1113static void bus_space_set_region_1(bus_space_tag_t,
1117 bus_space_handle_t, 1114 bus_space_handle_t,
1118 bus_size_t, 1115 bus_size_t,
1119 const uint8_t, 1116 const uint8_t,
1120 bus_size_t); 1117 bus_size_t);
1121static void bus_space_set_region_2(bus_space_tag_t, 1118static void bus_space_set_region_2(bus_space_tag_t,
1122 bus_space_handle_t, 1119 bus_space_handle_t,
1123 bus_size_t, 1120 bus_size_t,
1124 const uint16_t, 1121 const uint16_t,
1125 bus_size_t); 1122 bus_size_t);
1126static void bus_space_set_region_4(bus_space_tag_t, 1123static void bus_space_set_region_4(bus_space_tag_t,
1127 bus_space_handle_t, 1124 bus_space_handle_t,
1128 bus_size_t, 1125 bus_size_t,
1129 const uint32_t, 1126 const uint32_t,
1130 bus_size_t); 1127 bus_size_t);
1131static void bus_space_set_region_8(bus_space_tag_t, 1128static void bus_space_set_region_8(bus_space_tag_t,
1132 bus_space_handle_t, 1129 bus_space_handle_t,
1133 bus_size_t, 1130 bus_size_t,
1134 const uint64_t, 1131 const uint64_t,
1135 bus_size_t); 1132 bus_size_t);
1136 1133
1137static __inline void 1134static __inline void
1138bus_space_set_region_1(t, h, o, v, c) 1135bus_space_set_region_1(t, h, o, v, c)
1139 bus_space_tag_t t; 1136 bus_space_tag_t t;
1140 bus_space_handle_t h; 1137 bus_space_handle_t h;
1141 bus_size_t o, c; 1138 bus_size_t o, c;
1142 const uint8_t v; 1139 const uint8_t v;
1143{ 1140{
1144 for (; c; c--, o++) 1141 for (; c; c--, o++)
1145 bus_space_write_1(t, h, o, v); 1142 bus_space_write_1(t, h, o, v);
1146} 1143}
1147 1144
1148static __inline void 1145static __inline void
1149bus_space_set_region_2(t, h, o, v, c) 1146bus_space_set_region_2(t, h, o, v, c)
1150 bus_space_tag_t t; 1147 bus_space_tag_t t;
1151 bus_space_handle_t h; 1148 bus_space_handle_t h;
1152 bus_size_t o, c; 1149 bus_size_t o, c;
1153 const uint16_t v; 1150 const uint16_t v;
1154{ 1151{
1155 for (; c; c--, o+=2) 1152 for (; c; c--, o+=2)
1156 bus_space_write_2(t, h, o, v); 1153 bus_space_write_2(t, h, o, v);
1157} 1154}
1158 1155
1159static __inline void 1156static __inline void
1160bus_space_set_region_4(t, h, o, v, c) 1157bus_space_set_region_4(t, h, o, v, c)
1161 bus_space_tag_t t; 1158 bus_space_tag_t t;
1162 bus_space_handle_t h; 1159 bus_space_handle_t h;
1163 bus_size_t o, c; 1160 bus_size_t o, c;
1164 const uint32_t v; 1161 const uint32_t v;
1165{ 1162{
1166 for (; c; c--, o+=4) 1163 for (; c; c--, o+=4)
1167 bus_space_write_4(t, h, o, v); 1164 bus_space_write_4(t, h, o, v);
1168} 1165}
1169 1166
1170static __inline void 1167static __inline void
1171bus_space_set_region_8(t, h, o, v, c) 1168bus_space_set_region_8(t, h, o, v, c)
1172 bus_space_tag_t t; 1169 bus_space_tag_t t;
1173 bus_space_handle_t h; 1170 bus_space_handle_t h;
1174 bus_size_t o, c; 1171 bus_size_t o, c;
1175 const uint64_t v; 1172 const uint64_t v;
1176{ 1173{
1177 for (; c; c--, o+=8) 1174 for (; c; c--, o+=8)
1178 bus_space_write_8(t, h, o, v); 1175 bus_space_write_8(t, h, o, v);
1179} 1176}
1180 1177
1181 1178
1182/* 1179/*
1183 * void bus_space_copy_region_N(bus_space_tag_t tag, 1180 * void bus_space_copy_region_N(bus_space_tag_t tag,
1184 * bus_space_handle_t bsh1, bus_size_t off1, 1181 * bus_space_handle_t bsh1, bus_size_t off1,
1185 * bus_space_handle_t bsh2, bus_size_t off2, 1182 * bus_space_handle_t bsh2, bus_size_t off2,
1186 * bus_size_t count); 1183 * bus_size_t count);
1187 * 1184 *
1188 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting 1185 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
1189 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. 1186 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
1190 */ 1187 */
1191static void bus_space_copy_region_1(bus_space_tag_t, 1188static void bus_space_copy_region_1(bus_space_tag_t,
1192 bus_space_handle_t, 1189 bus_space_handle_t,
1193 bus_size_t, 1190 bus_size_t,
1194 bus_space_handle_t, 1191 bus_space_handle_t,
1195 bus_size_t, 1192 bus_size_t,
1196 bus_size_t); 1193 bus_size_t);
1197static void bus_space_copy_region_2(bus_space_tag_t, 1194static void bus_space_copy_region_2(bus_space_tag_t,
1198 bus_space_handle_t, 1195 bus_space_handle_t,
1199 bus_size_t, 1196 bus_size_t,
1200 bus_space_handle_t, 1197 bus_space_handle_t,
1201 bus_size_t, 1198 bus_size_t,
1202 bus_size_t); 1199 bus_size_t);
1203static void bus_space_copy_region_4(bus_space_tag_t, 1200static void bus_space_copy_region_4(bus_space_tag_t,
1204 bus_space_handle_t, 1201 bus_space_handle_t,
1205 bus_size_t, 1202 bus_size_t,
1206 bus_space_handle_t, 1203 bus_space_handle_t,
1207 bus_size_t, 1204 bus_size_t,
1208 bus_size_t); 1205 bus_size_t);
1209static void bus_space_copy_region_8(bus_space_tag_t, 1206static void bus_space_copy_region_8(bus_space_tag_t,
1210 bus_space_handle_t, 1207 bus_space_handle_t,
1211 bus_size_t, 1208 bus_size_t,
1212 bus_space_handle_t, 1209 bus_space_handle_t,
1213 bus_size_t, 1210 bus_size_t,
1214 bus_size_t); 1211 bus_size_t);
1215 1212
1216 1213
1217static __inline void 1214static __inline void
1218bus_space_copy_region_1(t, h1, o1, h2, o2, c) 1215bus_space_copy_region_1(t, h1, o1, h2, o2, c)
1219 bus_space_tag_t t; 1216 bus_space_tag_t t;
1220 bus_space_handle_t h1, h2; 1217 bus_space_handle_t h1, h2;
1221 bus_size_t o1, o2; 1218 bus_size_t o1, o2;
1222 bus_size_t c; 1219 bus_size_t c;
1223{ 1220{
1224 for (; c; c--, o1++, o2++) 1221 for (; c; c--, o1++, o2++)
1225 bus_space_write_1(t, h1, o1, bus_space_read_1(t, h2, o2)); 1222 bus_space_write_1(t, h1, o1, bus_space_read_1(t, h2, o2));
1226} 1223}
1227 1224
1228static __inline void 1225static __inline void
1229bus_space_copy_region_2(t, h1, o1, h2, o2, c) 1226bus_space_copy_region_2(t, h1, o1, h2, o2, c)
1230 bus_space_tag_t t; 1227 bus_space_tag_t t;
1231 bus_space_handle_t h1, h2; 1228 bus_space_handle_t h1, h2;
1232 bus_size_t o1, o2; 1229 bus_size_t o1, o2;
1233 bus_size_t c; 1230 bus_size_t c;
1234{ 1231{
1235 for (; c; c--, o1+=2, o2+=2) 1232 for (; c; c--, o1+=2, o2+=2)
1236 bus_space_write_2(t, h1, o1, bus_space_read_2(t, h2, o2)); 1233 bus_space_write_2(t, h1, o1, bus_space_read_2(t, h2, o2));
1237} 1234}
1238 1235
1239static __inline void 1236static __inline void
1240bus_space_copy_region_4(t, h1, o1, h2, o2, c) 1237bus_space_copy_region_4(t, h1, o1, h2, o2, c)
1241 bus_space_tag_t t; 1238 bus_space_tag_t t;
1242 bus_space_handle_t h1, h2; 1239 bus_space_handle_t h1, h2;
1243 bus_size_t o1, o2; 1240 bus_size_t o1, o2;
1244 bus_size_t c; 1241 bus_size_t c;
1245{ 1242{
1246 for (; c; c--, o1+=4, o2+=4) 1243 for (; c; c--, o1+=4, o2+=4)
1247 bus_space_write_4(t, h1, o1, bus_space_read_4(t, h2, o2)); 1244 bus_space_write_4(t, h1, o1, bus_space_read_4(t, h2, o2));
1248} 1245}
1249 1246
1250static __inline void 1247static __inline void
1251bus_space_copy_region_8(t, h1, o1, h2, o2, c) 1248bus_space_copy_region_8(t, h1, o1, h2, o2, c)
1252 bus_space_tag_t t; 1249 bus_space_tag_t t;
1253 bus_space_handle_t h1, h2; 1250 bus_space_handle_t h1, h2;
1254 bus_size_t o1, o2; 1251 bus_size_t o1, o2;
1255 bus_size_t c; 1252 bus_size_t c;
1256{ 1253{
1257 for (; c; c--, o1+=8, o2+=8) 1254 for (; c; c--, o1+=8, o2+=8)
1258 bus_space_write_8(t, h1, o1, bus_space_read_8(t, h2, o2)); 1255 bus_space_write_8(t, h1, o1, bus_space_read_8(t, h2, o2));
1259} 1256}
1260 1257
1261/* 1258/*
1262 * void bus_space_read_region_stream_N(bus_space_tag_t tag, 1259 * void bus_space_read_region_stream_N(bus_space_tag_t tag,
1263 * bus_space_handle_t bsh, bus_size_t off, 1260 * bus_space_handle_t bsh, bus_size_t off,
1264 * u_intN_t *addr, bus_size_t count); 1261 * u_intN_t *addr, bus_size_t count);
1265 * 1262 *
1266 */ 1263 */
1267static void bus_space_read_region_stream_1(bus_space_tag_t, 1264static void bus_space_read_region_stream_1(bus_space_tag_t,
1268 bus_space_handle_t, 1265 bus_space_handle_t,
1269 bus_size_t, 1266 bus_size_t,
1270 uint8_t *, 1267 uint8_t *,
1271 bus_size_t); 1268 bus_size_t);
1272static void bus_space_read_region_stream_2(bus_space_tag_t, 1269static void bus_space_read_region_stream_2(bus_space_tag_t,
1273 bus_space_handle_t, 1270 bus_space_handle_t,
1274 bus_size_t, 1271 bus_size_t,
1275 uint16_t *, 1272 uint16_t *,
1276 bus_size_t); 1273 bus_size_t);
1277static void bus_space_read_region_stream_4(bus_space_tag_t, 1274static void bus_space_read_region_stream_4(bus_space_tag_t,
1278 bus_space_handle_t, 1275 bus_space_handle_t,
1279 bus_size_t, 1276 bus_size_t,
1280 uint32_t *, 1277 uint32_t *,
1281 bus_size_t); 1278 bus_size_t);
1282static void bus_space_read_region_stream_8(bus_space_tag_t, 1279static void bus_space_read_region_stream_8(bus_space_tag_t,
1283 bus_space_handle_t, 1280 bus_space_handle_t,
1284 bus_size_t, 1281 bus_size_t,
1285 uint64_t *, 1282 uint64_t *,
1286 bus_size_t); 1283 bus_size_t);
1287 1284
1288static __inline void 1285static __inline void
1289bus_space_read_region_stream_1(t, h, o, a, c) 1286bus_space_read_region_stream_1(t, h, o, a, c)
1290 bus_space_tag_t t; 1287 bus_space_tag_t t;
1291 bus_space_handle_t h; 1288 bus_space_handle_t h;
1292 bus_size_t o, c; 1289 bus_size_t o, c;
1293 uint8_t *a; 1290 uint8_t *a;
1294{ 1291{
1295 for (; c; a++, c--, o++) 1292 for (; c; a++, c--, o++)
1296 *a = bus_space_read_stream_1(t, h, o); 1293 *a = bus_space_read_stream_1(t, h, o);
1297} 1294}
1298static __inline void 1295static __inline void
1299bus_space_read_region_stream_2(t, h, o, a, c) 1296bus_space_read_region_stream_2(t, h, o, a, c)
1300 bus_space_tag_t t; 1297 bus_space_tag_t t;
1301 bus_space_handle_t h; 1298 bus_space_handle_t h;
1302 bus_size_t o, c; 1299 bus_size_t o, c;
1303 uint16_t *a; 1300 uint16_t *a;
1304{ 1301{
1305 for (; c; a++, c--, o+=2) 1302 for (; c; a++, c--, o+=2)
1306 *a = bus_space_read_stream_2(t, h, o); 1303 *a = bus_space_read_stream_2(t, h, o);
1307 } 1304 }
1308static __inline void 1305static __inline void
1309bus_space_read_region_stream_4(t, h, o, a, c) 1306bus_space_read_region_stream_4(t, h, o, a, c)
1310 bus_space_tag_t t; 1307 bus_space_tag_t t;
1311 bus_space_handle_t h; 1308 bus_space_handle_t h;
1312 bus_size_t o, c; 1309 bus_size_t o, c;
1313 uint32_t *a; 1310 uint32_t *a;
1314{ 1311{
1315 for (; c; a++, c--, o+=4) 1312 for (; c; a++, c--, o+=4)
1316 *a = bus_space_read_stream_4(t, h, o); 1313 *a = bus_space_read_stream_4(t, h, o);
1317} 1314}
1318static __inline void 1315static __inline void
1319bus_space_read_region_stream_8(t, h, o, a, c) 1316bus_space_read_region_stream_8(t, h, o, a, c)
1320 bus_space_tag_t t; 1317 bus_space_tag_t t;
1321 bus_space_handle_t h; 1318 bus_space_handle_t h;
1322 bus_size_t o, c; 1319 bus_size_t o, c;
1323 uint64_t *a; 1320 uint64_t *a;
1324{ 1321{
1325 for (; c; a++, c--, o+=8) 1322 for (; c; a++, c--, o+=8)
1326 *a = bus_space_read_stream_8(t, h, o); 1323 *a = bus_space_read_stream_8(t, h, o);
1327} 1324}
1328 1325
1329/* 1326/*
1330 * void bus_space_write_region_stream_N(bus_space_tag_t tag, 1327 * void bus_space_write_region_stream_N(bus_space_tag_t tag,
1331 * bus_space_handle_t bsh, bus_size_t off, 1328 * bus_space_handle_t bsh, bus_size_t off,
1332 * u_intN_t *addr, bus_size_t count); 1329 * u_intN_t *addr, bus_size_t count);
1333 * 1330 *
1334 */ 1331 */
1335static void bus_space_write_region_stream_1(bus_space_tag_t, 1332static void bus_space_write_region_stream_1(bus_space_tag_t,
1336 bus_space_handle_t, 1333 bus_space_handle_t,
1337 bus_size_t, 1334 bus_size_t,
1338 const uint8_t *, 1335 const uint8_t *,
1339 bus_size_t); 1336 bus_size_t);
1340static void bus_space_write_region_stream_2(bus_space_tag_t, 1337static void bus_space_write_region_stream_2(bus_space_tag_t,
1341 bus_space_handle_t, 1338 bus_space_handle_t,
1342 bus_size_t, 1339 bus_size_t,
1343 const uint16_t *, 1340 const uint16_t *,
1344 bus_size_t); 1341 bus_size_t);
1345static void bus_space_write_region_stream_4(bus_space_tag_t, 1342static void bus_space_write_region_stream_4(bus_space_tag_t,
1346 bus_space_handle_t, 1343 bus_space_handle_t,
1347 bus_size_t, 1344 bus_size_t,
1348 const uint32_t *, 1345 const uint32_t *,
1349 bus_size_t); 1346 bus_size_t);
1350static void bus_space_write_region_stream_8(bus_space_tag_t, 1347static void bus_space_write_region_stream_8(bus_space_tag_t,
1351 bus_space_handle_t, 1348 bus_space_handle_t,
1352 bus_size_t, 1349 bus_size_t,
1353 const uint64_t *, 1350 const uint64_t *,
1354 bus_size_t); 1351 bus_size_t);
1355static __inline void 1352static __inline void
1356bus_space_write_region_stream_1(t, h, o, a, c) 1353bus_space_write_region_stream_1(t, h, o, a, c)
1357 bus_space_tag_t t; 1354 bus_space_tag_t t;
1358 bus_space_handle_t h; 1355 bus_space_handle_t h;

cvs diff -r1.293 -r1.294 src/sys/arch/sparc/sparc/machdep.c (switch to unified diff)

--- src/sys/arch/sparc/sparc/machdep.c 2009/05/16 17:01:15 1.293
+++ src/sys/arch/sparc/sparc/machdep.c 2009/05/26 03:30:24 1.294
@@ -1,2185 +1,2197 @@ @@ -1,2185 +1,2197 @@
1/* $NetBSD: machdep.c,v 1.293 2009/05/16 17:01:15 cegger Exp $ */ 1/* $NetBSD: machdep.c,v 1.294 2009/05/26 03:30:24 macallan Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998 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 of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer. 15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright 16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the 17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution. 18 * documentation and/or other materials provided with the distribution.
19 * 19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33/* 33/*
34 * Copyright (c) 1992, 1993 34 * Copyright (c) 1992, 1993
35 * The Regents of the University of California. All rights reserved. 35 * The Regents of the University of California. All rights reserved.
36 * 36 *
37 * This software was developed by the Computer Systems Engineering group 37 * This software was developed by the Computer Systems Engineering group
38 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 38 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
39 * contributed to Berkeley. 39 * contributed to Berkeley.
40 * 40 *
41 * All advertising materials mentioning features or use of this software 41 * All advertising materials mentioning features or use of this software
42 * must display the following acknowledgement: 42 * must display the following acknowledgement:
43 * This product includes software developed by the University of 43 * This product includes software developed by the University of
44 * California, Lawrence Berkeley Laboratory. 44 * California, Lawrence Berkeley Laboratory.
45 * 45 *
46 * Redistribution and use in source and binary forms, with or without 46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions 47 * modification, are permitted provided that the following conditions
48 * are met: 48 * are met:
49 * 1. Redistributions of source code must retain the above copyright 49 * 1. Redistributions of source code must retain the above copyright
50 * notice, this list of conditions and the following disclaimer. 50 * notice, this list of conditions and the following disclaimer.
51 * 2. Redistributions in binary form must reproduce the above copyright 51 * 2. Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the 52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution. 53 * documentation and/or other materials provided with the distribution.
54 * 3. Neither the name of the University nor the names of its contributors 54 * 3. Neither the name of the University nor the names of its contributors
55 * may be used to endorse or promote products derived from this software 55 * may be used to endorse or promote products derived from this software
56 * without specific prior written permission. 56 * without specific prior written permission.
57 * 57 *
58 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 58 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE. 68 * SUCH DAMAGE.
69 * 69 *
70 * @(#)machdep.c 8.6 (Berkeley) 1/14/94 70 * @(#)machdep.c 8.6 (Berkeley) 1/14/94
71 */ 71 */
72 72
73#include <sys/cdefs.h> 73#include <sys/cdefs.h>
74__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.293 2009/05/16 17:01:15 cegger Exp $"); 74__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.294 2009/05/26 03:30:24 macallan Exp $");
75 75
76#include "opt_compat_netbsd.h" 76#include "opt_compat_netbsd.h"
77#include "opt_compat_sunos.h" 77#include "opt_compat_sunos.h"
78#include "opt_sparc_arch.h" 78#include "opt_sparc_arch.h"
79#include "opt_modular.h" 79#include "opt_modular.h"
80#include "opt_multiprocessor.h" 80#include "opt_multiprocessor.h"
81 81
82#include <sys/param.h> 82#include <sys/param.h>
83#include <sys/signal.h> 83#include <sys/signal.h>
84#include <sys/signalvar.h> 84#include <sys/signalvar.h>
85#include <sys/proc.h> 85#include <sys/proc.h>
86#include <sys/user.h> 86#include <sys/user.h>
87#include <sys/extent.h> 87#include <sys/extent.h>
88#include <sys/savar.h> 88#include <sys/savar.h>
89#include <sys/buf.h> 89#include <sys/buf.h>
90#include <sys/device.h> 90#include <sys/device.h>
91#include <sys/reboot.h> 91#include <sys/reboot.h>
92#include <sys/systm.h> 92#include <sys/systm.h>
93#include <sys/kernel.h> 93#include <sys/kernel.h>
94#include <sys/conf.h> 94#include <sys/conf.h>
95#include <sys/file.h> 95#include <sys/file.h>
96#include <sys/malloc.h> 96#include <sys/malloc.h>
97#include <sys/mbuf.h> 97#include <sys/mbuf.h>
98#include <sys/mount.h> 98#include <sys/mount.h>
99#include <sys/msgbuf.h> 99#include <sys/msgbuf.h>
100#include <sys/syscallargs.h> 100#include <sys/syscallargs.h>
101#include <sys/exec.h> 101#include <sys/exec.h>
102#include <sys/ucontext.h> 102#include <sys/ucontext.h>
103#include <sys/simplelock.h> 103#include <sys/simplelock.h>
104#include <sys/module.h> 104#include <sys/module.h>
105 105
106#include <uvm/uvm.h> /* we use uvm.kernel_object */ 106#include <uvm/uvm.h> /* we use uvm.kernel_object */
107 107
108#include <sys/sysctl.h> 108#include <sys/sysctl.h>
109 109
110#ifdef COMPAT_13 110#ifdef COMPAT_13
111#include <compat/sys/signal.h> 111#include <compat/sys/signal.h>
112#include <compat/sys/signalvar.h> 112#include <compat/sys/signalvar.h>
113#endif 113#endif
114 114
115#define _SPARC_BUS_DMA_PRIVATE 115#define _SPARC_BUS_DMA_PRIVATE
116#include <machine/autoconf.h> 116#include <machine/autoconf.h>
117#include <machine/bus.h> 117#include <machine/bus.h>
118#include <machine/frame.h> 118#include <machine/frame.h>
119#include <machine/cpu.h> 119#include <machine/cpu.h>
120#include <machine/pmap.h> 120#include <machine/pmap.h>
121#include <machine/oldmon.h> 121#include <machine/oldmon.h>
122#include <machine/bsd_openprom.h> 122#include <machine/bsd_openprom.h>
123#include <machine/bootinfo.h> 123#include <machine/bootinfo.h>
124 124
125#include <sparc/sparc/asm.h> 125#include <sparc/sparc/asm.h>
126#include <sparc/sparc/cache.h> 126#include <sparc/sparc/cache.h>
127#include <sparc/sparc/vaddrs.h> 127#include <sparc/sparc/vaddrs.h>
128#include <sparc/sparc/cpuvar.h> 128#include <sparc/sparc/cpuvar.h>
129 129
130#include "fb.h" 130#include "fb.h"
131#include "power.h" 131#include "power.h"
132 132
133#if NPOWER > 0 133#if NPOWER > 0
134#include <sparc/dev/power.h> 134#include <sparc/dev/power.h>
135#endif 135#endif
136 136
137struct vm_map *mb_map = NULL; 137struct vm_map *mb_map = NULL;
138extern paddr_t avail_end; 138extern paddr_t avail_end;
139 139
140int physmem; 140int physmem;
141 141
142struct simplelock fpulock = SIMPLELOCK_INITIALIZER; 142struct simplelock fpulock = SIMPLELOCK_INITIALIZER;
143 143
144/* 144/*
145 * safepri is a safe priority for sleep to set for a spin-wait 145 * safepri is a safe priority for sleep to set for a spin-wait
146 * during autoconfiguration or after a panic. 146 * during autoconfiguration or after a panic.
147 */ 147 */
148int safepri = 0; 148int safepri = 0;
149 149
150/* 150/*
151 * dvmamap24 is used to manage DVMA memory for devices that have the upper 151 * dvmamap24 is used to manage DVMA memory for devices that have the upper
152 * eight address bits wired to all-ones (e.g. `le' and `ie') 152 * eight address bits wired to all-ones (e.g. `le' and `ie')
153 */ 153 */
154struct extent *dvmamap24; 154struct extent *dvmamap24;
155 155
156void dumpsys(void); 156void dumpsys(void);
157void stackdump(void); 157void stackdump(void);
158 158
159/* 159/*
160 * Machine-dependent startup code 160 * Machine-dependent startup code
161 */ 161 */
162void 162void
163cpu_startup(void) 163cpu_startup(void)
164{ 164{
165#ifdef DEBUG 165#ifdef DEBUG
166 extern int pmapdebug; 166 extern int pmapdebug;
167 int opmapdebug = pmapdebug; 167 int opmapdebug = pmapdebug;
168#endif 168#endif
169 vaddr_t minaddr, maxaddr; 169 vaddr_t minaddr, maxaddr;
170 vsize_t size; 170 vsize_t size;
171 paddr_t pa; 171 paddr_t pa;
172 char pbuf[9]; 172 char pbuf[9];
173 173
174#ifdef DEBUG 174#ifdef DEBUG
175 pmapdebug = 0; 175 pmapdebug = 0;
176#endif 176#endif
177 177
178 /* XXX */ 178 /* XXX */
179 if (lwp0.l_addr && lwp0.l_addr->u_pcb.pcb_psr == 0) 179 if (lwp0.l_addr && lwp0.l_addr->u_pcb.pcb_psr == 0)
180 lwp0.l_addr->u_pcb.pcb_psr = getpsr(); 180 lwp0.l_addr->u_pcb.pcb_psr = getpsr();
181 181
182 /* 182 /*
183 * Re-map the message buffer from its temporary address 183 * Re-map the message buffer from its temporary address
184 * at KERNBASE to MSGBUF_VA. 184 * at KERNBASE to MSGBUF_VA.
185 */ 185 */
186#if !defined(MSGBUFSIZE) || MSGBUFSIZE <= 8192 186#if !defined(MSGBUFSIZE) || MSGBUFSIZE <= 8192
187 /* 187 /*
188 * We use the free page(s) in front of the kernel load address. 188 * We use the free page(s) in front of the kernel load address.
189 */ 189 */
190 size = 8192; 190 size = 8192;
191 191
192 /* Get physical address of the message buffer */ 192 /* Get physical address of the message buffer */
193 pmap_extract(pmap_kernel(), (vaddr_t)KERNBASE, &pa); 193 pmap_extract(pmap_kernel(), (vaddr_t)KERNBASE, &pa);
194 194
195 /* Invalidate the current mapping at KERNBASE. */ 195 /* Invalidate the current mapping at KERNBASE. */
196 pmap_kremove((vaddr_t)KERNBASE, size); 196 pmap_kremove((vaddr_t)KERNBASE, size);
197 pmap_update(pmap_kernel()); 197 pmap_update(pmap_kernel());
198 198
199 /* Enter the new mapping */ 199 /* Enter the new mapping */
200 pmap_map(MSGBUF_VA, pa, pa + size, VM_PROT_READ|VM_PROT_WRITE); 200 pmap_map(MSGBUF_VA, pa, pa + size, VM_PROT_READ|VM_PROT_WRITE);
201 201
202 /* 202 /*
203 * Re-initialize the message buffer. 203 * Re-initialize the message buffer.
204 */ 204 */
205 initmsgbuf((void *)MSGBUF_VA, size); 205 initmsgbuf((void *)MSGBUF_VA, size);
206#else /* MSGBUFSIZE */ 206#else /* MSGBUFSIZE */
207 { 207 {
208 struct pglist mlist; 208 struct pglist mlist;
209 struct vm_page *m; 209 struct vm_page *m;
210 vaddr_t va0, va; 210 vaddr_t va0, va;
211 211
212 /* 212 /*
213 * We use the free page(s) in front of the kernel load address, 213 * We use the free page(s) in front of the kernel load address,
214 * and then allocate some more. 214 * and then allocate some more.
215 */ 215 */
216 size = round_page(MSGBUFSIZE); 216 size = round_page(MSGBUFSIZE);
217 217
218 /* Get physical address of first 8192 chunk of the message buffer */ 218 /* Get physical address of first 8192 chunk of the message buffer */
219 pmap_extract(pmap_kernel(), (vaddr_t)KERNBASE, &pa); 219 pmap_extract(pmap_kernel(), (vaddr_t)KERNBASE, &pa);
220 220
221 /* Allocate additional physical pages */ 221 /* Allocate additional physical pages */
222 if (uvm_pglistalloc(size - 8192, 222 if (uvm_pglistalloc(size - 8192,
223 vm_first_phys, vm_first_phys+vm_num_phys, 223 vm_first_phys, vm_first_phys+vm_num_phys,
224 0, 0, &mlist, 1, 0) != 0) 224 0, 0, &mlist, 1, 0) != 0)
225 panic("cpu_start: no memory for message buffer"); 225 panic("cpu_start: no memory for message buffer");
226 226
227 /* Invalidate the current mapping at KERNBASE. */ 227 /* Invalidate the current mapping at KERNBASE. */
228 pmap_kremove((vaddr_t)KERNBASE, 8192); 228 pmap_kremove((vaddr_t)KERNBASE, 8192);
229 pmap_update(pmap_kernel()); 229 pmap_update(pmap_kernel());
230 230
231 /* Allocate virtual memory space */ 231 /* Allocate virtual memory space */
232 va0 = va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY); 232 va0 = va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY);
233 if (va == 0) 233 if (va == 0)
234 panic("cpu_start: no virtual memory for message buffer"); 234 panic("cpu_start: no virtual memory for message buffer");
235 235
236 /* Map first 8192 */ 236 /* Map first 8192 */
237 while (va < va0 + 8192) { 237 while (va < va0 + 8192) {
238 pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE); 238 pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
239 pa += PAGE_SIZE; 239 pa += PAGE_SIZE;
240 va += PAGE_SIZE; 240 va += PAGE_SIZE;
241 } 241 }
242 pmap_update(pmap_kernel()); 242 pmap_update(pmap_kernel());
243 243
244 /* Map the rest of the pages */ 244 /* Map the rest of the pages */
245 TAILQ_FOREACH(m, &mlist ,pageq.queue) { 245 TAILQ_FOREACH(m, &mlist ,pageq.queue) {
246 if (va >= va0 + size) 246 if (va >= va0 + size)
247 panic("cpu_start: memory buffer size botch"); 247 panic("cpu_start: memory buffer size botch");
248 pa = VM_PAGE_TO_PHYS(m); 248 pa = VM_PAGE_TO_PHYS(m);
249 pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE); 249 pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
250 va += PAGE_SIZE; 250 va += PAGE_SIZE;
251 } 251 }
252 pmap_update(pmap_kernel()); 252 pmap_update(pmap_kernel());
253 253
254 /* 254 /*
255 * Re-initialize the message buffer. 255 * Re-initialize the message buffer.
256 */ 256 */
257 initmsgbuf((void *)va0, size); 257 initmsgbuf((void *)va0, size);
258 } 258 }
259#endif /* MSGBUFSIZE */ 259#endif /* MSGBUFSIZE */
260 260
261 /* 261 /*
262 * Good {morning,afternoon,evening,night}. 262 * Good {morning,afternoon,evening,night}.
263 */ 263 */
264 printf("%s%s", copyright, version); 264 printf("%s%s", copyright, version);
265 /*identifycpu();*/ 265 /*identifycpu();*/
266 format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); 266 format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
267 printf("total memory = %s\n", pbuf); 267 printf("total memory = %s\n", pbuf);
268 268
269 /* 269 /*
270 * Tune buffer cache variables based on the capabilities of the MMU 270 * Tune buffer cache variables based on the capabilities of the MMU
271 * to cut down on VM space allocated for the buffer caches that 271 * to cut down on VM space allocated for the buffer caches that
272 * would lead to MMU resource shortage. 272 * would lead to MMU resource shortage.
273 */ 273 */
274 if (CPU_ISSUN4 || CPU_ISSUN4C) { 274 if (CPU_ISSUN4 || CPU_ISSUN4C) {
275 /* Clip UBC windows */ 275 /* Clip UBC windows */
276 if (cpuinfo.mmu_nsegment <= 128) { 276 if (cpuinfo.mmu_nsegment <= 128) {
277 /* 277 /*
278 * ubc_nwins and ubc_winshift control the amount 278 * ubc_nwins and ubc_winshift control the amount
279 * of VM used by the UBC. Normally, this VM is 279 * of VM used by the UBC. Normally, this VM is
280 * not wired in the kernel map, hence non-locked 280 * not wired in the kernel map, hence non-locked
281 * `PMEGs' (see pmap.c) are used for this space. 281 * `PMEGs' (see pmap.c) are used for this space.
282 * We still limit possible fragmentation to prevent 282 * We still limit possible fragmentation to prevent
283 * the occasional wired UBC mappings from tying up 283 * the occasional wired UBC mappings from tying up
284 * too many PMEGs. 284 * too many PMEGs.
285 * 285 *
286 * Set the upper limit to 9 segments (default 286 * Set the upper limit to 9 segments (default
287 * winshift = 13). 287 * winshift = 13).
288 */ 288 */
289 ubc_nwins = 512; 289 ubc_nwins = 512;
290 290
291 /* 291 /*
292 * buf_setvalimit() allocates a submap for buffer 292 * buf_setvalimit() allocates a submap for buffer
293 * allocation. We use it to limit the number of locked 293 * allocation. We use it to limit the number of locked
294 * `PMEGs' (see pmap.c) dedicated to the buffer cache. 294 * `PMEGs' (see pmap.c) dedicated to the buffer cache.
295 * 295 *
296 * Set the upper limit to 12 segments (3MB), which 296 * Set the upper limit to 12 segments (3MB), which
297 * corresponds approximately to the size of the 297 * corresponds approximately to the size of the
298 * traditional 5% rule (assuming a maximum 64MB of 298 * traditional 5% rule (assuming a maximum 64MB of
299 * memory in small sun4c machines). 299 * memory in small sun4c machines).
300 */ 300 */
301 buf_setvalimit(12 * 256*1024); 301 buf_setvalimit(12 * 256*1024);
302 } 302 }
303 303
304 /* Clip max data & stack to avoid running into the MMU hole */ 304 /* Clip max data & stack to avoid running into the MMU hole */
305#if MAXDSIZ > 256*1024*1024 305#if MAXDSIZ > 256*1024*1024
306 maxdmap = 256*1024*1024; 306 maxdmap = 256*1024*1024;
307#endif 307#endif
308#if MAXSSIZ > 256*1024*1024 308#if MAXSSIZ > 256*1024*1024
309 maxsmap = 256*1024*1024; 309 maxsmap = 256*1024*1024;
310#endif 310#endif
311 } 311 }
312 312
313 minaddr = 0; 313 minaddr = 0;
314 if (CPU_ISSUN4 || CPU_ISSUN4C) { 314 if (CPU_ISSUN4 || CPU_ISSUN4C) {
315 /* 315 /*
316 * Allocate DMA map for 24-bit devices (le, ie) 316 * Allocate DMA map for 24-bit devices (le, ie)
317 * [dvma_base - dvma_end] is for VME devices.. 317 * [dvma_base - dvma_end] is for VME devices..
318 */ 318 */
319 dvmamap24 = extent_create("dvmamap24", 319 dvmamap24 = extent_create("dvmamap24",
320 D24_DVMA_BASE, D24_DVMA_END, 320 D24_DVMA_BASE, D24_DVMA_END,
321 M_DEVBUF, 0, 0, EX_NOWAIT); 321 M_DEVBUF, 0, 0, EX_NOWAIT);
322 if (dvmamap24 == NULL) 322 if (dvmamap24 == NULL)
323 panic("unable to allocate DVMA map"); 323 panic("unable to allocate DVMA map");
324 } 324 }
325 325
326 /* 326 /*
327 * Finally, allocate mbuf cluster submap. 327 * Finally, allocate mbuf cluster submap.
328 */ 328 */
329 mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, 329 mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
330 nmbclusters * mclbytes, VM_MAP_INTRSAFE, false, NULL); 330 nmbclusters * mclbytes, VM_MAP_INTRSAFE, false, NULL);
331 331
332#ifdef DEBUG 332#ifdef DEBUG
333 pmapdebug = opmapdebug; 333 pmapdebug = opmapdebug;
334#endif 334#endif
335 format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); 335 format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
336 printf("avail memory = %s\n", pbuf); 336 printf("avail memory = %s\n", pbuf);
337 337
338 pmap_redzone(); 338 pmap_redzone();
339} 339}
340 340
341/* 341/*
342 * Set up registers on exec. 342 * Set up registers on exec.
343 * 343 *
344 * XXX this entire mess must be fixed 344 * XXX this entire mess must be fixed
345 */ 345 */
346/* ARGSUSED */ 346/* ARGSUSED */
347void 347void
348setregs(struct lwp *l, struct exec_package *pack, u_long stack) 348setregs(struct lwp *l, struct exec_package *pack, u_long stack)
349{ 349{
350 struct trapframe *tf = l->l_md.md_tf; 350 struct trapframe *tf = l->l_md.md_tf;
351 struct fpstate *fs; 351 struct fpstate *fs;
352 int psr; 352 int psr;
353 353
354 /* Don't allow unaligned data references by default */ 354 /* Don't allow unaligned data references by default */
355 l->l_proc->p_md.md_flags &= ~MDP_FIXALIGN; 355 l->l_proc->p_md.md_flags &= ~MDP_FIXALIGN;
356 356
357 /* 357 /*
358 * Set the registers to 0 except for: 358 * Set the registers to 0 except for:
359 * %o6: stack pointer, built in exec()) 359 * %o6: stack pointer, built in exec())
360 * %psr: (retain CWP and PSR_S bits) 360 * %psr: (retain CWP and PSR_S bits)
361 * %g1: address of p->p_psstr (used by crt0) 361 * %g1: address of p->p_psstr (used by crt0)
362 * %pc,%npc: entry point of program 362 * %pc,%npc: entry point of program
363 */ 363 */
364 psr = tf->tf_psr & (PSR_S | PSR_CWP); 364 psr = tf->tf_psr & (PSR_S | PSR_CWP);
365 if ((fs = l->l_md.md_fpstate) != NULL) { 365 if ((fs = l->l_md.md_fpstate) != NULL) {
366 struct cpu_info *cpi; 366 struct cpu_info *cpi;
367 int s; 367 int s;
368 /* 368 /*
369 * We hold an FPU state. If we own *some* FPU chip state 369 * We hold an FPU state. If we own *some* FPU chip state
370 * we must get rid of it, and the only way to do that is 370 * we must get rid of it, and the only way to do that is
371 * to save it. In any case, get rid of our FPU state. 371 * to save it. In any case, get rid of our FPU state.
372 */ 372 */
373 FPU_LOCK(s); 373 FPU_LOCK(s);
374 if ((cpi = l->l_md.md_fpu) != NULL) { 374 if ((cpi = l->l_md.md_fpu) != NULL) {
375 if (cpi->fplwp != l) 375 if (cpi->fplwp != l)
376 panic("FPU(%d): fplwp %p", 376 panic("FPU(%d): fplwp %p",
377 cpi->ci_cpuid, cpi->fplwp); 377 cpi->ci_cpuid, cpi->fplwp);
378 if (l == cpuinfo.fplwp) 378 if (l == cpuinfo.fplwp)
379 savefpstate(fs); 379 savefpstate(fs);
380#if defined(MULTIPROCESSOR) 380#if defined(MULTIPROCESSOR)
381 else 381 else
382 XCALL1(savefpstate, fs, 1 << cpi->ci_cpuid); 382 XCALL1(savefpstate, fs, 1 << cpi->ci_cpuid);
383#endif 383#endif
384 cpi->fplwp = NULL; 384 cpi->fplwp = NULL;
385 } 385 }
386 l->l_md.md_fpu = NULL; 386 l->l_md.md_fpu = NULL;
387 FPU_UNLOCK(s); 387 FPU_UNLOCK(s);
388 free((void *)fs, M_SUBPROC); 388 free((void *)fs, M_SUBPROC);
389 l->l_md.md_fpstate = NULL; 389 l->l_md.md_fpstate = NULL;
390 } 390 }
391 memset((void *)tf, 0, sizeof *tf); 391 memset((void *)tf, 0, sizeof *tf);
392 tf->tf_psr = psr; 392 tf->tf_psr = psr;
393 tf->tf_global[1] = (int)l->l_proc->p_psstr; 393 tf->tf_global[1] = (int)l->l_proc->p_psstr;
394 tf->tf_pc = pack->ep_entry & ~3; 394 tf->tf_pc = pack->ep_entry & ~3;
395 tf->tf_npc = tf->tf_pc + 4; 395 tf->tf_npc = tf->tf_pc + 4;
396 stack -= sizeof(struct rwindow); 396 stack -= sizeof(struct rwindow);
397 tf->tf_out[6] = stack; 397 tf->tf_out[6] = stack;
398} 398}
399 399
400#ifdef DEBUG 400#ifdef DEBUG
401int sigdebug = 0; 401int sigdebug = 0;
402int sigpid = 0; 402int sigpid = 0;
403#define SDB_FOLLOW 0x01 403#define SDB_FOLLOW 0x01
404#define SDB_KSTACK 0x02 404#define SDB_KSTACK 0x02
405#define SDB_FPSTATE 0x04 405#define SDB_FPSTATE 0x04
406#endif 406#endif
407 407
408/* 408/*
409 * machine dependent system variables. 409 * machine dependent system variables.
410 */ 410 */
411static int 411static int
412sysctl_machdep_boot(SYSCTLFN_ARGS) 412sysctl_machdep_boot(SYSCTLFN_ARGS)
413{ 413{
414 struct sysctlnode node = *rnode; 414 struct sysctlnode node = *rnode;
415 struct btinfo_kernelfile *bi_file; 415 struct btinfo_kernelfile *bi_file;
416 const char *cp; 416 const char *cp;
417 417
418 418
419 switch (node.sysctl_num) { 419 switch (node.sysctl_num) {
420 case CPU_BOOTED_KERNEL: 420 case CPU_BOOTED_KERNEL:
421 if ((bi_file = lookup_bootinfo(BTINFO_KERNELFILE)) != NULL) 421 if ((bi_file = lookup_bootinfo(BTINFO_KERNELFILE)) != NULL)
422 cp = bi_file->name; 422 cp = bi_file->name;
423 else 423 else
424 cp = prom_getbootfile(); 424 cp = prom_getbootfile();
425 if (cp != NULL && cp[0] == '\0') 425 if (cp != NULL && cp[0] == '\0')
426 cp = "netbsd"; 426 cp = "netbsd";
427 break; 427 break;
428 case CPU_BOOTED_DEVICE: 428 case CPU_BOOTED_DEVICE:
429 cp = prom_getbootpath(); 429 cp = prom_getbootpath();
430 break; 430 break;
431 case CPU_BOOT_ARGS: 431 case CPU_BOOT_ARGS:
432 cp = prom_getbootargs(); 432 cp = prom_getbootargs();
433 break; 433 break;
434 default: 434 default:
435 return (EINVAL); 435 return (EINVAL);
436 } 436 }
437 437
438 if (cp == NULL || cp[0] == '\0') 438 if (cp == NULL || cp[0] == '\0')
439 return (ENOENT); 439 return (ENOENT);
440 440
441 node.sysctl_data = __UNCONST(cp); 441 node.sysctl_data = __UNCONST(cp);
442 node.sysctl_size = strlen(cp) + 1; 442 node.sysctl_size = strlen(cp) + 1;
443 return (sysctl_lookup(SYSCTLFN_CALL(&node))); 443 return (sysctl_lookup(SYSCTLFN_CALL(&node)));
444} 444}
445 445
446SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup") 446SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
447{ 447{
448 448
449 sysctl_createv(clog, 0, NULL, NULL, 449 sysctl_createv(clog, 0, NULL, NULL,
450 CTLFLAG_PERMANENT, 450 CTLFLAG_PERMANENT,
451 CTLTYPE_NODE, "machdep", NULL, 451 CTLTYPE_NODE, "machdep", NULL,
452 NULL, 0, NULL, 0, 452 NULL, 0, NULL, 0,
453 CTL_MACHDEP, CTL_EOL); 453 CTL_MACHDEP, CTL_EOL);
454 454
455 sysctl_createv(clog, 0, NULL, NULL, 455 sysctl_createv(clog, 0, NULL, NULL,
456 CTLFLAG_PERMANENT, 456 CTLFLAG_PERMANENT,
457 CTLTYPE_STRING, "booted_kernel", NULL, 457 CTLTYPE_STRING, "booted_kernel", NULL,
458 sysctl_machdep_boot, 0, NULL, 0, 458 sysctl_machdep_boot, 0, NULL, 0,
459 CTL_MACHDEP, CPU_BOOTED_KERNEL, CTL_EOL); 459 CTL_MACHDEP, CPU_BOOTED_KERNEL, CTL_EOL);
460 sysctl_createv(clog, 0, NULL, NULL, 460 sysctl_createv(clog, 0, NULL, NULL,
461 CTLFLAG_PERMANENT, 461 CTLFLAG_PERMANENT,
462 CTLTYPE_STRING, "booted_device", NULL, 462 CTLTYPE_STRING, "booted_device", NULL,
463 sysctl_machdep_boot, 0, NULL, 0, 463 sysctl_machdep_boot, 0, NULL, 0,
464 CTL_MACHDEP, CPU_BOOTED_DEVICE, CTL_EOL); 464 CTL_MACHDEP, CPU_BOOTED_DEVICE, CTL_EOL);
465 sysctl_createv(clog, 0, NULL, NULL, 465 sysctl_createv(clog, 0, NULL, NULL,
466 CTLFLAG_PERMANENT, 466 CTLFLAG_PERMANENT,
467 CTLTYPE_STRING, "boot_args", NULL, 467 CTLTYPE_STRING, "boot_args", NULL,
468 sysctl_machdep_boot, 0, NULL, 0, 468 sysctl_machdep_boot, 0, NULL, 0,
469 CTL_MACHDEP, CPU_BOOT_ARGS, CTL_EOL); 469 CTL_MACHDEP, CPU_BOOT_ARGS, CTL_EOL);
470 sysctl_createv(clog, 0, NULL, NULL, 470 sysctl_createv(clog, 0, NULL, NULL,
471 CTLFLAG_PERMANENT, 471 CTLFLAG_PERMANENT,
472 CTLTYPE_INT, "cpu_arch", NULL, 472 CTLTYPE_INT, "cpu_arch", NULL,
473 NULL, 0, &cpu_arch, 0, 473 NULL, 0, &cpu_arch, 0,
474 CTL_MACHDEP, CPU_ARCH, CTL_EOL); 474 CTL_MACHDEP, CPU_ARCH, CTL_EOL);
475} 475}
476 476
477/* 477/*
478 * Send an interrupt to process. 478 * Send an interrupt to process.
479 */ 479 */
480struct sigframe { 480struct sigframe {
481 siginfo_t sf_si; 481 siginfo_t sf_si;
482 ucontext_t sf_uc; 482 ucontext_t sf_uc;
483}; 483};
484 484
485void 485void
486sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask) 486sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
487{ 487{
488 struct lwp *l = curlwp; 488 struct lwp *l = curlwp;
489 struct proc *p = l->l_proc; 489 struct proc *p = l->l_proc;
490 struct sigacts *ps = p->p_sigacts; 490 struct sigacts *ps = p->p_sigacts;
491 struct trapframe *tf; 491 struct trapframe *tf;
492 ucontext_t uc; 492 ucontext_t uc;
493 struct sigframe *fp; 493 struct sigframe *fp;
494 u_int onstack, oldsp, newsp; 494 u_int onstack, oldsp, newsp;
495 u_int catcher; 495 u_int catcher;
496 int sig, error; 496 int sig, error;
497 size_t ucsz; 497 size_t ucsz;
498 498
499 sig = ksi->ksi_signo; 499 sig = ksi->ksi_signo;
500 500
501 tf = l->l_md.md_tf; 501 tf = l->l_md.md_tf;
502 oldsp = tf->tf_out[6]; 502 oldsp = tf->tf_out[6];
503 503
504 /* 504 /*
505 * Compute new user stack addresses, subtract off 505 * Compute new user stack addresses, subtract off
506 * one signal frame, and align. 506 * one signal frame, and align.
507 */ 507 */
508 onstack = 508 onstack =
509 (l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 && 509 (l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
510 (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0; 510 (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
511 511
512 if (onstack) 512 if (onstack)
513 fp = (struct sigframe *) 513 fp = (struct sigframe *)
514 ((char *)l->l_sigstk.ss_sp + 514 ((char *)l->l_sigstk.ss_sp +
515 l->l_sigstk.ss_size); 515 l->l_sigstk.ss_size);
516 else 516 else
517 fp = (struct sigframe *)oldsp; 517 fp = (struct sigframe *)oldsp;
518 518
519 fp = (struct sigframe *)((int)(fp - 1) & ~7); 519 fp = (struct sigframe *)((int)(fp - 1) & ~7);
520 520
521#ifdef DEBUG 521#ifdef DEBUG
522 if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) 522 if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
523 printf("sendsig: %s[%d] sig %d newusp %p si %p uc %p\n", 523 printf("sendsig: %s[%d] sig %d newusp %p si %p uc %p\n",
524 p->p_comm, p->p_pid, sig, fp, &fp->sf_si, &fp->sf_uc); 524 p->p_comm, p->p_pid, sig, fp, &fp->sf_si, &fp->sf_uc);
525#endif 525#endif
526 526
527 /* 527 /*
528 * Build the signal context to be used by sigreturn. 528 * Build the signal context to be used by sigreturn.
529 */ 529 */
530 uc.uc_flags = _UC_SIGMASK | 530 uc.uc_flags = _UC_SIGMASK |
531 ((l->l_sigstk.ss_flags & SS_ONSTACK) 531 ((l->l_sigstk.ss_flags & SS_ONSTACK)
532 ? _UC_SETSTACK : _UC_CLRSTACK); 532 ? _UC_SETSTACK : _UC_CLRSTACK);
533 uc.uc_sigmask = *mask; 533 uc.uc_sigmask = *mask;
534 uc.uc_link = l->l_ctxlink; 534 uc.uc_link = l->l_ctxlink;
535 memset(&uc.uc_stack, 0, sizeof(uc.uc_stack)); 535 memset(&uc.uc_stack, 0, sizeof(uc.uc_stack));
536 536
537 /* 537 /*
538 * Now copy the stack contents out to user space. 538 * Now copy the stack contents out to user space.
539 * We need to make sure that when we start the signal handler, 539 * We need to make sure that when we start the signal handler,
540 * its %i6 (%fp), which is loaded from the newly allocated stack area, 540 * its %i6 (%fp), which is loaded from the newly allocated stack area,
541 * joins seamlessly with the frame it was in when the signal occurred, 541 * joins seamlessly with the frame it was in when the signal occurred,
542 * so that the debugger and _longjmp code can back up through it. 542 * so that the debugger and _longjmp code can back up through it.
543 * Since we're calling the handler directly, allocate a full size 543 * Since we're calling the handler directly, allocate a full size
544 * C stack frame. 544 * C stack frame.
545 */ 545 */
546 sendsig_reset(l, sig); 546 sendsig_reset(l, sig);
547 mutex_exit(p->p_lock); 547 mutex_exit(p->p_lock);
548 newsp = (int)fp - sizeof(struct frame); 548 newsp = (int)fp - sizeof(struct frame);
549 cpu_getmcontext(l, &uc.uc_mcontext, &uc.uc_flags); 549 cpu_getmcontext(l, &uc.uc_mcontext, &uc.uc_flags);
550 ucsz = (int)&uc.__uc_pad - (int)&uc; 550 ucsz = (int)&uc.__uc_pad - (int)&uc;
551 error = (copyout(&ksi->ksi_info, &fp->sf_si, sizeof ksi->ksi_info) || 551 error = (copyout(&ksi->ksi_info, &fp->sf_si, sizeof ksi->ksi_info) ||
552 copyout(&uc, &fp->sf_uc, ucsz) || 552 copyout(&uc, &fp->sf_uc, ucsz) ||
553 suword(&((struct rwindow *)newsp)->rw_in[6], oldsp)); 553 suword(&((struct rwindow *)newsp)->rw_in[6], oldsp));
554 mutex_enter(p->p_lock); 554 mutex_enter(p->p_lock);
555 555
556 if (error) { 556 if (error) {
557 /* 557 /*
558 * Process has trashed its stack; give it an illegal 558 * Process has trashed its stack; give it an illegal
559 * instruction to halt it in its tracks. 559 * instruction to halt it in its tracks.
560 */ 560 */
561#ifdef DEBUG 561#ifdef DEBUG
562 if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) 562 if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
563 printf("sendsig: window save or copyout error\n"); 563 printf("sendsig: window save or copyout error\n");
564#endif 564#endif
565 sigexit(l, SIGILL); 565 sigexit(l, SIGILL);
566 /* NOTREACHED */ 566 /* NOTREACHED */
567 } 567 }
568 568
569 switch (ps->sa_sigdesc[sig].sd_vers) { 569 switch (ps->sa_sigdesc[sig].sd_vers) {
570 default: 570 default:
571 /* Unsupported trampoline version; kill the process. */ 571 /* Unsupported trampoline version; kill the process. */
572 sigexit(l, SIGILL); 572 sigexit(l, SIGILL);
573 case 2: 573 case 2:
574 /* 574 /*
575 * Arrange to continue execution at the user's handler. 575 * Arrange to continue execution at the user's handler.
576 * It needs a new stack pointer, a return address and 576 * It needs a new stack pointer, a return address and
577 * three arguments: (signo, siginfo *, ucontext *). 577 * three arguments: (signo, siginfo *, ucontext *).
578 */ 578 */
579 catcher = (u_int)SIGACTION(p, sig).sa_handler; 579 catcher = (u_int)SIGACTION(p, sig).sa_handler;
580 tf->tf_pc = catcher; 580 tf->tf_pc = catcher;
581 tf->tf_npc = catcher + 4; 581 tf->tf_npc = catcher + 4;
582 tf->tf_out[0] = sig; 582 tf->tf_out[0] = sig;
583 tf->tf_out[1] = (int)&fp->sf_si; 583 tf->tf_out[1] = (int)&fp->sf_si;
584 tf->tf_out[2] = (int)&fp->sf_uc; 584 tf->tf_out[2] = (int)&fp->sf_uc;
585 tf->tf_out[6] = newsp; 585 tf->tf_out[6] = newsp;
586 tf->tf_out[7] = (int)ps->sa_sigdesc[sig].sd_tramp - 8; 586 tf->tf_out[7] = (int)ps->sa_sigdesc[sig].sd_tramp - 8;
587 break; 587 break;
588 } 588 }
589 589
590 /* Remember that we're now on the signal stack. */ 590 /* Remember that we're now on the signal stack. */
591 if (onstack) 591 if (onstack)
592 l->l_sigstk.ss_flags |= SS_ONSTACK; 592 l->l_sigstk.ss_flags |= SS_ONSTACK;
593 593
594#ifdef DEBUG 594#ifdef DEBUG
595 if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) 595 if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
596 printf("sendsig: about to return to catcher\n"); 596 printf("sendsig: about to return to catcher\n");
597#endif 597#endif
598} 598}
599 599
600/* 600/*
601 * cpu_upcall: 601 * cpu_upcall:
602 * 602 *
603 * Send an an upcall to userland. 603 * Send an an upcall to userland.
604 */ 604 */
605void 605void
606cpu_upcall(struct lwp *l, int type, int nevents, int ninterrupted, 606cpu_upcall(struct lwp *l, int type, int nevents, int ninterrupted,
607 void *sas, void *ap, void *sp, sa_upcall_t upcall) 607 void *sas, void *ap, void *sp, sa_upcall_t upcall)
608{ 608{
609 struct trapframe *tf; 609 struct trapframe *tf;
610 vaddr_t addr; 610 vaddr_t addr;
611 611
612 tf = l->l_md.md_tf; 612 tf = l->l_md.md_tf;
613 addr = (vaddr_t) upcall; 613 addr = (vaddr_t) upcall;
614 614
615 /* Arguments to the upcall... */ 615 /* Arguments to the upcall... */
616 tf->tf_out[0] = type; 616 tf->tf_out[0] = type;
617 tf->tf_out[1] = (vaddr_t) sas; 617 tf->tf_out[1] = (vaddr_t) sas;
618 tf->tf_out[2] = nevents; 618 tf->tf_out[2] = nevents;
619 tf->tf_out[3] = ninterrupted; 619 tf->tf_out[3] = ninterrupted;
620 tf->tf_out[4] = (vaddr_t) ap; 620 tf->tf_out[4] = (vaddr_t) ap;
621 621
622 /* 622 /*
623 * Ensure the stack is double-word aligned, and provide a 623 * Ensure the stack is double-word aligned, and provide a
624 * C call frame. 624 * C call frame.
625 */ 625 */
626 sp = (void *)(((vaddr_t)sp & ~0x7) - CCFSZ); 626 sp = (void *)(((vaddr_t)sp & ~0x7) - CCFSZ);
627 627
628 /* Arrange to begin execution at the upcall handler. */ 628 /* Arrange to begin execution at the upcall handler. */
629 tf->tf_pc = addr; 629 tf->tf_pc = addr;
630 tf->tf_npc = addr + 4; 630 tf->tf_npc = addr + 4;
631 tf->tf_out[6] = (vaddr_t) sp; 631 tf->tf_out[6] = (vaddr_t) sp;
632 tf->tf_out[7] = -1; /* "you lose" if upcall returns */ 632 tf->tf_out[7] = -1; /* "you lose" if upcall returns */
633} 633}
634 634
635void 635void
636cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags) 636cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags)
637{ 637{
638 struct trapframe *tf = (struct trapframe *)l->l_md.md_tf; 638 struct trapframe *tf = (struct trapframe *)l->l_md.md_tf;
639 __greg_t *r = mcp->__gregs; 639 __greg_t *r = mcp->__gregs;
640#ifdef FPU_CONTEXT 640#ifdef FPU_CONTEXT
641 __fpregset_t *f = &mcp->__fpregs; 641 __fpregset_t *f = &mcp->__fpregs;
642 struct fpstate *fps = l->l_md.md_fpstate; 642 struct fpstate *fps = l->l_md.md_fpstate;
643#endif 643#endif
644 644
645 /* 645 /*
646 * Put the stack in a consistent state before we whack away 646 * Put the stack in a consistent state before we whack away
647 * at it. Note that write_user_windows may just dump the 647 * at it. Note that write_user_windows may just dump the
648 * registers into the pcb; we need them in the process's memory. 648 * registers into the pcb; we need them in the process's memory.
649 */ 649 */
650 write_user_windows(); 650 write_user_windows();
651 if ((l->l_flag & LW_SA_SWITCHING) == 0 && rwindow_save(l)) { 651 if ((l->l_flag & LW_SA_SWITCHING) == 0 && rwindow_save(l)) {
652 mutex_enter(l->l_proc->p_lock); 652 mutex_enter(l->l_proc->p_lock);
653 sigexit(l, SIGILL); 653 sigexit(l, SIGILL);
654 } 654 }
655 655
656 /* 656 /*
657 * Get the general purpose registers 657 * Get the general purpose registers
658 */ 658 */
659 r[_REG_PSR] = tf->tf_psr; 659 r[_REG_PSR] = tf->tf_psr;
660 r[_REG_PC] = tf->tf_pc; 660 r[_REG_PC] = tf->tf_pc;
661 r[_REG_nPC] = tf->tf_npc; 661 r[_REG_nPC] = tf->tf_npc;
662 r[_REG_Y] = tf->tf_y; 662 r[_REG_Y] = tf->tf_y;
663 r[_REG_G1] = tf->tf_global[1]; 663 r[_REG_G1] = tf->tf_global[1];
664 r[_REG_G2] = tf->tf_global[2]; 664 r[_REG_G2] = tf->tf_global[2];
665 r[_REG_G3] = tf->tf_global[3]; 665 r[_REG_G3] = tf->tf_global[3];
666 r[_REG_G4] = tf->tf_global[4]; 666 r[_REG_G4] = tf->tf_global[4];
667 r[_REG_G5] = tf->tf_global[5]; 667 r[_REG_G5] = tf->tf_global[5];
668 r[_REG_G6] = tf->tf_global[6]; 668 r[_REG_G6] = tf->tf_global[6];
669 r[_REG_G7] = tf->tf_global[7]; 669 r[_REG_G7] = tf->tf_global[7];
670 r[_REG_O0] = tf->tf_out[0]; 670 r[_REG_O0] = tf->tf_out[0];
671 r[_REG_O1] = tf->tf_out[1]; 671 r[_REG_O1] = tf->tf_out[1];
672 r[_REG_O2] = tf->tf_out[2]; 672 r[_REG_O2] = tf->tf_out[2];
673 r[_REG_O3] = tf->tf_out[3]; 673 r[_REG_O3] = tf->tf_out[3];
674 r[_REG_O4] = tf->tf_out[4]; 674 r[_REG_O4] = tf->tf_out[4];
675 r[_REG_O5] = tf->tf_out[5]; 675 r[_REG_O5] = tf->tf_out[5];
676 r[_REG_O6] = tf->tf_out[6]; 676 r[_REG_O6] = tf->tf_out[6];
677 r[_REG_O7] = tf->tf_out[7]; 677 r[_REG_O7] = tf->tf_out[7];
678 678
679 *flags |= _UC_CPU; 679 *flags |= _UC_CPU;
680 680
681#ifdef FPU_CONTEXT 681#ifdef FPU_CONTEXT
682 /* 682 /*
683 * Get the floating point registers 683 * Get the floating point registers
684 */ 684 */
685 memcpy(f->__fpu_regs, fps->fs_regs, sizeof(fps->fs_regs)); 685 memcpy(f->__fpu_regs, fps->fs_regs, sizeof(fps->fs_regs));
686 f->__fp_nqsize = sizeof(struct fp_qentry); 686 f->__fp_nqsize = sizeof(struct fp_qentry);
687 f->__fp_nqel = fps->fs_qsize; 687 f->__fp_nqel = fps->fs_qsize;
688 f->__fp_fsr = fps->fs_fsr; 688 f->__fp_fsr = fps->fs_fsr;
689 if (f->__fp_q != NULL) { 689 if (f->__fp_q != NULL) {
690 size_t sz = f->__fp_nqel * f->__fp_nqsize; 690 size_t sz = f->__fp_nqel * f->__fp_nqsize;
691 if (sz > sizeof(fps->fs_queue)) { 691 if (sz > sizeof(fps->fs_queue)) {
692#ifdef DIAGNOSTIC 692#ifdef DIAGNOSTIC
693 printf("getcontext: fp_queue too large\n"); 693 printf("getcontext: fp_queue too large\n");
694#endif 694#endif
695 return; 695 return;
696 } 696 }
697 if (copyout(fps->fs_queue, f->__fp_q, sz) != 0) { 697 if (copyout(fps->fs_queue, f->__fp_q, sz) != 0) {
698#ifdef DIAGNOSTIC 698#ifdef DIAGNOSTIC
699 printf("getcontext: copy of fp_queue failed %d\n", 699 printf("getcontext: copy of fp_queue failed %d\n",
700 error); 700 error);
701#endif 701#endif
702 return; 702 return;
703 } 703 }
704 } 704 }
705 f->fp_busy = 0; /* XXX: How do we determine that? */ 705 f->fp_busy = 0; /* XXX: How do we determine that? */
706 *flags |= _UC_FPU; 706 *flags |= _UC_FPU;
707#endif 707#endif
708 708
709 return; 709 return;
710} 710}
711 711
712/* 712/*
713 * Set to mcontext specified. 713 * Set to mcontext specified.
714 * Return to previous pc and psl as specified by 714 * Return to previous pc and psl as specified by
715 * context left by sendsig. Check carefully to 715 * context left by sendsig. Check carefully to
716 * make sure that the user has not modified the 716 * make sure that the user has not modified the
717 * psl to gain improper privileges or to cause 717 * psl to gain improper privileges or to cause
718 * a machine fault. 718 * a machine fault.
719 * This is almost like sigreturn() and it shows. 719 * This is almost like sigreturn() and it shows.
720 */ 720 */
721int 721int
722cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags) 722cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags)
723{ 723{
724 struct trapframe *tf; 724 struct trapframe *tf;
725 const __greg_t *r = mcp->__gregs; 725 const __greg_t *r = mcp->__gregs;
726 struct proc *p = l->l_proc; 726 struct proc *p = l->l_proc;
727#ifdef FPU_CONTEXT 727#ifdef FPU_CONTEXT
728 __fpregset_t *f = &mcp->__fpregs; 728 __fpregset_t *f = &mcp->__fpregs;
729 struct fpstate *fps = l->l_md.md_fpstate; 729 struct fpstate *fps = l->l_md.md_fpstate;
730#endif 730#endif
731 731
732 write_user_windows(); 732 write_user_windows();
733 if (rwindow_save(l)) { 733 if (rwindow_save(l)) {
734 mutex_enter(p->p_lock); 734 mutex_enter(p->p_lock);
735 sigexit(l, SIGILL); 735 sigexit(l, SIGILL);
736 } 736 }
737 737
738#ifdef DEBUG 738#ifdef DEBUG
739 if (sigdebug & SDB_FOLLOW) 739 if (sigdebug & SDB_FOLLOW)
740 printf("__setmcontext: %s[%d], __mcontext %p\n", 740 printf("__setmcontext: %s[%d], __mcontext %p\n",
741 l->l_proc->p_comm, l->l_proc->p_pid, mcp); 741 l->l_proc->p_comm, l->l_proc->p_pid, mcp);
742#endif 742#endif
743 743
744 if (flags & _UC_CPU) { 744 if (flags & _UC_CPU) {
745 /* Restore register context. */ 745 /* Restore register context. */
746 tf = (struct trapframe *)l->l_md.md_tf; 746 tf = (struct trapframe *)l->l_md.md_tf;
747 747
748 /* 748 /*
749 * Only the icc bits in the psr are used, so it need not be 749 * Only the icc bits in the psr are used, so it need not be
750 * verified. pc and npc must be multiples of 4. This is all 750 * verified. pc and npc must be multiples of 4. This is all
751 * that is required; if it holds, just do it. 751 * that is required; if it holds, just do it.
752 */ 752 */
753 if (((r[_REG_PC] | r[_REG_nPC]) & 3) != 0) { 753 if (((r[_REG_PC] | r[_REG_nPC]) & 3) != 0) {
754 printf("pc or npc are not multiples of 4!\n"); 754 printf("pc or npc are not multiples of 4!\n");
755 return (EINVAL); 755 return (EINVAL);
756 } 756 }
757 757
758 /* take only psr ICC field */ 758 /* take only psr ICC field */
759 tf->tf_psr = (tf->tf_psr & ~PSR_ICC) | 759 tf->tf_psr = (tf->tf_psr & ~PSR_ICC) |
760 (r[_REG_PSR] & PSR_ICC); 760 (r[_REG_PSR] & PSR_ICC);
761 tf->tf_pc = r[_REG_PC]; 761 tf->tf_pc = r[_REG_PC];
762 tf->tf_npc = r[_REG_nPC]; 762 tf->tf_npc = r[_REG_nPC];
763 tf->tf_y = r[_REG_Y]; 763 tf->tf_y = r[_REG_Y];
764 764
765 /* Restore everything */ 765 /* Restore everything */
766 tf->tf_global[1] = r[_REG_G1]; 766 tf->tf_global[1] = r[_REG_G1];
767 tf->tf_global[2] = r[_REG_G2]; 767 tf->tf_global[2] = r[_REG_G2];
768 tf->tf_global[3] = r[_REG_G3]; 768 tf->tf_global[3] = r[_REG_G3];
769 tf->tf_global[4] = r[_REG_G4]; 769 tf->tf_global[4] = r[_REG_G4];
770 tf->tf_global[5] = r[_REG_G5]; 770 tf->tf_global[5] = r[_REG_G5];
771 tf->tf_global[6] = r[_REG_G6]; 771 tf->tf_global[6] = r[_REG_G6];
772 tf->tf_global[7] = r[_REG_G7]; 772 tf->tf_global[7] = r[_REG_G7];
773 773
774 tf->tf_out[0] = r[_REG_O0]; 774 tf->tf_out[0] = r[_REG_O0];
775 tf->tf_out[1] = r[_REG_O1]; 775 tf->tf_out[1] = r[_REG_O1];
776 tf->tf_out[2] = r[_REG_O2]; 776 tf->tf_out[2] = r[_REG_O2];
777 tf->tf_out[3] = r[_REG_O3]; 777 tf->tf_out[3] = r[_REG_O3];
778 tf->tf_out[4] = r[_REG_O4]; 778 tf->tf_out[4] = r[_REG_O4];
779 tf->tf_out[5] = r[_REG_O5]; 779 tf->tf_out[5] = r[_REG_O5];
780 tf->tf_out[6] = r[_REG_O6]; 780 tf->tf_out[6] = r[_REG_O6];
781 tf->tf_out[7] = r[_REG_O7]; 781 tf->tf_out[7] = r[_REG_O7];
782 } 782 }
783 783
784#ifdef FPU_CONTEXT 784#ifdef FPU_CONTEXT
785 if (flags & _UC_FPU) { 785 if (flags & _UC_FPU) {
786 /* 786 /*
787 * Set the floating point registers 787 * Set the floating point registers
788 */ 788 */
789 int error; 789 int error;
790 size_t sz = f->__fp_nqel * f->__fp_nqsize; 790 size_t sz = f->__fp_nqel * f->__fp_nqsize;
791 if (sz > sizeof(fps->fs_queue)) { 791 if (sz > sizeof(fps->fs_queue)) {
792#ifdef DIAGNOSTIC 792#ifdef DIAGNOSTIC
793 printf("setmcontext: fp_queue too large\n"); 793 printf("setmcontext: fp_queue too large\n");
794#endif 794#endif
795 return (EINVAL); 795 return (EINVAL);
796 } 796 }
797 memcpy(fps->fs_regs, f->__fpu_regs, sizeof(fps->fs_regs)); 797 memcpy(fps->fs_regs, f->__fpu_regs, sizeof(fps->fs_regs));
798 fps->fs_qsize = f->__fp_nqel; 798 fps->fs_qsize = f->__fp_nqel;
799 fps->fs_fsr = f->__fp_fsr; 799 fps->fs_fsr = f->__fp_fsr;
800 if (f->__fp_q != NULL) { 800 if (f->__fp_q != NULL) {
801 if ((error = copyin(f->__fp_q, fps->fs_queue, sz)) != 0) { 801 if ((error = copyin(f->__fp_q, fps->fs_queue, sz)) != 0) {
802#ifdef DIAGNOSTIC 802#ifdef DIAGNOSTIC
803 printf("setmcontext: fp_queue copy failed\n"); 803 printf("setmcontext: fp_queue copy failed\n");
804#endif 804#endif
805 return (error); 805 return (error);
806 } 806 }
807 } 807 }
808 } 808 }
809#endif 809#endif
810 810
811 mutex_enter(p->p_lock); 811 mutex_enter(p->p_lock);
812 if (flags & _UC_SETSTACK) 812 if (flags & _UC_SETSTACK)
813 l->l_sigstk.ss_flags |= SS_ONSTACK; 813 l->l_sigstk.ss_flags |= SS_ONSTACK;
814 if (flags & _UC_CLRSTACK) 814 if (flags & _UC_CLRSTACK)
815 l->l_sigstk.ss_flags &= ~SS_ONSTACK; 815 l->l_sigstk.ss_flags &= ~SS_ONSTACK;
816 mutex_exit(p->p_lock); 816 mutex_exit(p->p_lock);
817 817
818 return (0); 818 return (0);
819} 819}
820 820
821int waittime = -1; 821int waittime = -1;
822 822
823void 823void
824cpu_reboot(int howto, char *user_boot_string) 824cpu_reboot(int howto, char *user_boot_string)
825{ 825{
826 int i; 826 int i;
827 char opts[4]; 827 char opts[4];
828 static char str[128]; 828 static char str[128];
829 829
830 /* If system is cold, just halt. */ 830 /* If system is cold, just halt. */
831 if (cold) { 831 if (cold) {
832 howto |= RB_HALT; 832 howto |= RB_HALT;
833 goto haltsys; 833 goto haltsys;
834 } 834 }
835 835
836#if NFB > 0 836#if NFB > 0
837 fb_unblank(); 837 fb_unblank();
838#endif 838#endif
839 boothowto = howto; 839 boothowto = howto;
840 if ((howto & RB_NOSYNC) == 0 && waittime < 0) { 840 if ((howto & RB_NOSYNC) == 0 && waittime < 0) {
841 extern struct lwp lwp0; 841 extern struct lwp lwp0;
842 842
843 /* XXX protect against curlwp->p_stats.foo refs in sync() */ 843 /* XXX protect against curlwp->p_stats.foo refs in sync() */
844 if (curlwp == NULL) 844 if (curlwp == NULL)
845 curlwp = &lwp0; 845 curlwp = &lwp0;
846 waittime = 0; 846 waittime = 0;
847 vfs_shutdown(); 847 vfs_shutdown();
848 848
849 /* 849 /*
850 * If we've been adjusting the clock, the todr 850 * If we've been adjusting the clock, the todr
851 * will be out of synch; adjust it now. 851 * will be out of synch; adjust it now.
852 * resettodr will only do this only if inittodr() 852 * resettodr will only do this only if inittodr()
853 * has already been called. 853 * has already been called.
854 */ 854 */
855 resettodr(); 855 resettodr();
856 } 856 }
857 857
858 /* Disable interrupts. But still allow IPI on MP systems */ 858 /* Disable interrupts. But still allow IPI on MP systems */
859 if (sparc_ncpus > 1) 859 if (sparc_ncpus > 1)
860 (void)splsched(); 860 (void)splsched();
861 else 861 else
862 (void)splhigh(); 862 (void)splhigh();
863 863
864#if defined(MULTIPROCESSOR) 864#if defined(MULTIPROCESSOR)
865 /* Direct system interrupts to this CPU, since dump uses polled I/O */ 865 /* Direct system interrupts to this CPU, since dump uses polled I/O */
866 if (CPU_ISSUN4M) 866 if (CPU_ISSUN4M)
867 *((u_int *)ICR_ITR) = cpuinfo.mid - 8; 867 *((u_int *)ICR_ITR) = cpuinfo.mid - 8;
868#endif 868#endif
869 869
870 /* If rebooting and a dump is requested, do it. */ 870 /* If rebooting and a dump is requested, do it. */
871#if 0 871#if 0
872 if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP) 872 if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
873#else 873#else
874 if (howto & RB_DUMP) 874 if (howto & RB_DUMP)
875#endif 875#endif
876 dumpsys(); 876 dumpsys();
877 877
878 haltsys: 878 haltsys:
879 879
880 /* Run any shutdown hooks. */ 880 /* Run any shutdown hooks. */
881 doshutdownhooks(); 881 doshutdownhooks();
882 882
883 pmf_system_shutdown(boothowto); 883 pmf_system_shutdown(boothowto);
884 884
885 /* If powerdown was requested, do it. */ 885 /* If powerdown was requested, do it. */
886 if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { 886 if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
887 prom_interpret("power-off"); 887 prom_interpret("power-off");
888#if NPOWER > 0 888#if NPOWER > 0
889 /* Fall back on `power' device if the PROM can't do it */ 889 /* Fall back on `power' device if the PROM can't do it */
890 powerdown(); 890 powerdown();
891#endif 891#endif
892 printf("WARNING: powerdown not supported\n"); 892 printf("WARNING: powerdown not supported\n");
893 /* 893 /*
894 * RB_POWERDOWN implies RB_HALT... fall into it... 894 * RB_POWERDOWN implies RB_HALT... fall into it...
895 */ 895 */
896 } 896 }
897 897
898 if (howto & RB_HALT) { 898 if (howto & RB_HALT) {
899#if defined(MULTIPROCESSOR) 899#if defined(MULTIPROCESSOR)
900 mp_halt_cpus(); 900 mp_halt_cpus();
901 printf("cpu%d halted\n\n", cpu_number()); 901 printf("cpu%d halted\n\n", cpu_number());
902#else 902#else
903 printf("halted\n\n"); 903 printf("halted\n\n");
904#endif 904#endif
905 prom_halt(); 905 prom_halt();
906 } 906 }
907 907
908 printf("rebooting\n\n"); 908 printf("rebooting\n\n");
909 909
910 i = 1; 910 i = 1;
911 if (howto & RB_SINGLE) 911 if (howto & RB_SINGLE)
912 opts[i++] = 's'; 912 opts[i++] = 's';
913 if (howto & RB_KDB) 913 if (howto & RB_KDB)
914 opts[i++] = 'd'; 914 opts[i++] = 'd';
915 opts[i] = '\0'; 915 opts[i] = '\0';
916 opts[0] = (i > 1) ? '-' : '\0'; 916 opts[0] = (i > 1) ? '-' : '\0';
917 917
918 if (user_boot_string && *user_boot_string) { 918 if (user_boot_string && *user_boot_string) {
919 i = strlen(user_boot_string); 919 i = strlen(user_boot_string);
920 if (i > sizeof(str) - sizeof(opts) - 1) 920 if (i > sizeof(str) - sizeof(opts) - 1)
921 prom_boot(user_boot_string); /* XXX */ 921 prom_boot(user_boot_string); /* XXX */
922 memcpy(str, user_boot_string, i); 922 memcpy(str, user_boot_string, i);
923 if (opts[0] != '\0') 923 if (opts[0] != '\0')
924 str[i] = ' '; 924 str[i] = ' ';
925 } 925 }
926 strcat(str, opts); 926 strcat(str, opts);
927 prom_boot(str); 927 prom_boot(str);
928 /*NOTREACHED*/ 928 /*NOTREACHED*/
929} 929}
930 930
931uint32_t dumpmag = 0x8fca0101; /* magic number for savecore */ 931uint32_t dumpmag = 0x8fca0101; /* magic number for savecore */
932int dumpsize = 0; /* also for savecore */ 932int dumpsize = 0; /* also for savecore */
933long dumplo = 0; 933long dumplo = 0;
934 934
935void 935void
936cpu_dumpconf(void) 936cpu_dumpconf(void)
937{ 937{
938 const struct bdevsw *bdev; 938 const struct bdevsw *bdev;
939 int nblks, dumpblks; 939 int nblks, dumpblks;
940 940
941 if (dumpdev == NODEV) 941 if (dumpdev == NODEV)
942 return; 942 return;
943 bdev = bdevsw_lookup(dumpdev); 943 bdev = bdevsw_lookup(dumpdev);
944 if (bdev == NULL || bdev->d_psize == NULL) 944 if (bdev == NULL || bdev->d_psize == NULL)
945 return; 945 return;
946 946
947 nblks = (*bdev->d_psize)(dumpdev); 947 nblks = (*bdev->d_psize)(dumpdev);
948 948
949 dumpblks = ctod(physmem) + pmap_dumpsize(); 949 dumpblks = ctod(physmem) + pmap_dumpsize();
950 if (dumpblks > (nblks - ctod(1))) 950 if (dumpblks > (nblks - ctod(1)))
951 /* 951 /*
952 * dump size is too big for the partition. 952 * dump size is too big for the partition.
953 * Note, we safeguard a click at the front for a 953 * Note, we safeguard a click at the front for a
954 * possible disk label. 954 * possible disk label.
955 */ 955 */
956 return; 956 return;
957 957
958 /* Put the dump at the end of the partition */ 958 /* Put the dump at the end of the partition */
959 dumplo = nblks - dumpblks; 959 dumplo = nblks - dumpblks;
960 960
961 /* 961 /*
962 * savecore(8) expects dumpsize to be the number of pages 962 * savecore(8) expects dumpsize to be the number of pages
963 * of actual core dumped (i.e. excluding the MMU stuff). 963 * of actual core dumped (i.e. excluding the MMU stuff).
964 */ 964 */
965 dumpsize = physmem; 965 dumpsize = physmem;
966} 966}
967 967
968#define BYTES_PER_DUMP (32 * 1024) /* must be a multiple of pagesize */ 968#define BYTES_PER_DUMP (32 * 1024) /* must be a multiple of pagesize */
969static vaddr_t dumpspace; 969static vaddr_t dumpspace;
970 970
971void * 971void *
972reserve_dumppages(void *p) 972reserve_dumppages(void *p)
973{ 973{
974 974
975 dumpspace = (vaddr_t)p; 975 dumpspace = (vaddr_t)p;
976 return ((char *)p + BYTES_PER_DUMP); 976 return ((char *)p + BYTES_PER_DUMP);
977} 977}
978 978
979/* 979/*
980 * Write a crash dump. 980 * Write a crash dump.
981 */ 981 */
982void 982void
983dumpsys(void) 983dumpsys(void)
984{ 984{
985 const struct bdevsw *bdev; 985 const struct bdevsw *bdev;
986 int psize; 986 int psize;
987 daddr_t blkno; 987 daddr_t blkno;
988 int (*dump)(dev_t, daddr_t, void *, size_t); 988 int (*dump)(dev_t, daddr_t, void *, size_t);
989 int error = 0; 989 int error = 0;
990 struct memarr *mp; 990 struct memarr *mp;
991 int nmem; 991 int nmem;
992 extern struct memarr pmemarr[]; 992 extern struct memarr pmemarr[];
993 extern int npmemarr; 993 extern int npmemarr;
994 994
995 /* copy registers to memory */ 995 /* copy registers to memory */
996 snapshot(cpuinfo.curpcb); 996 snapshot(cpuinfo.curpcb);
997 stackdump(); 997 stackdump();
998 998
999 if (dumpdev == NODEV) 999 if (dumpdev == NODEV)
1000 return; 1000 return;
1001 bdev = bdevsw_lookup(dumpdev); 1001 bdev = bdevsw_lookup(dumpdev);
1002 if (bdev == NULL || bdev->d_psize == NULL) 1002 if (bdev == NULL || bdev->d_psize == NULL)
1003 return; 1003 return;
1004 1004
1005 /* 1005 /*
1006 * For dumps during autoconfiguration, 1006 * For dumps during autoconfiguration,
1007 * if dump device has already configured... 1007 * if dump device has already configured...
1008 */ 1008 */
1009 if (dumpsize == 0) 1009 if (dumpsize == 0)
1010 cpu_dumpconf(); 1010 cpu_dumpconf();
1011 if (dumplo <= 0) { 1011 if (dumplo <= 0) {
1012 printf("\ndump to dev %u,%u not possible\n", 1012 printf("\ndump to dev %u,%u not possible\n",
1013 major(dumpdev), minor(dumpdev)); 1013 major(dumpdev), minor(dumpdev));
1014 return; 1014 return;
1015 } 1015 }
1016 printf("\ndumping to dev %u,%u offset %ld\n", 1016 printf("\ndumping to dev %u,%u offset %ld\n",
1017 major(dumpdev), minor(dumpdev), dumplo); 1017 major(dumpdev), minor(dumpdev), dumplo);
1018 1018
1019 psize = (*bdev->d_psize)(dumpdev); 1019 psize = (*bdev->d_psize)(dumpdev);
1020 printf("dump "); 1020 printf("dump ");
1021 if (psize == -1) { 1021 if (psize == -1) {
1022 printf("area unavailable\n"); 1022 printf("area unavailable\n");
1023 return; 1023 return;
1024 } 1024 }
1025 blkno = dumplo; 1025 blkno = dumplo;
1026 dump = bdev->d_dump; 1026 dump = bdev->d_dump;
1027 1027
1028 error = pmap_dumpmmu(dump, blkno); 1028 error = pmap_dumpmmu(dump, blkno);
1029 blkno += pmap_dumpsize(); 1029 blkno += pmap_dumpsize();
1030 1030
1031 for (mp = pmemarr, nmem = npmemarr; --nmem >= 0 && error == 0; mp++) { 1031 for (mp = pmemarr, nmem = npmemarr; --nmem >= 0 && error == 0; mp++) {
1032 unsigned i = 0, n; 1032 unsigned i = 0, n;
1033 int maddr = mp->addr; 1033 int maddr = mp->addr;
1034 1034
1035 if (maddr == 0) { 1035 if (maddr == 0) {
1036 /* Skip first page at physical address 0 */ 1036 /* Skip first page at physical address 0 */
1037 maddr += PAGE_SIZE; 1037 maddr += PAGE_SIZE;
1038 i += PAGE_SIZE; 1038 i += PAGE_SIZE;
1039 blkno += btodb(PAGE_SIZE); 1039 blkno += btodb(PAGE_SIZE);
1040 } 1040 }
1041 1041
1042 for (; i < mp->len; i += n) { 1042 for (; i < mp->len; i += n) {
1043 n = mp->len - i; 1043 n = mp->len - i;
1044 if (n > BYTES_PER_DUMP) 1044 if (n > BYTES_PER_DUMP)
1045 n = BYTES_PER_DUMP; 1045 n = BYTES_PER_DUMP;
1046 1046
1047 /* print out how many MBs we have dumped */ 1047 /* print out how many MBs we have dumped */
1048 if (i && (i % (1024*1024)) == 0) 1048 if (i && (i % (1024*1024)) == 0)
1049 printf_nolog("%d ", i / (1024*1024)); 1049 printf_nolog("%d ", i / (1024*1024));
1050 1050
1051 (void) pmap_map(dumpspace, maddr, maddr + n, 1051 (void) pmap_map(dumpspace, maddr, maddr + n,
1052 VM_PROT_READ); 1052 VM_PROT_READ);
1053 error = (*dump)(dumpdev, blkno, 1053 error = (*dump)(dumpdev, blkno,
1054 (void *)dumpspace, (int)n); 1054 (void *)dumpspace, (int)n);
1055 pmap_kremove(dumpspace, n); 1055 pmap_kremove(dumpspace, n);
1056 pmap_update(pmap_kernel()); 1056 pmap_update(pmap_kernel());
1057 if (error) 1057 if (error)
1058 break; 1058 break;
1059 maddr += n; 1059 maddr += n;
1060 blkno += btodb(n); 1060 blkno += btodb(n);
1061 } 1061 }
1062 } 1062 }
1063 1063
1064 switch (error) { 1064 switch (error) {
1065 1065
1066 case ENXIO: 1066 case ENXIO:
1067 printf("device bad\n"); 1067 printf("device bad\n");
1068 break; 1068 break;
1069 1069
1070 case EFAULT: 1070 case EFAULT:
1071 printf("device not ready\n"); 1071 printf("device not ready\n");
1072 break; 1072 break;
1073 1073
1074 case EINVAL: 1074 case EINVAL:
1075 printf("area improper\n"); 1075 printf("area improper\n");
1076 break; 1076 break;
1077 1077
1078 case EIO: 1078 case EIO:
1079 printf("i/o error\n"); 1079 printf("i/o error\n");
1080 break; 1080 break;
1081 1081
1082 case 0: 1082 case 0:
1083 printf("succeeded\n"); 1083 printf("succeeded\n");
1084 break; 1084 break;
1085 1085
1086 default: 1086 default:
1087 printf("error %d\n", error); 1087 printf("error %d\n", error);
1088 break; 1088 break;
1089 } 1089 }
1090} 1090}
1091 1091
1092/* 1092/*
1093 * get the fp and dump the stack as best we can. don't leave the 1093 * get the fp and dump the stack as best we can. don't leave the
1094 * current stack page 1094 * current stack page
1095 */ 1095 */
1096void 1096void
1097stackdump(void) 1097stackdump(void)
1098{ 1098{
1099 struct frame *fp = getfp(), *sfp; 1099 struct frame *fp = getfp(), *sfp;
1100 1100
1101 sfp = fp; 1101 sfp = fp;
1102 printf("Frame pointer is at %p\n", fp); 1102 printf("Frame pointer is at %p\n", fp);
1103 printf("Call traceback:\n"); 1103 printf("Call traceback:\n");
1104 while (fp && ((u_long)fp >> PGSHIFT) == ((u_long)sfp >> PGSHIFT)) { 1104 while (fp && ((u_long)fp >> PGSHIFT) == ((u_long)sfp >> PGSHIFT)) {
1105 printf(" pc = 0x%x args = (0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) fp = %p\n", 1105 printf(" pc = 0x%x args = (0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) fp = %p\n",
1106 fp->fr_pc, fp->fr_arg[0], fp->fr_arg[1], fp->fr_arg[2], 1106 fp->fr_pc, fp->fr_arg[0], fp->fr_arg[1], fp->fr_arg[2],
1107 fp->fr_arg[3], fp->fr_arg[4], fp->fr_arg[5], fp->fr_arg[6], 1107 fp->fr_arg[3], fp->fr_arg[4], fp->fr_arg[5], fp->fr_arg[6],
1108 fp->fr_fp); 1108 fp->fr_fp);
1109 fp = fp->fr_fp; 1109 fp = fp->fr_fp;
1110 } 1110 }
1111} 1111}
1112 1112
1113int 1113int
1114cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp) 1114cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp)
1115{ 1115{
1116 1116
1117 return (ENOEXEC); 1117 return (ENOEXEC);
1118} 1118}
1119 1119
1120#if defined(SUN4) 1120#if defined(SUN4)
1121void 1121void
1122oldmon_w_trace(u_long va) 1122oldmon_w_trace(u_long va)
1123{ 1123{
1124 u_long stop; 1124 u_long stop;
1125 struct frame *fp; 1125 struct frame *fp;
1126 1126
1127 if (curlwp) 1127 if (curlwp)
1128 printf("curlwp = %p, pid %d\n", 1128 printf("curlwp = %p, pid %d\n",
1129 curlwp, curproc->p_pid); 1129 curlwp, curproc->p_pid);
1130 else 1130 else
1131 printf("no curlwp\n"); 1131 printf("no curlwp\n");
1132 1132
1133 printf("uvm: swtch %d, trap %d, sys %d, intr %d, soft %d, faults %d\n", 1133 printf("uvm: swtch %d, trap %d, sys %d, intr %d, soft %d, faults %d\n",
1134 uvmexp.swtch, uvmexp.traps, uvmexp.syscalls, uvmexp.intrs, 1134 uvmexp.swtch, uvmexp.traps, uvmexp.syscalls, uvmexp.intrs,
1135 uvmexp.softs, uvmexp.faults); 1135 uvmexp.softs, uvmexp.faults);
1136 write_user_windows(); 1136 write_user_windows();
1137 1137
1138#define round_up(x) (( (x) + (PAGE_SIZE-1) ) & (~(PAGE_SIZE-1)) ) 1138#define round_up(x) (( (x) + (PAGE_SIZE-1) ) & (~(PAGE_SIZE-1)) )
1139 1139
1140 printf("\nstack trace with sp = 0x%lx\n", va); 1140 printf("\nstack trace with sp = 0x%lx\n", va);
1141 stop = round_up(va); 1141 stop = round_up(va);
1142 printf("stop at 0x%lx\n", stop); 1142 printf("stop at 0x%lx\n", stop);
1143 fp = (struct frame *) va; 1143 fp = (struct frame *) va;
1144 while (round_up((u_long) fp) == stop) { 1144 while (round_up((u_long) fp) == stop) {
1145 printf(" 0x%x(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) fp %p\n", fp->fr_pc, 1145 printf(" 0x%x(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) fp %p\n", fp->fr_pc,
1146 fp->fr_arg[0], fp->fr_arg[1], fp->fr_arg[2], fp->fr_arg[3], 1146 fp->fr_arg[0], fp->fr_arg[1], fp->fr_arg[2], fp->fr_arg[3],
1147 fp->fr_arg[4], fp->fr_arg[5], fp->fr_arg[6], fp->fr_fp); 1147 fp->fr_arg[4], fp->fr_arg[5], fp->fr_arg[6], fp->fr_fp);
1148 fp = fp->fr_fp; 1148 fp = fp->fr_fp;
1149 if (fp == NULL) 1149 if (fp == NULL)
1150 break; 1150 break;
1151 } 1151 }
1152 printf("end of stack trace\n"); 1152 printf("end of stack trace\n");
1153} 1153}
1154 1154
1155void 1155void
1156oldmon_w_cmd(u_long va, char *ar) 1156oldmon_w_cmd(u_long va, char *ar)
1157{ 1157{
1158 switch (*ar) { 1158 switch (*ar) {
1159 case '\0': 1159 case '\0':
1160 switch (va) { 1160 switch (va) {
1161 case 0: 1161 case 0:
1162 panic("g0 panic"); 1162 panic("g0 panic");
1163 case 4: 1163 case 4:
1164 printf("w: case 4\n"); 1164 printf("w: case 4\n");
1165 break; 1165 break;
1166 default: 1166 default:
1167 printf("w: unknown case %ld\n", va); 1167 printf("w: unknown case %ld\n", va);
1168 break; 1168 break;
1169 } 1169 }
1170 break; 1170 break;
1171 case 't': 1171 case 't':
1172 oldmon_w_trace(va); 1172 oldmon_w_trace(va);
1173 break; 1173 break;
1174 default: 1174 default:
1175 printf("w: arg not allowed\n"); 1175 printf("w: arg not allowed\n");
1176 } 1176 }
1177} 1177}
1178 1178
1179int 1179int
1180ldcontrolb(void *addr) 1180ldcontrolb(void *addr)
1181{ 1181{
1182 struct pcb *xpcb; 1182 struct pcb *xpcb;
1183 extern struct user *proc0paddr; 1183 extern struct user *proc0paddr;
1184 u_long saveonfault; 1184 u_long saveonfault;
1185 int res; 1185 int res;
1186 int s; 1186 int s;
1187 1187
1188 if (CPU_ISSUN4M || CPU_ISSUN4D) { 1188 if (CPU_ISSUN4M || CPU_ISSUN4D) {
1189 printf("warning: ldcontrolb called on sun4m/sun4d\n"); 1189 printf("warning: ldcontrolb called on sun4m/sun4d\n");
1190 return 0; 1190 return 0;
1191 } 1191 }
1192 1192
1193 s = splhigh(); 1193 s = splhigh();
1194 if (curlwp == NULL) 1194 if (curlwp == NULL)
1195 xpcb = (struct pcb *)proc0paddr; 1195 xpcb = (struct pcb *)proc0paddr;
1196 else 1196 else
1197 xpcb = &curlwp->l_addr->u_pcb; 1197 xpcb = &curlwp->l_addr->u_pcb;
1198 1198
1199 saveonfault = (u_long)xpcb->pcb_onfault; 1199 saveonfault = (u_long)xpcb->pcb_onfault;
1200 res = xldcontrolb(addr, xpcb); 1200 res = xldcontrolb(addr, xpcb);
1201 xpcb->pcb_onfault = (void *)saveonfault; 1201 xpcb->pcb_onfault = (void *)saveonfault;
1202 1202
1203 splx(s); 1203 splx(s);
1204 return (res); 1204 return (res);
1205} 1205}
1206#endif /* SUN4 */ 1206#endif /* SUN4 */
1207 1207
1208void 1208void
1209wzero(void *vb, u_int l) 1209wzero(void *vb, u_int l)
1210{ 1210{
1211 u_char *b = vb; 1211 u_char *b = vb;
1212 u_char *be = b + l; 1212 u_char *be = b + l;
1213 u_short *sp; 1213 u_short *sp;
1214 1214
1215 if (l == 0) 1215 if (l == 0)
1216 return; 1216 return;
1217 1217
1218 /* front, */ 1218 /* front, */
1219 if ((u_long)b & 1) 1219 if ((u_long)b & 1)
1220 *b++ = 0; 1220 *b++ = 0;
1221 1221
1222 /* back, */ 1222 /* back, */
1223 if (b != be && ((u_long)be & 1) != 0) { 1223 if (b != be && ((u_long)be & 1) != 0) {
1224 be--; 1224 be--;
1225 *be = 0; 1225 *be = 0;
1226 } 1226 }
1227 1227
1228 /* and middle. */ 1228 /* and middle. */
1229 sp = (u_short *)b; 1229 sp = (u_short *)b;
1230 while (sp != (u_short *)be) 1230 while (sp != (u_short *)be)
1231 *sp++ = 0; 1231 *sp++ = 0;
1232} 1232}
1233 1233
1234void 1234void
1235wcopy(const void *vb1, void *vb2, u_int l) 1235wcopy(const void *vb1, void *vb2, u_int l)
1236{ 1236{
1237 const u_char *b1e, *b1 = vb1; 1237 const u_char *b1e, *b1 = vb1;
1238 u_char *b2 = vb2; 1238 u_char *b2 = vb2;
1239 const u_short *sp; 1239 const u_short *sp;
1240 int bstore = 0; 1240 int bstore = 0;
1241 1241
1242 if (l == 0) 1242 if (l == 0)
1243 return; 1243 return;
1244 1244
1245 /* front, */ 1245 /* front, */
1246 if ((u_long)b1 & 1) { 1246 if ((u_long)b1 & 1) {
1247 *b2++ = *b1++; 1247 *b2++ = *b1++;
1248 l--; 1248 l--;
1249 } 1249 }
1250 1250
1251 /* middle, */ 1251 /* middle, */
1252 sp = (const u_short *)b1; 1252 sp = (const u_short *)b1;
1253 b1e = b1 + l; 1253 b1e = b1 + l;
1254 if (l & 1) 1254 if (l & 1)
1255 b1e--; 1255 b1e--;
1256 bstore = (u_long)b2 & 1; 1256 bstore = (u_long)b2 & 1;
1257 1257
1258 while (sp < (const u_short *)b1e) { 1258 while (sp < (const u_short *)b1e) {
1259 if (bstore) { 1259 if (bstore) {
1260 b2[1] = *sp & 0xff; 1260 b2[1] = *sp & 0xff;
1261 b2[0] = *sp >> 8; 1261 b2[0] = *sp >> 8;
1262 } else 1262 } else
1263 *((short *)b2) = *sp; 1263 *((short *)b2) = *sp;
1264 sp++; 1264 sp++;
1265 b2 += 2; 1265 b2 += 2;
1266 } 1266 }
1267 1267
1268 /* and back. */ 1268 /* and back. */
1269 if (l & 1) 1269 if (l & 1)
1270 *b2 = *b1e; 1270 *b2 = *b1e;
1271} 1271}
1272 1272
1273#ifdef MODULAR 1273#ifdef MODULAR
1274void 1274void
1275module_init_md(void) 1275module_init_md(void)
1276{ 1276{
1277} 1277}
1278#endif 1278#endif
1279 1279
1280/* 1280/*
1281 * Common function for DMA map creation. May be called by bus-specific 1281 * Common function for DMA map creation. May be called by bus-specific
1282 * DMA map creation functions. 1282 * DMA map creation functions.
1283 */ 1283 */
1284int 1284int
1285_bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments, 1285_bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
1286 bus_size_t maxsegsz, bus_size_t boundary, int flags, 1286 bus_size_t maxsegsz, bus_size_t boundary, int flags,
1287 bus_dmamap_t *dmamp) 1287 bus_dmamap_t *dmamp)
1288{ 1288{
1289 struct sparc_bus_dmamap *map; 1289 struct sparc_bus_dmamap *map;
1290 void *mapstore; 1290 void *mapstore;
1291 size_t mapsize; 1291 size_t mapsize;
1292 1292
1293 /* 1293 /*
1294 * Allocate and initialize the DMA map. The end of the map 1294 * Allocate and initialize the DMA map. The end of the map
1295 * is a variable-sized array of segments, so we allocate enough 1295 * is a variable-sized array of segments, so we allocate enough
1296 * room for them in one shot. 1296 * room for them in one shot.
1297 * 1297 *
1298 * Note we don't preserve the WAITOK or NOWAIT flags. Preservation 1298 * Note we don't preserve the WAITOK or NOWAIT flags. Preservation
1299 * of ALLOCNOW notifies others that we've reserved these resources, 1299 * of ALLOCNOW notifies others that we've reserved these resources,
1300 * and they are not to be freed. 1300 * and they are not to be freed.
1301 * 1301 *
1302 * The bus_dmamap_t includes one bus_dma_segment_t, hence 1302 * The bus_dmamap_t includes one bus_dma_segment_t, hence
1303 * the (nsegments - 1). 1303 * the (nsegments - 1).
1304 */ 1304 */
1305 mapsize = sizeof(struct sparc_bus_dmamap) + 1305 mapsize = sizeof(struct sparc_bus_dmamap) +
1306 (sizeof(bus_dma_segment_t) * (nsegments - 1)); 1306 (sizeof(bus_dma_segment_t) * (nsegments - 1));
1307 if ((mapstore = malloc(mapsize, M_DMAMAP, 1307 if ((mapstore = malloc(mapsize, M_DMAMAP,
1308 (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL) 1308 (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
1309 return (ENOMEM); 1309 return (ENOMEM);
1310 1310
1311 memset(mapstore, 0, mapsize); 1311 memset(mapstore, 0, mapsize);
1312 map = (struct sparc_bus_dmamap *)mapstore; 1312 map = (struct sparc_bus_dmamap *)mapstore;
1313 map->_dm_size = size; 1313 map->_dm_size = size;
1314 map->_dm_segcnt = nsegments; 1314 map->_dm_segcnt = nsegments;
1315 map->_dm_maxmaxsegsz = maxsegsz; 1315 map->_dm_maxmaxsegsz = maxsegsz;
1316 map->_dm_boundary = boundary; 1316 map->_dm_boundary = boundary;
1317 map->_dm_align = PAGE_SIZE; 1317 map->_dm_align = PAGE_SIZE;
1318 map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT); 1318 map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
1319 map->dm_maxsegsz = maxsegsz; 1319 map->dm_maxsegsz = maxsegsz;
1320 map->dm_mapsize = 0; /* no valid mappings */ 1320 map->dm_mapsize = 0; /* no valid mappings */
1321 map->dm_nsegs = 0; 1321 map->dm_nsegs = 0;
1322 1322
1323 *dmamp = map; 1323 *dmamp = map;
1324 return (0); 1324 return (0);
1325} 1325}
1326 1326
1327/* 1327/*
1328 * Common function for DMA map destruction. May be called by bus-specific 1328 * Common function for DMA map destruction. May be called by bus-specific
1329 * DMA map destruction functions. 1329 * DMA map destruction functions.
1330 */ 1330 */
1331void 1331void
1332_bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map) 1332_bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
1333{ 1333{
1334 1334
1335 free(map, M_DMAMAP); 1335 free(map, M_DMAMAP);
1336} 1336}
1337 1337
1338/* 1338/*
1339 * Like _bus_dmamap_load(), but for mbufs. 1339 * Like _bus_dmamap_load(), but for mbufs.
1340 */ 1340 */
1341int 1341int
1342_bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, 1342_bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map,
1343 struct mbuf *m, int flags) 1343 struct mbuf *m, int flags)
1344{ 1344{
1345 1345
1346 panic("_bus_dmamap_load_mbuf: not implemented"); 1346 panic("_bus_dmamap_load_mbuf: not implemented");
1347} 1347}
1348 1348
1349/* 1349/*
1350 * Like _bus_dmamap_load(), but for uios. 1350 * Like _bus_dmamap_load(), but for uios.
1351 */ 1351 */
1352int 1352int
1353_bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, 1353_bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map,
1354 struct uio *uio, int flags) 1354 struct uio *uio, int flags)
1355{ 1355{
1356 1356
1357 panic("_bus_dmamap_load_uio: not implemented"); 1357 panic("_bus_dmamap_load_uio: not implemented");
1358} 1358}
1359 1359
1360/* 1360/*
1361 * Like _bus_dmamap_load(), but for raw memory allocated with 1361 * Like _bus_dmamap_load(), but for raw memory allocated with
1362 * bus_dmamem_alloc(). 1362 * bus_dmamem_alloc().
1363 */ 1363 */
1364int 1364int
1365_bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, 1365_bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map,
1366 bus_dma_segment_t *segs, int nsegs, bus_size_t size, 1366 bus_dma_segment_t *segs, int nsegs, bus_size_t size,
1367 int flags) 1367 int flags)
1368{ 1368{
1369 1369
1370 panic("_bus_dmamap_load_raw: not implemented"); 1370 panic("_bus_dmamap_load_raw: not implemented");
1371} 1371}
1372 1372
1373/* 1373/*
1374 * Common function for DMA map synchronization. May be called 1374 * Common function for DMA map synchronization. May be called
1375 * by bus-specific DMA map synchronization functions. 1375 * by bus-specific DMA map synchronization functions.
1376 */ 1376 */
1377void 1377void
1378_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, 1378_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map,
1379 bus_addr_t offset, bus_size_t len, int ops) 1379 bus_addr_t offset, bus_size_t len, int ops)
1380{ 1380{
1381} 1381}
1382 1382
1383/* 1383/*
1384 * Common function for DMA-safe memory allocation. May be called 1384 * Common function for DMA-safe memory allocation. May be called
1385 * by bus-specific DMA memory allocation functions. 1385 * by bus-specific DMA memory allocation functions.
1386 */ 1386 */
1387int 1387int
1388_bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, 1388_bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size,
1389 bus_size_t alignment, bus_size_t boundary, 1389 bus_size_t alignment, bus_size_t boundary,
1390 bus_dma_segment_t *segs, int nsegs, int *rsegs, 1390 bus_dma_segment_t *segs, int nsegs, int *rsegs,
1391 int flags) 1391 int flags)
1392{ 1392{
1393 vaddr_t low, high; 1393 vaddr_t low, high;
1394 struct pglist *mlist; 1394 struct pglist *mlist;
1395 int error; 1395 int error;
1396 1396
1397 /* Always round the size. */ 1397 /* Always round the size. */
1398 size = round_page(size); 1398 size = round_page(size);
1399 low = vm_first_phys; 1399 low = vm_first_phys;
1400 high = vm_first_phys + vm_num_phys - PAGE_SIZE; 1400 high = vm_first_phys + vm_num_phys - PAGE_SIZE;
1401 1401
1402 if ((mlist = malloc(sizeof(*mlist), M_DEVBUF, 1402 if ((mlist = malloc(sizeof(*mlist), M_DEVBUF,
1403 (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL) 1403 (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
1404 return (ENOMEM); 1404 return (ENOMEM);
1405 1405
1406 /* 1406 /*
1407 * Allocate pages from the VM system. 1407 * Allocate pages from the VM system.
1408 */ 1408 */
1409 error = uvm_pglistalloc(size, low, high, 0, 0, 1409 error = uvm_pglistalloc(size, low, high, 0, 0,
1410 mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); 1410 mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
1411 if (error) 1411 if (error)
1412 return (error); 1412 return (error);
1413 1413
1414 /* 1414 /*
1415 * Simply keep a pointer around to the linked list, so 1415 * Simply keep a pointer around to the linked list, so
1416 * bus_dmamap_free() can return it. 1416 * bus_dmamap_free() can return it.
1417 * 1417 *
1418 * NOBODY SHOULD TOUCH THE pageq.queue FIELDS WHILE THESE PAGES 1418 * NOBODY SHOULD TOUCH THE pageq.queue FIELDS WHILE THESE PAGES
1419 * ARE IN OUR CUSTODY. 1419 * ARE IN OUR CUSTODY.
1420 */ 1420 */
1421 segs[0]._ds_mlist = mlist; 1421 segs[0]._ds_mlist = mlist;
1422 1422
1423 /* 1423 /*
1424 * We now have physical pages, but no DVMA addresses yet. These 1424 * We now have physical pages, but no DVMA addresses yet. These
1425 * will be allocated in bus_dmamap_load*() routines. Hence we 1425 * will be allocated in bus_dmamap_load*() routines. Hence we
1426 * save any alignment and boundary requirements in this DMA 1426 * save any alignment and boundary requirements in this DMA
1427 * segment. 1427 * segment.
1428 */ 1428 */
1429 segs[0].ds_addr = 0; 1429 segs[0].ds_addr = 0;
1430 segs[0].ds_len = 0; 1430 segs[0].ds_len = 0;
1431 segs[0]._ds_va = 0; 1431 segs[0]._ds_va = 0;
1432 *rsegs = 1; 1432 *rsegs = 1;
1433 return (0); 1433 return (0);
1434} 1434}
1435 1435
1436/* 1436/*
1437 * Common function for freeing DMA-safe memory. May be called by 1437 * Common function for freeing DMA-safe memory. May be called by
1438 * bus-specific DMA memory free functions. 1438 * bus-specific DMA memory free functions.
1439 */ 1439 */
1440void 1440void
1441_bus_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs) 1441_bus_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
1442{ 1442{
1443 1443
1444 if (nsegs != 1) 1444 if (nsegs != 1)
1445 panic("bus_dmamem_free: nsegs = %d", nsegs); 1445 panic("bus_dmamem_free: nsegs = %d", nsegs);
1446 1446
1447 /* 1447 /*
1448 * Return the list of pages back to the VM system. 1448 * Return the list of pages back to the VM system.
1449 */ 1449 */
1450 uvm_pglistfree(segs[0]._ds_mlist); 1450 uvm_pglistfree(segs[0]._ds_mlist);
1451 free(segs[0]._ds_mlist, M_DEVBUF); 1451 free(segs[0]._ds_mlist, M_DEVBUF);
1452} 1452}
1453 1453
1454/* 1454/*
1455 * Common function for unmapping DMA-safe memory. May be called by 1455 * Common function for unmapping DMA-safe memory. May be called by
1456 * bus-specific DMA memory unmapping functions. 1456 * bus-specific DMA memory unmapping functions.
1457 */ 1457 */
1458void 1458void
1459_bus_dmamem_unmap(bus_dma_tag_t t, void *kva, size_t size) 1459_bus_dmamem_unmap(bus_dma_tag_t t, void *kva, size_t size)
1460{ 1460{
1461 1461
1462#ifdef DIAGNOSTIC 1462#ifdef DIAGNOSTIC
1463 if ((u_long)kva & PAGE_MASK) 1463 if ((u_long)kva & PAGE_MASK)
1464 panic("_bus_dmamem_unmap"); 1464 panic("_bus_dmamem_unmap");
1465#endif 1465#endif
1466 1466
1467 size = round_page(size); 1467 size = round_page(size);
1468 pmap_kremove((vaddr_t)kva, size); 1468 pmap_kremove((vaddr_t)kva, size);
1469 pmap_update(pmap_kernel()); 1469 pmap_update(pmap_kernel());
1470 uvm_km_free(kernel_map, (vaddr_t)kva, size, UVM_KMF_VAONLY); 1470 uvm_km_free(kernel_map, (vaddr_t)kva, size, UVM_KMF_VAONLY);
1471} 1471}
1472 1472
1473/* 1473/*
1474 * Common functin for mmap(2)'ing DMA-safe memory. May be called by 1474 * Common functin for mmap(2)'ing DMA-safe memory. May be called by
1475 * bus-specific DMA mmap(2)'ing functions. 1475 * bus-specific DMA mmap(2)'ing functions.
1476 */ 1476 */
1477paddr_t 1477paddr_t
1478_bus_dmamem_mmap(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, 1478_bus_dmamem_mmap(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
1479 off_t off, int prot, int flags) 1479 off_t off, int prot, int flags)
1480{ 1480{
1481 1481
1482 panic("_bus_dmamem_mmap: not implemented"); 1482 panic("_bus_dmamem_mmap: not implemented");
1483} 1483}
1484 1484
1485/* 1485/*
1486 * Utility to allocate an aligned kernel virtual address range 1486 * Utility to allocate an aligned kernel virtual address range
1487 */ 1487 */
1488vaddr_t 1488vaddr_t
1489_bus_dma_valloc_skewed(size_t size, u_long boundary, u_long align, u_long skew) 1489_bus_dma_valloc_skewed(size_t size, u_long boundary, u_long align, u_long skew)
1490{ 1490{
1491 size_t oversize; 1491 size_t oversize;
1492 vaddr_t va, sva; 1492 vaddr_t va, sva;
1493 1493
1494 /* 1494 /*
1495 * Find a region of kernel virtual addresses that is aligned 1495 * Find a region of kernel virtual addresses that is aligned
1496 * to the given address modulo the requested alignment, i.e. 1496 * to the given address modulo the requested alignment, i.e.
1497 * 1497 *
1498 * (va - skew) == 0 mod align 1498 * (va - skew) == 0 mod align
1499 * 1499 *
1500 * The following conditions apply to the arguments: 1500 * The following conditions apply to the arguments:
1501 * 1501 *
1502 * - `size' must be a multiple of the VM page size 1502 * - `size' must be a multiple of the VM page size
1503 * - `align' must be a power of two 1503 * - `align' must be a power of two
1504 * and greater than or equal to the VM page size 1504 * and greater than or equal to the VM page size
1505 * - `skew' must be smaller than `align' 1505 * - `skew' must be smaller than `align'
1506 * - `size' must be smaller than `boundary' 1506 * - `size' must be smaller than `boundary'
1507 */ 1507 */
1508 1508
1509#ifdef DIAGNOSTIC 1509#ifdef DIAGNOSTIC
1510 if ((size & PAGE_MASK) != 0) 1510 if ((size & PAGE_MASK) != 0)
1511 panic("_bus_dma_valloc_skewed: invalid size %lx", size); 1511 panic("_bus_dma_valloc_skewed: invalid size %lx", size);
1512 if ((align & PAGE_MASK) != 0) 1512 if ((align & PAGE_MASK) != 0)
1513 panic("_bus_dma_valloc_skewed: invalid alignment %lx", align); 1513 panic("_bus_dma_valloc_skewed: invalid alignment %lx", align);
1514 if (align < skew) 1514 if (align < skew)
1515 panic("_bus_dma_valloc_skewed: align %lx < skew %lx", 1515 panic("_bus_dma_valloc_skewed: align %lx < skew %lx",
1516 align, skew); 1516 align, skew);
1517#endif 1517#endif
1518 1518
1519 /* XXX - Implement this! */ 1519 /* XXX - Implement this! */
1520 if (boundary) { 1520 if (boundary) {
1521 printf("_bus_dma_valloc_skewed: " 1521 printf("_bus_dma_valloc_skewed: "
1522 "boundary check not implemented"); 1522 "boundary check not implemented");
1523 return (0); 1523 return (0);
1524 } 1524 }
1525 1525
1526 /* 1526 /*
1527 * First, find a region large enough to contain any aligned chunk 1527 * First, find a region large enough to contain any aligned chunk
1528 */ 1528 */
1529 oversize = size + align - PAGE_SIZE; 1529 oversize = size + align - PAGE_SIZE;
1530 sva = vm_map_min(kernel_map); 1530 sva = vm_map_min(kernel_map);
1531 if (uvm_map(kernel_map, &sva, oversize, NULL, UVM_UNKNOWN_OFFSET, 1531 if (uvm_map(kernel_map, &sva, oversize, NULL, UVM_UNKNOWN_OFFSET,
1532 align, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE, 1532 align, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE,
1533 UVM_ADV_RANDOM, UVM_FLAG_NOWAIT))) 1533 UVM_ADV_RANDOM, UVM_FLAG_NOWAIT)))
1534 return (0); 1534 return (0);
1535 1535
1536 /* 1536 /*
1537 * Compute start of aligned region 1537 * Compute start of aligned region
1538 */ 1538 */
1539 va = sva; 1539 va = sva;
1540 va += (skew + align - va) & (align - 1); 1540 va += (skew + align - va) & (align - 1);
1541 1541
1542 /* 1542 /*
1543 * Return excess virtual addresses 1543 * Return excess virtual addresses
1544 */ 1544 */
1545 if (va != sva) 1545 if (va != sva)
1546 (void)uvm_unmap(kernel_map, sva, va); 1546 (void)uvm_unmap(kernel_map, sva, va);
1547 if (va + size != sva + oversize) 1547 if (va + size != sva + oversize)
1548 (void)uvm_unmap(kernel_map, va + size, sva + oversize); 1548 (void)uvm_unmap(kernel_map, va + size, sva + oversize);
1549 1549
1550 return (va); 1550 return (va);
1551} 1551}
1552 1552
1553/* sun4/sun4c DMA map functions */ 1553/* sun4/sun4c DMA map functions */
1554int sun4_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *, 1554int sun4_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *,
1555 bus_size_t, struct proc *, int); 1555 bus_size_t, struct proc *, int);
1556int sun4_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t, 1556int sun4_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t,
1557 bus_dma_segment_t *, int, bus_size_t, int); 1557 bus_dma_segment_t *, int, bus_size_t, int);
1558void sun4_dmamap_unload(bus_dma_tag_t, bus_dmamap_t); 1558void sun4_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
1559int sun4_dmamem_map(bus_dma_tag_t, bus_dma_segment_t *, 1559int sun4_dmamem_map(bus_dma_tag_t, bus_dma_segment_t *,
1560 int, size_t, void **, int); 1560 int, size_t, void **, int);
1561 1561
1562/* 1562/*
1563 * sun4/sun4c: load DMA map with a linear buffer. 1563 * sun4/sun4c: load DMA map with a linear buffer.
1564 */ 1564 */
1565int 1565int
1566sun4_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, 1566sun4_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map,
1567 void *buf, bus_size_t buflen, 1567 void *buf, bus_size_t buflen,
1568 struct proc *p, int flags) 1568 struct proc *p, int flags)
1569{ 1569{
1570 bus_size_t sgsize; 1570 bus_size_t sgsize;
1571 vaddr_t va = (vaddr_t)buf; 1571 vaddr_t va = (vaddr_t)buf;
1572 int pagesz = PAGE_SIZE; 1572 int pagesz = PAGE_SIZE;
1573 vaddr_t dva; 1573 vaddr_t dva;
1574 pmap_t pmap; 1574 pmap_t pmap;
1575 1575
1576 /* 1576 /*
1577 * Make sure that on error condition we return "no valid mappings". 1577 * Make sure that on error condition we return "no valid mappings".
1578 */ 1578 */
1579 map->dm_nsegs = 0; 1579 map->dm_nsegs = 0;
1580 1580
1581 if (buflen > map->_dm_size) 1581 if (buflen > map->_dm_size)
1582 return (EINVAL); 1582 return (EINVAL);
1583 1583
1584 cache_flush(buf, buflen); 1584 cache_flush(buf, buflen);
1585 1585
1586 if ((map->_dm_flags & BUS_DMA_24BIT) == 0) { 1586 if ((map->_dm_flags & BUS_DMA_24BIT) == 0) {
1587 /* 1587 /*
1588 * XXX Need to implement "don't DMA across this boundry". 1588 * XXX Need to implement "don't DMA across this boundry".
1589 */ 1589 */
1590 if (map->_dm_boundary != 0) { 1590 if (map->_dm_boundary != 0) {
1591 bus_addr_t baddr; 1591 bus_addr_t baddr;
1592 1592
1593 /* Calculate first boundary line after `buf' */ 1593 /* Calculate first boundary line after `buf' */
1594 baddr = ((bus_addr_t)va + map->_dm_boundary) & 1594 baddr = ((bus_addr_t)va + map->_dm_boundary) &
1595 -map->_dm_boundary; 1595 -map->_dm_boundary;
1596 1596
1597 /* 1597 /*
1598 * If the requested segment crosses the boundary, 1598 * If the requested segment crosses the boundary,
1599 * we can't grant a direct map. For now, steal some 1599 * we can't grant a direct map. For now, steal some
1600 * space from the `24BIT' map instead. 1600 * space from the `24BIT' map instead.
1601 * 1601 *
1602 * (XXX - no overflow detection here) 1602 * (XXX - no overflow detection here)
1603 */ 1603 */
1604 if (buflen > (baddr - (bus_addr_t)va)) 1604 if (buflen > (baddr - (bus_addr_t)va))
1605 goto no_fit; 1605 goto no_fit;
1606 } 1606 }
1607 map->dm_mapsize = buflen; 1607 map->dm_mapsize = buflen;
1608 map->dm_nsegs = 1; 1608 map->dm_nsegs = 1;
1609 map->dm_segs[0].ds_addr = (bus_addr_t)va; 1609 map->dm_segs[0].ds_addr = (bus_addr_t)va;
1610 map->dm_segs[0].ds_len = buflen; 1610 map->dm_segs[0].ds_len = buflen;
1611 map->_dm_flags |= _BUS_DMA_DIRECTMAP; 1611 map->_dm_flags |= _BUS_DMA_DIRECTMAP;
1612 return (0); 1612 return (0);
1613 } 1613 }
1614 1614
1615no_fit: 1615no_fit:
1616 sgsize = round_page(buflen + (va & (pagesz - 1))); 1616 sgsize = round_page(buflen + (va & (pagesz - 1)));
1617 1617
1618 if (extent_alloc(dvmamap24, sgsize, pagesz, map->_dm_boundary, 1618 if (extent_alloc(dvmamap24, sgsize, pagesz, map->_dm_boundary,
1619 (flags & BUS_DMA_NOWAIT) == 0 ? EX_WAITOK : EX_NOWAIT, 1619 (flags & BUS_DMA_NOWAIT) == 0 ? EX_WAITOK : EX_NOWAIT,
1620 &dva) != 0) { 1620 &dva) != 0) {
1621 return (ENOMEM); 1621 return (ENOMEM);
1622 } 1622 }
1623 1623
1624 /* 1624 /*
1625 * We always use just one segment. 1625 * We always use just one segment.
1626 */ 1626 */
1627 map->dm_mapsize = buflen; 1627 map->dm_mapsize = buflen;
1628 map->dm_segs[0].ds_addr = dva + (va & (pagesz - 1)); 1628 map->dm_segs[0].ds_addr = dva + (va & (pagesz - 1));
1629 map->dm_segs[0].ds_len = buflen; 1629 map->dm_segs[0].ds_len = buflen;
1630 map->dm_segs[0]._ds_sgsize = sgsize; 1630 map->dm_segs[0]._ds_sgsize = sgsize;
1631 1631
1632 if (p != NULL) 1632 if (p != NULL)
1633 pmap = p->p_vmspace->vm_map.pmap; 1633 pmap = p->p_vmspace->vm_map.pmap;
1634 else 1634 else
1635 pmap = pmap_kernel(); 1635 pmap = pmap_kernel();
1636 1636
1637 for (; buflen > 0; ) { 1637 for (; buflen > 0; ) {
1638 paddr_t pa; 1638 paddr_t pa;
1639 1639
1640 /* 1640 /*
1641 * Get the physical address for this page. 1641 * Get the physical address for this page.
1642 */ 1642 */
1643 (void) pmap_extract(pmap, va, &pa); 1643 (void) pmap_extract(pmap, va, &pa);
1644 1644
1645 /* 1645 /*
1646 * Compute the segment size, and adjust counts. 1646 * Compute the segment size, and adjust counts.
1647 */ 1647 */
1648 sgsize = pagesz - (va & (pagesz - 1)); 1648 sgsize = pagesz - (va & (pagesz - 1));
1649 if (buflen < sgsize) 1649 if (buflen < sgsize)
1650 sgsize = buflen; 1650 sgsize = buflen;
1651 1651
1652#ifdef notyet 1652#ifdef notyet
1653#if defined(SUN4) 1653#if defined(SUN4)
1654 if (have_iocache) 1654 if (have_iocache)
1655 pa |= PG_IOC; 1655 pa |= PG_IOC;
1656#endif 1656#endif
1657#endif 1657#endif
1658 pmap_kenter_pa(dva, (pa & -pagesz) | PMAP_NC, 1658 pmap_kenter_pa(dva, (pa & -pagesz) | PMAP_NC,
1659 VM_PROT_READ | VM_PROT_WRITE); 1659 VM_PROT_READ | VM_PROT_WRITE);
1660 1660
1661 dva += pagesz; 1661 dva += pagesz;
1662 va += sgsize; 1662 va += sgsize;
1663 buflen -= sgsize; 1663 buflen -= sgsize;
1664 } 1664 }
1665 pmap_update(pmap_kernel()); 1665 pmap_update(pmap_kernel());
1666 1666
1667 map->dm_nsegs = 1; 1667 map->dm_nsegs = 1;
1668 return (0); 1668 return (0);
1669} 1669}
1670 1670
1671/* 1671/*
1672 * Like _bus_dmamap_load(), but for raw memory allocated with 1672 * Like _bus_dmamap_load(), but for raw memory allocated with
1673 * bus_dmamem_alloc(). 1673 * bus_dmamem_alloc().
1674 */ 1674 */
1675int 1675int
1676sun4_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, 1676sun4_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map,
1677 bus_dma_segment_t *segs, int nsegs, bus_size_t size, 1677 bus_dma_segment_t *segs, int nsegs, bus_size_t size,
1678 int flags) 1678 int flags)
1679{ 1679{
1680 struct vm_page *m; 1680 struct vm_page *m;
1681 paddr_t pa; 1681 paddr_t pa;
1682 vaddr_t dva; 1682 vaddr_t dva;
1683 bus_size_t sgsize; 1683 bus_size_t sgsize;
1684 struct pglist *mlist; 1684 struct pglist *mlist;
1685 int pagesz = PAGE_SIZE; 1685 int pagesz = PAGE_SIZE;
1686 int error; 1686 int error;
1687 1687
1688 map->dm_nsegs = 0; 1688 map->dm_nsegs = 0;
1689 sgsize = (size + pagesz - 1) & -pagesz; 1689 sgsize = (size + pagesz - 1) & -pagesz;
1690 1690
1691 /* Allocate DVMA addresses */ 1691 /* Allocate DVMA addresses */
1692 if ((map->_dm_flags & BUS_DMA_24BIT) != 0) { 1692 if ((map->_dm_flags & BUS_DMA_24BIT) != 0) {
1693 error = extent_alloc(dvmamap24, sgsize, pagesz, 1693 error = extent_alloc(dvmamap24, sgsize, pagesz,
1694 map->_dm_boundary, 1694 map->_dm_boundary,
1695 (flags & BUS_DMA_NOWAIT) == 0 1695 (flags & BUS_DMA_NOWAIT) == 0
1696 ? EX_WAITOK : EX_NOWAIT, 1696 ? EX_WAITOK : EX_NOWAIT,
1697 &dva); 1697 &dva);
1698 if (error) 1698 if (error)
1699 return (error); 1699 return (error);
1700 } else { 1700 } else {
1701 /* Any properly aligned virtual address will do */ 1701 /* Any properly aligned virtual address will do */
1702 dva = _bus_dma_valloc_skewed(sgsize, map->_dm_boundary, 1702 dva = _bus_dma_valloc_skewed(sgsize, map->_dm_boundary,
1703 pagesz, 0); 1703 pagesz, 0);
1704 if (dva == 0) 1704 if (dva == 0)
1705 return (ENOMEM); 1705 return (ENOMEM);
1706 } 1706 }
1707 1707
1708 map->dm_segs[0].ds_addr = dva; 1708 map->dm_segs[0].ds_addr = dva;
1709 map->dm_segs[0].ds_len = size; 1709 map->dm_segs[0].ds_len = size;
1710 map->dm_segs[0]._ds_sgsize = sgsize; 1710 map->dm_segs[0]._ds_sgsize = sgsize;
1711 1711
1712 /* Map physical pages into IOMMU */ 1712 /* Map physical pages into IOMMU */
1713 mlist = segs[0]._ds_mlist; 1713 mlist = segs[0]._ds_mlist;
1714 for (m = TAILQ_FIRST(mlist); m != NULL; m = TAILQ_NEXT(m,pageq.queue)) { 1714 for (m = TAILQ_FIRST(mlist); m != NULL; m = TAILQ_NEXT(m,pageq.queue)) {
1715 if (sgsize == 0) 1715 if (sgsize == 0)
1716 panic("sun4_dmamap_load_raw: size botch"); 1716 panic("sun4_dmamap_load_raw: size botch");
1717 pa = VM_PAGE_TO_PHYS(m); 1717 pa = VM_PAGE_TO_PHYS(m);
1718#ifdef notyet 1718#ifdef notyet
1719#if defined(SUN4) 1719#if defined(SUN4)
1720 if (have_iocache) 1720 if (have_iocache)
1721 pa |= PG_IOC; 1721 pa |= PG_IOC;
1722#endif 1722#endif
1723#endif 1723#endif
1724 pmap_kenter_pa(dva, (pa & -pagesz) | PMAP_NC, 1724 pmap_kenter_pa(dva, (pa & -pagesz) | PMAP_NC,
1725 VM_PROT_READ | VM_PROT_WRITE); 1725 VM_PROT_READ | VM_PROT_WRITE);
1726 1726
1727 dva += pagesz; 1727 dva += pagesz;
1728 sgsize -= pagesz; 1728 sgsize -= pagesz;
1729 } 1729 }
1730 pmap_update(pmap_kernel()); 1730 pmap_update(pmap_kernel());
1731 1731
1732 map->dm_nsegs = 1; 1732 map->dm_nsegs = 1;
1733 map->dm_mapsize = size; 1733 map->dm_mapsize = size;
1734 1734
1735 return (0); 1735 return (0);
1736} 1736}
1737 1737
1738/* 1738/*
1739 * sun4/sun4c function for unloading a DMA map. 1739 * sun4/sun4c function for unloading a DMA map.
1740 */ 1740 */
1741void 1741void
1742sun4_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) 1742sun4_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
1743{ 1743{
1744 bus_dma_segment_t *segs = map->dm_segs; 1744 bus_dma_segment_t *segs = map->dm_segs;
1745 int nsegs = map->dm_nsegs; 1745 int nsegs = map->dm_nsegs;
1746 int flags = map->_dm_flags; 1746 int flags = map->_dm_flags;
1747 vaddr_t dva; 1747 vaddr_t dva;
1748 bus_size_t len; 1748 bus_size_t len;
1749 int i, s, error; 1749 int i, s, error;
1750 1750
1751 map->dm_maxsegsz = map->_dm_maxmaxsegsz; 1751 map->dm_maxsegsz = map->_dm_maxmaxsegsz;
1752 1752
1753 if ((flags & _BUS_DMA_DIRECTMAP) != 0) { 1753 if ((flags & _BUS_DMA_DIRECTMAP) != 0) {
1754 /* Nothing to release */ 1754 /* Nothing to release */
1755 map->dm_mapsize = 0; 1755 map->dm_mapsize = 0;
1756 map->dm_nsegs = 0; 1756 map->dm_nsegs = 0;
1757 map->_dm_flags &= ~_BUS_DMA_DIRECTMAP; 1757 map->_dm_flags &= ~_BUS_DMA_DIRECTMAP;
1758 return; 1758 return;
1759 } 1759 }
1760 1760
1761 for (i = 0; i < nsegs; i++) { 1761 for (i = 0; i < nsegs; i++) {
1762 dva = segs[i].ds_addr & -PAGE_SIZE; 1762 dva = segs[i].ds_addr & -PAGE_SIZE;
1763 len = segs[i]._ds_sgsize; 1763 len = segs[i]._ds_sgsize;
1764 1764
1765 pmap_kremove(dva, len); 1765 pmap_kremove(dva, len);
1766 1766
1767 if ((flags & BUS_DMA_24BIT) != 0) { 1767 if ((flags & BUS_DMA_24BIT) != 0) {
1768 s = splhigh(); 1768 s = splhigh();
1769 error = extent_free(dvmamap24, dva, len, EX_NOWAIT); 1769 error = extent_free(dvmamap24, dva, len, EX_NOWAIT);
1770 splx(s); 1770 splx(s);
1771 if (error != 0) 1771 if (error != 0)
1772 printf("warning: %ld of DVMA space lost\n", len); 1772 printf("warning: %ld of DVMA space lost\n", len);
1773 } else { 1773 } else {
1774 uvm_unmap(kernel_map, dva, dva + len); 1774 uvm_unmap(kernel_map, dva, dva + len);
1775 } 1775 }
1776 } 1776 }
1777 pmap_update(pmap_kernel()); 1777 pmap_update(pmap_kernel());
1778 1778
1779 /* Mark the mappings as invalid. */ 1779 /* Mark the mappings as invalid. */
1780 map->dm_mapsize = 0; 1780 map->dm_mapsize = 0;
1781 map->dm_nsegs = 0; 1781 map->dm_nsegs = 0;
1782} 1782}
1783 1783
1784/* 1784/*
1785 * Common function for mapping DMA-safe memory. May be called by 1785 * Common function for mapping DMA-safe memory. May be called by
1786 * bus-specific DMA memory map functions. 1786 * bus-specific DMA memory map functions.
1787 */ 1787 */
1788int 1788int
1789sun4_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, 1789sun4_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
1790 size_t size, void **kvap, int flags) 1790 size_t size, void **kvap, int flags)
1791{ 1791{
1792 struct vm_page *m; 1792 struct vm_page *m;
1793 vaddr_t va; 1793 vaddr_t va;
1794 struct pglist *mlist; 1794 struct pglist *mlist;
1795 const uvm_flag_t kmflags = 1795 const uvm_flag_t kmflags =
1796 (flags & BUS_DMA_NOWAIT) != 0 ? UVM_KMF_NOWAIT : 0; 1796 (flags & BUS_DMA_NOWAIT) != 0 ? UVM_KMF_NOWAIT : 0;
1797 1797
1798 if (nsegs != 1) 1798 if (nsegs != 1)
1799 panic("sun4_dmamem_map: nsegs = %d", nsegs); 1799 panic("sun4_dmamem_map: nsegs = %d", nsegs);
1800 1800
1801 size = round_page(size); 1801 size = round_page(size);
1802 1802
1803 va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY | kmflags); 1803 va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY | kmflags);
1804 if (va == 0) 1804 if (va == 0)
1805 return (ENOMEM); 1805 return (ENOMEM);
1806 1806
1807 segs[0]._ds_va = va; 1807 segs[0]._ds_va = va;
1808 *kvap = (void *)va; 1808 *kvap = (void *)va;
1809 1809
1810 mlist = segs[0]._ds_mlist; 1810 mlist = segs[0]._ds_mlist;
1811 TAILQ_FOREACH(m, mlist, pageq.queue) { 1811 TAILQ_FOREACH(m, mlist, pageq.queue) {
1812 paddr_t pa; 1812 paddr_t pa;
1813 1813
1814 if (size == 0) 1814 if (size == 0)
1815 panic("sun4_dmamem_map: size botch"); 1815 panic("sun4_dmamem_map: size botch");
1816 1816
1817 pa = VM_PAGE_TO_PHYS(m); 1817 pa = VM_PAGE_TO_PHYS(m);
1818 pmap_kenter_pa(va, pa | PMAP_NC, VM_PROT_READ | VM_PROT_WRITE); 1818 pmap_kenter_pa(va, pa | PMAP_NC, VM_PROT_READ | VM_PROT_WRITE);
1819 1819
1820 va += PAGE_SIZE; 1820 va += PAGE_SIZE;
1821 size -= PAGE_SIZE; 1821 size -= PAGE_SIZE;
1822 } 1822 }
1823 pmap_update(pmap_kernel()); 1823 pmap_update(pmap_kernel());
1824 1824
1825 return (0); 1825 return (0);
1826} 1826}
1827 1827
1828 1828
1829struct sparc_bus_dma_tag mainbus_dma_tag = { 1829struct sparc_bus_dma_tag mainbus_dma_tag = {
1830 NULL, 1830 NULL,
1831 _bus_dmamap_create, 1831 _bus_dmamap_create,
1832 _bus_dmamap_destroy, 1832 _bus_dmamap_destroy,
1833 sun4_dmamap_load, 1833 sun4_dmamap_load,
1834 _bus_dmamap_load_mbuf, 1834 _bus_dmamap_load_mbuf,
1835 _bus_dmamap_load_uio, 1835 _bus_dmamap_load_uio,
1836 sun4_dmamap_load_raw, 1836 sun4_dmamap_load_raw,
1837 sun4_dmamap_unload, 1837 sun4_dmamap_unload,
1838 _bus_dmamap_sync, 1838 _bus_dmamap_sync,
1839 1839
1840 _bus_dmamem_alloc, 1840 _bus_dmamem_alloc,
1841 _bus_dmamem_free, 1841 _bus_dmamem_free,
1842 sun4_dmamem_map, 1842 sun4_dmamem_map,
1843 _bus_dmamem_unmap, 1843 _bus_dmamem_unmap,
1844 _bus_dmamem_mmap 1844 _bus_dmamem_mmap
1845}; 1845};
1846 1846
1847 1847
1848/* 1848/*
1849 * Base bus space handlers. 1849 * Base bus space handlers.
1850 */ 1850 */
1851static int sparc_bus_map(bus_space_tag_t, bus_addr_t, 1851static int sparc_bus_map(bus_space_tag_t, bus_addr_t,
1852 bus_size_t, int, vaddr_t, 1852 bus_size_t, int, vaddr_t,
1853 bus_space_handle_t *); 1853 bus_space_handle_t *);
1854static int sparc_bus_unmap(bus_space_tag_t, bus_space_handle_t, 1854static int sparc_bus_unmap(bus_space_tag_t, bus_space_handle_t,
1855 bus_size_t); 1855 bus_size_t);
1856static int sparc_bus_subregion(bus_space_tag_t, bus_space_handle_t, 1856static int sparc_bus_subregion(bus_space_tag_t, bus_space_handle_t,
1857 bus_size_t, bus_size_t, 1857 bus_size_t, bus_size_t,
1858 bus_space_handle_t *); 1858 bus_space_handle_t *);
1859static paddr_t sparc_bus_mmap(bus_space_tag_t, bus_addr_t, off_t, 1859static paddr_t sparc_bus_mmap(bus_space_tag_t, bus_addr_t, off_t,
1860 int, int); 1860 int, int);
1861static void *sparc_mainbus_intr_establish(bus_space_tag_t, int, int, 1861static void *sparc_mainbus_intr_establish(bus_space_tag_t, int, int,
1862 int (*)(void *), 1862 int (*)(void *),
1863 void *, 1863 void *,
1864 void (*)(void)); 1864 void (*)(void));
1865static void sparc_bus_barrier(bus_space_tag_t, bus_space_handle_t, 1865static void sparc_bus_barrier(bus_space_tag_t, bus_space_handle_t,
1866 bus_size_t, bus_size_t, int); 1866 bus_size_t, bus_size_t, int);
1867 1867
1868/* 1868/*
1869 * Allocate a new bus tag and have it inherit the methods of the 1869 * Allocate a new bus tag and have it inherit the methods of the
1870 * given parent. 1870 * given parent.
1871 */ 1871 */
1872bus_space_tag_t 1872bus_space_tag_t
1873bus_space_tag_alloc(bus_space_tag_t parent, void *cookie) 1873bus_space_tag_alloc(bus_space_tag_t parent, void *cookie)
1874{ 1874{
1875 struct sparc_bus_space_tag *sbt; 1875 struct sparc_bus_space_tag *sbt;
1876 1876
1877 sbt = malloc(sizeof(struct sparc_bus_space_tag), 1877 sbt = malloc(sizeof(struct sparc_bus_space_tag),
1878 M_DEVBUF, M_NOWAIT|M_ZERO); 1878 M_DEVBUF, M_NOWAIT|M_ZERO);
1879 if (sbt == NULL) 1879 if (sbt == NULL)
1880 return (NULL); 1880 return (NULL);
1881 1881
1882 if (parent) { 1882 if (parent) {
1883 memcpy(sbt, parent, sizeof(*sbt)); 1883 memcpy(sbt, parent, sizeof(*sbt));
1884 sbt->parent = parent; 1884 sbt->parent = parent;
1885 sbt->ranges = NULL; 1885 sbt->ranges = NULL;
1886 sbt->nranges = 0; 1886 sbt->nranges = 0;
1887 } 1887 }
1888 1888
1889 sbt->cookie = cookie; 1889 sbt->cookie = cookie;
1890 return (sbt); 1890 return (sbt);
1891} 1891}
1892 1892
1893/* 1893/*
1894 * Generic routine to translate an address using OpenPROM `ranges'. 1894 * Generic routine to translate an address using OpenPROM `ranges'.
1895 */ 1895 */
1896int 1896int
1897bus_space_translate_address_generic(struct openprom_range *ranges, int nranges, 1897bus_space_translate_address_generic(struct openprom_range *ranges, int nranges,
1898 bus_addr_t *bap) 1898 bus_addr_t *bap)
1899{ 1899{
1900 int i, space = BUS_ADDR_IOSPACE(*bap); 1900 int i, space = BUS_ADDR_IOSPACE(*bap);
1901 1901
1902 for (i = 0; i < nranges; i++) { 1902 for (i = 0; i < nranges; i++) {
1903 struct openprom_range *rp = &ranges[i]; 1903 struct openprom_range *rp = &ranges[i];
1904 1904
1905 if (rp->or_child_space != space) 1905 if (rp->or_child_space != space)
1906 continue; 1906 continue;
1907 1907
1908 /* We've found the connection to the parent bus. */ 1908 /* We've found the connection to the parent bus. */
1909 *bap = BUS_ADDR(rp->or_parent_space, 1909 *bap = BUS_ADDR(rp->or_parent_space,
1910 rp->or_parent_base + BUS_ADDR_PADDR(*bap)); 1910 rp->or_parent_base + BUS_ADDR_PADDR(*bap));
1911 return (0); 1911 return (0);
1912 } 1912 }
1913 1913
1914 return (EINVAL); 1914 return (EINVAL);
1915} 1915}
1916 1916
1917int 1917static int
1918sparc_bus_map(bus_space_tag_t t, bus_addr_t ba, bus_size_t size, int flags, 1918sparc_bus_map_iodev(bus_space_tag_t t, bus_addr_t ba, bus_size_t size, int flags,
1919 vaddr_t va, bus_space_handle_t *hp) 1919 vaddr_t va, bus_space_handle_t *hp)
1920{ 1920{
1921 vaddr_t v; 1921 vaddr_t v;
1922 paddr_t pa; 1922 paddr_t pa;
1923 unsigned int pmtype; 1923 unsigned int pmtype;
1924 bus_space_tag_t pt; 1924 bus_space_tag_t pt;
1925static vaddr_t iobase; 1925static vaddr_t iobase;
1926 1926
1927 /* 1927 /*
1928 * This base class bus map function knows about address range 1928 * This base class bus map function knows about address range
1929 * translation so bus drivers that need no other special 1929 * translation so bus drivers that need no other special
1930 * handling can just keep this method in their tags. 1930 * handling can just keep this method in their tags.
1931 * 1931 *
1932 * We expect to resolve range translations iteratively, but allow 1932 * We expect to resolve range translations iteratively, but allow
1933 * for recursion just in case. 1933 * for recursion just in case.
1934 */ 1934 */
1935 while ((pt = t->parent) != NULL) { 1935 while ((pt = t->parent) != NULL) {
1936 if (t->ranges != NULL) { 1936 if (t->ranges != NULL) {
1937 int error; 1937 int error;
1938 1938
1939 if ((error = bus_space_translate_address_generic( 1939 if ((error = bus_space_translate_address_generic(
1940 t->ranges, t->nranges, &ba)) != 0) 1940 t->ranges, t->nranges, &ba)) != 0)
1941 return (error); 1941 return (error);
1942 } 1942 }
1943 if (pt->sparc_bus_map != sparc_bus_map) 1943 if (pt->sparc_bus_map != sparc_bus_map)
1944 return (bus_space_map2(pt, ba, size, flags, va, hp)); 1944 return (bus_space_map2(pt, ba, size, flags, va, hp));
1945 t = pt; 1945 t = pt;
1946 } 1946 }
1947 1947
1948 if (iobase == 0) 1948 if (iobase == 0)
1949 iobase = IODEV_BASE; 1949 iobase = IODEV_BASE;
1950 1950
1951 size = round_page(size); 1951 size = round_page(size);
1952 if (size == 0) { 1952 if (size == 0) {
1953 printf("sparc_bus_map: zero size\n"); 1953 printf("sparc_bus_map: zero size\n");
1954 return (EINVAL); 1954 return (EINVAL);
1955 } 1955 }
1956 1956
1957 if (va) 1957 if (va)
1958 v = trunc_page(va); 1958 v = trunc_page(va);
1959 else { 1959 else {
1960 v = iobase; 1960 v = iobase;
1961 iobase += size; 1961 iobase += size;
1962 if (iobase > IODEV_END) /* unlikely */ 1962 if (iobase > IODEV_END) /* unlikely */
1963 panic("sparc_bus_map: iobase=0x%lx", iobase); 1963 panic("sparc_bus_map: iobase=0x%lx", iobase);
1964 } 1964 }
1965 1965
1966 pmtype = PMAP_IOENC(BUS_ADDR_IOSPACE(ba)); 1966 pmtype = PMAP_IOENC(BUS_ADDR_IOSPACE(ba));
1967 pa = BUS_ADDR_PADDR(ba); 1967 pa = BUS_ADDR_PADDR(ba);
1968 1968
1969 /* note: preserve page offset */ 1969 /* note: preserve page offset */
1970 *hp = (bus_space_handle_t)(v | ((u_long)pa & PGOFSET)); 1970 *hp = (bus_space_handle_t)(v | ((u_long)pa & PGOFSET));
1971 1971
1972 pa = trunc_page(pa); 1972 pa = trunc_page(pa);
1973 do { 1973 do {
1974 pmap_kenter_pa(v, pa | pmtype | PMAP_NC, 1974 pmap_kenter_pa(v, pa | pmtype | PMAP_NC,
1975 VM_PROT_READ | VM_PROT_WRITE); 1975 VM_PROT_READ | VM_PROT_WRITE);
1976 v += PAGE_SIZE; 1976 v += PAGE_SIZE;
1977 pa += PAGE_SIZE; 1977 pa += PAGE_SIZE;
1978 } while ((size -= PAGE_SIZE) > 0); 1978 } while ((size -= PAGE_SIZE) > 0);
1979 1979
1980 pmap_update(pmap_kernel()); 1980 pmap_update(pmap_kernel());
1981 return (0); 1981 return (0);
1982} 1982}
1983 1983
1984int 1984static int
1985sparc_bus_map_large(bus_space_tag_t t, int slot, bus_size_t offset, 1985sparc_bus_map_large(bus_space_tag_t t, bus_addr_t ba,
1986 bus_size_t size, int flags, bus_space_handle_t *hp) 1986 bus_size_t size, int flags, bus_space_handle_t *hp)
1987{ 1987{
1988 bus_addr_t pa = BUS_ADDR(slot,offset); 
1989 vaddr_t v = 0; 1988 vaddr_t v = 0;
1990 1989
1991 if (uvm_map(kernel_map, &v, size, NULL, 0, PAGE_SIZE, 1990 if (uvm_map(kernel_map, &v, size, NULL, 0, PAGE_SIZE,
1992 UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW, UVM_INH_SHARE, UVM_ADV_NORMAL, 1991 UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW, UVM_INH_SHARE, UVM_ADV_NORMAL,
1993 0)) == 0) { 1992 0)) == 0) {
1994 return sparc_bus_map(t, pa, size, flags, v, hp); 1993 return sparc_bus_map_iodev(t, ba, size, flags, v, hp);
1995 } 1994 }
1996 return -1; 1995 return -1;
1997} 1996}
1998 1997
1999int 1998int
 1999sparc_bus_map(bus_space_tag_t t, bus_addr_t ba,
 2000 bus_size_t size, int flags, vaddr_t va,
 2001 bus_space_handle_t *hp)
 2002{
 2003
 2004 if (flags & BUS_SPACE_MAP_LARGE) {
 2005 return sparc_bus_map_large(t, ba, size, flags, hp);
 2006 } else
 2007 return sparc_bus_map_iodev(t, ba, size, flags, va, hp);
 2008
 2009}
 2010
 2011int
2000sparc_bus_unmap(bus_space_tag_t t, bus_space_handle_t bh, bus_size_t size) 2012sparc_bus_unmap(bus_space_tag_t t, bus_space_handle_t bh, bus_size_t size)
2001{ 2013{
2002 vaddr_t va = trunc_page((vaddr_t)bh); 2014 vaddr_t va = trunc_page((vaddr_t)bh);
2003 2015
2004 /* 2016 /*
2005 * XXX 2017 * XXX
2006 * mappings from sparc_bus_map_large() probably need additional care 2018 * mappings with BUS_SPACE_MAP_LARGE need additional care here
2007 * here 2019 * we can just check if the VA is in the IODEV range
2008 */ 2020 */
2009 2021
2010 pmap_kremove(va, round_page(size)); 2022 pmap_kremove(va, round_page(size));
2011 pmap_update(pmap_kernel()); 2023 pmap_update(pmap_kernel());
2012 return (0); 2024 return (0);
2013} 2025}
2014 2026
2015int 2027int
2016sparc_bus_subregion(bus_space_tag_t tag, bus_space_handle_t handle, 2028sparc_bus_subregion(bus_space_tag_t tag, bus_space_handle_t handle,
2017 bus_size_t offset, bus_size_t size, 2029 bus_size_t offset, bus_size_t size,
2018 bus_space_handle_t *nhandlep) 2030 bus_space_handle_t *nhandlep)
2019{ 2031{
2020 2032
2021 *nhandlep = handle + offset; 2033 *nhandlep = handle + offset;
2022 return (0); 2034 return (0);
2023} 2035}
2024 2036
2025paddr_t 2037paddr_t
2026sparc_bus_mmap(bus_space_tag_t t, bus_addr_t ba, off_t off, 2038sparc_bus_mmap(bus_space_tag_t t, bus_addr_t ba, off_t off,
2027 int prot, int flags) 2039 int prot, int flags)
2028{ 2040{
2029 u_int pmtype; 2041 u_int pmtype;
2030 paddr_t pa; 2042 paddr_t pa;
2031 bus_space_tag_t pt; 2043 bus_space_tag_t pt;
2032 2044
2033 /* 2045 /*
2034 * Base class bus mmap function; see also sparc_bus_map 2046 * Base class bus mmap function; see also sparc_bus_map
2035 */ 2047 */
2036 while ((pt = t->parent) != NULL) { 2048 while ((pt = t->parent) != NULL) {
2037 if (t->ranges != NULL) { 2049 if (t->ranges != NULL) {
2038 int error; 2050 int error;
2039 2051
2040 if ((error = bus_space_translate_address_generic( 2052 if ((error = bus_space_translate_address_generic(
2041 t->ranges, t->nranges, &ba)) != 0) 2053 t->ranges, t->nranges, &ba)) != 0)
2042 return (-1); 2054 return (-1);
2043 } 2055 }
2044 if (pt->sparc_bus_mmap != sparc_bus_mmap) 2056 if (pt->sparc_bus_mmap != sparc_bus_mmap)
2045 return (bus_space_mmap(pt, ba, off, prot, flags)); 2057 return (bus_space_mmap(pt, ba, off, prot, flags));
2046 t = pt; 2058 t = pt;
2047 } 2059 }
2048 2060
2049 pmtype = PMAP_IOENC(BUS_ADDR_IOSPACE(ba)); 2061 pmtype = PMAP_IOENC(BUS_ADDR_IOSPACE(ba));
2050 pa = trunc_page(BUS_ADDR_PADDR(ba) + off); 2062 pa = trunc_page(BUS_ADDR_PADDR(ba) + off);
2051 2063
2052 return (paddr_t)(pa | pmtype | PMAP_NC); 2064 return (paddr_t)(pa | pmtype | PMAP_NC);
2053} 2065}
2054 2066
2055/* 2067/*
2056 * Establish a temporary bus mapping for device probing. 2068 * Establish a temporary bus mapping for device probing.
2057 */ 2069 */
2058int 2070int
2059bus_space_probe(bus_space_tag_t tag, bus_addr_t paddr, bus_size_t size, 2071bus_space_probe(bus_space_tag_t tag, bus_addr_t paddr, bus_size_t size,
2060 size_t offset, int flags, 2072 size_t offset, int flags,
2061 int (*callback)(void *, void *), void *arg) 2073 int (*callback)(void *, void *), void *arg)
2062{ 2074{
2063 bus_space_handle_t bh; 2075 bus_space_handle_t bh;
2064 void *tmp; 2076 void *tmp;
2065 int result; 2077 int result;
2066 2078
2067 if (bus_space_map2(tag, paddr, size, flags, TMPMAP_VA, &bh) != 0) 2079 if (bus_space_map2(tag, paddr, size, flags, TMPMAP_VA, &bh) != 0)
2068 return (0); 2080 return (0);
2069 2081
2070 tmp = (void *)bh; 2082 tmp = (void *)bh;
2071 result = (probeget((char *)tmp + offset, size) != -1); 2083 result = (probeget((char *)tmp + offset, size) != -1);
2072 if (result && callback != NULL) 2084 if (result && callback != NULL)
2073 result = (*callback)(tmp, arg); 2085 result = (*callback)(tmp, arg);
2074 bus_space_unmap(tag, bh, size); 2086 bus_space_unmap(tag, bh, size);
2075 return (result); 2087 return (result);
2076} 2088}
2077 2089
2078 2090
2079void * 2091void *
2080sparc_mainbus_intr_establish(bus_space_tag_t t, int pil, int level, 2092sparc_mainbus_intr_establish(bus_space_tag_t t, int pil, int level,
2081 int (*handler)(void *), void *arg, 2093 int (*handler)(void *), void *arg,
2082 void (*fastvec)(void)) 2094 void (*fastvec)(void))
2083{ 2095{
2084 struct intrhand *ih; 2096 struct intrhand *ih;
2085 2097
2086 ih = (struct intrhand *) 2098 ih = (struct intrhand *)
2087 malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT); 2099 malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT);
2088 if (ih == NULL) 2100 if (ih == NULL)
2089 return (NULL); 2101 return (NULL);
2090 2102
2091 ih->ih_fun = handler; 2103 ih->ih_fun = handler;
2092 ih->ih_arg = arg; 2104 ih->ih_arg = arg;
2093 intr_establish(pil, level, ih, fastvec); 2105 intr_establish(pil, level, ih, fastvec);
2094 return (ih); 2106 return (ih);
2095} 2107}
2096 2108
2097void sparc_bus_barrier (bus_space_tag_t t, bus_space_handle_t h, 2109void sparc_bus_barrier (bus_space_tag_t t, bus_space_handle_t h,
2098 bus_size_t offset, bus_size_t size, int flags) 2110 bus_size_t offset, bus_size_t size, int flags)
2099{ 2111{
2100 2112
2101 /* No default barrier action defined */ 2113 /* No default barrier action defined */
2102 return; 2114 return;
2103} 2115}
2104 2116
2105static uint8_t 2117static uint8_t
2106sparc_bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) 2118sparc_bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
2107{ 2119{
2108 2120
2109 return bus_space_read_1_real(t, h, o); 2121 return bus_space_read_1_real(t, h, o);
2110} 2122}
2111 2123
2112static uint16_t 2124static uint16_t
2113sparc_bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) 2125sparc_bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
2114{ 2126{
2115 2127
2116 return bus_space_read_2_real(t, h, o); 2128 return bus_space_read_2_real(t, h, o);
2117} 2129}
2118 2130
2119static uint32_t 2131static uint32_t
2120sparc_bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) 2132sparc_bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
2121{ 2133{
2122 2134
2123 return bus_space_read_4_real(t, h, o); 2135 return bus_space_read_4_real(t, h, o);
2124} 2136}
2125 2137
2126static uint64_t 2138static uint64_t
2127sparc_bus_space_read_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) 2139sparc_bus_space_read_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
2128{ 2140{
2129 2141
2130 return bus_space_read_8_real(t, h, o); 2142 return bus_space_read_8_real(t, h, o);
2131} 2143}
2132 2144
2133static void 2145static void
2134sparc_bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 2146sparc_bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
2135 uint8_t v) 2147 uint8_t v)
2136{ 2148{
2137 2149
2138 bus_space_write_1_real(t, h, o, v); 2150 bus_space_write_1_real(t, h, o, v);
2139} 2151}
2140 2152
2141static void 2153static void
2142sparc_bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 2154sparc_bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
2143 uint16_t v) 2155 uint16_t v)
2144{ 2156{
2145 2157
2146 bus_space_write_2_real(t, h, o, v); 2158 bus_space_write_2_real(t, h, o, v);
2147} 2159}
2148 2160
2149static void 2161static void
2150sparc_bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 2162sparc_bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
2151 uint32_t v) 2163 uint32_t v)
2152{ 2164{
2153 2165
2154 bus_space_write_4_real(t, h, o, v); 2166 bus_space_write_4_real(t, h, o, v);
2155} 2167}
2156 2168
2157static void 2169static void
2158sparc_bus_space_write_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, 2170sparc_bus_space_write_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
2159 uint64_t v) 2171 uint64_t v)
2160{ 2172{
2161 2173
2162 bus_space_write_8_real(t, h, o, v); 2174 bus_space_write_8_real(t, h, o, v);
2163} 2175}
2164 2176
2165struct sparc_bus_space_tag mainbus_space_tag = { 2177struct sparc_bus_space_tag mainbus_space_tag = {
2166 NULL, /* cookie */ 2178 NULL, /* cookie */
2167 NULL, /* parent bus tag */ 2179 NULL, /* parent bus tag */
2168 NULL, /* ranges */ 2180 NULL, /* ranges */
2169 0, /* nranges */ 2181 0, /* nranges */
2170 sparc_bus_map, /* bus_space_map */ 2182 sparc_bus_map, /* bus_space_map */
2171 sparc_bus_unmap, /* bus_space_unmap */ 2183 sparc_bus_unmap, /* bus_space_unmap */
2172 sparc_bus_subregion, /* bus_space_subregion */ 2184 sparc_bus_subregion, /* bus_space_subregion */
2173 sparc_bus_barrier, /* bus_space_barrier */ 2185 sparc_bus_barrier, /* bus_space_barrier */
2174 sparc_bus_mmap, /* bus_space_mmap */ 2186 sparc_bus_mmap, /* bus_space_mmap */
2175 sparc_mainbus_intr_establish, /* bus_intr_establish */ 2187 sparc_mainbus_intr_establish, /* bus_intr_establish */
2176 2188
2177 sparc_bus_space_read_1, /* bus_space_read_1 */ 2189 sparc_bus_space_read_1, /* bus_space_read_1 */
2178 sparc_bus_space_read_2, /* bus_space_read_2 */ 2190 sparc_bus_space_read_2, /* bus_space_read_2 */
2179 sparc_bus_space_read_4, /* bus_space_read_4 */ 2191 sparc_bus_space_read_4, /* bus_space_read_4 */
2180 sparc_bus_space_read_8, /* bus_space_read_8 */ 2192 sparc_bus_space_read_8, /* bus_space_read_8 */
2181 sparc_bus_space_write_1, /* bus_space_write_1 */ 2193 sparc_bus_space_write_1, /* bus_space_write_1 */
2182 sparc_bus_space_write_2, /* bus_space_write_2 */ 2194 sparc_bus_space_write_2, /* bus_space_write_2 */
2183 sparc_bus_space_write_4, /* bus_space_write_4 */ 2195 sparc_bus_space_write_4, /* bus_space_write_4 */
2184 sparc_bus_space_write_8 /* bus_space_write_8 */ 2196 sparc_bus_space_write_8 /* bus_space_write_8 */
2185}; 2197};