[BACK]Return to eisa_machdep.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / i386 / eisa

Annotation of src/sys/arch/i386/eisa/eisa_machdep.c, Revision 1.22.6.1

1.22.6.1! yamt        1: /*     $NetBSD$        */
1.6       thorpej     2:
                      3: /*-
1.7       thorpej     4:  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
1.6       thorpej     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:  */
1.1       cgd        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:  */
1.14      lukem      73:
                     74: #include <sys/cdefs.h>
1.22.6.1! yamt       75: __KERNEL_RCSID(0, "$NetBSD$");
1.16      fvdl       76:
                     77: #include "ioapic.h"
1.1       cgd        78:
                     79: #include <sys/types.h>
                     80: #include <sys/param.h>
                     81: #include <sys/time.h>
                     82: #include <sys/systm.h>
                     83: #include <sys/errno.h>
                     84: #include <sys/device.h>
1.5       thorpej    85: #include <sys/extent.h>
1.1       cgd        86:
1.18      fvdl       87: #define _X86_BUS_DMA_PRIVATE
1.6       thorpej    88: #include <machine/bus.h>
                     89:
1.5       thorpej    90: #include <dev/isa/isareg.h>
1.1       cgd        91: #include <dev/isa/isavar.h>
                     92: #include <dev/eisa/eisavar.h>
                     93:
1.16      fvdl       94: #if NIOAPIC > 0
                     95: #include <machine/i82093var.h>
                     96: #include <machine/mpbiosvar.h>
                     97: #endif
                     98:
1.6       thorpej    99: /*
                    100:  * EISA doesn't have any special needs; just use the generic versions
                    101:  * of these funcions.
                    102:  */
1.18      fvdl      103: struct x86_bus_dma_tag eisa_bus_dma_tag = {
1.10      thorpej   104:        0,                      /* _bounce_thresh */
1.19      fvdl      105:        0,                      /* _bounce_alloc_lo */
                    106:        0,                      /* _bounce_alloc_hi */
                    107:        NULL,                   /* _may_bounce */
1.6       thorpej   108:        _bus_dmamap_create,
                    109:        _bus_dmamap_destroy,
                    110:        _bus_dmamap_load,
                    111:        _bus_dmamap_load_mbuf,
                    112:        _bus_dmamap_load_uio,
                    113:        _bus_dmamap_load_raw,
                    114:        _bus_dmamap_unload,
                    115:        NULL,                   /* _dmamap_sync */
                    116:        _bus_dmamem_alloc,
                    117:        _bus_dmamem_free,
                    118:        _bus_dmamem_map,
                    119:        _bus_dmamem_unmap,
                    120:        _bus_dmamem_mmap,
                    121: };
                    122:
1.1       cgd       123: void
1.22.6.1! yamt      124: eisa_attach_hook(struct device *parent, struct device *self,
        !           125:     struct eisabus_attach_args *eba)
1.1       cgd       126: {
1.7       thorpej   127:        extern int eisa_has_been_seen;
1.1       cgd       128:
1.7       thorpej   129:        /*
1.8       thorpej   130:         * Notify others that might need to know that the EISA bus
1.7       thorpej   131:         * has now been attached.
                    132:         */
                    133:        if (eisa_has_been_seen)
                    134:                panic("eisaattach: EISA bus already seen!");
                    135:        eisa_has_been_seen = 1;
1.1       cgd       136: }
                    137:
                    138: int
1.22.6.1! yamt      139: eisa_maxslots(eisa_chipset_tag_t ec)
1.1       cgd       140: {
                    141:
                    142:        /*
                    143:         * Always try 16 slots.
                    144:         */
                    145:        return (16);
                    146: }
                    147:
                    148: int
1.22.6.1! yamt      149: eisa_intr_map(eisa_chipset_tag_t ec, u_int irq, eisa_intr_handle_t *ihp)
1.1       cgd       150: {
1.17      fvdl      151:        if (irq >= NUM_LEGACY_IRQS) {
1.4       christos  152:                printf("eisa_intr_map: bad IRQ %d\n", irq);
1.1       cgd       153:                *ihp = -1;
                    154:                return 1;
                    155:        }
                    156:        if (irq == 2) {
1.4       christos  157:                printf("eisa_intr_map: changed IRQ 2 to IRQ 9\n");
1.1       cgd       158:                irq = 9;
                    159:        }
                    160:
1.16      fvdl      161: #if NIOAPIC > 0
1.17      fvdl      162:
1.16      fvdl      163:        if (mp_busses != NULL) {
1.21      fvdl      164:                if (intr_find_mpmapping(mp_eisa_bus, irq, ihp) == 0 ||
                    165:                    intr_find_mpmapping(mp_isa_bus, irq, ihp) == 0) {
1.17      fvdl      166:                        *ihp |= irq;
                    167:                        return 0;
                    168:                } else
                    169:                        printf("eisa_intr_map: no MP mapping found\n");
1.16      fvdl      170:        }
1.17      fvdl      171:        printf("eisa_intr_map: no MP mapping found\n");
1.16      fvdl      172: #endif
                    173:
1.1       cgd       174:        *ihp = irq;
                    175:        return 0;
                    176: }
                    177:
                    178: const char *
