1 /* $NetBSD: bus.h,v 1.16 2006/03/04 01:55:03 uwe Exp $ */
4 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
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
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
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
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
30 * POSSIBILITY OF SUCH DAMAGE.
34 * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
35 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by Christopher G. Demetriou
48 * for the NetBSD Project.
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
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
54 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 #include <sys/bswap.h>
69 #define __BUS_SPACE_HAS_STREAM_METHODS
71 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
74 * Values for the sh3 bus space tag, not to be used directly by MI code.
76 #define SH3_BUS_SPACE_IO 0 /* space is i/o space */
77 #define SH3_BUS_SPACE_MEM 1 /* space is mem space */
78 #define SH3_BUS_SPACE_PCMCIA_IO 2 /* PCMCIA IO space */
79 #define SH3_BUS_SPACE_PCMCIA_MEM 3 /* PCMCIA Mem space */
80 #define SH3_BUS_SPACE_PCMCIA_ATT 4 /* PCMCIA Attr space */
81 #define SH3_BUS_SPACE_PCMCIA_8BIT 0x8000 /* PCMCIA BUS 8 BIT WIDTH */
82 #define SH3_BUS_SPACE_PCMCIA_IO8 \
83 (SH3_BUS_SPACE_PCMCIA_IO|SH3_BUS_SPACE_PCMCIA_8BIT)
84 #define SH3_BUS_SPACE_PCMCIA_MEM8 \
85 (SH3_BUS_SPACE_PCMCIA_MEM|SH3_BUS_SPACE_PCMCIA_8BIT)
86 #define SH3_BUS_SPACE_PCMCIA_ATT8 \
87 (SH3_BUS_SPACE_PCMCIA_ATT|SH3_BUS_SPACE_PCMCIA_8BIT)
90 * Bus address and size types
92 typedef u_long bus_addr_t
;
93 typedef u_long bus_size_t
;
96 * Access methods for bus resources and address space.
98 typedef int bus_space_tag_t
;
99 typedef u_long bus_space_handle_t
;
102 * int bus_space_map (bus_space_tag_t t, bus_addr_t addr,
103 * bus_size_t size, int flags, bus_space_handle_t *bshp);
105 * Map a region of bus space.
107 #define BUS_SPACE_MAP_CACHEABLE 0x01
108 #define BUS_SPACE_MAP_LINEAR 0x02
110 int bus_space_map(bus_space_tag_t
, bus_addr_t
, bus_size_t size
,
111 int, bus_space_handle_t
*);
114 int shpcmcia_memio_map(bus_space_tag_t
, bus_addr_t
, bus_size_t size
,
115 int, bus_space_handle_t
*);
117 int shpcmcia_mem_add_mapping(bus_addr_t
, bus_size_t
, int,
118 bus_space_handle_t
*);
119 void shpcmcia_memio_unmap(bus_space_tag_t
, bus_space_handle_t
,
121 void shpcmcia_memio_free(bus_space_tag_t
, bus_space_handle_t
,
123 int shpcmcia_memio_subregion(bus_space_tag_t
, bus_space_handle_t
,
124 bus_size_t
, bus_size_t
, bus_space_handle_t
*);
128 * u_intN_t bus_space_read_N(bus_space_tag_t tag,
129 * bus_space_handle_t bsh, bus_size_t offset);
131 * Read a 1, 2, 4, or 8 byte quantity from bus space
132 * described by tag/handle/offset.
134 static __inline
uint8_t bus_space_read_1
135 (bus_space_tag_t
, bus_space_handle_t
, bus_size_t
);
136 static __inline
uint16_t bus_space_read_2
137 (bus_space_tag_t
, bus_space_handle_t
, bus_size_t
);
138 static __inline
uint32_t bus_space_read_4
139 (bus_space_tag_t
, bus_space_handle_t
, bus_size_t
);
142 bus_space_read_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
146 return *(volatile uint8_t *)(bsh
+ offset
);
150 bus_space_read_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
154 return bswap16(*(volatile uint16_t *)(bsh
+ offset
));
158 bus_space_read_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
162 return bswap32(*(volatile uint32_t *)(bsh
+ offset
));
165 static __inline
uint16_t bus_space_read_stream_2
166 (bus_space_tag_t
, bus_space_handle_t
, bus_size_t
);
168 static __inline
uint32_t bus_space_read_stream_4
169 (bus_space_tag_t
, bus_space_handle_t
, bus_size_t
);
172 bus_space_read_stream_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
176 return *(volatile uint16_t *)(bsh
+ offset
);
180 bus_space_read_stream_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
184 return *(volatile uint32_t *)(bsh
+ offset
);
188 * void bus_space_read_multi_N(bus_space_tag_t tag,
189 * bus_space_handle_t bsh, bus_size_t offset,
190 * u_intN_t *addr, size_t count);
192 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
193 * described by tag/handle/offset and copy into buffer provided.
195 static __inline
void bus_space_read_multi_1(bus_space_tag_t
,
196 bus_space_handle_t
, bus_size_t
, uint8_t *, bus_size_t
);
197 static __inline
void bus_space_read_multi_2(bus_space_tag_t
,
198 bus_space_handle_t
, bus_size_t
, uint16_t *, bus_size_t
);
199 static __inline
void bus_space_read_multi_4(bus_space_tag_t
,
200 bus_space_handle_t
, bus_size_t
, uint32_t *, bus_size_t
);
203 bus_space_read_multi_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
204 bus_size_t offset
, uint8_t *addr
, bus_size_t count
)
208 *addr
++ = bus_space_read_1(tag
, bsh
, offset
);
212 bus_space_read_multi_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
213 bus_size_t offset
, uint16_t *addr
, bus_size_t count
)
217 *addr
++ = bus_space_read_2(tag
, bsh
, offset
);
221 bus_space_read_multi_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
222 bus_size_t offset
, uint32_t *addr
, bus_size_t count
)
226 *addr
++ = bus_space_read_4(tag
, bsh
, offset
);
229 static __inline
void bus_space_read_multi_stream_2(bus_space_tag_t
,
230 bus_space_handle_t
, bus_size_t
, uint16_t *, bus_size_t
);
231 static __inline
void bus_space_read_multi_stream_4(bus_space_tag_t
,
232 bus_space_handle_t
, bus_size_t
, uint32_t *, bus_size_t
);
235 bus_space_read_multi_stream_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
236 bus_size_t offset
, uint16_t *addr
, bus_size_t count
)
240 *addr
++ = *(volatile uint16_t *)(bsh
+ offset
);
244 bus_space_read_multi_stream_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
245 bus_size_t offset
, uint32_t *addr
, bus_size_t count
)
249 *addr
++ = *(volatile uint32_t *)(bsh
+ offset
);
253 * int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
254 * bus_addr_t rend, bus_size_t size, bus_size_t align,
255 * bus_size_t boundary, int flags, bus_addr_t *addrp,
256 * bus_space_handle_t *bshp);
258 * Allocate a region of bus space.
260 int sh_memio_alloc(bus_space_tag_t
, bus_addr_t
, bus_addr_t
, bus_size_t
,
261 bus_size_t
, bus_size_t
, int, bus_addr_t
*, bus_space_handle_t
*);
263 #define bus_space_alloc(t, rs, re, s, a, b, f, ap, hp) \
264 sh_memio_alloc((t), (rs), (re), (s), (a), (b), (f), (ap), (hp))
267 * int bus_space_free(bus_space_tag_t t,
268 * bus_space_handle_t bsh, bus_size_t size);
270 * Free a region of bus space.
272 void sh_memio_free(bus_space_tag_t
, bus_space_handle_t
, bus_size_t
);
274 #define bus_space_free(t, h, s) \
275 sh_memio_free((t), (h), (s))
278 * int bus_space_unmap(bus_space_tag_t t,
279 * bus_space_handle_t bsh, bus_size_t size);
281 * Unmap a region of bus space.
283 void sh_memio_unmap(bus_space_tag_t
, bus_space_handle_t
, bus_size_t
);
285 #define bus_space_unmap(t, h, s) \
286 sh_memio_unmap((t), (h), (s))
289 * int bus_space_subregion(bus_space_tag_t t,
290 * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
291 * bus_space_handle_t *nbshp);
293 * Get a new handle for a subregion of an already-mapped area of bus space.
295 int sh_memio_subregion(bus_space_tag_t
, bus_space_handle_t
,
296 bus_size_t
, bus_size_t
, bus_space_handle_t
*);
298 #define bus_space_subregion(t, h, o, s, nhp) \
299 sh_memio_subregion((t), (h), (o), (s), (nhp))
302 * void bus_space_read_region_N(bus_space_tag_t tag,
303 * bus_space_handle_t bsh, bus_size_t offset,
304 * u_intN_t *addr, size_t count);
306 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
307 * described by tag/handle and starting at `offset' and copy into
310 static __inline
void bus_space_read_region_1(bus_space_tag_t
,
311 bus_space_handle_t
, bus_size_t
, uint8_t *, bus_size_t
);
312 static __inline
void bus_space_read_region_2(bus_space_tag_t
,
313 bus_space_handle_t
, bus_size_t
, uint16_t *, bus_size_t
);
314 static __inline
void bus_space_read_region_4(bus_space_tag_t
,
315 bus_space_handle_t
, bus_size_t
, uint32_t *, bus_size_t
);
318 bus_space_read_region_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
319 bus_size_t offset
, uint8_t *addr
, bus_size_t count
)
321 uint8_t *p
= (uint8_t *)(bsh
+ offset
);
328 bus_space_read_region_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
329 bus_size_t offset
, uint16_t *addr
, bus_size_t count
)
331 uint16_t *p
= (uint16_t *)(bsh
+ offset
);
334 *addr
++ = bswap16(*p
++);
338 bus_space_read_region_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
339 bus_size_t offset
, uint32_t *addr
, bus_size_t count
)
341 uint32_t *p
= (uint32_t *)(bsh
+ offset
);
344 *addr
++ = bswap32(*p
++);
348 * void bus_space_read_region_stream_N(bus_space_tag_t tag,
349 * bus_space_handle_t bsh, bus_size_t offset,
350 * u_intN_t *addr, size_t count);
352 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
353 * described by tag/handle and starting at `offset' and copy into
356 static __inline
void bus_space_read_region_stream_1(bus_space_tag_t
,
357 bus_space_handle_t
, bus_size_t
, uint8_t *, bus_size_t
);
358 static __inline
void bus_space_read_region_stream_2(bus_space_tag_t
,
359 bus_space_handle_t
, bus_size_t
, uint16_t *, bus_size_t
);
360 static __inline
void bus_space_read_region_stream_4(bus_space_tag_t
,
361 bus_space_handle_t
, bus_size_t
, uint32_t *, bus_size_t
);
364 bus_space_read_region_stream_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
365 bus_size_t offset
, uint8_t *addr
, bus_size_t count
)
367 uint8_t *p
= (uint8_t *)(bsh
+ offset
);
374 bus_space_read_region_stream_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
375 bus_size_t offset
, uint16_t *addr
, bus_size_t count
)
377 uint16_t *p
= (uint16_t *)(bsh
+ offset
);
384 bus_space_read_region_stream_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
385 bus_size_t offset
, uint32_t *addr
, bus_size_t count
)
387 uint32_t *p
= (uint32_t *)(bsh
+ offset
);
394 * void bus_space_write_region_N(bus_space_tag_t tag,
395 * bus_space_handle_t bsh, bus_size_t offset,
396 * const u_intN_t *addr, size_t count);
398 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
399 * to bus space described by tag/handle starting at `offset'.
401 static __inline
void bus_space_write_region_1(bus_space_tag_t
,
402 bus_space_handle_t
, bus_size_t
, const uint8_t *, bus_size_t
);
403 static __inline
void bus_space_write_region_2(bus_space_tag_t
,
404 bus_space_handle_t
, bus_size_t
, const uint16_t *, bus_size_t
);
405 static __inline
void bus_space_write_region_4(bus_space_tag_t
,
406 bus_space_handle_t
, bus_size_t
, const uint32_t *, bus_size_t
);
409 bus_space_write_region_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
410 bus_size_t offset
, const uint8_t *addr
, bus_size_t count
)
412 uint8_t *p
= (uint8_t *)(bsh
+ offset
);
419 bus_space_write_region_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
420 bus_size_t offset
, const uint16_t *addr
, bus_size_t count
)
422 uint16_t *p
= (uint16_t *)(bsh
+ offset
);
425 *p
++ = bswap16(*addr
++);
429 bus_space_write_region_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
430 bus_size_t offset
, const uint32_t *addr
, bus_size_t count
)
432 uint32_t *p
= (uint32_t *)(bsh
+ offset
);
435 *p
++ = bswap32(*addr
++);
439 * void bus_space_write_region_stream_N(bus_space_tag_t tag,
440 * bus_space_handle_t bsh, bus_size_t offset,
441 * const u_intN_t *addr, size_t count);
443 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
444 * to bus space described by tag/handle starting at `offset'.
446 static __inline
void bus_space_write_region_stream_1(bus_space_tag_t
,
447 bus_space_handle_t
, bus_size_t
, const uint8_t *, bus_size_t
);
448 static __inline
void bus_space_write_region_stream_2(bus_space_tag_t
,
449 bus_space_handle_t
, bus_size_t
, const uint16_t *, bus_size_t
);
450 static __inline
void bus_space_write_region_stream_4(bus_space_tag_t
,
451 bus_space_handle_t
, bus_size_t
, const uint32_t *, bus_size_t
);
454 bus_space_write_region_stream_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
455 bus_size_t offset
, const uint8_t *addr
, bus_size_t count
)
457 uint8_t *p
= (uint8_t *)(bsh
+ offset
);
464 bus_space_write_region_stream_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
465 bus_size_t offset
, const uint16_t *addr
, bus_size_t count
)
467 uint16_t *p
= (uint16_t *)(bsh
+ offset
);
474 bus_space_write_region_stream_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
475 bus_size_t offset
, const uint32_t *addr
, bus_size_t count
)
477 uint32_t *p
= (uint32_t *)(bsh
+ offset
);
484 * void bus_space_write_N(bus_space_tag_t tag,
485 * bus_space_handle_t bsh, bus_size_t offset,
488 * Write the 1, 2, 4, or 8 byte value `value' to bus space
489 * described by tag/handle/offset.
491 static __inline
void bus_space_write_1(bus_space_tag_t
,
492 bus_space_handle_t
, bus_size_t
, uint8_t);
493 static __inline
void bus_space_write_2(bus_space_tag_t
,
494 bus_space_handle_t
, bus_size_t
, uint16_t);
495 static __inline
void bus_space_write_4(bus_space_tag_t
,
496 bus_space_handle_t
, bus_size_t
, uint32_t);
499 bus_space_write_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
500 bus_size_t offset
, uint8_t value
)
503 *(volatile uint8_t *)(bsh
+ offset
) = value
;
507 bus_space_write_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
508 bus_size_t offset
, uint16_t value
)
511 *(volatile uint16_t *)(bsh
+ offset
) = bswap16(value
);
515 bus_space_write_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
516 bus_size_t offset
, uint32_t value
)
519 *(volatile uint32_t *)(bsh
+ offset
) = bswap32(value
);
522 static __inline
void bus_space_write_stream_2(bus_space_tag_t
,
523 bus_space_handle_t
, bus_size_t
, uint16_t);
524 static __inline
void bus_space_write_stream_4(bus_space_tag_t
,
525 bus_space_handle_t
, bus_size_t
, uint32_t);
528 bus_space_write_stream_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
529 bus_size_t offset
, uint16_t value
)
532 *(volatile uint16_t *)(bsh
+ offset
) = value
;
536 bus_space_write_stream_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
537 bus_size_t offset
, uint32_t value
)
540 *(volatile uint32_t *)(bsh
+ offset
) = value
;
544 * void bus_space_write_multi_N(bus_space_tag_t tag,
545 * bus_space_handle_t bsh, bus_size_t offset,
546 * const u_intN_t *addr, size_t count);
548 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
549 * provided to bus space described by tag/handle/offset.
551 static __inline
void bus_space_write_multi_1(bus_space_tag_t
,
552 bus_space_handle_t
, bus_size_t
, uint8_t *, bus_size_t
);
553 static __inline
void bus_space_write_multi_2(bus_space_tag_t
,
554 bus_space_handle_t
, bus_size_t
, uint16_t *, bus_size_t
);
555 static __inline
void bus_space_write_multi_4(bus_space_tag_t
,
556 bus_space_handle_t
, bus_size_t
, uint32_t *, bus_size_t
);
559 bus_space_write_multi_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
560 bus_size_t offset
, uint8_t *addr
, bus_size_t count
)
564 bus_space_write_1(tag
, bsh
, offset
, *addr
++);
568 bus_space_write_multi_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
569 bus_size_t offset
, uint16_t *addr
, bus_size_t count
)
573 bus_space_write_2(tag
, bsh
, offset
, *addr
++);
577 bus_space_write_multi_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
578 bus_size_t offset
, uint32_t *addr
, bus_size_t count
)
582 bus_space_write_4(tag
, bsh
, offset
, *addr
++);
585 static __inline
void bus_space_write_multi_stream_2(bus_space_tag_t
,
586 bus_space_handle_t
, bus_size_t
, uint16_t *, bus_size_t
);
587 static __inline
void bus_space_write_multi_stream_4(bus_space_tag_t
,
588 bus_space_handle_t
, bus_size_t
, uint32_t *, bus_size_t
);
591 bus_space_write_multi_stream_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
592 bus_size_t offset
, uint16_t *addr
, bus_size_t count
)
596 bus_space_write_stream_2(tag
, bsh
, offset
, *addr
++);
600 bus_space_write_multi_stream_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
601 bus_size_t offset
, uint32_t *addr
, bus_size_t count
)
605 bus_space_write_stream_4(tag
, bsh
, offset
, *addr
++);
609 * void bus_space_set_multi_N(bus_space_tag_t tag,
610 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
613 * Write the 1, 2, 4, or 8 byte value `val' to bus space described
614 * by tag/handle/offset `count' times.
616 static __inline
void bus_space_set_multi_1(bus_space_tag_t
,
617 bus_space_handle_t
, bus_size_t
, uint8_t, bus_size_t
);
618 static __inline
void bus_space_set_multi_2(bus_space_tag_t
,
619 bus_space_handle_t
, bus_size_t
, uint16_t, bus_size_t
);
620 static __inline
void bus_space_set_multi_4(bus_space_tag_t
,
621 bus_space_handle_t
, bus_size_t
, uint32_t, bus_size_t
);
624 bus_space_set_multi_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
625 bus_size_t offset
, uint8_t val
, bus_size_t count
)
629 bus_space_write_1(tag
, bsh
, offset
, val
);
633 bus_space_set_multi_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
634 bus_size_t offset
, uint16_t val
, bus_size_t count
)
638 bus_space_write_2(tag
, bsh
, offset
, val
);
642 bus_space_set_multi_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
643 bus_size_t offset
, uint32_t val
, bus_size_t count
)
647 bus_space_write_4(tag
, bsh
, offset
, val
);
651 * void bus_space_set_region_N(bus_space_tag_t tag,
652 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
655 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
656 * by tag/handle starting at `offset'.
658 static __inline
void bus_space_set_region_1(bus_space_tag_t
,
659 bus_space_handle_t
, bus_size_t
, uint8_t, bus_size_t
);
660 static __inline
void bus_space_set_region_2(bus_space_tag_t
,
661 bus_space_handle_t
, bus_size_t
, uint16_t, bus_size_t
);
662 static __inline
void bus_space_set_region_4(bus_space_tag_t
,
663 bus_space_handle_t
, bus_size_t
, uint32_t, bus_size_t
);
666 bus_space_set_region_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
667 bus_size_t offset
, uint8_t val
, bus_size_t count
)
669 volatile uint8_t *addr
= (void *)(bsh
+ offset
);
676 bus_space_set_region_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
677 bus_size_t offset
, uint16_t val
, bus_size_t count
)
679 volatile uint16_t *addr
= (void *)(bsh
+ offset
);
687 bus_space_set_region_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
688 bus_size_t offset
, uint32_t val
, bus_size_t count
)
690 volatile uint32_t *addr
= (void *)(bsh
+ offset
);
698 * void bus_space_set_region_stream_N(bus_space_tag_t tag,
699 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
702 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
703 * by tag/handle starting at `offset'.
705 static __inline
void bus_space_set_region_stream_1(bus_space_tag_t
,
706 bus_space_handle_t
, bus_size_t
, uint8_t, bus_size_t
);
707 static __inline
void bus_space_set_region_stream_2(bus_space_tag_t
,
708 bus_space_handle_t
, bus_size_t
, uint16_t, bus_size_t
);
709 static __inline
void bus_space_set_region_stream_4(bus_space_tag_t
,
710 bus_space_handle_t
, bus_size_t
, uint32_t, bus_size_t
);
713 bus_space_set_region_stream_1(bus_space_tag_t tag
, bus_space_handle_t bsh
,
714 bus_size_t offset
, uint8_t val
, bus_size_t count
)
716 volatile uint8_t *addr
= (void *)(bsh
+ offset
);
723 bus_space_set_region_stream_2(bus_space_tag_t tag
, bus_space_handle_t bsh
,
724 bus_size_t offset
, uint16_t val
, bus_size_t count
)
726 volatile uint16_t *addr
= (void *)(bsh
+ offset
);
733 bus_space_set_region_stream_4(bus_space_tag_t tag
, bus_space_handle_t bsh
,
734 bus_size_t offset
, uint32_t val
, bus_size_t count
)
736 volatile uint32_t *addr
= (void *)(bsh
+ offset
);
743 * void bus_space_copy_region_N(bus_space_tag_t tag,
744 * bus_space_handle_t bsh1, bus_size_t off1,
745 * bus_space_handle_t bsh2, bus_size_t off2,
748 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
749 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
751 static __inline
void bus_space_copy_region_1(bus_space_tag_t
,
752 bus_space_handle_t
, bus_size_t
, bus_space_handle_t
, bus_size_t
,
754 static __inline
void bus_space_copy_region_2(bus_space_tag_t
,
755 bus_space_handle_t
, bus_size_t
, bus_space_handle_t
, bus_size_t
,
757 static __inline
void bus_space_copy_region_4(bus_space_tag_t
,
758 bus_space_handle_t
, bus_size_t
, bus_space_handle_t
, bus_size_t
,
762 bus_space_copy_region_1(bus_space_tag_t t
, bus_space_handle_t h1
,
763 bus_size_t o1
, bus_space_handle_t h2
, bus_size_t o2
, bus_size_t c
)
765 volatile uint8_t *addr1
= (void *)(h1
+ o1
);
766 volatile uint8_t *addr2
= (void *)(h2
+ o2
);
768 if (addr1
>= addr2
) { /* src after dest: copy forward */
771 } else { /* dest after src: copy backwards */
780 bus_space_copy_region_2(bus_space_tag_t t
, bus_space_handle_t h1
,
781 bus_size_t o1
, bus_space_handle_t h2
, bus_size_t o2
, bus_size_t c
)
783 volatile uint16_t *addr1
= (void *)(h1
+ o1
);
784 volatile uint16_t *addr2
= (void *)(h2
+ o2
);
786 if (addr1
>= addr2
) { /* src after dest: copy forward */
789 } else { /* dest after src: copy backwards */
798 bus_space_copy_region_4(bus_space_tag_t t
, bus_space_handle_t h1
,
799 bus_size_t o1
, bus_space_handle_t h2
, bus_size_t o2
, bus_size_t c
)
801 volatile uint32_t *addr1
= (void *)(h1
+ o1
);
802 volatile uint32_t *addr2
= (void *)(h2
+ o2
);
804 if (addr1
>= addr2
) { /* src after dest: copy forward */
807 } else { /* dest after src: copy backwards */
816 * Bus read/write barrier methods.
818 * void bus_space_barrier(bus_space_tag_t tag,
819 * bus_space_handle_t bsh, bus_size_t offset,
820 * bus_size_t len, int flags);
822 * Note: the sh3 does not currently require barriers, but we must
823 * provide the flags to MI code.
825 #define bus_space_barrier(t, h, o, l, f) \
826 ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
827 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
828 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
830 #endif /* _SH3_BUS_H_ */