Annotation of 42BSD/sys/vaxuba/ik.c, revision 1.1

1.1     ! root        1: /*     ik.c    6.1     83/07/29        */
        !             2: 
        !             3: #include "ik.h"
        !             4: #if NIK > 0
        !             5: /*
        !             6:  * Ikonas Frame Buffer Interface -- Bill Reeves.
        !             7:  */
        !             8: #include "../machine/pte.h"
        !             9: 
        !            10: #include "../h/param.h"
        !            11: #include "../h/dir.h"
        !            12: #include "../h/user.h"
        !            13: #include "../h/buf.h"
        !            14: #include "../h/systm.h"
        !            15: #include "../h/map.h"
        !            16: #include "../h/uio.h"
        !            17: #include "../h/ioctl.h"
        !            18: 
        !            19: #include "../vaxuba/ubareg.h"
        !            20: #include "../vaxuba/ubavar.h"
        !            21: #include "../vaxuba/ikreg.h"
        !            22: 
        !            23: #define IKBUSY 01
        !            24: #define IKDMAPRI (PZERO-1)
        !            25: #define IKWAITPRI (PZERO+1)
        !            26: 
        !            27: int    ikprobe(), ikattach(), ikintr();
        !            28: struct uba_device *ikdinfo[NIK];
        !            29: u_short        ikstd[] = { 0772460, 0000000, 0 };
        !            30: struct uba_driver ikdriver =
        !            31:        { ikprobe, 0, ikattach, 0, ikstd, "ik", ikdinfo, 0, 0 };
        !            32: 
        !            33: struct ik_softc {
        !            34:        char    ik_open;
        !            35:        short   ik_uid;
        !            36:        short   ik_state;
        !            37:        int     ik_ubinfo;
        !            38:        int     ik_count;
        !            39:        struct  buf *ik_bp;
        !            40:        int     ik_bufp;
        !            41:        int     ik_icnt;
        !            42: } ik_softc[NIK];
        !            43: 
        !            44: int    ikstrategy();
        !            45: u_int  ikminphys();
        !            46: struct buf rikbuf[NIK];
        !            47: 
        !            48: #define IKUNIT(dev) (minor(dev))
        !            49: 
        !            50: ikprobe(reg)
        !            51:        caddr_t reg;
        !            52: {
        !            53:        register int br, cvec;          /* value-result */
        !            54:        register struct ikdevice *ikaddr = (struct ikdevice *) reg;
        !            55: 
        !            56: #ifdef lint
        !            57:        br = 0; cvec = br; br = cvec;
        !            58:        ikintr(0);
        !            59: #endif
        !            60:        ikaddr->ik_istat = 0;
        !            61:        ikaddr->ik_xaddr = 0;
        !            62:        ikaddr->ik_yaddr = 0;
        !            63:        ikaddr->ik_ustat = IK_IENABLE | IK_GO;
        !            64:        DELAY(10000);
        !            65:        ikaddr->ik_ustat = 0;
        !            66:        return (sizeof (struct ikdevice));
        !            67: }
        !            68: 
        !            69: /*ARGSUSED*/
        !            70: ikattach(ui)
        !            71:        struct uba_device *ui;
        !            72: {
        !            73: 
        !            74: }
        !            75: 
        !            76: ikopen(dev)
        !            77:        dev_t dev;
        !            78: {
        !            79:        register struct ik_softc *ikp;
        !            80:        register struct uba_device *ui;
        !            81: 
        !            82:        if (IKUNIT(dev) >= NIK || (ikp = &ik_softc[minor(dev)])->ik_open ||
        !            83:            (ui = ikdinfo[IKUNIT(dev)]) == 0 || ui->ui_alive == 0)
        !            84:                return (ENXIO);
        !            85:        ikp->ik_open = 1;
        !            86:        ikp->ik_icnt = 0;
        !            87:        ikp->ik_state = 0;
        !            88:        ikp->ik_uid = u.u_uid;
        !            89:        maptouser(ui->ui_addr);
        !            90:        return (0);
        !            91: }
        !            92: 
        !            93: ikclose(dev)
        !            94:        dev_t dev;
        !            95: {
        !            96: 
        !            97:        ik_softc[minor(dev)].ik_open = 0;
        !            98:        ik_softc[minor(dev)].ik_state = 0;
        !            99:        unmaptouser(ikdinfo[IKUNIT(dev)]->ui_addr);
        !           100: }
        !           101: 
        !           102: ikread(dev, uio)
        !           103:        dev_t dev;
        !           104:        struct uio *uio;
        !           105: {
        !           106:        register int unit = IKUNIT(dev);
        !           107: 
        !           108:        if (unit >= NIK)
        !           109:                return (ENXIO);
        !           110:        return (physio(ikstrategy, &rikbuf[unit], dev, B_READ, ikminphys, uio));
        !           111: }
        !           112: 
        !           113: ikwrite(dev, uio)
        !           114:        dev_t dev;
        !           115:        struct uio *uio;
        !           116: {
        !           117:        register int unit = IKUNIT(dev);
        !           118: 
        !           119:        if (unit >= NIK)
        !           120:                return (ENXIO);
        !           121:        return (physio(ikstrategy, &rikbuf[unit], dev, B_WRITE, ikminphys, uio));
        !           122: }
        !           123: 
        !           124: u_int
        !           125: ikminphys(bp)
        !           126:        register struct buf *bp;
        !           127: {
        !           128: 
        !           129:        if (bp->b_bcount > 65536)       /* may be able to do twice as much */
        !           130:                bp->b_bcount = 65536;
        !           131: }
        !           132: 
        !           133: ikstrategy(bp)
        !           134:        register struct buf *bp;
        !           135: {
        !           136:        register struct ik_softc *ikp = &ik_softc[IKUNIT(bp->b_dev)];
        !           137:        register struct uba_device *ui;
        !           138: 
        !           139:        if (IKUNIT(bp->b_dev) >= NIK || (ui = ikdinfo[IKUNIT(bp->b_dev)]) == 0
        !           140:                                || ui->ui_alive == 0)
        !           141:                goto bad;
        !           142:        (void) spl5();
        !           143:        while (ikp->ik_state & IKBUSY)
        !           144:                sleep((caddr_t)ikp, IKDMAPRI+1);
        !           145:        ikp->ik_state |= IKBUSY;
        !           146:        ikp->ik_bp = bp;
        !           147:        ikp->ik_ubinfo = ubasetup(ui->ui_ubanum, bp, UBA_NEEDBDP);
        !           148:        ikp->ik_bufp = ikp->ik_ubinfo & 0x3ffff;
        !           149:        ikp->ik_count = -(bp->b_bcount>>1);     /* its a word count */
        !           150:        ikstart(ui);
        !           151:        while (ikp->ik_state&IKBUSY)
        !           152:                sleep((caddr_t)ikp, IKDMAPRI);
        !           153:        ikp->ik_count = 0;
        !           154:        ikp->ik_bufp = 0;
        !           155:        (void) spl0();
        !           156:        ubarelse(ui->ui_ubanum, &ikp->ik_ubinfo);
        !           157:        ikp->ik_bp = 0;
        !           158:        iodone(bp);
        !           159:        wakeup((caddr_t)ikp);
        !           160:        return;
        !           161: bad:
        !           162:        bp->b_flags |= B_ERROR;
        !           163:        iodone(bp);
        !           164:        return;
        !           165: }
        !           166: 
        !           167: ikstart(ui)
        !           168:        register struct uba_device *ui;
        !           169: {
        !           170:        register int istat;
        !           171:        register struct ikdevice *ikaddr = (struct ikdevice *) ui->ui_addr;
        !           172:        register struct ik_softc *ikp = &ik_softc[IKUNIT(ui->ui_unit)];
        !           173: 
        !           174:        istat = ikaddr->ik_istat|DMAENABLE;
        !           175:        ikaddr->ik_istat = istat;
        !           176:        ikaddr->ik_wc =  ikp->ik_count;
        !           177:        ikaddr->ik_ubaddr = ikp->ik_bufp;
        !           178:        ikaddr->ik_ustat = IK_GO|IK_IENABLE|((ikp->ik_bufp>>12)&060);
        !           179: }
        !           180: 
        !           181: /*ARGSUSED*/
        !           182: ikioctl(dev, cmd, data, flag)
        !           183:        dev_t dev;
        !           184:        int cmd;
        !           185:        register caddr_t data;
        !           186:        int flag;
        !           187: {
        !           188:        register struct uba_device *ui = ikdinfo[IKUNIT(dev)];
        !           189:        register struct ik_softc *ikp;
        !           190: 
        !           191:        switch (cmd) {
        !           192: 
        !           193:        case IKIOGETADDR:
        !           194:                *(caddr_t *)data = ui->ui_addr;
        !           195:                break;
        !           196: 
        !           197:        case IKIOWAITINT:
        !           198:                ikp = &ik_softc[IKUNIT(dev)];
        !           199:                ikp->ik_state |= IKBUSY;
        !           200:                while (ikp->ik_state&IKBUSY)
        !           201:                        sleep((caddr_t)ikp, IKWAITPRI);
        !           202:                break;
        !           203: 
        !           204:        default:
        !           205:                return (ENOTTY);
        !           206:        }
        !           207:        return (0);
        !           208: }
        !           209: 
        !           210: /*ARGSUSED*/
        !           211: ikintr(dev)
        !           212:        dev_t dev;
        !           213: {
        !           214:        register struct ikdevice *ikaddr =
        !           215:                        (struct ikdevice *) ikdinfo[IKUNIT(dev)]->ui_addr;
        !           216:        register struct ik_softc *ikp = &ik_softc[IKUNIT(dev)];
        !           217: 
        !           218:        ikp->ik_icnt++;
        !           219:        if (ikp->ik_state&IKBUSY) {
        !           220:                ikaddr->ik_ustat = 0;
        !           221:                ikp->ik_state &= ~IKBUSY;
        !           222:                wakeup((caddr_t)ikp);
        !           223:        }
        !           224: }
        !           225: 
        !           226: ikreset(uban)
        !           227:        int uban;
        !           228: {
        !           229:        register int i;
        !           230:        register struct uba_device *ui;
        !           231:        register struct ik_softc *ikp = ik_softc;
        !           232: 
        !           233:        for (i = 0; i < NIK; i++, ikp++) {
        !           234:                if ((ui = ikdinfo[i]) == 0 || ui->ui_alive == 0 ||
        !           235:                    ui->ui_ubanum != uban || ikp->ik_open == 0)
        !           236:                        continue;
        !           237:                printf(" ik%d", i);
        !           238:                if ((ikp->ik_state&IKBUSY) == 0)
        !           239:                        continue;
        !           240:                ikp->ik_ubinfo =
        !           241:                    ubasetup(ui->ui_ubanum, ikp->ik_bp, UBA_NEEDBDP);
        !           242:                ikp->ik_count = -(ikp->ik_bp->b_bcount/2);
        !           243:                ikstart(ui);
        !           244:        }
        !           245: }
        !           246: #endif

unix.superglobalmegacorp.com

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