source: rtems-libbsd/rtemsbsd/include/machine/bus.h @ cbffdb7f

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since cbffdb7f was cbffdb7f, checked in by Joel Sherrill <joel.sherrill@…>, on 03/07/12 at 22:14:13

Separate RTEMS Specific Files from Those Direct from FreeBSD

  • Property mode set to 100644
File size: 23.8 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup rtems_bsd_machine
5 *
6 * @brief TODO.
7 *
8 * File origin from FreeBSD 'sys/amd64/include/bus.h'.
9 */
10
11/*-
12 * Copyright (c) 2009, 2010 embedded brains GmbH.  All rights reserved.
13 *
14 *  embedded brains GmbH
15 *  Obere Lagerstr. 30
16 *  82178 Puchheim
17 *  Germany
18 *  <rtems@embedded-brains.de>
19 *
20 * Copyright (c) KATO Takenori, 1999.
21 *
22 * All rights reserved.  Unpublished rights reserved under the copyright
23 * laws of Japan.
24 *
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
27 * are met:
28 *
29 * 1. Redistributions of source code must retain the above copyright
30 *    notice, this list of conditions and the following disclaimer as
31 *    the first lines of this file unmodified.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 *    notice, this list of conditions and the following disclaimer in the
34 *    documentation and/or other materials provided with the distribution.
35 * 3. The name of the author may not be used to endorse or promote products
36 *    derived from this software without specific prior written permission.
37 *
38 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
39 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
41 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
42 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
47 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 */
49
50/*-
51 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
52 * All rights reserved.
53 *
54 * This code is derived from software contributed to The NetBSD Foundation
55 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
56 * NASA Ames Research Center.
57 *
58 * Redistribution and use in source and binary forms, with or without
59 * modification, are permitted provided that the following conditions
60 * are met:
61 * 1. Redistributions of source code must retain the above copyright
62 *    notice, this list of conditions and the following disclaimer.
63 * 2. Redistributions in binary form must reproduce the above copyright
64 *    notice, this list of conditions and the following disclaimer in the
65 *    documentation and/or other materials provided with the distribution.
66 * 3. All advertising materials mentioning features or use of this software
67 *    must display the following acknowledgement:
68 *      This product includes software developed by the NetBSD
69 *      Foundation, Inc. and its contributors.
70 * 4. Neither the name of The NetBSD Foundation nor the names of its
71 *    contributors may be used to endorse or promote products derived
72 *    from this software without specific prior written permission.
73 *
74 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
75 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
76 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
77 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
78 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
79 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
80 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
81 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
82 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
83 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
84 * POSSIBILITY OF SUCH DAMAGE.
85 */
86
87/*-
88 * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
89 * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
90 *
91 * Redistribution and use in source and binary forms, with or without
92 * modification, are permitted provided that the following conditions
93 * are met:
94 * 1. Redistributions of source code must retain the above copyright
95 *    notice, this list of conditions and the following disclaimer.
96 * 2. Redistributions in binary form must reproduce the above copyright
97 *    notice, this list of conditions and the following disclaimer in the
98 *    documentation and/or other materials provided with the distribution.
99 * 3. All advertising materials mentioning features or use of this software
100 *    must display the following acknowledgement:
101 *      This product includes software developed by Christopher G. Demetriou
102 *      for the NetBSD Project.
103 * 4. The name of the author may not be used to endorse or promote products
104 *    derived from this software without specific prior written permission
105 *
106 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
107 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
108 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
109 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
110 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
111 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
112 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
113 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
114 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
115 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
116 */
117
118#ifndef _RTEMS_BSD_MACHINE_BUS_H_
119#define _RTEMS_BSD_MACHINE_BUS_H_
120
121#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_CONFIG_H_
122#error "the header file <rtems/freebsd/machine/rtems-bsd-config.h> must be included first"
123#endif
124
125/*
126 * Bus address alignment.
127 */
128#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
129
130/*
131 * Bus address maxima.
132 */
133#define BUS_SPACE_MAXADDR_24BIT 0xffffffU
134#define BUS_SPACE_MAXADDR_32BIT 0xffffffffU
135#define BUS_SPACE_MAXADDR       0xffffffffU
136#define BUS_SPACE_MAXSIZE_24BIT 0xffffffU
137#define BUS_SPACE_MAXSIZE_32BIT 0xffffffffU
138#define BUS_SPACE_MAXSIZE       0xffffffffU
139
140/*
141 * Bus access.
142 */
143#define BUS_SPACE_UNRESTRICTED  (~0U)
144
145/*
146 * Bus read/write barrier method.
147 */
148#define BUS_SPACE_BARRIER_READ  0x01            /* force read barrier */
149#define BUS_SPACE_BARRIER_WRITE 0x02            /* force write barrier */
150
151/*
152 * Bus address and size types
153 */
154typedef unsigned int bus_addr_t;
155typedef unsigned int bus_size_t;
156
157/*
158 * Access methods for bus resources and address space.
159 */
160typedef int bus_space_tag_t;
161typedef unsigned int bus_space_handle_t;
162
163/*
164 * Map a region of device bus space into CPU virtual address space.
165 */
166
167static __inline int
168bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr,
169              bus_size_t size __unused, int flags __unused,
170              bus_space_handle_t *bshp)
171{
172        *bshp = addr;
173        return (0);
174}
175
176/*
177 * Unmap a region of device bus space.
178 */
179static __inline void
180bus_space_unmap(bus_space_tag_t bst __unused, bus_space_handle_t bsh __unused,
181    bus_size_t size __unused)
182{
183        /* Do nothing */
184}
185
186
187/*
188 * Get a new handle for a subregion of an already-mapped area of bus space.
189 */
190static __inline int
191bus_space_subregion(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
192    bus_size_t ofs, bus_size_t size, bus_space_handle_t *nbshp)
193{
194        *nbshp = bsh + ofs;
195        return (0);
196}
197
198
199/*
200 * Allocate a region of memory that is accessible to devices in bus space.
201 */
202int
203bus_space_alloc(bus_space_tag_t bst __unused, bus_addr_t rstart, bus_addr_t rend,
204    bus_size_t size, bus_size_t align, bus_size_t boundary, int flags,
205    bus_addr_t *addrp, bus_space_handle_t *bshp);
206
207
208/*
209 * Free a region of bus space accessible memory.
210 */
211void
212bus_space_free(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t size);
213
214
215static __inline void
216bus_space_barrier(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs,
217    bus_size_t size, int flags)
218{
219        /* Do nothing */
220}
221
222
223/*
224 * Read 1 unit of data from bus space described by the tag, handle and ofs
225 * tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
226 * data is returned.
227 */
228static __inline uint8_t
229bus_space_read_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs)
230{
231        uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
232        return (*bsp);
233}
234
235static __inline uint16_t
236bus_space_read_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs)
237{
238        uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
239        return (*bsp);
240}
241
242static __inline uint32_t
243bus_space_read_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs)
244{
245        uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
246        return (*bsp);
247}
248
249static __inline uint64_t
250bus_space_read_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs)
251{
252        uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
253        return (*bsp);
254}
255
256
257/*
258 * Write 1 unit of data to bus space described by the tag, handle and ofs
259 * tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
260 * data is passed by value.
261 */
262static __inline void
263bus_space_write_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs,
264    uint8_t val)
265{
266        uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
267        *bsp = val;
268}
269
270static __inline void
271bus_space_write_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs,
272    uint16_t val)
273{
274        uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
275        *bsp = val;
276}
277
278static __inline void
279bus_space_write_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs,
280    uint32_t val)
281{
282        uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
283        *bsp = val;
284}
285
286static __inline void
287bus_space_write_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs,
288    uint64_t val)
289{
290        uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
291        *bsp = val;
292}
293
294
295/*
296 * Read count units of data from bus space described by the tag, handle and
297 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
298 * data is returned in the buffer passed by reference.
299 */
300static __inline void
301bus_space_read_multi_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
302    bus_size_t ofs, uint8_t *bufp, bus_size_t count)
303{
304        uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
305        while (count-- > 0) {
306                *bufp++ = *bsp;
307        }
308}
309
310static __inline void
311bus_space_read_multi_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
312    bus_size_t ofs, uint16_t *bufp, bus_size_t count)
313{
314        uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
315        while (count-- > 0) {
316                *bufp++ = *bsp;
317        }
318}
319
320static __inline void
321bus_space_read_multi_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
322    bus_size_t ofs, uint32_t *bufp, bus_size_t count)
323{
324        uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
325        while (count-- > 0) {
326                *bufp++ = *bsp;
327        }
328}
329
330static __inline void
331bus_space_read_multi_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
332    bus_size_t ofs, uint64_t *bufp, bus_size_t count)
333{
334        uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
335        while (count-- > 0) {
336                *bufp++ = *bsp;
337        }
338}
339
340
341/*
342 * Write count units of data to bus space described by the tag, handle and
343 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
344 * data is read from the buffer passed by reference.
345 */
346static __inline void
347bus_space_write_multi_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
348    bus_size_t ofs, const uint8_t *bufp, bus_size_t count)
349{
350        uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
351        while (count-- > 0) {
352                *bsp = *bufp++;
353        }
354}
355
356static __inline void
357bus_space_write_multi_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
358    bus_size_t ofs, const uint16_t *bufp, bus_size_t count)
359{
360        uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
361        while (count-- > 0) {
362                *bsp = *bufp++;
363        }
364}
365
366static __inline void
367bus_space_write_multi_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
368    bus_size_t ofs, const uint32_t *bufp, bus_size_t count)
369{
370        uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
371        while (count-- > 0) {
372                *bsp = *bufp++;
373        }
374}
375
376static __inline void
377bus_space_write_multi_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
378    bus_size_t ofs, const uint64_t *bufp, bus_size_t count)
379{
380        uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
381        while (count-- > 0) {
382                *bsp = *bufp++;
383        }
384}
385
386
387/*
388 * Read count units of data from bus space described by the tag, handle and
389 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
390 * data is written to the buffer passed by reference and read from successive
391 * bus space addresses. Access is unordered.
392 */
393static __inline void
394bus_space_read_region_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
395    bus_size_t ofs, uint8_t *bufp, bus_size_t count)
396{
397        while (count-- > 0) {
398                uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
399                *bufp++ = *bsp;
400                ofs += 1;
401        }
402}
403
404static __inline void
405bus_space_read_region_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
406    bus_size_t ofs, uint16_t *bufp, bus_size_t count)
407{
408        while (count-- > 0) {
409                uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
410                *bufp++ = *bsp;
411                ofs += 2;
412        }
413}
414
415static __inline void
416bus_space_read_region_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
417    bus_size_t ofs, uint32_t *bufp, bus_size_t count)
418{
419        while (count-- > 0) {
420                uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
421                *bufp++ = *bsp;
422                ofs += 4;
423        }
424}
425
426static __inline void
427bus_space_read_region_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
428    bus_size_t ofs, uint64_t *bufp, bus_size_t count)
429{
430        while (count-- > 0) {
431                uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
432                *bufp++ = *bsp;
433                ofs += 8;
434        }
435}
436
437
438/*
439 * Write count units of data from bus space described by the tag, handle and
440 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
441 * data is read from the buffer passed by reference and written to successive
442 * bus space addresses. Access is unordered.
443 */
444static __inline void
445bus_space_write_region_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
446    bus_size_t ofs, const uint8_t *bufp, bus_size_t count)
447{
448        while (count-- > 0) {
449                uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
450                *bsp = *bufp++;
451                ofs += 1;
452        }
453}
454
455static __inline void
456bus_space_write_region_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
457    bus_size_t ofs, const uint16_t *bufp, bus_size_t count)
458{
459        while (count-- > 0) {
460                uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
461                *bsp = *bufp++;
462                ofs += 2;
463        }
464}
465
466static __inline void
467bus_space_write_region_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
468    bus_size_t ofs, const uint32_t *bufp, bus_size_t count)
469{
470        while (count-- > 0) {
471                uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
472                *bsp = *bufp++;
473                ofs += 4;
474        }
475}
476
477static __inline void
478bus_space_write_region_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
479    bus_size_t ofs, const uint64_t *bufp, bus_size_t count)
480{
481        while (count-- > 0) {
482                uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
483                *bsp = *bufp++;
484                ofs += 8;
485        }
486}
487
488
489/*
490 * Write count units of data from bus space described by the tag, handle and
491 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
492 * data is passed by value. Writes are unordered.
493 */
494static __inline void
495bus_space_set_multi_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
496    bus_size_t ofs, uint8_t val, bus_size_t count)
497{
498        uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
499        while (count-- > 0) {
500                *bsp = val;
501        }
502}
503
504static __inline void
505bus_space_set_multi_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
506    bus_size_t ofs, uint16_t val, bus_size_t count)
507{
508        uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
509        while (count-- > 0) {
510                *bsp = val;
511        }
512}
513
514static __inline void
515bus_space_set_multi_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
516    bus_size_t ofs, uint32_t val, bus_size_t count)
517{
518        uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
519        while (count-- > 0) {
520                *bsp = val;
521        }
522}
523
524static __inline void
525bus_space_set_multi_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
526    bus_size_t ofs, uint64_t val, bus_size_t count)
527{
528        uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
529        while (count-- > 0) {
530                *bsp = val;
531        }
532}
533
534
535/*
536 * Write count units of data from bus space described by the tag, handle and
537 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
538 * data is passed by value and written to successive bus space addresses.
539 * Writes are unordered.
540 */
541static __inline void
542bus_space_set_region_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
543    bus_size_t ofs, uint8_t val, bus_size_t count)
544{
545        while (count-- > 0) {
546                uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
547                *bsp = val;
548                ofs += 1;
549        }
550}
551
552static __inline void
553bus_space_set_region_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
554    bus_size_t ofs, uint16_t val, bus_size_t count)
555{
556        while (count-- > 0) {
557                uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
558                *bsp = val;
559                ofs += 2;
560        }
561}
562
563static __inline void
564bus_space_set_region_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
565    bus_size_t ofs, uint32_t val, bus_size_t count)
566{
567        while (count-- > 0) {
568                uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
569                *bsp = val;
570                ofs += 4;
571        }
572}
573
574static __inline void
575bus_space_set_region_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
576    bus_size_t ofs, uint64_t val, bus_size_t count)
577{
578        while (count-- > 0) {
579                uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
580                *bsp = val;
581                ofs += 8;
582        }
583}
584
585
586/*
587 * Copy count units of data from bus space described by the tag and the first
588 * handle and ofs pair to bus space described by the tag and the second handle
589 * and ofs pair. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes.
590 * The data is read from successive bus space addresses and also written to
591 * successive bus space addresses. Both reads and writes are unordered.
592 */
593static __inline void
594bus_space_copy_region_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh1,
595    bus_size_t ofs1, bus_space_handle_t bsh2, bus_size_t ofs2, bus_size_t count)
596{
597        bus_addr_t dst = bsh1 + ofs1;
598        bus_addr_t src = bsh2 + ofs2;
599        uint8_t __volatile *dstp = (uint8_t __volatile *) dst;
600        uint8_t __volatile *srcp = (uint8_t __volatile *) src;
601        if (dst > src) {
602                src += count - 1;
603                dst += count - 1;
604                while (count-- > 0) {
605                        *dstp = *srcp;
606                        src -= 1;
607                        dst -= 1;
608                }
609        } else {
610                while (count-- > 0) {
611                        *dstp = *srcp;
612                        src += 1;
613                        dst += 1;
614                }
615        }
616}
617
618static __inline void
619bus_space_copy_region_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh1,
620    bus_size_t ofs1, bus_space_handle_t bsh2, bus_size_t ofs2, bus_size_t count)
621{
622        bus_addr_t dst = bsh1 + ofs1;
623        bus_addr_t src = bsh2 + ofs2;
624        uint16_t __volatile *dstp = (uint16_t __volatile *) dst;
625        uint16_t __volatile *srcp = (uint16_t __volatile *) src;
626        if (dst > src) {
627                src += (count - 1) << 1;
628                dst += (count - 1) << 1;
629                while (count-- > 0) {
630                        *dstp = *srcp;
631                        src -= 2;
632                        dst -= 2;
633                }
634        } else {
635                while (count-- > 0) {
636                        *dstp = *srcp;
637                        src += 2;
638                        dst += 2;
639                }
640        }
641}
642
643static __inline void
644bus_space_copy_region_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh1,
645    bus_size_t ofs1, bus_space_handle_t bsh2, bus_size_t ofs2, bus_size_t count)
646{
647        bus_addr_t dst = bsh1 + ofs1;
648        bus_addr_t src = bsh2 + ofs2;
649        uint32_t __volatile *dstp = (uint32_t __volatile *) dst;
650        uint32_t __volatile *srcp = (uint32_t __volatile *) src;
651        if (dst > src) {
652                src += (count - 1) << 2;
653                dst += (count - 1) << 2;
654                while (count-- > 0) {
655                        *dstp = *srcp;
656                        src -= 4;
657                        dst -= 4;
658                }
659        } else {
660                while (count-- > 0) {
661                        *dstp = *srcp;
662                        src += 4;
663                        dst += 4;
664                }
665        }
666}
667
668static __inline void
669bus_space_copy_region_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh1,
670    bus_size_t ofs1, bus_space_handle_t bsh2, bus_size_t ofs2, bus_size_t count)
671{
672        bus_addr_t dst = bsh1 + ofs1;
673        bus_addr_t src = bsh2 + ofs2;
674        uint64_t __volatile *dstp = (uint64_t __volatile *) dst;
675        uint64_t __volatile *srcp = (uint64_t __volatile *) src;
676        if (dst > src) {
677                src += (count - 1) << 3;
678                dst += (count - 1) << 3;
679                while (count-- > 0) {
680                        *dstp = *srcp;
681                        src -= 8;
682                        dst -= 8;
683                }
684        } else {
685                while (count-- > 0) {
686                        *dstp = *srcp;
687                        src += 8;
688                        dst += 8;
689                }
690        }
691}
692
693
694/*
695 * Stream accesses are the same as normal accesses on RTEMS; there are no
696 * supported bus systems with an endianess different from the host one.
697 */
698#define bus_space_read_stream_1(t, h, o)        \
699        bus_space_read_1(t, h, o)
700#define bus_space_read_stream_2(t, h, o)        \
701        bus_space_read_2(t, h, o)
702#define bus_space_read_stream_4(t, h, o)        \
703        bus_space_read_4(t, h, o)
704#define bus_space_read_stream_8(t, h, o)        \
705        bus_space_read_8(t, h, o)
706
707#define bus_space_read_multi_stream_1(t, h, o, a, c)    \
708        bus_space_read_multi_1(t, h, o, a, c)
709#define bus_space_read_multi_stream_2(t, h, o, a, c)    \
710        bus_space_read_multi_2(t, h, o, a, c)
711#define bus_space_read_multi_stream_4(t, h, o, a, c)    \
712        bus_space_read_multi_4(t, h, o, a, c)
713#define bus_space_read_multi_stream_8(t, h, o, a, c)    \
714        bus_space_read_multi_8(t, h, o, a, c)
715
716#define bus_space_write_stream_1(t, h, o, v)    \
717        bus_space_write_1(t, h, o, v)
718#define bus_space_write_stream_2(t, h, o, v)    \
719        bus_space_write_2(t, h, o, v)
720#define bus_space_write_stream_4(t, h, o, v)    \
721        bus_space_write_4(t, h, o, v)
722#define bus_space_write_stream_8(t, h, o, v)    \
723        bus_space_write_8(t, h, o, v)
724
725#define bus_space_write_multi_stream_1(t, h, o, a, c)   \
726        bus_space_write_multi_1(t, h, o, a, c)
727#define bus_space_write_multi_stream_2(t, h, o, a, c)   \
728        bus_space_write_multi_2(t, h, o, a, c)
729#define bus_space_write_multi_stream_4(t, h, o, a, c)   \
730        bus_space_write_multi_4(t, h, o, a, c)
731#define bus_space_write_multi_stream_8(t, h, o, a, c)   \
732        bus_space_write_multi_8(t, h, o, a, c)
733
734#define bus_space_set_multi_stream_1(t, h, o, v, c)     \
735        bus_space_set_multi_1(t, h, o, v, c)
736#define bus_space_set_multi_stream_2(t, h, o, v, c)     \
737        bus_space_set_multi_2(t, h, o, v, c)
738#define bus_space_set_multi_stream_4(t, h, o, v, c)     \
739        bus_space_set_multi_4(t, h, o, v, c)
740#define bus_space_set_multi_stream_8(t, h, o, v, c)     \
741        bus_space_set_multi_8(t, h, o, v, c)
742
743#define bus_space_read_region_stream_1(t, h, o, a, c)   \
744        bus_space_read_region_1(t, h, o, a, c)
745#define bus_space_read_region_stream_2(t, h, o, a, c)   \
746        bus_space_read_region_2(t, h, o, a, c)
747#define bus_space_read_region_stream_4(t, h, o, a, c)   \
748        bus_space_read_region_4(t, h, o, a, c)
749#define bus_space_read_region_stream_8(t, h, o, a, c)   \
750        bus_space_read_region_8(t, h, o, a, c)
751
752#define bus_space_write_region_stream_1(t, h, o, a, c)  \
753        bus_space_write_region_1(t, h, o, a, c)
754#define bus_space_write_region_stream_2(t, h, o, a, c)  \
755        bus_space_write_region_2(t, h, o, a, c)
756#define bus_space_write_region_stream_4(t, h, o, a, c)  \
757        bus_space_write_region_4(t, h, o, a, c)
758#define bus_space_write_region_stream_8(t, h, o, a, c)  \
759        bus_space_write_region_8(t, h, o, a, c)
760
761#define bus_space_set_region_stream_1(t, h, o, v, c)    \
762        bus_space_set_region_1(t, h, o, v, c)
763#define bus_space_set_region_stream_2(t, h, o, v, c)    \
764        bus_space_set_region_2(t, h, o, v, c)
765#define bus_space_set_region_stream_4(t, h, o, v, c)    \
766        bus_space_set_region_4(t, h, o, v, c)
767#define bus_space_set_region_stream_8(t, h, o, v, c)    \
768        bus_space_set_region_8(t, h, o, v, c)
769
770#define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c)    \
771        bus_space_copy_region_1(t, h1, o1, h2, o2, c)
772#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c)    \
773        bus_space_copy_region_2(t, h1, o1, h2, o2, c)
774#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c)    \
775        bus_space_copy_region_4(t, h1, o1, h2, o2, c)
776#define bus_space_copy_region_stream_8(t, h1, o1, h2, o2, c)    \
777        bus_space_copy_region_8(t, h1, o1, h2, o2, c)
778
779#include <rtems/freebsd/machine/bus_dma.h>
780
781#endif /* _RTEMS_BSD_MACHINE_BUS_H_ */
Note: See TracBrowser for help on using the repository browser.