isa_machdep.h revision 1.2
1/*	$NetBSD: isa_machdep.h,v 1.2 2003/05/09 23:51:25 fvdl Exp $	*/
2
3/*-
4 * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 *    must display the following acknowledgement:
20 *	This product includes software developed by the NetBSD
21 *	Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 *    contributors may be used to endorse or promote products derived
24 *    from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39/*
40 * Copyright (c) 1996 Carnegie-Mellon University.
41 * All rights reserved.
42 *
43 * Author: Chris G. Demetriou
44 *
45 * Permission to use, copy, modify and distribute this software and
46 * its documentation is hereby granted, provided that both the copyright
47 * notice and this permission notice appear in all copies of the
48 * software, derivative works or modified versions, and any portions
49 * thereof, and that both notices appear in supporting documentation.
50 *
51 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
52 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
53 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
54 *
55 * Carnegie Mellon requests users of this software to return to
56 *
57 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
58 *  School of Computer Science
59 *  Carnegie Mellon University
60 *  Pittsburgh PA 15213-3890
61 *
62 * any improvements or extensions that they make and grant Carnegie the
63 * rights to redistribute these changes.
64 */
65
66#include <dev/isa/isadmavar.h>
67
68/*
69 * Types provided to machine-independent ISA code.
70 */
71typedef struct algor_isa_chipset *isa_chipset_tag_t;
72
73struct algor_isa_chipset {
74	void	*ic_v;
75
76	struct isa_dma_state ic_dmastate;
77
78	void	(*ic_attach_hook)(struct device *, struct device *,
79		    struct isabus_attach_args *);
80	const struct evcnt *(*ic_intr_evcnt)(void *, int);
81	void	*(*ic_intr_establish)(void *, int, int, int,
82		    int (*)(void *), void *);
83	void	(*ic_intr_disestablish)(void *, void *);
84	int	(*ic_intr_alloc)(void *, int, int, int *);
85};
86
87
88/*
89 * Functions provided to machine-independent ISA code.
90 */
91#define	isa_attach_hook(p, s, a)					\
92    (*(a)->iba_ic->ic_attach_hook)((p), (s), (a))
93#define	isa_intr_evcnt(c, i)					\
94    (*(c)->ic_intr_evcnt)((c)->ic_v, (i))
95#define	isa_intr_establish(c, i, t, l, f, a)				\
96    (*(c)->ic_intr_establish)((c)->ic_v, (i), (t), (l), (f), (a))
97#define	isa_intr_disestablish(c, h)					\
98    (*(c)->ic_intr_disestablish)((c)->ic_v, (h))
99#define	isa_intr_alloc(c, m, t, i)					\
100    (*(c)->ic_intr_alloc)((c)->ic_v, (m), (t), (i))
101
102#define	isa_dmainit(ic, bst, dmat, d)					\
103	_isa_dmainit(&(ic)->ic_dmastate, (bst), (dmat), (d))
104#define	isa_dmacascade(ic, c)						\
105	_isa_dmacascade(&(ic)->ic_dmastate, (c))
106#define	isa_dmamaxsize(ic, c)						\
107	_isa_dmamaxsize(&(ic)->ic_dmastate, (c))
108#define	isa_dmamap_create(ic, c, s, f)					\
109	_isa_dmamap_create(&(ic)->ic_dmastate, (c), (s), (f))
110#define	isa_dmamap_destroy(ic, c)					\
111	_isa_dmamap_destroy(&(ic)->ic_dmastate, (c))
112#define	isa_dmastart(ic, c, a, n, p, f, bf)				\
113	_isa_dmastart(&(ic)->ic_dmastate, (c), (a), (n), (p), (f), (bf))
114#define	isa_dmaabort(ic, c)						\
115	_isa_dmaabort(&(ic)->ic_dmastate, (c))
116#define	isa_dmacount(ic, c)						\
117	_isa_dmacount(&(ic)->ic_dmastate, (c))
118#define	isa_dmafinished(ic, c)						\
119	_isa_dmafinished(&(ic)->ic_dmastate, (c))
120#define	isa_dmadone(ic, c)						\
121	_isa_dmadone(&(ic)->ic_dmastate, (c))
122#define	isa_dmafreeze(ic)						\
123	_isa_dmafreeze(&(ic)->ic_dmastate)
124#define	isa_dmathaw(ic)							\
125	_isa_dmathaw(&(ic)->ic_dmastate)
126#define	isa_dmamem_alloc(ic, c, s, ap, f)				\
127	_isa_dmamem_alloc(&(ic)->ic_dmastate, (c), (s), (ap), (f))
128#define	isa_dmamem_free(ic, c, a, s)					\
129	_isa_dmamem_free(&(ic)->ic_dmastate, (c), (a), (s))
130#define	isa_dmamem_map(ic, c, a, s, kp, f)				\
131	_isa_dmamem_map(&(ic)->ic_dmastate, (c), (a), (s), (kp), (f))
132#define	isa_dmamem_unmap(ic, c, k, s)					\
133	_isa_dmamem_unmap(&(ic)->ic_dmastate, (c), (k), (s))
134#define	isa_dmamem_mmap(ic, c, a, s, o, p, f)				\
135	_isa_dmamem_mmap(&(ic)->ic_dmastate, (c), (a), (s), (o), (p), (f))
136#define isa_drq_alloc(ic, c)						\
137	_isa_drq_alloc(&(ic)->ic_dmastate, c)
138#define isa_drq_free(ic, c)						\
139	_isa_drq_free(&(ic)->ic_dmastate, c)
140#define	isa_drq_isfree(ic, c)						\
141	_isa_drq_isfree(&(ic)->ic_dmastate, (c))
142#define	isa_malloc(ic, c, s, p, f)					\
143	_isa_malloc(&(ic)->ic_dmastate, (c), (s), (p), (f))
144#define	isa_free(a, p)							\
145	_isa_free((a), (p))
146#define	isa_mappage(m, o, p)						\
147	_isa_mappage((m), (o), (p))
148
149/*
150 * algor-specific ISA functions.
151 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
152 */
153int	isa_display_console(bus_space_tag_t, bus_space_tag_t);
154void	isabeep(int, int);
155
156#ifdef _ALGOR_BUS_DMA_PRIVATE
157int	isadma_bounce_dmamap_create(bus_dma_tag_t, bus_size_t, int,
158	    bus_size_t, bus_size_t, int, bus_dmamap_t *);
159void	isadma_bounce_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t);
160int	isadma_bounce_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *,
161	    bus_size_t, struct proc *, int);
162int	isadma_bounce_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t,
163	    struct mbuf *, int);
164int	isadma_bounce_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t,
165	    struct uio *, int);
166int	isadma_bounce_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t,
167	    bus_dma_segment_t *, int, bus_size_t, int);
168void	isadma_bounce_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
169void	isadma_bounce_dmamap_sync(bus_dma_tag_t, bus_dmamap_t,
170	    bus_addr_t, bus_size_t, int);
171
172int	isadma_bounce_dmamem_alloc(bus_dma_tag_t, bus_size_t, bus_size_t,
173	    bus_size_t, bus_dma_segment_t *, int, int *, int);
174#endif /* _ALGOR_BUS_DMA_PRIVATE */
175