1 /* $NetBSD: isa_io.c,v 1.6 2011/07/01 19:32:28 dyoung Exp $ */ 2 3 /* 4 * Copyright 1997 5 * Digital Equipment Corporation. All rights reserved. 6 * 7 * This software is furnished under license and may be used and 8 * copied only in accordance with the following terms and conditions. 9 * Subject to these conditions, you may download, copy, install, 10 * use, modify and distribute this software in source and/or binary 11 * form. No title or ownership is transferred hereby. 12 * 13 * 1) Any source code used, modified or distributed must reproduce 14 * and retain this copyright notice and list of conditions as 15 * they appear in the source file. 16 * 17 * 2) No right is granted to use any trade name, trademark, or logo of 18 * Digital Equipment Corporation. Neither the "Digital Equipment 19 * Corporation" name nor any trademark or logo of Digital Equipment 20 * Corporation may be used to endorse or promote products derived 21 * from this software without the prior written permission of 22 * Digital Equipment Corporation. 23 * 24 * 3) This software is provided "AS-IS" and any express or implied 25 * warranties, including but not limited to, any implied warranties 26 * of merchantability, fitness for a particular purpose, or 27 * non-infringement are disclaimed. In no event shall DIGITAL be 28 * liable for any damages whatsoever, and in particular, DIGITAL 29 * shall not be liable for special, indirect, consequential, or 30 * incidental damages or damages for lost profits, loss of 31 * revenue or loss of use, whether such damages arise in contract, 32 * negligence, tort, under statute, in equity, at law or otherwise, 33 * even if advised of the possibility of such damage. 34 */ 35 36 /* 37 * bus_space I/O functions for isa 38 */ 39 40 #include <sys/cdefs.h> 41 __KERNEL_RCSID(0, "$NetBSD: isa_io.c,v 1.6 2011/07/01 19:32:28 dyoung Exp $"); 42 43 #include <sys/param.h> 44 #include <sys/systm.h> 45 #include <sys/bus.h> 46 #include <machine/pio.h> 47 #include <machine/isa_machdep.h> 48 49 /* Proto types for all the bus_space structure functions */ 50 51 bs_protos(isa); 52 bs_protos(bs_notimpl); 53 54 /* 55 * Declare the isa bus space tags 56 * The IO and MEM structs are identical, except for the cookies, 57 * which contain the address space bases. 58 */ 59 60 /* 61 * NOTE: ASSEMBLY LANGUAGE RELIES ON THE COOKIE -- THE FIRST MEMBER OF 62 * THIS STRUCTURE -- TO BE THE VIRTUAL ADDRESS OF ISA/IO! 63 */ 64 struct bus_space isa_io_bs_tag = { 65 /* cookie */ 66 NULL, /* initialized below */ 67 68 /* mapping/unmapping */ 69 isa_bs_map, 70 isa_bs_unmap, 71 isa_bs_subregion, 72 73 /* allocation/deallocation */ 74 isa_bs_alloc, 75 isa_bs_free, 76 77 /* get kernel virtual address */ 78 isa_bs_vaddr, 79 80 /* mmap bus space for userland */ 81 bs_notimpl_bs_mmap, /* XXX possible even? XXX */ 82 83 /* barrier */ 84 isa_bs_barrier, 85 86 /* read (single) */ 87 isa_bs_r_1, 88 isa_bs_r_2, 89 isa_bs_r_4, 90 bs_notimpl_bs_r_8, 91 92 /* read multiple */ 93 isa_bs_rm_1, 94 isa_bs_rm_2, 95 isa_bs_rm_4, 96 bs_notimpl_bs_rm_8, 97 98 /* read region */ 99 isa_bs_rr_1, 100 isa_bs_rr_2, 101 isa_bs_rr_4, 102 bs_notimpl_bs_rr_8, 103 104 /* write (single) */ 105 isa_bs_w_1, 106 isa_bs_w_2, 107 isa_bs_w_4, 108 bs_notimpl_bs_w_8, 109 110 /* write multiple */ 111 isa_bs_wm_1, 112 isa_bs_wm_2, 113 isa_bs_wm_4, 114 bs_notimpl_bs_wm_8, 115 116 /* write region */ 117 isa_bs_wr_1, 118 isa_bs_wr_2, 119 isa_bs_wr_4, 120 bs_notimpl_bs_wr_8, 121 122 /* set multiple */ 123 bs_notimpl_bs_sm_1, 124 bs_notimpl_bs_sm_2, 125 bs_notimpl_bs_sm_4, 126 bs_notimpl_bs_sm_8, 127 128 /* set region */ 129 bs_notimpl_bs_sr_1, 130 isa_bs_sr_2, 131 bs_notimpl_bs_sr_4, 132 bs_notimpl_bs_sr_8, 133 134 /* copy */ 135 bs_notimpl_bs_c_1, 136 bs_notimpl_bs_c_2, 137 bs_notimpl_bs_c_4, 138 bs_notimpl_bs_c_8, 139 }; 140 141 /* 142 * NOTE: ASSEMBLY LANGUAGE RELIES ON THE COOKIE -- THE FIRST MEMBER OF 143 * THIS STRUCTURE -- TO BE THE VIRTUAL ADDRESS OF ISA/MEMORY! 144 */ 145 struct bus_space isa_mem_bs_tag = { 146 /* cookie */ 147 NULL, /* initialized below */ 148 149 /* mapping/unmapping */ 150 isa_bs_map, 151 isa_bs_unmap, 152 isa_bs_subregion, 153 154 /* allocation/deallocation */ 155 isa_bs_alloc, 156 isa_bs_free, 157 158 /* get kernel virtual address */ 159 isa_bs_vaddr, 160 161 /* mmap bus space for userland */ 162 bs_notimpl_bs_mmap, /* XXX open for now ... XXX */ 163 164 /* barrier */ 165 isa_bs_barrier, 166 167 /* read (single) */ 168 isa_bs_r_1, 169 isa_bs_r_2, 170 isa_bs_r_4, 171 bs_notimpl_bs_r_8, 172 173 /* read multiple */ 174 isa_bs_rm_1, 175 isa_bs_rm_2, 176 isa_bs_rm_4, 177 bs_notimpl_bs_rm_8, 178 179 /* read region */ 180 isa_bs_rr_1, 181 isa_bs_rr_2, 182 isa_bs_rr_4, 183 bs_notimpl_bs_rr_8, 184 185 /* write (single) */ 186 isa_bs_w_1, 187 isa_bs_w_2, 188 isa_bs_w_4, 189 bs_notimpl_bs_w_8, 190 191 /* write multiple */ 192 isa_bs_wm_1, 193 isa_bs_wm_2, 194 isa_bs_wm_4, 195 bs_notimpl_bs_wm_8, 196 197 /* write region */ 198 isa_bs_wr_1, 199 isa_bs_wr_2, 200 isa_bs_wr_4, 201 bs_notimpl_bs_wr_8, 202 203 /* set multiple */ 204 bs_notimpl_bs_sm_1, 205 bs_notimpl_bs_sm_2, 206 bs_notimpl_bs_sm_4, 207 bs_notimpl_bs_sm_8, 208 209 /* set region */ 210 bs_notimpl_bs_sr_1, 211 isa_bs_sr_2, 212 bs_notimpl_bs_sr_4, 213 bs_notimpl_bs_sr_8, 214 215 /* copy */ 216 bs_notimpl_bs_c_1, 217 bs_notimpl_bs_c_2, 218 bs_notimpl_bs_c_4, 219 bs_notimpl_bs_c_8, 220 }; 221 222 /* bus space functions */ 223 224 void 225 isa_io_init(vm_offset_t isa_io_addr, vm_offset_t isa_mem_addr) 226 { 227 isa_io_bs_tag.bs_cookie = (void *)isa_io_addr; 228 isa_mem_bs_tag.bs_cookie = (void *)isa_mem_addr; 229 } 230 231 /* 232 * break the abstraction: sometimes, other parts of the system 233 * (e.g. X servers) need to map ISA space directly. use these 234 * functions sparingly! 235 */ 236 vm_offset_t 237 isa_io_data_vaddr(void) 238 { 239 return (vm_offset_t)isa_io_bs_tag.bs_cookie; 240 } 241 242 vm_offset_t 243 isa_mem_data_vaddr(void) 244 { 245 return (vm_offset_t)isa_mem_bs_tag.bs_cookie; 246 } 247 248 int 249 isa_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int cacheable, bus_space_handle_t *bshp) 250 { 251 *bshp = bpa + (bus_addr_t)t; 252 return(0); 253 } 254 255 void 256 isa_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) 257 { 258 /* Nothing to do. */ 259 } 260 261 int 262 isa_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp) 263 { 264 /* printf("isa_subregion(tag=%p, bsh=%lx, off=%lx, sz=%lx)\n", 265 t, bsh, offset, size);*/ 266 *nbshp = bsh + offset; 267 return(0); 268 } 269 270 int 271 isa_bs_alloc(t, rstart, rend, size, alignment, boundary, cacheable, 272 bpap, bshp) 273 void *t; 274 bus_addr_t rstart, rend; 275 bus_size_t size, alignment, boundary; 276 int cacheable; 277 bus_addr_t *bpap; 278 bus_space_handle_t *bshp; 279 { 280 panic("isa_alloc(): Help!"); 281 } 282 283 void 284 isa_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size) 285 { 286 panic("isa_free(): Help!"); 287 } 288 289 void * 290 isa_bs_vaddr(void *t, bus_space_handle_t bsh) 291 { 292 293 return ((void *)bsh); 294 } 295 296 void 297 isa_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset, bus_size_t len, int flags) 298 { 299 /* just return */ 300 } 301