1 /* $NetBSD: isa_io.c,v 1.4 2009/03/14 15:36:02 dsl Exp $ */
5 * Digital Equipment Corporation. All rights reserved.
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.
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.
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.
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.
37 * bus_space I/O functions for isa
40 #include <sys/cdefs.h>
41 __KERNEL_RCSID(0, "$NetBSD: isa_io.c,v 1.4 2009/03/14 15:36:02 dsl Exp $");
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <machine/bus.h>
46 #include <machine/pio.h>
47 #include <machine/isa_machdep.h>
49 /* Proto types for all the bus_space structure functions */
52 bs_protos(bs_notimpl
);
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.
61 * NOTE: ASSEMBLY LANGUAGE RELIES ON THE COOKIE -- THE FIRST MEMBER OF
62 * THIS STRUCTURE -- TO BE THE VIRTUAL ADDRESS OF ISA/IO!
64 struct bus_space isa_io_bs_tag
= {
66 NULL
, /* initialized below */
68 /* mapping/unmapping */
73 /* allocation/deallocation */
77 /* get kernel virtual address */
80 /* mmap bus space for userland */
81 bs_notimpl_bs_mmap
, /* XXX possible even? XXX */
142 * NOTE: ASSEMBLY LANGUAGE RELIES ON THE COOKIE -- THE FIRST MEMBER OF
143 * THIS STRUCTURE -- TO BE THE VIRTUAL ADDRESS OF ISA/MEMORY!
145 struct bus_space isa_mem_bs_tag
= {
147 NULL
, /* initialized below */
149 /* mapping/unmapping */
154 /* allocation/deallocation */
158 /* get kernel virtual address */
161 /* mmap bus space for userland */
162 bs_notimpl_bs_mmap
, /* XXX open for now ... XXX */
222 /* bus space functions */
225 isa_io_init(vm_offset_t isa_io_addr
, vm_offset_t isa_mem_addr
)
227 isa_io_bs_tag
.bs_cookie
= (void *)isa_io_addr
;
228 isa_mem_bs_tag
.bs_cookie
= (void *)isa_mem_addr
;
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!
237 isa_io_data_vaddr(void)
239 return (vm_offset_t
)isa_io_bs_tag
.bs_cookie
;
243 isa_mem_data_vaddr(void)
245 return (vm_offset_t
)isa_mem_bs_tag
.bs_cookie
;
249 isa_bs_map(void *t
, bus_addr_t bpa
, bus_size_t size
, int cacheable
, bus_space_handle_t
*bshp
)
251 *bshp
= bpa
+ (bus_addr_t
)t
;
256 isa_bs_unmap(void *t
, bus_space_handle_t bsh
, bus_size_t size
)
262 isa_bs_subregion(void *t
, bus_space_handle_t bsh
, bus_size_t offset
, bus_size_t size
, bus_space_handle_t
*nbshp
)
264 /* printf("isa_subregion(tag=%p, bsh=%lx, off=%lx, sz=%lx)\n",
265 t, bsh, offset, size);*/
266 *nbshp
= bsh
+ offset
;
271 isa_bs_alloc(t
, rstart
, rend
, size
, alignment
, boundary
, cacheable
,
274 bus_addr_t rstart
, rend
;
275 bus_size_t size
, alignment
, boundary
;
278 bus_space_handle_t
*bshp
;
280 panic("isa_alloc(): Help!");
284 isa_bs_free(void *t
, bus_space_handle_t bsh
, bus_size_t size
)
286 panic("isa_free(): Help!");
290 isa_bs_vaddr(void *t
, bus_space_handle_t bsh
)
293 return ((void *)bsh
);
297 isa_bs_barrier(void *t
, bus_space_handle_t bsh
, bus_size_t offset
, bus_size_t len
, int flags
)