source: rtems-libbsd/rtemsbsd/include/machine/bus_space-simple_memory.h @ b84c04e

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since b84c04e was bceabc9, checked in by Sebastian Huber <sebastian.huber@…>, on 10/09/13 at 20:42:09

Move files to match FreeBSD layout

  • Property mode set to 100644
File size: 21.7 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_SIMPLE_MEMORY_H_
119#define _RTEMS_BSD_MACHINE_BUS_SIMPLE_MEMORY_H_
120
121static __inline void
122bus_space_barrier(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs,
123    bus_size_t size, int flags)
124{
125        /* Do nothing */
126}
127
128/*
129 * Read 1 unit of data from bus space described by the tag, handle and ofs
130 * tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
131 * data is returned.
132 */
133static __inline uint8_t
134bus_space_read_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs)
135{
136        uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
137        return (*bsp);
138}
139
140static __inline uint16_t
141bus_space_read_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs)
142{
143        uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
144        return (*bsp);
145}
146
147static __inline uint32_t
148bus_space_read_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs)
149{
150        uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
151        return (*bsp);
152}
153
154static __inline uint64_t
155bus_space_read_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs)
156{
157        uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
158        return (*bsp);
159}
160
161
162/*
163 * Write 1 unit of data to bus space described by the tag, handle and ofs
164 * tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
165 * data is passed by value.
166 */
167static __inline void
168bus_space_write_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs,
169    uint8_t val)
170{
171        uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
172        *bsp = val;
173}
174
175static __inline void
176bus_space_write_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs,
177    uint16_t val)
178{
179        uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
180        *bsp = val;
181}
182
183static __inline void
184bus_space_write_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs,
185    uint32_t val)
186{
187        uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
188        *bsp = val;
189}
190
191static __inline void
192bus_space_write_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh, bus_size_t ofs,
193    uint64_t val)
194{
195        uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
196        *bsp = val;
197}
198
199
200/*
201 * Read count units of data from bus space described by the tag, handle and
202 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
203 * data is returned in the buffer passed by reference.
204 */
205static __inline void
206bus_space_read_multi_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
207    bus_size_t ofs, uint8_t *bufp, bus_size_t count)
208{
209        uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
210        while (count-- > 0) {
211                *bufp++ = *bsp;
212        }
213}
214
215static __inline void
216bus_space_read_multi_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
217    bus_size_t ofs, uint16_t *bufp, bus_size_t count)
218{
219        uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
220        while (count-- > 0) {
221                *bufp++ = *bsp;
222        }
223}
224
225static __inline void
226bus_space_read_multi_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
227    bus_size_t ofs, uint32_t *bufp, bus_size_t count)
228{
229        uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
230        while (count-- > 0) {
231                *bufp++ = *bsp;
232        }
233}
234
235static __inline void
236bus_space_read_multi_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
237    bus_size_t ofs, uint64_t *bufp, bus_size_t count)
238{
239        uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
240        while (count-- > 0) {
241                *bufp++ = *bsp;
242        }
243}
244
245
246/*
247 * Write count units of data to bus space described by the tag, handle and
248 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
249 * data is read from the buffer passed by reference.
250 */
251static __inline void
252bus_space_write_multi_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
253    bus_size_t ofs, const uint8_t *bufp, bus_size_t count)
254{
255        uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
256        while (count-- > 0) {
257                *bsp = *bufp++;
258        }
259}
260
261static __inline void
262bus_space_write_multi_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
263    bus_size_t ofs, const uint16_t *bufp, bus_size_t count)
264{
265        uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
266        while (count-- > 0) {
267                *bsp = *bufp++;
268        }
269}
270
271static __inline void
272bus_space_write_multi_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
273    bus_size_t ofs, const uint32_t *bufp, bus_size_t count)
274{
275        uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
276        while (count-- > 0) {
277                *bsp = *bufp++;
278        }
279}
280
281static __inline void
282bus_space_write_multi_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
283    bus_size_t ofs, const uint64_t *bufp, bus_size_t count)
284{
285        uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
286        while (count-- > 0) {
287                *bsp = *bufp++;
288        }
289}
290
291
292/*
293 * Read count units of data from bus space described by the tag, handle and
294 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
295 * data is written to the buffer passed by reference and read from successive
296 * bus space addresses. Access is unordered.
297 */
298static __inline void
299bus_space_read_region_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
300    bus_size_t ofs, uint8_t *bufp, bus_size_t count)
301{
302        while (count-- > 0) {
303                uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
304                *bufp++ = *bsp;
305                ofs += 1;
306        }
307}
308
309static __inline void
310bus_space_read_region_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
311    bus_size_t ofs, uint16_t *bufp, bus_size_t count)
312{
313        while (count-- > 0) {
314                uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
315                *bufp++ = *bsp;
316                ofs += 2;
317        }
318}
319
320static __inline void
321bus_space_read_region_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        while (count-- > 0) {
325                uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
326                *bufp++ = *bsp;
327                ofs += 4;
328        }
329}
330
331static __inline void
332bus_space_read_region_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
333    bus_size_t ofs, uint64_t *bufp, bus_size_t count)
334{
335        while (count-- > 0) {
336                uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
337                *bufp++ = *bsp;
338                ofs += 8;
339        }
340}
341
342
343/*
344 * Write count units of data from bus space described by the tag, handle and
345 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
346 * data is read from the buffer passed by reference and written to successive
347 * bus space addresses. Access is unordered.
348 */
349static __inline void
350bus_space_write_region_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
351    bus_size_t ofs, const uint8_t *bufp, bus_size_t count)
352{
353        while (count-- > 0) {
354                uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
355                *bsp = *bufp++;
356                ofs += 1;
357        }
358}
359
360static __inline void
361bus_space_write_region_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
362    bus_size_t ofs, const uint16_t *bufp, bus_size_t count)
363{
364        while (count-- > 0) {
365                uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
366                *bsp = *bufp++;
367                ofs += 2;
368        }
369}
370
371static __inline void
372bus_space_write_region_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
373    bus_size_t ofs, const uint32_t *bufp, bus_size_t count)
374{
375        while (count-- > 0) {
376                uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
377                *bsp = *bufp++;
378                ofs += 4;
379        }
380}
381
382static __inline void
383bus_space_write_region_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
384    bus_size_t ofs, const uint64_t *bufp, bus_size_t count)
385{
386        while (count-- > 0) {
387                uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
388                *bsp = *bufp++;
389                ofs += 8;
390        }
391}
392
393
394/*
395 * Write count units of data from bus space described by the tag, handle and
396 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
397 * data is passed by value. Writes are unordered.
398 */
399static __inline void
400bus_space_set_multi_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
401    bus_size_t ofs, uint8_t val, bus_size_t count)
402{
403        uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
404        while (count-- > 0) {
405                *bsp = val;
406        }
407}
408
409static __inline void
410bus_space_set_multi_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
411    bus_size_t ofs, uint16_t val, bus_size_t count)
412{
413        uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
414        while (count-- > 0) {
415                *bsp = val;
416        }
417}
418
419static __inline void
420bus_space_set_multi_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
421    bus_size_t ofs, uint32_t val, bus_size_t count)
422{
423        uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
424        while (count-- > 0) {
425                *bsp = val;
426        }
427}
428
429static __inline void
430bus_space_set_multi_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
431    bus_size_t ofs, uint64_t val, bus_size_t count)
432{
433        uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
434        while (count-- > 0) {
435                *bsp = val;
436        }
437}
438
439
440/*
441 * Write count units of data from bus space described by the tag, handle and
442 * ofs tuple. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes. The
443 * data is passed by value and written to successive bus space addresses.
444 * Writes are unordered.
445 */
446static __inline void
447bus_space_set_region_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
448    bus_size_t ofs, uint8_t val, bus_size_t count)
449{
450        while (count-- > 0) {
451                uint8_t __volatile *bsp = (uint8_t __volatile *)(bsh + ofs);
452                *bsp = val;
453                ofs += 1;
454        }
455}
456
457static __inline void
458bus_space_set_region_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
459    bus_size_t ofs, uint16_t val, bus_size_t count)
460{
461        while (count-- > 0) {
462                uint16_t __volatile *bsp = (uint16_t __volatile *)(bsh + ofs);
463                *bsp = val;
464                ofs += 2;
465        }
466}
467
468static __inline void
469bus_space_set_region_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
470    bus_size_t ofs, uint32_t val, bus_size_t count)
471{
472        while (count-- > 0) {
473                uint32_t __volatile *bsp = (uint32_t __volatile *)(bsh + ofs);
474                *bsp = val;
475                ofs += 4;
476        }
477}
478
479static __inline void
480bus_space_set_region_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh,
481    bus_size_t ofs, uint64_t val, bus_size_t count)
482{
483        while (count-- > 0) {
484                uint64_t __volatile *bsp = (uint64_t __volatile *)(bsh + ofs);
485                *bsp = val;
486                ofs += 8;
487        }
488}
489
490
491/*
492 * Copy count units of data from bus space described by the tag and the first
493 * handle and ofs pair to bus space described by the tag and the second handle
494 * and ofs pair. A unit of data can be 1 byte, 2 bytes, 4 bytes or 8 bytes.
495 * The data is read from successive bus space addresses and also written to
496 * successive bus space addresses. Both reads and writes are unordered.
497 */
498static __inline void
499bus_space_copy_region_1(bus_space_tag_t bst __unused, bus_space_handle_t bsh1,
500    bus_size_t ofs1, bus_space_handle_t bsh2, bus_size_t ofs2, bus_size_t count)
501{
502        bus_addr_t dst = bsh1 + ofs1;
503        bus_addr_t src = bsh2 + ofs2;
504        uint8_t __volatile *dstp = (uint8_t __volatile *) dst;
505        uint8_t __volatile *srcp = (uint8_t __volatile *) src;
506        if (dst > src) {
507                src += count - 1;
508                dst += count - 1;
509                while (count-- > 0) {
510                        *dstp = *srcp;
511                        src -= 1;
512                        dst -= 1;
513                }
514        } else {
515                while (count-- > 0) {
516                        *dstp = *srcp;
517                        src += 1;
518                        dst += 1;
519                }
520        }
521}
522
523static __inline void
524bus_space_copy_region_2(bus_space_tag_t bst __unused, bus_space_handle_t bsh1,
525    bus_size_t ofs1, bus_space_handle_t bsh2, bus_size_t ofs2, bus_size_t count)
526{
527        bus_addr_t dst = bsh1 + ofs1;
528        bus_addr_t src = bsh2 + ofs2;
529        uint16_t __volatile *dstp = (uint16_t __volatile *) dst;
530        uint16_t __volatile *srcp = (uint16_t __volatile *) src;
531        if (dst > src) {
532                src += (count - 1) << 1;
533                dst += (count - 1) << 1;
534                while (count-- > 0) {
535                        *dstp = *srcp;
536                        src -= 2;
537                        dst -= 2;
538                }
539        } else {
540                while (count-- > 0) {
541                        *dstp = *srcp;
542                        src += 2;
543                        dst += 2;
544                }
545        }
546}
547
548static __inline void
549bus_space_copy_region_4(bus_space_tag_t bst __unused, bus_space_handle_t bsh1,
550    bus_size_t ofs1, bus_space_handle_t bsh2, bus_size_t ofs2, bus_size_t count)
551{
552        bus_addr_t dst = bsh1 + ofs1;
553        bus_addr_t src = bsh2 + ofs2;
554        uint32_t __volatile *dstp = (uint32_t __volatile *) dst;
555        uint32_t __volatile *srcp = (uint32_t __volatile *) src;
556        if (dst > src) {
557                src += (count - 1) << 2;
558                dst += (count - 1) << 2;
559                while (count-- > 0) {
560                        *dstp = *srcp;
561                        src -= 4;
562                        dst -= 4;
563                }
564        } else {
565                while (count-- > 0) {
566                        *dstp = *srcp;
567                        src += 4;
568                        dst += 4;
569                }
570        }
571}
572
573static __inline void
574bus_space_copy_region_8(bus_space_tag_t bst __unused, bus_space_handle_t bsh1,
575    bus_size_t ofs1, bus_space_handle_t bsh2, bus_size_t ofs2, bus_size_t count)
576{
577        bus_addr_t dst = bsh1 + ofs1;
578        bus_addr_t src = bsh2 + ofs2;
579        uint64_t __volatile *dstp = (uint64_t __volatile *) dst;
580        uint64_t __volatile *srcp = (uint64_t __volatile *) src;
581        if (dst > src) {
582                src += (count - 1) << 3;
583                dst += (count - 1) << 3;
584                while (count-- > 0) {
585                        *dstp = *srcp;
586                        src -= 8;
587                        dst -= 8;
588                }
589        } else {
590                while (count-- > 0) {
591                        *dstp = *srcp;
592                        src += 8;
593                        dst += 8;
594                }
595        }
596}
597
598
599/*
600 * Stream accesses are the same as normal accesses on RTEMS; there are no
601 * supported bus systems with an endianess different from the host one.
602 */
603#define bus_space_read_stream_1(t, h, o)        \
604        bus_space_read_1(t, h, o)
605#define bus_space_read_stream_2(t, h, o)        \
606        bus_space_read_2(t, h, o)
607#define bus_space_read_stream_4(t, h, o)        \
608        bus_space_read_4(t, h, o)
609#define bus_space_read_stream_8(t, h, o)        \
610        bus_space_read_8(t, h, o)
611
612#define bus_space_read_multi_stream_1(t, h, o, a, c)    \
613        bus_space_read_multi_1(t, h, o, a, c)
614#define bus_space_read_multi_stream_2(t, h, o, a, c)    \
615        bus_space_read_multi_2(t, h, o, a, c)
616#define bus_space_read_multi_stream_4(t, h, o, a, c)    \
617        bus_space_read_multi_4(t, h, o, a, c)
618#define bus_space_read_multi_stream_8(t, h, o, a, c)    \
619        bus_space_read_multi_8(t, h, o, a, c)
620
621#define bus_space_write_stream_1(t, h, o, v)    \
622        bus_space_write_1(t, h, o, v)
623#define bus_space_write_stream_2(t, h, o, v)    \
624        bus_space_write_2(t, h, o, v)
625#define bus_space_write_stream_4(t, h, o, v)    \
626        bus_space_write_4(t, h, o, v)
627#define bus_space_write_stream_8(t, h, o, v)    \
628        bus_space_write_8(t, h, o, v)
629
630#define bus_space_write_multi_stream_1(t, h, o, a, c)   \
631        bus_space_write_multi_1(t, h, o, a, c)
632#define bus_space_write_multi_stream_2(t, h, o, a, c)   \
633        bus_space_write_multi_2(t, h, o, a, c)
634#define bus_space_write_multi_stream_4(t, h, o, a, c)   \
635        bus_space_write_multi_4(t, h, o, a, c)
636#define bus_space_write_multi_stream_8(t, h, o, a, c)   \
637        bus_space_write_multi_8(t, h, o, a, c)
638
639#define bus_space_set_multi_stream_1(t, h, o, v, c)     \
640        bus_space_set_multi_1(t, h, o, v, c)
641#define bus_space_set_multi_stream_2(t, h, o, v, c)     \
642        bus_space_set_multi_2(t, h, o, v, c)
643#define bus_space_set_multi_stream_4(t, h, o, v, c)     \
644        bus_space_set_multi_4(t, h, o, v, c)
645#define bus_space_set_multi_stream_8(t, h, o, v, c)     \
646        bus_space_set_multi_8(t, h, o, v, c)
647
648#define bus_space_read_region_stream_1(t, h, o, a, c)   \
649        bus_space_read_region_1(t, h, o, a, c)
650#define bus_space_read_region_stream_2(t, h, o, a, c)   \
651        bus_space_read_region_2(t, h, o, a, c)
652#define bus_space_read_region_stream_4(t, h, o, a, c)   \
653        bus_space_read_region_4(t, h, o, a, c)
654#define bus_space_read_region_stream_8(t, h, o, a, c)   \
655        bus_space_read_region_8(t, h, o, a, c)
656
657#define bus_space_write_region_stream_1(t, h, o, a, c)  \
658        bus_space_write_region_1(t, h, o, a, c)
659#define bus_space_write_region_stream_2(t, h, o, a, c)  \
660        bus_space_write_region_2(t, h, o, a, c)
661#define bus_space_write_region_stream_4(t, h, o, a, c)  \
662        bus_space_write_region_4(t, h, o, a, c)
663#define bus_space_write_region_stream_8(t, h, o, a, c)  \
664        bus_space_write_region_8(t, h, o, a, c)
665
666#define bus_space_set_region_stream_1(t, h, o, v, c)    \
667        bus_space_set_region_1(t, h, o, v, c)
668#define bus_space_set_region_stream_2(t, h, o, v, c)    \
669        bus_space_set_region_2(t, h, o, v, c)
670#define bus_space_set_region_stream_4(t, h, o, v, c)    \
671        bus_space_set_region_4(t, h, o, v, c)
672#define bus_space_set_region_stream_8(t, h, o, v, c)    \
673        bus_space_set_region_8(t, h, o, v, c)
674
675#define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c)    \
676        bus_space_copy_region_1(t, h1, o1, h2, o2, c)
677#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c)    \
678        bus_space_copy_region_2(t, h1, o1, h2, o2, c)
679#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c)    \
680        bus_space_copy_region_4(t, h1, o1, h2, o2, c)
681#define bus_space_copy_region_stream_8(t, h1, o1, h2, o2, c)    \
682        bus_space_copy_region_8(t, h1, o1, h2, o2, c)
683
684#endif /* _RTEMS_BSD_MACHINE_BUS_SIMPLE_MEMORY_H_ */
Note: See TracBrowser for help on using the repository browser.