1 /* $NetBSD: isa_io.c,v 1.9 2009/03/14 15:36:13 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.9 2009/03/14 15:36:13 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>
48 #include <machine/ofw.h>
49 #include "igsfb_ofbus.h"
52 extern vaddr_t igsfb_mem_vaddr
, igsfb_mmio_vaddr
;
53 extern paddr_t igsfb_mem_paddr
;
56 /* Proto types for all the bus_space structure functions */
59 bs_protos(bs_notimpl
);
62 * Declare the isa bus space tags
63 * The IO and MEM structs are identical, except for the cookies,
64 * which contain the address space bases.
68 * NOTE: ASSEMBLY LANGUAGE RELIES ON THE COOKIE -- THE FIRST MEMBER OF
69 * THIS STRUCTURE -- TO BE THE VIRTUAL ADDRESS OF ISA/IO!
71 struct bus_space isa_io_bs_tag
= {
73 NULL
, /* initialized below */
75 /* mapping/unmapping */
80 /* allocation/deallocation */
84 /* get kernel virtual address */
87 /* mmap bus space for userland */
147 /* stream methods are identical to regular read/write here */
148 /* read stream single */
154 /* read stream multiple */
160 /* read region stream */
166 /* write stream single */
172 /* write stream multiple */
178 /* write region stream */
187 * NOTE: ASSEMBLY LANGUAGE RELIES ON THE COOKIE -- THE FIRST MEMBER OF
188 * THIS STRUCTURE -- TO BE THE VIRTUAL ADDRESS OF ISA/MEMORY!
190 struct bus_space isa_mem_bs_tag
= {
192 NULL
, /* initialized below */
194 /* mapping/unmapping */
199 /* allocation/deallocation */
203 /* get kernel virtual address */
206 /* mmap bus space for userland */
266 /* stream methods are identical to regular read/write here */
267 /* read stream single */
273 /* read stream multiple */
279 /* read region stream */
285 /* write stream single */
291 /* write stream multiple */
297 /* write region stream */
304 /* bus space functions */
307 isa_io_init(vaddr_t isa_io_addr
, vaddr_t isa_mem_addr
)
309 isa_io_bs_tag
.bs_cookie
= (void *)isa_io_addr
;
310 isa_mem_bs_tag
.bs_cookie
= (void *)isa_mem_addr
;
314 * break the abstraction: sometimes, other parts of the system
315 * (e.g. X servers) need to map ISA space directly. use these
316 * functions sparingly!
319 isa_io_data_vaddr(void)
321 return (vaddr_t
)isa_io_bs_tag
.bs_cookie
;
325 isa_mem_data_vaddr(void)
327 return (vaddr_t
)isa_mem_bs_tag
.bs_cookie
;
331 isa_bs_map(void *t
, bus_addr_t bpa
, bus_size_t size
, int cacheable
, bus_space_handle_t
*bshp
)
333 *bshp
= bpa
+ (bus_addr_t
)t
;
338 isa_bs_unmap(void *t
, bus_space_handle_t bsh
, bus_size_t size
)
344 isa_bs_mmap(void *cookie
, bus_addr_t addr
, off_t off
, int prot
,
350 printf("mmap %08x %08x %08x", (uint32_t)cookie
, (uint32_t)addr
, (uint32_t)off
);
353 if ((vaddr_t
)cookie
== igsfb_mem_vaddr
) {
354 paddr
= igsfb_mem_paddr
;
357 paddr
= ofw_gettranslation((vaddr_t
)cookie
);
361 printf(" no translation\n");
365 ret
= paddr
+ addr
+ off
;
367 printf(" -> %08x %08x\n", (uint32_t)paddr
, (uint32_t)ret
);
369 return arm_btop(ret
);
373 isa_bs_subregion(void *t
, bus_space_handle_t bsh
, bus_size_t offset
, bus_size_t size
, bus_space_handle_t
*nbshp
)
375 /* printf("isa_subregion(tag=%p, bsh=%lx, off=%lx, sz=%lx)\n",
376 t, bsh, offset, size);*/
377 *nbshp
= bsh
+ offset
;
382 isa_bs_alloc(t
, rstart
, rend
, size
, alignment
, boundary
, cacheable
,
385 bus_addr_t rstart
, rend
;
386 bus_size_t size
, alignment
, boundary
;
389 bus_space_handle_t
*bshp
;
391 panic("isa_alloc(): Help!");
395 isa_bs_free(void *t
, bus_space_handle_t bsh
, bus_size_t size
)
397 panic("isa_free(): Help!");
401 isa_bs_vaddr(void *t
, bus_space_handle_t bsh
)
404 return ((void *)bsh
);
408 isa_bs_barrier(void *t
, bus_space_handle_t bsh
, bus_size_t offset
, bus_size_t len
, int flags
)