Home | History | Annotate | Line # | Download | only in eisa
eisa_machdep.c revision 1.38.2.1
      1  1.38.2.1     rmind /*	$NetBSD: eisa_machdep.c,v 1.38.2.1 2014/05/18 17:45:12 rmind Exp $	*/
      2       1.6   thorpej 
      3       1.6   thorpej /*-
      4       1.7   thorpej  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
      5       1.6   thorpej  * All rights reserved.
      6       1.6   thorpej  *
      7       1.6   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8       1.6   thorpej  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9       1.6   thorpej  * NASA Ames Research Center.
     10       1.6   thorpej  *
     11       1.6   thorpej  * Redistribution and use in source and binary forms, with or without
     12       1.6   thorpej  * modification, are permitted provided that the following conditions
     13       1.6   thorpej  * are met:
     14       1.6   thorpej  * 1. Redistributions of source code must retain the above copyright
     15       1.6   thorpej  *    notice, this list of conditions and the following disclaimer.
     16       1.6   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.6   thorpej  *    notice, this list of conditions and the following disclaimer in the
     18       1.6   thorpej  *    documentation and/or other materials provided with the distribution.
     19       1.6   thorpej  *
     20       1.6   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21       1.6   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22       1.6   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23       1.6   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24       1.6   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25       1.6   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26       1.6   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27       1.6   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28       1.6   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29       1.6   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30       1.6   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     31       1.6   thorpej  */
     32       1.1       cgd 
     33       1.1       cgd /*
     34       1.1       cgd  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
     35       1.1       cgd  *
     36       1.1       cgd  * Redistribution and use in source and binary forms, with or without
     37       1.1       cgd  * modification, are permitted provided that the following conditions
     38       1.1       cgd  * are met:
     39       1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     40       1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     41       1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     42       1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     43       1.1       cgd  *    documentation and/or other materials provided with the distribution.
     44       1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     45       1.1       cgd  *    must display the following acknowledgement:
     46       1.1       cgd  *      This product includes software developed by Christopher G. Demetriou
     47       1.1       cgd  *	for the NetBSD Project.
     48       1.1       cgd  * 4. The name of the author may not be used to endorse or promote products
     49       1.1       cgd  *    derived from this software without specific prior written permission
     50       1.1       cgd  *
     51       1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     52       1.1       cgd  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     53       1.1       cgd  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     54       1.1       cgd  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     55       1.1       cgd  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     56       1.1       cgd  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     57       1.1       cgd  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     58       1.1       cgd  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     59       1.1       cgd  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     60       1.1       cgd  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     61       1.1       cgd  */
     62       1.1       cgd 
     63       1.1       cgd /*
     64       1.1       cgd  * Machine-specific functions for EISA autoconfiguration.
     65       1.1       cgd  */
     66      1.14     lukem 
     67      1.14     lukem #include <sys/cdefs.h>
     68  1.38.2.1     rmind __KERNEL_RCSID(0, "$NetBSD: eisa_machdep.c,v 1.38.2.1 2014/05/18 17:45:12 rmind Exp $");
     69      1.16      fvdl 
     70      1.16      fvdl #include "ioapic.h"
     71       1.1       cgd 
     72       1.1       cgd #include <sys/types.h>
     73       1.1       cgd #include <sys/param.h>
     74       1.1       cgd #include <sys/time.h>
     75       1.1       cgd #include <sys/systm.h>
     76       1.1       cgd #include <sys/errno.h>
     77       1.1       cgd #include <sys/device.h>
     78       1.1       cgd 
     79      1.35    dyoung #include <sys/bus.h>
     80      1.24      yamt #include <machine/bus_private.h>
     81       1.6   thorpej 
     82       1.5   thorpej #include <dev/isa/isareg.h>
     83       1.1       cgd #include <dev/isa/isavar.h>
     84       1.1       cgd #include <dev/eisa/eisavar.h>
     85       1.1       cgd 
     86      1.16      fvdl #if NIOAPIC > 0
     87      1.16      fvdl #include <machine/i82093var.h>
     88      1.16      fvdl #include <machine/mpbiosvar.h>
     89      1.16      fvdl #endif
     90      1.16      fvdl 
     91       1.6   thorpej /*
     92       1.6   thorpej  * EISA doesn't have any special needs; just use the generic versions
     93       1.6   thorpej  * of these funcions.
     94      1.37  christos  *
     95      1.37  christos  * XXX really doesn't use bounce buffers? --dyoung
     96       1.6   thorpej  */
     97      1.18      fvdl struct x86_bus_dma_tag eisa_bus_dma_tag = {
     98      1.36  christos 	._tag_needs_free	= 0,
     99      1.36  christos 	._bounce_thresh		= 0,
    100      1.36  christos 	._bounce_alloc_lo	= 0,
    101      1.36  christos 	._bounce_alloc_hi	= 0,
    102      1.36  christos 	._may_bounce		= NULL,
    103       1.6   thorpej };
    104       1.6   thorpej 
    105       1.1       cgd void
    106      1.32    cegger eisa_attach_hook(device_t parent, device_t self,
    107      1.28  christos     struct eisabus_attach_args *eba)
    108       1.1       cgd {
    109      1.38  uebayasi 	extern int eisa_has_been_seen;
    110       1.1       cgd 
    111       1.7   thorpej 	/*
    112       1.8   thorpej 	 * Notify others that might need to know that the EISA bus
    113       1.7   thorpej 	 * has now been attached.
    114       1.7   thorpej 	 */
    115       1.7   thorpej 	if (eisa_has_been_seen)
    116       1.7   thorpej 		panic("eisaattach: EISA bus already seen!");
    117       1.7   thorpej 	eisa_has_been_seen = 1;
    118       1.1       cgd }
    119       1.1       cgd 
    120       1.1       cgd int
    121      1.28  christos eisa_maxslots(eisa_chipset_tag_t ec)
    122       1.1       cgd {
    123       1.1       cgd 
    124       1.1       cgd 	/*
    125       1.1       cgd 	 * Always try 16 slots.
    126       1.1       cgd 	 */
    127       1.1       cgd 	return (16);
    128       1.1       cgd }
    129       1.1       cgd 
    130       1.1       cgd int
    131      1.28  christos eisa_intr_map(eisa_chipset_tag_t ec, u_int irq,
    132      1.27  christos     eisa_intr_handle_t *ihp)
    133       1.1       cgd {
    134      1.17      fvdl 	if (irq >= NUM_LEGACY_IRQS) {
    135      1.26   thorpej 		aprint_error("eisa_intr_map: bad IRQ %d\n", irq);
    136       1.1       cgd 		*ihp = -1;
    137       1.1       cgd 		return 1;
    138       1.1       cgd 	}
    139       1.1       cgd 	if (irq == 2) {
    140      1.26   thorpej 		aprint_verbose("eisa_intr_map: changed IRQ 2 to IRQ 9\n");
    141       1.1       cgd 		irq = 9;
    142       1.1       cgd 	}
    143       1.1       cgd 
    144      1.16      fvdl #if NIOAPIC > 0
    145      1.16      fvdl 	if (mp_busses != NULL) {
    146      1.21      fvdl 		if (intr_find_mpmapping(mp_eisa_bus, irq, ihp) == 0 ||
    147      1.21      fvdl 		    intr_find_mpmapping(mp_isa_bus, irq, ihp) == 0) {
    148      1.17      fvdl 			*ihp |= irq;
    149      1.17      fvdl 			return 0;
    150      1.17      fvdl 		} else
    151      1.26   thorpej 			aprint_verbose("eisa_intr_map: no MP mapping found\n");
    152      1.16      fvdl 	}
    153      1.16      fvdl #endif
    154      1.16      fvdl 
    155       1.1       cgd 	*ihp = irq;
    156       1.1       cgd 	return 0;
    157       1.1       cgd }
    158       1.1       cgd 
    159       1.1       cgd const char *
    160  1.38.2.1     rmind eisa_intr_string(eisa_chipset_tag_t ec, eisa_intr_handle_t ih, char *buf,
    161  1.38.2.1     rmind     size_t len)
    162       1.1       cgd {
    163      1.17      fvdl 	if (ih == 0 || (ih & 0xff) >= NUM_LEGACY_IRQS || ih == 2)
    164      1.15    provos 		panic("eisa_intr_string: bogus handle 0x%x", ih);
    165       1.1       cgd 
    166      1.16      fvdl #if NIOAPIC > 0
    167      1.16      fvdl 	if (ih & APIC_INT_VIA_APIC)
    168  1.38.2.1     rmind 		snprintf(buf, len, "apic %d int %d (irq %d)",
    169      1.16      fvdl 		    APIC_IRQ_APIC(ih),
    170      1.16      fvdl 		    APIC_IRQ_PIN(ih),
    171      1.16      fvdl 		    ih&0xff);
    172      1.16      fvdl 	else
    173  1.38.2.1     rmind 		snprintf(buf, len, "irq %d", ih&0xff);
    174      1.16      fvdl #else
    175  1.38.2.1     rmind 	snprintf(buf, len, "irq %d", ih);
    176      1.16      fvdl #endif
    177  1.38.2.1     rmind 	return buf;
    178      1.11       cgd }
    179      1.11       cgd 
    180      1.11       cgd const struct evcnt *
    181      1.28  christos eisa_intr_evcnt(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
    182      1.11       cgd {
    183      1.11       cgd 
    184      1.11       cgd 	/* XXX for now, no evcnt parent reported */
    185      1.11       cgd 	return NULL;
    186       1.1       cgd }
    187       1.1       cgd 
    188       1.1       cgd void *
    189      1.28  christos eisa_intr_establish(eisa_chipset_tag_t ec, eisa_intr_handle_t ih,
    190      1.23     perry     int type, int level, int (*func)(void *), void *arg)
    191       1.1       cgd {
    192      1.17      fvdl 	int pin, irq;
    193      1.17      fvdl 	struct pic *pic;
    194      1.17      fvdl 
    195      1.17      fvdl 	pic = &i8259_pic;
    196      1.17      fvdl 	pin = irq = ih;
    197      1.17      fvdl 
    198      1.16      fvdl #if NIOAPIC > 0
    199      1.17      fvdl 	if (ih & APIC_INT_VIA_APIC) {
    200      1.38  uebayasi 		struct ioapic_softc * const ioapic = ioapic_find(APIC_IRQ_APIC(ih));
    201      1.38  uebayasi 		if (ioapic == NULL) {
    202      1.38  uebayasi 			aprint_normal("eisa_intr_establish: bad ioapic %d\n",
    203      1.17      fvdl 			    APIC_IRQ_APIC(ih));
    204      1.17      fvdl 			return NULL;
    205      1.16      fvdl 		}
    206      1.38  uebayasi 		pic = &ioapic->sc_pic;
    207      1.17      fvdl 		pin = APIC_IRQ_PIN(ih);
    208      1.17      fvdl 		irq = APIC_IRQ_LEGACY_IRQ(ih);
    209      1.17      fvdl 		if (irq < 0 || irq >= NUM_LEGACY_IRQS)
    210      1.17      fvdl 			irq = -1;
    211      1.17      fvdl 	}
    212      1.16      fvdl #endif
    213       1.1       cgd 
    214      1.31        ad 	return intr_establish(irq, pic, pin, type, level, func, arg, false);
    215       1.1       cgd }
    216       1.1       cgd 
    217       1.1       cgd void
    218      1.28  christos eisa_intr_disestablish(eisa_chipset_tag_t ec, void *cookie)
    219       1.1       cgd {
    220       1.1       cgd 
    221      1.17      fvdl 	intr_disestablish(cookie);
    222       1.5   thorpej }
    223       1.5   thorpej 
    224       1.5   thorpej int
    225      1.28  christos eisa_conf_read_mem(eisa_chipset_tag_t ec, int slot,
    226      1.28  christos     int func, int entry, struct eisa_cfg_mem *ecm)
    227      1.12   thorpej {
    228      1.12   thorpej 
    229      1.12   thorpej 	/* XXX XXX XXX */
    230      1.12   thorpej 	return (ENOENT);
    231      1.12   thorpej }
    232      1.12   thorpej 
    233      1.12   thorpej int
    234      1.28  christos eisa_conf_read_irq(eisa_chipset_tag_t ec, int slot,
    235      1.28  christos     int func, int entry, struct eisa_cfg_irq *eci)
    236      1.12   thorpej {
    237      1.12   thorpej 
    238      1.12   thorpej 	/* XXX XXX XXX */
    239      1.12   thorpej 	return (ENOENT);
    240      1.12   thorpej }
    241      1.12   thorpej 
    242      1.12   thorpej int
    243      1.28  christos eisa_conf_read_dma(eisa_chipset_tag_t ec, int slot,
    244      1.28  christos     int func, int entry, struct eisa_cfg_dma *ecd)
    245      1.12   thorpej {
    246      1.12   thorpej 
    247      1.12   thorpej 	/* XXX XXX XXX */
    248      1.12   thorpej 	return (ENOENT);
    249      1.12   thorpej }
    250      1.12   thorpej 
    251      1.12   thorpej int
    252      1.28  christos eisa_conf_read_io(eisa_chipset_tag_t ec, int slot,
    253      1.28  christos     int func, int entry, struct eisa_cfg_io *ecio)
    254      1.12   thorpej {
    255      1.12   thorpej 
    256      1.12   thorpej 	/* XXX XXX XXX */
    257      1.12   thorpej 	return (ENOENT);
    258       1.1       cgd }
    259