1.22.6.1! yamt      179: eisa_intr_string(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
1.1       cgd       180: {
                    181:        static char irqstr[8];          /* 4 + 2 + NULL + sanity */
                    182:
1.17      fvdl      183:        if (ih == 0 || (ih & 0xff) >= NUM_LEGACY_IRQS || ih == 2)
1.15      provos    184:                panic("eisa_intr_string: bogus handle 0x%x", ih);
1.1       cgd       185:
1.16      fvdl      186: #if NIOAPIC > 0
                    187:        if (ih & APIC_INT_VIA_APIC)
1.22      itojun    188:                snprintf(irqstr, sizeof(irqstr), "apic %d int %d (irq %d)",
1.16      fvdl      189:                    APIC_IRQ_APIC(ih),
                    190:                    APIC_IRQ_PIN(ih),
                    191:                    ih&0xff);
                    192:        else
1.22      itojun    193:                snprintf(irqstr, sizeof(irqstr), "irq %d", ih&0xff);
1.16      fvdl      194: #else
1.22      itojun    195:        snprintf(irqstr, sizeof(irqstr), "irq %d", ih);
1.16      fvdl      196: #endif
1.1       cgd       197:        return (irqstr);
                    198:
1.11      cgd       199: }
                    200:
                    201: const struct evcnt *
                    202: eisa_intr_evcnt(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
                    203: {
                    204:
                    205:        /* XXX for now, no evcnt parent reported */
                    206:        return NULL;
1.1       cgd       207: }
                    208:
                    209: void *
1.22.6.1! yamt      210: eisa_intr_establish(eisa_chipset_tag_t ec, eisa_intr_handle_t ih,
        !           211:     int type, int level, int (*func)(void *), void *arg)
1.1       cgd       212: {
1.17      fvdl      213:        int pin, irq;
                    214:        struct pic *pic;
                    215:
                    216:        pic = &i8259_pic;
                    217:        pin = irq = ih;
                    218:
1.16      fvdl      219: #if NIOAPIC > 0
1.17      fvdl      220:        if (ih & APIC_INT_VIA_APIC) {
                    221:                pic = (struct pic *)ioapic_find(APIC_IRQ_APIC(ih));
                    222:                if (pic == NULL) {
                    223:                        printf("eisa_intr_establish: bad ioapic %d\n",
                    224:                            APIC_IRQ_APIC(ih));
                    225:                        return NULL;
1.16      fvdl      226:                }
1.17      fvdl      227:                pin = APIC_IRQ_PIN(ih);
                    228:                irq = APIC_IRQ_LEGACY_IRQ(ih);
                    229:                if (irq < 0 || irq >= NUM_LEGACY_IRQS)
                    230:                        irq = -1;
                    231:        }
1.16      fvdl      232: #endif
1.1       cgd       233:
1.17      fvdl      234:        return intr_establish(irq, pic, pin, type, level, func, arg);
1.1       cgd       235: }
                    236:
                    237: void
1.22.6.1! yamt      238: eisa_intr_disestablish(eisa_chipset_tag_t ec, void *cookie)
1.1       cgd       239: {
                    240:
1.17      fvdl      241:        intr_disestablish(cookie);
1.5       thorpej   242: }
                    243:
                    244: int
1.22.6.1! yamt      245: eisa_mem_alloc(bus_space_tag_t t, bus_size_t size, bus_size_t align,
        !           246:     bus_addr_t boundary, int cacheable,
        !           247:     bus_addr_t *addrp, bus_space_handle_t *bahp)
1.5       thorpej   248: {
                    249:        extern struct extent *iomem_ex;
                    250:
                    251:        /*
                    252:         * Allocate physical address space after the ISA hole.
                    253:         */
                    254:        return bus_space_alloc(t, IOM_END, iomem_ex->ex_end, size, align,
                    255:            boundary, cacheable, addrp, bahp);
                    256: }
                    257:
                    258: void
1.22.6.1! yamt      259: eisa_mem_free(bus_space_tag_t t, bus_space_handle_t bah, bus_size_t size)
1.5       thorpej   260: {
                    261:
                    262:        bus_space_free(t, bah, size);
1.12      thorpej   263: }
                    264:
                    265: int
1.22.6.1! yamt      266: eisa_conf_read_mem(eisa_chipset_tag_t ec, int slot, int func, int entry,
        !           267:     struct eisa_cfg_mem *ecm)
1.12      thorpej   268: {
                    269:
                    270:        /* XXX XXX XXX */
                    271:        return (ENOENT);
                    272: }
                    273:
                    274: int
1.22.6.1! yamt      275: eisa_conf_read_irq(eisa_chipset_tag_t ec, int slot, int func, int entry,
        !           276:     struct eisa_cfg_irq *eci)
1.12      thorpej   277: {
                    278:
                    279:        /* XXX XXX XXX */
                    280:        return (ENOENT);
                    281: }
                    282:
                    283: int
1.22.6.1! yamt      284: eisa_conf_read_dma(eisa_chipset_tag_t ec, int slot, int func, int entry,
        !           285:     struct eisa_cfg_dma *ecd)
1.12      thorpej   286: {
                    287:
                    288:        /* XXX XXX XXX */
                    289:        return (ENOENT);
                    290: }
                    291:
                    292: int
1.22.6.1! yamt      293: eisa_conf_read_io(eisa_chipset_tag_t ec, int slot, int func, int entry,
        !           294:     struct eisa_cfg_io *ecio)
1.12      thorpej   295: {
                    296:
                    297:        /* XXX XXX XXX */
                    298:        return (ENOENT);
1.1       cgd       299: }

CVSweb <webmaster@jp.NetBSD.org>