1 1.4 dyoung /* $NetBSD: bus_funcs.h,v 1.4 2011/07/25 21:12:23 dyoung Exp $ */ 2 1.1 dyoung 3 1.1 dyoung /*- 4 1.1 dyoung * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. 5 1.1 dyoung * All rights reserved. 6 1.1 dyoung * 7 1.1 dyoung * This code is derived from software contributed to The NetBSD Foundation 8 1.1 dyoung * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9 1.1 dyoung * NASA Ames Research Center. 10 1.1 dyoung * 11 1.1 dyoung * Redistribution and use in source and binary forms, with or without 12 1.1 dyoung * modification, are permitted provided that the following conditions 13 1.1 dyoung * are met: 14 1.1 dyoung * 1. Redistributions of source code must retain the above copyright 15 1.1 dyoung * notice, this list of conditions and the following disclaimer. 16 1.1 dyoung * 2. Redistributions in binary form must reproduce the above copyright 17 1.1 dyoung * notice, this list of conditions and the following disclaimer in the 18 1.1 dyoung * documentation and/or other materials provided with the distribution. 19 1.1 dyoung * 20 1.1 dyoung * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 1.1 dyoung * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 1.1 dyoung * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 1.1 dyoung * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 1.1 dyoung * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 1.1 dyoung * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 1.1 dyoung * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 1.1 dyoung * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 1.1 dyoung * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 1.1 dyoung * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 1.1 dyoung * POSSIBILITY OF SUCH DAMAGE. 31 1.1 dyoung */ 32 1.1 dyoung 33 1.1 dyoung /* 34 1.1 dyoung * Copyright (c) 1996 Charles M. Hannum. All rights reserved. 35 1.1 dyoung * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 36 1.1 dyoung * 37 1.1 dyoung * Redistribution and use in source and binary forms, with or without 38 1.1 dyoung * modification, are permitted provided that the following conditions 39 1.1 dyoung * are met: 40 1.1 dyoung * 1. Redistributions of source code must retain the above copyright 41 1.1 dyoung * notice, this list of conditions and the following disclaimer. 42 1.1 dyoung * 2. Redistributions in binary form must reproduce the above copyright 43 1.1 dyoung * notice, this list of conditions and the following disclaimer in the 44 1.1 dyoung * documentation and/or other materials provided with the distribution. 45 1.1 dyoung * 3. All advertising materials mentioning features or use of this software 46 1.1 dyoung * must display the following acknowledgement: 47 1.1 dyoung * This product includes software developed by Christopher G. Demetriou 48 1.1 dyoung * for the NetBSD Project. 49 1.1 dyoung * 4. The name of the author may not be used to endorse or promote products 50 1.1 dyoung * derived from this software without specific prior written permission 51 1.1 dyoung * 52 1.1 dyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 53 1.1 dyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 54 1.1 dyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 55 1.1 dyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 56 1.1 dyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 57 1.1 dyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 58 1.1 dyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 59 1.1 dyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 60 1.1 dyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 61 1.1 dyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 62 1.1 dyoung */ 63 1.1 dyoung 64 1.1 dyoung #ifndef _SH3_BUS_FUNCS_H_ 65 1.1 dyoung #define _SH3_BUS_FUNCS_H_ 66 1.1 dyoung 67 1.1 dyoung #ifdef SH4_PCMCIA 68 1.1 dyoung int shpcmcia_memio_map(bus_space_tag_t, bus_addr_t, bus_size_t size, 69 1.1 dyoung int, bus_space_handle_t *); 70 1.1 dyoung 71 1.1 dyoung int shpcmcia_mem_add_mapping(bus_addr_t, bus_size_t, int, 72 1.1 dyoung bus_space_handle_t *); 73 1.1 dyoung void shpcmcia_memio_unmap(bus_space_tag_t, bus_space_handle_t, 74 1.1 dyoung bus_size_t); 75 1.1 dyoung void shpcmcia_memio_free(bus_space_tag_t, bus_space_handle_t, 76 1.1 dyoung bus_size_t); 77 1.1 dyoung int shpcmcia_memio_subregion(bus_space_tag_t, bus_space_handle_t, 78 1.1 dyoung bus_size_t, bus_size_t, bus_space_handle_t *); 79 1.1 dyoung #endif 80 1.1 dyoung 81 1.3 dyoung int sh_memio_alloc(bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t, 82 1.3 dyoung bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *); 83 1.3 dyoung void sh_memio_free(bus_space_tag_t, bus_space_handle_t, bus_size_t); 84 1.3 dyoung void sh_memio_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t); 85 1.3 dyoung int sh_memio_subregion(bus_space_tag_t, bus_space_handle_t, 86 1.3 dyoung bus_size_t, bus_size_t, bus_space_handle_t *); 87 1.3 dyoung 88 1.1 dyoung /* 89 1.4 dyoung * int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart, 90 1.4 dyoung * bus_addr_t rend, bus_size_t size, bus_size_t align, 91 1.4 dyoung * bus_size_t boundary, int flags, bus_addr_t *addrp, 92 1.4 dyoung * bus_space_handle_t *bshp); 93 1.4 dyoung * 94 1.4 dyoung * Allocate a region of bus space. 95 1.4 dyoung */ 96 1.4 dyoung 97 1.4 dyoung #define bus_space_alloc(t, rs, re, s, a, b, f, ap, hp) \ 98 1.4 dyoung sh_memio_alloc((t), (rs), (re), (s), (a), (b), (f), (ap), (hp)) 99 1.4 dyoung 100 1.4 dyoung /* 101 1.4 dyoung * int bus_space_free(bus_space_tag_t t, 102 1.4 dyoung * bus_space_handle_t bsh, bus_size_t size); 103 1.4 dyoung * 104 1.4 dyoung * Free a region of bus space. 105 1.4 dyoung */ 106 1.4 dyoung 107 1.4 dyoung #define bus_space_free(t, h, s) \ 108 1.4 dyoung sh_memio_free((t), (h), (s)) 109 1.4 dyoung 110 1.4 dyoung /* 111 1.4 dyoung * int bus_space_unmap(bus_space_tag_t t, 112 1.4 dyoung * bus_space_handle_t bsh, bus_size_t size); 113 1.4 dyoung * 114 1.4 dyoung * Unmap a region of bus space. 115 1.4 dyoung */ 116 1.4 dyoung 117 1.4 dyoung #define bus_space_unmap(t, h, s) \ 118 1.4 dyoung sh_memio_unmap((t), (h), (s)) 119 1.4 dyoung 120 1.4 dyoung /* 121 1.4 dyoung * int bus_space_subregion(bus_space_tag_t t, 122 1.4 dyoung * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, 123 1.4 dyoung * bus_space_handle_t *nbshp); 124 1.4 dyoung * 125 1.4 dyoung * Get a new handle for a subregion of an already-mapped area of bus space. 126 1.4 dyoung */ 127 1.4 dyoung 128 1.4 dyoung #define bus_space_subregion(t, h, o, s, nhp) \ 129 1.4 dyoung sh_memio_subregion((t), (h), (o), (s), (nhp)) 130 1.4 dyoung 131 1.4 dyoung /* 132 1.1 dyoung * Bus read/write barrier methods. 133 1.1 dyoung * 134 1.1 dyoung * void bus_space_barrier(bus_space_tag_t tag, 135 1.1 dyoung * bus_space_handle_t bsh, bus_size_t offset, 136 1.1 dyoung * bus_size_t len, int flags); 137 1.1 dyoung * 138 1.1 dyoung * Note: the sh3 does not currently require barriers, but we must 139 1.1 dyoung * provide the flags to MI code. 140 1.1 dyoung */ 141 1.1 dyoung #define bus_space_barrier(t, h, o, l, f) \ 142 1.1 dyoung ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f))) 143 1.1 dyoung 144 1.1 dyoung #endif /* _SH3_BUS_FUNCS_H_ */ 145