Annotation of researchv8dc/sys/dev/lex.c, revision 1.1.1.1

1.1       root        1: #include "lex.h"
                      2: #if NLEX > 0
                      3: 
                      4: /*
                      5:  *      LEXIDATA 3400 DEVICE DRIVER
                      6: */
                      7: 
                      8: #include "../h/param.h"
                      9: #include "../h/dir.h"
                     10: #include "../h/user.h"
                     11: #include "../h/proc.h"
                     12: #include "../h/ioctl.h"
                     13: #include "../h/buf.h"
                     14: #include "../h/systm.h"
                     15: #include "../h/map.h"
                     16: #include "../h/pte.h"
                     17: #include "../h/ubavar.h"
                     18: #include "../h/ubareg.h"
                     19: 
                     20: #define ERROR 0160000
                     21: #define GO 01
                     22: #define IE 0100
                     23: #define READY 0200
                     24: #define ORDY 01000
                     25: #define RESET 04
                     26: #define LOAD 02
                     27: #define TEST 06
                     28: #define SEND 010000
                     29: #define LEXPRI PZERO+1
                     30: #define LXRST 01
                     31: #define LXULD 02
                     32: #define LXWAKE 03
                     33: 
                     34: short cursxy[NLEX] = {29}; /*CURSXY command code*/
                     35: int cursxmax[NLEX] = {640}; /*Max. screen x dimension*/
                     36: int cursymax[NLEX] = {512}; /*Max. screen x dimension*/
                     37: 
                     38: struct lexdevice{
                     39:         short wc;
                     40:         short ba;
                     41:         short cs;
                     42:         short db;
                     43:         };
                     44: 
                     45: struct lexparam{
                     46:         int lex_open;           /*open flag*/
                     47:         struct buf lex_buf;     /*i/o buffer header*/
                     48:         int lex_uba;            /*unibus data path descriptor*/
                     49:         } lexsoft[NLEX];
                     50: 
                     51: int lexprobe(),lexattach();
                     52: 
                     53: struct uba_device *lexinfo[NLEX];
                     54: u_short lexstd[] = {0164100,0164110,0};
                     55: 
                     56: struct uba_driver lexdriver =
                     57:         {lexprobe,0,lexattach,0,lexstd,"lex",lexinfo};
                     58: 
                     59: lexprobe(reg)           /*called by autoconfig(4) - fake an interrupt*/
                     60: caddr_t reg;{
                     61:         register int br,cvec;
                     62:         br=0x15;
                     63:         switch((int)(reg)&070){
                     64:         case 0: cvec=0370; break;
                     65:         case 010: cvec=0364; break;
                     66:                 }
                     67:         return(1);
                     68:         }
                     69: 
                     70: lexattach(ui)           /*driver initialization*/
                     71: struct uba_dev *ui;{
                     72:         }
                     73: 
                     74: lexopen(dev)
                     75: dev_t dev;{
                     76:         register struct lexdevice *lxp;
                     77:         register struct uba_device *ui;
                     78:         register struct lexparam *lexs;
                     79:         if(minor(dev)>=NLEX){
                     80:                 u.u_error=ENXIO;        /*device does not exist*/
                     81:                 return;
                     82:                 }
                     83:         lexs= &lexsoft[minor(dev)];
                     84:         ui=lexinfo[minor(dev)];
                     85:         if((lexs->lex_open)||(ui==0)||(ui->ui_alive==0)){
                     86:                 u.u_error=ENXIO;        /*device already open or not really present*/
                     87:                 return;
                     88:                 }
                     89:         lxp=(struct lexdevice *)(ui->ui_addr);
                     90:         lexs->lex_open++;       /*flag device as open*/
                     91:         lxp->cs=RESET;
                     92:         lxp->db=0;                      /*send START to 3400*/
                     93:         lxp->cs=0;
                     94:         }
                     95: 
                     96: lexclose(dev)
                     97: dev_t dev;{
                     98:         register struct lexdevice *lxp;
                     99:         register struct uba_device *ui;
                    100:         register struct lexparam *lexs;
                    101:         register spri;
                    102:         ui=lexinfo[minor(dev)];
                    103:         lxp=(struct lexdevice *)(ui->ui_addr);
                    104:         lexs= &lexsoft[minor(dev)];
                    105:         spri=spl5();
                    106:         if(lxp->cs&READY==0) tsleep(&lexs->lex_buf,LEXPRI,15);              /*wait for DMA to complete*/
                    107:         splx(spri);
                    108:         if(lexs->lex_uba) ubarelse(ui->ui_ubanum,&lexs->lex_uba);
                    109: 
                    110:         lxp->cs=0;                      /*interrupts off*/
                    111:         lexs->lex_open=lexs->lex_uba=0; /*clear flags*/
                    112:         }
                    113: 
                    114: lexstrategy(bp)
                    115: register struct buf *bp;{
                    116:         register struct lexdevice *lxp;
                    117:         register struct uba_device *ui;
                    118:         register struct lexparam *lexs;
                    119:         register eabits;
                    120:         lexs= &lexsoft[minor(bp->b_dev)];
                    121:         ui=lexinfo[minor(bp->b_dev)];
                    122:         lxp=(struct lexdevice *)(ui->ui_addr);
                    123:         lexs->lex_uba=ubasetup(ui->ui_ubanum,bp,UBA_NEEDBDP);
                    124:         lxp->wc=(short)(-(bp->b_bcount)/2);
                    125:         lxp->ba=(short)(lexs->lex_uba&0xffff);
                    126:         eabits=(lexs->lex_uba>>12)&0x30;
                    127:         spl5();
                    128:         lxp->cs=(short)(IE|GO|((bp->b_flags&B_READ)?0:SEND)|eabits);
                    129:         }
                    130: 
                    131: lexwrite(dev)
                    132: dev_t dev;{
                    133:         physio(lexstrategy,&lexsoft[minor(dev)].lex_buf,dev,B_WRITE,minphys);
                    134:         }
                    135: 
                    136: lexread(dev)
                    137: dev_t dev;{
                    138:         physio(lexstrategy,&lexsoft[minor(dev)].lex_buf,dev,B_READ,minphys);
                    139:         }
                    140: 
                    141: lexintr(dev)
                    142: dev_t dev;{
                    143:         register struct lexdevice *lxp;
                    144:         register struct lexparam *lexs;
                    145:         register struct uba_device *ui;
                    146:         register struct buf *bp;
                    147:         lexs= &lexsoft[minor(dev)];
                    148:         bp= &lexs->lex_buf;
                    149:         ui=lexinfo[minor(dev)];
                    150:         lxp=(struct lexdevice *)(ui->ui_addr);
                    151:         bp->b_flags|=B_DONE;
                    152:         if(lxp->cs&ERROR) bp->b_flags|=B_ERROR;
                    153:         lxp->cs=0;
                    154:         if(lexs->lex_uba) ubarelse(ui->ui_ubanum,&lexs->lex_uba);
                    155:         wakeup(bp);
                    156:         }
                    157: 
                    158: lexioctl(dev,cmd,addr,flag)
                    159: dev_t dev;
                    160: caddr_t addr;{
                    161:         register struct lexdevice *lxp;
                    162:         register struct uba_device *ui;
                    163:         register struct lexparam *lexs;
                    164: int i;
                    165:         ui=lexinfo[minor(dev)];
                    166:         lxp=(struct lexdevice *)(ui->ui_addr);
                    167:         lexs= &lexsoft[minor(dev)];
                    168:         switch(cmd){
                    169:         case LXRST:             /*send reset to display*/
                    170:                 lxp->cs=RESET;
                    171:                 lxp->db=0;
                    172:                 return;
                    173:         case LXULD:             /*load microcode*/
                    174:                 lxp->cs=SEND|LOAD;
                    175:                 lxp->db=0;
                    176:                 return;
                    177:         case LXWAKE:            /*panic-attempt to wakeup*/
                    178:                 printf("waking-up %x\n",&lexs->lex_buf);
                    179:                 printf("flags= %x\n",lexs->lex_buf.b_flags);
                    180:                 lexs->lex_buf.b_flags |= B_DONE;
                    181:                 wakeup(&lexs->lex_buf);
                    182:                 return;
                    183:         default:
                    184:                 u.u_error=EINVAL;
                    185:                 }
                    186:         }
                    187: 
                    188: lexcur(dev,x,y)         /*position cursor - called from bpd driver*/
                    189: dev_t dev;{
                    190:         register struct lexdevice *lxp;
                    191:         register struct uba_device *ui;
                    192:         register i;
                    193:         register struct lexparam *lexs;
                    194:         ui=lexinfo[minor(dev)];
                    195:         lxp=(struct lexdevice *)(ui->ui_addr);
                    196:         lexs= &lexsoft[minor(dev)];
                    197:         if(lexs->lex_open==0) return;
                    198:         if((lxp->cs&READY==0)||(lexs->lex_buf.b_flags&B_BUSY)) return;
                    199:         lxp->cs=SEND;
                    200:         lxp->db=cursxy[minor(dev)];
                    201:         x=(x*cursxmax[minor(dev)])/1024;
                    202:         for(i=1000;((lxp->cs&ORDY)==0)&&i;i--);
                    203:         if(i) lxp->db=(short)x;
                    204:         y=cursymax[minor(dev)]-1-(y*cursymax[minor(dev)])/1024;
                    205:         for(;((lxp->cs&ORDY)==0)&&i;i--);
                    206:         if(i) lxp->db=(short)y;
                    207:         for(;((lxp->cs&ORDY)==0)&&i;i--);
                    208:         if(i==0){
                    209:                 printf("plot cursor timeout\n");
                    210:                 lxp->cs=RESET;
                    211:                 lxp->db=0;
                    212:                 }
                    213:         }
                    214: 
                    215: #endif NLEX

unix.superglobalmegacorp.com

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