[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.10.22.6

1.10.22.4  sommerfe    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:  */
                     73:
1.10.22.6! sommerfe   74: #include <sys/cdefs.h>
        !            75: __KERNEL_RCSID(0, "$NetBSD$");
        !            76:
1.10.22.3  sommerfe   77: #include "ioapic.h"
                     78:
1.1       cgd        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.6       thorpej    87: #define _I386_BUS_DMA_PRIVATE
                     88: #include <machine/bus.h>
                     89:
1.1       cgd        90: #include <i386/isa/icu.h>
1.5       thorpej    91: #include <dev/isa/isareg.h>
1.1       cgd        92: #include <dev/isa/isavar.h>
                     93: #include <dev/eisa/eisavar.h>
                     94:
1.10.22.3  sommerfe   95: #if NIOAPIC > 0
                     96: #include <machine/i82093var.h>
                     97: #include <machine/mpbiosvar.h>
                     98: #endif
                     99:
1.6       thorpej   100: /*
                    101:  * EISA doesn't have any special needs; just use the generic versions
                    102:  * of these funcions.
                    103:  */
                    104: struct i386_bus_dma_tag eisa_bus_dma_tag = {
1.10      thorpej   105:        0,                      /* _bounce_thresh */
1.6       thorpej   106:        _bus_dmamap_create,
                    107:        _bus_dmamap_destroy,
                    108:        _bus_dmamap_load,
                    109:        _bus_dmamap_load_mbuf,
                    110:        _bus_dmamap_load_uio,
                    111:        _bus_dmamap_load_raw,
                    112:        _bus_dmamap_unload,
                    113:        NULL,                   /* _dmamap_sync */
                    114:        _bus_dmamem_alloc,
                    115:        _bus_dmamem_free,
                    116:        _bus_dmamem_map,
                    117:        _bus_dmamem_unmap,
                    118:        _bus_dmamem_mmap,
                    119: };
                    120:
1.1       cgd       121: void
                    122: eisa_attach_hook(parent, self, eba)
                    123:        struct device *parent, *self;
                    124:        struct eisabus_attach_args *eba;
                    125: {
1.7       thorpej   126:        extern int eisa_has_been_seen;
1.1       cgd       127:
1.7       thorpej   128:        /*
1.8       thorpej   129:         * Notify others that might need to know that the EISA bus
1.7       thorpej   130:         * has now been attached.
                    131:         */
                    132:        if (eisa_has_been_seen)
                    133:                panic("eisaattach: EISA bus already seen!");
                    134:        eisa_has_been_seen = 1;
1.1       cgd       135: }
                    136:
                    137: int
                    138: eisa_maxslots(ec)
                    139:        eisa_chipset_tag_t ec;
                    140: {
                    141:
                    142:        /*
                    143:         * Always try 16 slots.
                    144:         */
                    145:        return (16);
                    146: }
                    147:
                    148: int
                    149: eisa_intr_map(ec, irq, ihp)
                    150:        eisa_chipset_tag_t ec;
                    151:        u_int irq;
                    152:        eisa_intr_handle_t *ihp;
                    153: {
1.10.22.1  sommerfe  154: #if NIOAPIC > 0
                    155:        struct mp_intr_map *mip;
                    156: #endif
1.1       cgd       157:
                    158:        if (irq >= ICU_LEN) {
1.4       christos  159:                printf("eisa_intr_map: bad IRQ %d\n", irq);
1.1       cgd       160:                *ihp = -1;
                    161:                return 1;
                    162:        }
                    163:        if (irq == 2) {
1.4       christos  164:                printf("eisa_intr_map: changed IRQ 2 to IRQ 9\n");
1.1       cgd       165:                irq = 9;
                    166:        }
                    167:
1.10.22.1  sommerfe  168: #if NIOAPIC > 0
                    169:        if (mp_busses != NULL) {
1.10.22.3  sommerfe  170:                int bus = mp_eisa_bus;
                    171:
                    172:                if (bus != -1) {
                    173:                        for (mip = mp_busses[bus].mb_intrs; mip != NULL;
                    174:                             mip=mip->next) {
                    175:                                if (mip->bus_pin == irq) {
                    176:                                        *ihp = mip->ioapic_ih | irq;
                    177:                                        return 0;
                    178:                                }
                    179:                        }
                    180:                }
                    181:
                    182:                bus = mp_isa_bus;
1.10.22.1  sommerfe  183:
1.10.22.3  sommerfe  184:                if (bus != -1) {
                    185:                        for (mip = mp_busses[bus].mb_intrs; mip != NULL;
                    186:                             mip=mip->next) {
                    187:                                if (mip->bus_pin == irq) {
                    188:                                        *ihp = mip->ioapic_ih | irq;
                    189:                                        return 0;
                    190:                                }
1.10.22.1  sommerfe  191:                        }
                    192:                }
1.10.22.3  sommerfe  193:
                    194:                printf("eisa_intr_map: no MP mapping found\n");
1.10.22.1  sommerfe  195:        }
                    196: #endif
                    197:
                    198:
1.1       cgd       199:        *ihp = irq;
                    200:        return 0;
                    201: }
                    202:
                    203: const char *
                    204: eisa_intr_string(ec, ih)
                    205:        eisa_chipset_tag_t ec;
                    206:        eisa_intr_handle_t ih;
                    207: {
                    208:        static char irqstr[8];          /* 4 + 2 + NULL + sanity */
                    209:
1.10.22.1  sommerfe  210:        if (ih == 0 || (ih & 0xff) >= ICU_LEN || ih == 2)
1.1       cgd       211:                panic("eisa_intr_string: bogus handle 0x%x\n", ih);
                    212:
1.10.22.1  sommerfe  213: #if NIOAPIC > 0
                    214:        if (ih & APIC_INT_VIA_APIC)
                    215:                sprintf(irqstr, "apic %d int %d (irq %d)",
                    216:                    APIC_IRQ_APIC(ih),
                    217:                    APIC_IRQ_PIN(ih),
                    218:                    ih&0xff);
                    219:        else
                    220:                sprintf(irqstr, "irq %d", ih&0xff);
                    221: #else
1.4       christos  222:        sprintf(irqstr, "irq %d", ih);
1.10.22.1  sommerfe  223: #endif
1.1       cgd       224:        return (irqstr);
                    225:
1.10.22.2  sommerfe  226: }
                    227:
                    228: const struct evcnt *
                    229: eisa_intr_evcnt(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
                    230: {
                    231:
                    232:        /* XXX for now, no evcnt parent reported */
                    233:        return NULL;
1.1       cgd       234: }
                    235:
                    236: void *
                    237: eisa_intr_establish(ec, ih, type, level, func, arg)
                    238:        eisa_chipset_tag_t ec;
                    239:        eisa_intr_handle_t ih;
                    240:        int type, level, (*func) __P((void *));
                    241:        void *arg;
                    242: {
1.10.22.1  sommerfe  243:        if (ih != -1) {
                    244: #if NIOAPIC > 0
                    245:                if (ih & APIC_INT_VIA_APIC) {
                    246:                        return apic_intr_establish(ih, type, level,
                    247:                            func, arg);
                    248:                }
                    249: #endif
                    250:        }
1.1       cgd       251:
                    252:        if (ih == 0 || ih >= ICU_LEN || ih == 2)
                    253:                panic("eisa_intr_establish: bogus handle 0x%x\n", ih);
                    254:
1.2       cgd       255:        return isa_intr_establish(NULL, ih, type, level, func, arg);
1.1       cgd       256: }
                    257:
                    258: void
                    259: eisa_intr_disestablish(ec, cookie)
                    260:        eisa_chipset_tag_t ec;
                    261:        void *cookie;
                    262: {
                    263:
1.10.22.5  sommerfe  264:        isa_intr_disestablish(NULL, cookie);
1.5       thorpej   265: }
                    266:
                    267: int
                    268: eisa_mem_alloc(t, size, align, boundary, cacheable, addrp, bahp)
                    269:        bus_space_tag_t t;
                    270:        bus_size_t size, align;
                    271:        bus_addr_t boundary;
                    272:        int cacheable;
                    273:        bus_addr_t *addrp;
                    274:        bus_space_handle_t *bahp;
                    275: {
                    276:        extern struct extent *iomem_ex;
                    277:
                    278:        /*
                    279:         * Allocate physical address space after the ISA hole.
                    280:         */
                    281:        return bus_space_alloc(t, IOM_END, iomem_ex->ex_end, size, align,
                    282:            boundary, cacheable, addrp, bahp);
                    283: }
                    284:
                    285: void
                    286: eisa_mem_free(t, bah, size)
                    287:        bus_space_tag_t t;
                    288:        bus_space_handle_t bah;
                    289:        bus_size_t size;
                    290: {
                    291:
                    292:        bus_space_free(t, bah, size);
1.10.22.4  sommerfe  293: }
                    294:
                    295: int
                    296: eisa_conf_read_mem(ec, slot, func, entry, ecm)
                    297:        eisa_chipset_tag_t ec;
                    298:        int slot, func, entry;
                    299:        struct eisa_cfg_mem *ecm;
                    300: {
                    301:
                    302:        /* XXX XXX XXX */
                    303:        return (ENOENT);
                    304: }
                    305:
                    306: int
                    307: eisa_conf_read_irq(ec, slot, func, entry, eci)
                    308:        eisa_chipset_tag_t ec;
                    309:        int slot, func, entry;
                    310:        struct eisa_cfg_irq *eci;
                    311: {
                    312:
                    313:        /* XXX XXX XXX */
                    314:        return (ENOENT);
                    315: }
                    316:
                    317: int
                    318: eisa_conf_read_dma(ec, slot, func, entry, ecd)
                    319:        eisa_chipset_tag_t ec;
                    320:        int slot, func, entry;
                    321:        struct eisa_cfg_dma *ecd;
                    322: {
                    323:
                    324:        /* XXX XXX XXX */
                    325:        return (ENOENT);
                    326: }
                    327:
                    328: int
                    329: eisa_conf_read_io(ec, slot, func, entry, ecio)
                    330:        eisa_chipset_tag_t ec;
                    331:        int slot, func, entry;
                    332:        struct eisa_cfg_io *ecio;
                    333: {
                    334:
                    335:        /* XXX XXX XXX */
                    336:        return (ENOENT);
1.1       cgd       337: }

CVSweb <webmaster@jp.NetBSD.org>