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