Annotation of Net2/arch/i386/isa/isa.c, revision 1.1.1.2

1.1       root        1: /*-
                      2:  * Copyright (c) 1991 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * This code is derived from software contributed to Berkeley by
                      6:  * William Jolitz.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *     This product includes software developed by the University of
                     19:  *     California, Berkeley and its contributors.
                     20:  * 4. Neither the name of the University nor the names of its contributors
                     21:  *    may be used to endorse or promote products derived from this software
                     22:  *    without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
                     36:  *     @(#)isa.c       7.2 (Berkeley) 5/13/91
                     37:  */
1.1.1.2 ! root       38: static char rcsid[] = "$Header: /usr/src/sys.386bsd/i386/isa/RCS/isa.c,v 1.2 92/01/21 14:34:23 william Exp Locker: root $";
1.1       root       39: 
                     40: /*
                     41:  * code to manage AT bus
                     42:  */
                     43: 
                     44: #include "param.h"
                     45: #include "systm.h"
                     46: #include "conf.h"
                     47: #include "file.h"
                     48: #include "buf.h"
                     49: #include "uio.h"
                     50: #include "syslog.h"
                     51: #include "machine/segments.h"
                     52: #include "i386/isa/isa_device.h"
                     53: #include "i386/isa/icu.h"
                     54: 
                     55: /*
                     56:  * Configure all ISA devices
                     57:  */
                     58: isa_configure() {
                     59:        struct isa_device *dvp;
                     60:        struct isa_driver *dp;
                     61: 
                     62:        splhigh();
                     63:        INTREN(IRQ_SLAVE);
                     64:        for (dvp = isa_devtab_tty; config_isadev(dvp,&ttymask); dvp++);
1.1.1.2 ! root       65:        for (dvp = isa_devtab_bio; config_isadev(dvp,&biomask); dvp++);
1.1       root       66:        for (dvp = isa_devtab_net; config_isadev(dvp,&netmask); dvp++);
                     67:        for (dvp = isa_devtab_null; config_isadev(dvp,0); dvp++);
                     68: #include "sl.h"
                     69: #if NSL > 0
                     70:        netmask |= ttymask;
                     71:        ttymask |= netmask;
                     72: #endif
                     73:        /* biomask |= ttymask ;  can some tty devices use buffers? */
1.1.1.2 ! root       74:        /*printf("biomask %x ttymask %x netmask %x\n", biomask, ttymask, netmask);*/
1.1       root       75:        splnone();
                     76: }
                     77: 
                     78: /*
                     79:  * Configure an ISA device.
                     80:  */
                     81: config_isadev(isdp, mp)
                     82:        struct isa_device *isdp;
                     83:        int *mp;
                     84: {
                     85:        struct isa_driver *dp;
                     86:  
                     87:        if (dp = isdp->id_driver) {
                     88:                if (isdp->id_maddr) {
                     89:                        extern int atdevbase;
                     90: 
                     91:                        isdp->id_maddr -= 0xa0000;
                     92:                        isdp->id_maddr += atdevbase;
                     93:                }
                     94:                isdp->id_alive = (*dp->probe)(isdp);
                     95:                if (isdp->id_alive) {
                     96:                        printf("%s%d", dp->name, isdp->id_unit);
                     97:                        (*dp->attach)(isdp);
                     98:                        printf(" at 0x%x ", isdp->id_iobase);
                     99:                        if(isdp->id_irq) {
                    100:                                int intrno;
                    101: 
                    102:                                intrno = ffs(isdp->id_irq)-1;
                    103:                                printf("irq %d ", intrno);
                    104:                                INTREN(isdp->id_irq);
                    105:                                if(mp)INTRMASK(*mp,isdp->id_irq);
                    106:                                setidt(ICU_OFFSET+intrno, isdp->id_intr,
                    107:                                         SDT_SYS386IGT, SEL_KPL);
                    108:                        }
                    109:                        if (isdp->id_drq != -1) printf("drq %d ", isdp->id_drq);
                    110:                        printf("on isa\n");
                    111:                }
                    112:                return (1);
                    113:        } else  return(0);
                    114: }
                    115: 
                    116: #define        IDTVEC(name)    __CONCAT(X,name)
                    117: /* default interrupt vector table */
                    118: extern IDTVEC(intr0), IDTVEC(intr1), IDTVEC(intr2), IDTVEC(intr3),
                    119:        IDTVEC(intr4), IDTVEC(intr5), IDTVEC(intr6), IDTVEC(intr7),
                    120:        IDTVEC(intr8), IDTVEC(intr9), IDTVEC(intr10), IDTVEC(intr11),
                    121:        IDTVEC(intr12), IDTVEC(intr13), IDTVEC(intr14), IDTVEC(intr15);
                    122:        
                    123: /*
                    124:  * Fill in default interrupt table (in case of spuruious interrupt
                    125:  * during configuration of kernel, setup interrupt control unit
                    126:  */
                    127: isa_defaultirq() {
                    128: 
                    129: /* first icu */
                    130:        setidt(32, &IDTVEC(intr0),  SDT_SYS386IGT, SEL_KPL);
                    131:        setidt(33, &IDTVEC(intr1),  SDT_SYS386IGT, SEL_KPL);
                    132:        setidt(34, &IDTVEC(intr2),  SDT_SYS386IGT, SEL_KPL);
                    133:        setidt(35, &IDTVEC(intr3),  SDT_SYS386IGT, SEL_KPL);
                    134:        setidt(36, &IDTVEC(intr4),  SDT_SYS386IGT, SEL_KPL);
                    135:        setidt(37, &IDTVEC(intr5),  SDT_SYS386IGT, SEL_KPL);
                    136:        setidt(38, &IDTVEC(intr6),  SDT_SYS386IGT, SEL_KPL);
                    137:        setidt(39, &IDTVEC(intr7),  SDT_SYS386IGT, SEL_KPL);
                    138: 
                    139: /* second icu */
                    140:        setidt(40, &IDTVEC(intr8),  SDT_SYS386IGT, SEL_KPL);
                    141:        setidt(41, &IDTVEC(intr9),  SDT_SYS386IGT, SEL_KPL);
                    142:        setidt(42, &IDTVEC(intr10),  SDT_SYS386IGT, SEL_KPL);
                    143:        setidt(43, &IDTVEC(intr11),  SDT_SYS386IGT, SEL_KPL);
                    144:        setidt(44, &IDTVEC(intr12),  SDT_SYS386IGT, SEL_KPL);
                    145:        setidt(45, &IDTVEC(intr13),  SDT_SYS386IGT, SEL_KPL);
                    146:        setidt(46, &IDTVEC(intr14),  SDT_SYS386IGT, SEL_KPL);
                    147:        setidt(47, &IDTVEC(intr15),  SDT_SYS386IGT, SEL_KPL);
                    148: 
                    149:        /* initialize 8259's */
                    150:        outb(0xf1,0);
                    151:        outb(0x20,0x11);
                    152:        outb(0x21,32);
                    153:        outb(0x21,4);
                    154:        outb(0x21,1);
                    155:        outb(0x21,0xff);
                    156: 
                    157:        outb(0xa0,0x11);
                    158:        outb(0xa1,40);
                    159:        outb(0xa1,2);
                    160:        outb(0xa1,1);
                    161:        outb(0xa1,0xff);
                    162: }
                    163: 
                    164: /* stuff needed for virtual to physical calculations */
                    165: 
                    166: struct buf *dma_bounce[8];
                    167: #define MAXDMASZ 512
                    168: 
                    169: /* XXX temporary crud */
                    170: kernel_space(x)
                    171: unsigned long x;
                    172: {
                    173:        if (x >= KERNBASE) return 1;
                    174:        else return 0;
                    175: }
                    176: 
                    177: 
                    178: /****************************************************************************/
                    179: /*                                 at_dma                                   */
                    180: /* set up DMA read/write operation and virtual address addr for nbytes      */
                    181: /****************************************************************************/
                    182: at_dma(read,addr,nbytes, chan)
                    183: int read;
                    184: unsigned long addr;
                    185: int nbytes;
                    186: {
                    187:        unsigned long phys;
                    188:        int s,raw;
                    189:        caddr_t bounce;
                    190: 
                    191:        if (kernel_space(addr)) raw = 0;
                    192:        else raw = 1;
                    193: 
                    194:        if(raw) {
                    195:                if (dma_bounce[chan] == 0)
                    196:                        dma_bounce[chan] = geteblk(MAXDMASZ);
                    197:                bounce = dma_bounce[chan]->b_un.b_addr;
                    198:        }
                    199: 
                    200:        /* copy bounce buffer on write */
                    201:        if (raw && !read) bcopy(addr,bounce,nbytes);
                    202: 
                    203:        /* Set read/write bytes */
                    204:        if (read) {
                    205:                outb(0xC,0x46); outb(0xB,0x46);
                    206:        } else {
                    207:                outb(0xC,0x4A); outb(0xB,0x4A);
                    208:        }
                    209:        /* Send start address */
                    210:        if (raw) phys = (unsigned long) bounce;
                    211:        else phys = addr;
                    212:        /* translate to physical */
                    213:        phys = pmap_extract(pmap_kernel(), (vm_offset_t)phys);
                    214:        outb(0x4,phys & 0xFF);
                    215:        outb(0x4,(phys>>8) & 0xFF);
                    216:        outb(0x81,(phys>>16) & 0xFF);
                    217:        /* Send count */
                    218:        nbytes--;
                    219:        outb(0x5,nbytes & 0xFF);
                    220:        outb(0x5,(nbytes>>8) & 0xFF);
                    221:        /* set channel 2 */
                    222:        outb(0x0A,chan);
                    223: }
                    224: 
                    225: /*
                    226:  * Handle a NMI, possibly a machine check.
                    227:  * return true to panic system, false to ignore.
                    228:  */
                    229: isa_nmi(cd) {
                    230: 
                    231:        log(LOG_CRIT, "\nNMI port 61 %x, port 70 %x\n", inb(0x61), inb(0x70));
                    232:        return(0);
                    233: }
                    234: 
                    235: /*
                    236:  * Caught a stray interrupt, notify
                    237:  */
                    238: isa_strayintr(d) {
                    239: 
                    240:        /* for some reason, we get bursts of intr #7, even if not enabled! */
                    241:        log(LOG_ERR,"ISA strayintr %d", ffs(d)-1);
                    242: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.