xref: /openbsd/sys/arch/i386/eisa/eisa_machdep.c (revision 133306f0)
1 /*	$NetBSD: eisa_machdep.c,v 1.6 1997/06/06 23:12:52 thorpej Exp $	*/
2 
3 /*-
4  * Copyright (c) 1997 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 of the Numerical Aerospace Simulation Facility,
9  * NASA Ames Research Center.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *	This product includes software developed by the NetBSD
22  *	Foundation, Inc. and its contributors.
23  * 4. Neither the name of The NetBSD Foundation nor the names of its
24  *    contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  */
39 
40 /*
41  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
42  *
43  * Redistribution and use in source and binary forms, with or without
44  * modification, are permitted provided that the following conditions
45  * are met:
46  * 1. Redistributions of source code must retain the above copyright
47  *    notice, this list of conditions and the following disclaimer.
48  * 2. Redistributions in binary form must reproduce the above copyright
49  *    notice, this list of conditions and the following disclaimer in the
50  *    documentation and/or other materials provided with the distribution.
51  * 3. All advertising materials mentioning features or use of this software
52  *    must display the following acknowledgement:
53  *      This product includes software developed by Christopher G. Demetriou
54  *	for the NetBSD Project.
55  * 4. The name of the author may not be used to endorse or promote products
56  *    derived from this software without specific prior written permission
57  *
58  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
59  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
60  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
61  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
62  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
64  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
66  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
67  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68  */
69 
70 /*
71  * Machine-specific functions for EISA autoconfiguration.
72  */
73 
74 #include <sys/types.h>
75 #include <sys/param.h>
76 #include <sys/time.h>
77 #include <sys/systm.h>
78 #include <sys/errno.h>
79 #include <sys/device.h>
80 
81 #define _I386_BUS_DMA_PRIVATE
82 #include <machine/bus.h>
83 
84 #include <i386/isa/icu.h>
85 #include <dev/isa/isavar.h>
86 #include <dev/eisa/eisavar.h>
87 
88 /*
89  * EISA doesn't have any special needs; just use the generic versions
90  * of these funcions.
91  */
92 struct i386_bus_dma_tag eisa_bus_dma_tag = {
93 	NULL,			/* _cookie */
94 	_bus_dmamap_create,
95 	_bus_dmamap_destroy,
96 	_bus_dmamap_load,
97 	_bus_dmamap_load_mbuf,
98 	_bus_dmamap_load_uio,
99 	_bus_dmamap_load_raw,
100 	_bus_dmamap_unload,
101 	NULL,			/* _dmamap_sync */
102 	_bus_dmamem_alloc,
103 	_bus_dmamem_free,
104 	_bus_dmamem_map,
105 	_bus_dmamem_unmap,
106 	_bus_dmamem_mmap,
107 };
108 
109 void
110 eisa_attach_hook(parent, self, eba)
111 	struct device *parent, *self;
112 	struct eisabus_attach_args *eba;
113 {
114 
115 	/* Nothing to do */
116 }
117 
118 int
119 eisa_maxslots(ec)
120 	eisa_chipset_tag_t ec;
121 {
122 
123 	/*
124 	 * Always try 16 slots.
125 	 */
126 	return (16);
127 }
128 
129 int
130 eisa_intr_map(ec, irq, ihp)
131 	eisa_chipset_tag_t ec;
132 	u_int irq;
133 	eisa_intr_handle_t *ihp;
134 {
135 
136 	if (irq >= ICU_LEN) {
137 		printf("eisa_intr_map: bad IRQ %d\n", irq);
138 		*ihp = -1;
139 		return 1;
140 	}
141 	if (irq == 2) {
142 		printf("eisa_intr_map: changed IRQ 2 to IRQ 9\n");
143 		irq = 9;
144 	}
145 
146 	*ihp = irq;
147 	return 0;
148 }
149 
150 const char *
151 eisa_intr_string(ec, ih)
152 	eisa_chipset_tag_t ec;
153 	eisa_intr_handle_t ih;
154 {
155 	static char irqstr[8];		/* 4 + 2 + NULL + sanity */
156 
157 	if (ih == 0 || ih >= ICU_LEN || ih == 2)
158 		panic("eisa_intr_string: bogus handle 0x%x", ih);
159 
160 	sprintf(irqstr, "irq %d", ih);
161 	return (irqstr);
162 
163 }
164 
165 void *
166 eisa_intr_establish(ec, ih, type, level, func, arg, what)
167 	eisa_chipset_tag_t ec;
168 	eisa_intr_handle_t ih;
169 	int type, level, (*func) __P((void *));
170 	void *arg;
171 	char *what;
172 {
173 
174 	if (ih == 0 || ih >= ICU_LEN || ih == 2)
175 		panic("eisa_intr_establish: bogus handle 0x%x", ih);
176 
177 	return isa_intr_establish(NULL, ih, type, level, func, arg, what);
178 }
179 
180 void
181 eisa_intr_disestablish(ec, cookie)
182 	eisa_chipset_tag_t ec;
183 	void *cookie;
184 {
185 
186 	return isa_intr_disestablish(NULL, cookie);
187 }
188