1 1.2 riastrad /* $NetBSD: bus_funcs.h,v 1.2 2022/02/16 23:49:26 riastradh Exp $ */ 2 1.1 dyoung 3 1.1 dyoung /* 4 1.1 dyoung * Copyright (c) 1996 Leo Weppelman. All rights reserved. 5 1.1 dyoung * 6 1.1 dyoung * Redistribution and use in source and binary forms, with or without 7 1.1 dyoung * modification, are permitted provided that the following conditions 8 1.1 dyoung * are met: 9 1.1 dyoung * 1. Redistributions of source code must retain the above copyright 10 1.1 dyoung * notice, this list of conditions and the following disclaimer. 11 1.1 dyoung * 2. Redistributions in binary form must reproduce the above copyright 12 1.1 dyoung * notice, this list of conditions and the following disclaimer in the 13 1.1 dyoung * documentation and/or other materials provided with the distribution. 14 1.1 dyoung * 15 1.1 dyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 1.1 dyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 1.1 dyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 1.1 dyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 1.1 dyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 1.1 dyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 1.1 dyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 1.1 dyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 1.1 dyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 1.1 dyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 1.1 dyoung */ 26 1.1 dyoung 27 1.1 dyoung #ifndef _AMIGAPPC_BUS_FUNCS_H_ 28 1.1 dyoung #define _AMIGAPPC_BUS_FUNCS_H_ 29 1.1 dyoung 30 1.1 dyoung /* 31 1.1 dyoung * Macro definition of map, unmap, etc. 32 1.1 dyoung */ 33 1.1 dyoung 34 1.1 dyoung #define bus_space_map(t, o, s, f, hp) \ 35 1.1 dyoung ((t)->absm->bsm)((t), (o), (s), (f), (hp)) 36 1.1 dyoung 37 1.1 dyoung #define bus_space_subregion(t, h, o, s, hp) \ 38 1.1 dyoung ((t)->absm->bsms)((h), (o), (s), (hp)) 39 1.1 dyoung 40 1.1 dyoung #define bus_space_unmap(t, h, s) \ 41 1.1 dyoung ((t)->absm->bsu)((h), (s)) 42 1.1 dyoung 43 1.1 dyoung /* 44 1.1 dyoung * Macro definition of _2 functions as indirect method array calls 45 1.1 dyoung */ 46 1.1 dyoung 47 1.1 dyoung /* 0: Helper macros */ 48 1.1 dyoung 49 1.1 dyoung #define dbsdr(n, t, h, o) ((t)->absm->n)((h), (o)) 50 1.1 dyoung #define dbsdw(n, t, h, o, v) ((t)->absm->n)((h), (o), (v)) 51 1.1 dyoung #define dbsm(n, t, h, o, p, c) ((t)->absm->n)((h), (o), (p), (c)) 52 1.1 dyoung #define dbss(n, t, h, o, v, c) ((t)->absm->n)((h), (o), (v), (c)) 53 1.1 dyoung #define dbsc(n, t, h, o, v, c) ((t)->absm->n)((h), (o), (v), (c)) 54 1.1 dyoung 55 1.1 dyoung /* 1: byte-wide "functions" */ 56 1.1 dyoung 57 1.1 dyoung #define bus_space_read_1(t, h, o) dbsdr(bsr1, t, h, o) 58 1.1 dyoung #define bus_space_write_1(t, h, o, v) dbsdw(bsw1, t, h, o, v) 59 1.1 dyoung 60 1.1 dyoung #define bus_space_read_multi_1(t, h, o, p, c) dbsm(bsrm1, t, h, o, p, c) 61 1.1 dyoung #define bus_space_write_multi_1(t, h, o, p, c) dbsm(bswm1, t, h, o, p, c) 62 1.1 dyoung 63 1.1 dyoung #define bus_space_read_region_1(t, h, o, p, c) dbsm(bsrr1, t, h, o, p, c) 64 1.1 dyoung #define bus_space_write_region_1(t, h, o, p, c) dbsm(bswr1, t, h, o, p, c) 65 1.1 dyoung 66 1.1 dyoung #define bus_space_set_region_1(t, h, o, v, c) dbss(bssr1, t, h, o, v, c) 67 1.1 dyoung #define bus_space_copy_region_1(t, h, o, g, q, c) dbss(bscr1, t, h, o, g, q, c) 68 1.1 dyoung 69 1.1 dyoung 70 1.1 dyoung /* 2: word-wide "functions" */ 71 1.1 dyoung 72 1.1 dyoung #define bus_space_read_2(t, h, o) dbsdr(bsr2, t, h, o) 73 1.1 dyoung #define bus_space_write_2(t, h, o, v) dbsdw(bsw2, t, h, o, v) 74 1.1 dyoung #define bus_space_read_stream_2(t, h, o) dbsdr(bsrs2, t, h, o) 75 1.1 dyoung #define bus_space_write_stream_2(t, h, o, v) dbsdw(bsws2, t, h, o, v) 76 1.1 dyoung 77 1.1 dyoung #define bus_space_read_multi_2(t, h, o, p, c) dbsm(bsrm2, t, h, o, p, c) 78 1.1 dyoung #define bus_space_write_multi_2(t, h, o, p, c) dbsm(bswm2, t, h, o, p, c) 79 1.1 dyoung 80 1.1 dyoung #define bus_space_read_multi_stream_2(t, h, o, p, c) \ 81 1.1 dyoung dbsm(bsrms2, t, h, o, p, c) 82 1.1 dyoung 83 1.1 dyoung #define bus_space_write_multi_stream_2(t, h, o, p, c) \ 84 1.1 dyoung dbsm(bswms2, t, h, o, p, c) 85 1.1 dyoung 86 1.1 dyoung #define bus_space_read_region_2(t, h, o, p, c) dbsm(bsrr2, t, h, o, p, c) 87 1.1 dyoung #define bus_space_write_region_2(t, h, o, p, c) dbsm(bswr2, t, h, o, p, c) 88 1.1 dyoung 89 1.1 dyoung #define bus_space_read_region_stream_2(t, h, o, p, c) \ 90 1.1 dyoung dbsm(bsrrs2, t, h, o, p, c) 91 1.1 dyoung 92 1.1 dyoung #define bus_space_write_region_stream_2(t, h, o, p, c) \ 93 1.1 dyoung dbsm(bswrs2, t, h, o, p, c) 94 1.1 dyoung 95 1.1 dyoung #define bus_space_set_region_2(t, h, o, v, c) dbss(bssr2, t, h, o, v, c) 96 1.1 dyoung #define bus_space_copy_region_2(t, h, o, g, q, c) dbss(bscr2, t, h, o, g, q, c) 97 1.1 dyoung 98 1.1 dyoung /* 4: Fake 32-bit macros */ 99 1.1 dyoung 100 1.1 dyoung #define bus_space_read_4(t, h, o) \ 101 1.1 dyoung (panic("bus_space_read_4 not implemented"), 0) 102 1.1 dyoung 103 1.1 dyoung #define bus_space_write_4(t, h, o, v) \ 104 1.1 dyoung panic("bus_space_write_4 not implemented") 105 1.1 dyoung 106 1.1 dyoung #define bus_space_read_stream_4(t, h, o) \ 107 1.1 dyoung (panic("bus_space_read_stream_4 not implemented"), 0) 108 1.1 dyoung 109 1.1 dyoung #define bus_space_write_stream_4(t, h, o, v) \ 110 1.1 dyoung panic("bus_space_read_stream_4 not implemented") 111 1.1 dyoung 112 1.1 dyoung #define bus_space_read_multi_4(t, h, o, p, c) \ 113 1.1 dyoung panic("bus_space_read_multi_4 not implemented") 114 1.1 dyoung 115 1.1 dyoung #define bus_space_write_multi_4(t, h, o, p, c) \ 116 1.1 dyoung panic("bus_space_write_multi_4 not implemented") 117 1.1 dyoung 118 1.1 dyoung #define bus_space_read_multi_stream_4(t, h, o, p, c) \ 119 1.1 dyoung panic("bus_space_read_multi_stream_4 not implemented") 120 1.1 dyoung 121 1.1 dyoung #define bus_space_write_multi_stream_4(t, h, o, p, c) \ 122 1.1 dyoung panic("bus_space_write_multi_stream_4 not implemented") 123 1.1 dyoung 124 1.1 dyoung #define bus_space_read_region_stream_4(t, h, o, p, c) \ 125 1.1 dyoung panic("bus_space_read_region_stream_4 not implemented") 126 1.1 dyoung 127 1.1 dyoung #define bus_space_write_region_stream_4(t, h, o, p, c) \ 128 1.1 dyoung panic("bus_space_write_region_stream_4 not implemented") 129 1.1 dyoung 130 1.1 dyoung /* 131 1.1 dyoung * Bus read/write barrier methods. 132 1.1 dyoung * 133 1.1 dyoung * void bus_space_barrier __P((bus_space_tag_t tag, 134 1.1 dyoung * bus_space_handle_t bsh, bus_size_t offset, 135 1.1 dyoung * bus_size_t len, int flags)); 136 1.1 dyoung * 137 1.1 dyoung * Note: the 680x0 does not currently require barriers, but we must 138 1.1 dyoung * provide the flags to MI code. 139 1.1 dyoung */ 140 1.1 dyoung #define bus_space_barrier(t, h, o, l, f) \ 141 1.1 dyoung ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f))) 142 1.1 dyoung 143 1.1 dyoung /* Instruction for enforcing reorder protection. */ 144 1.2 riastrad #define amiga_bus_reorder_protect() __asm volatile("eieio" ::: "memory") 145 1.1 dyoung 146 1.1 dyoung #endif /* _AMIGAPPC_BUS_FUNCS_H_ */ 147