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

1.1       root        1: #include "bpd.h"
                      2: #if NBPD > 0
                      3: 
                      4: /*
                      5:  *      BIT-PAD 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: 
                     21: #define RIE 0100
                     22: #define DTR 02
                     23: #define RTS 04
                     24: #define SYNC 0100
                     25: #define DMASK 077
                     26: #define ERROR 060000
                     27: #define CMOD 01
                     28: #define STRM 02
                     29: #define CURON 03
                     30: #define POINT 04
                     31: #define NOPLOT 05
                     32: #define REPLOT 06
                     33: #define SLPRI PZERO+1
                     34: 
                     35: struct bpddevice{
                     36:         short rcs;
                     37:         short rdb;
                     38:         short tcs;
                     39:         short tdb;
                     40:         };
                     41: 
                     42: struct bpdparam{
                     43:         int bpd_x;              /*bitpad x address*/
                     44:         int bpd_y;              /*bitpad y address*/
                     45:         int bpd_cflags;         /*bitpad buttons*/
                     46:         int bpd_tx;             /*temp x address*/
                     47:         int bpd_ty;             /*temp y address*/
                     48:         int bpd_tflags;         /*temp buttons*/
                     49:         int bpd_curx;           /*current x screen cursor*/
                     50:         int bpd_cury;           /*current y screen cursor*/
                     51:         int bpd_bn;             /*byte no. - for sequencing*/
                     52:         int bpd_open;           /*device open flag*/
                     53:         int bpd_stream;         /*stream flag*/
                     54:         int bpd_cursor;         /*cursor enable flag*/
                     55:        int bpd_noplot;         /*noplot mode hack*/
                     56:         int bpd_on;             /*set if bit-pad running*/
                     57:        int bpd_ubad;           /*physical unibus address for dma's*/ 
                     58:         } bpdsoft[NBPD];
                     59: 
                     60: char curs_data[512];           /*buffer for cursor dma transfers*/
                     61: 
                     62: int bpdprobe(),bpdattach();
                     63: 
                     64: struct uba_device *bpdinfo[NBPD];
                     65: u_short bpdstd[]= {0176510,0176520,0};
                     66: 
                     67: struct uba_driver bpddriver =
                     68:         {bpdprobe,0,bpdattach,0,bpdstd,"bpd",bpdinfo};
                     69: 
                     70: bpdprobe(reg)           /*called by autoconfig(4) - fake an interrupt*/
                     71: caddr_t reg;{
                     72:         register int br,cvec;
                     73:         br=0x15;
                     74:         switch((int)(reg)&070){
                     75:         case 010: cvec=0410; break;
                     76:         case 020: cvec=0420; break;
                     77:                 }
                     78:         return(1);
                     79:         }
                     80: 
                     81: bpdattach(ui)           /*driver initialization*/
                     82: struct uba_dev *ui;{
                     83:        
                     84:         }
                     85: 
                     86: bpdopen(dev)
                     87: dev_t dev;{
                     88:         register struct bpddevice *bpp;
                     89:         register struct uba_device *ui;
                     90:         register struct bpdparam *bpds;
                     91:         if(minor(dev)>=NBPD){
                     92:                 u.u_error=ENXIO;        /*device does not exist*/
                     93:                 return;
                     94:                 }
                     95:         bpds= &bpdsoft[minor(dev)];
                     96:         ui=bpdinfo[minor(dev)];
                     97:         if((bpds->bpd_open)||(ui==0)||(ui->ui_alive==0)){
                     98:                 u.u_error=ENXIO;        /*device already open or not really present*/
                     99:                 return;
                    100:                 }
                    101:         bpp=(struct bpddevice *)(ui->ui_addr);
                    102:         bpds->bpd_open++;       /*flag device as open*/
                    103:         bpds->bpd_on++;         /*flag device as on*/
                    104:         bpds->bpd_stream=bpds->bpd_cursor=bpds->bpd_x=bpds->bpd_y=bpds->bpd_cflags=0;
                    105:         bpp->tcs=0;             /*output interrupt off*/
                    106:         bpp->rcs= RTS|DTR;      /*set up modem controls*/
                    107:         bpp->tdb= 'L';          /*set to 35 samples/sec. stream*/
                    108:         bpp->rcs= RIE|DTR|RTS;  /*enable receive interrupts*/
                    109:         }
                    110: 
                    111: bpdclose(dev)
                    112: dev_t dev;{
                    113:         register struct bpddevice *bpp;
                    114:         register struct uba_device *ui;
                    115:         register struct bpdparam *bpds;
                    116:         ui=bpdinfo[minor(dev)];
                    117:         bpp=(struct bpddevice *)(ui->ui_addr);
                    118:         bpds= &bpdsoft[minor(dev)];
                    119:         bpp->rcs= 0;            /*turn interrupts off*/
                    120:         bpds->bpd_stream=bpds->bpd_open=0;
                    121:         }
                    122: 
                    123: bpdintr(dev) dev_t dev;
                    124: {
                    125:  register struct uba_device *ui = bpdinfo[minor(dev)];
                    126:  register struct bpddevice *bpp = (struct bpddevice *)(ui->ui_addr);
                    127:  register struct bpdparam *bpds = &bpdsoft[minor(dev)];
                    128:  int dx, dy;
                    129: 
                    130:     if(bpp->rdb & ERROR)
                    131:       { bpds->bpd_bn= -1;
                    132:        return;
                    133:       }
                    134:     if(bpp->rdb & SYNC) bpds->bpd_bn=1;
                    135:     if(bpds->bpd_bn < 0) return;
                    136:     switch(bpds->bpd_bn)
                    137:       { case 1:        bpds->bpd_tflags = (int)(bpp->rdb&DMASK);
                    138:                break;
                    139:        case 2: bpds->bpd_tx = (int)(bpp->rdb&DMASK);
                    140:                 break;
                    141:         case 3: bpds->bpd_tx += (int)((bpp->rdb&DMASK)<<6);
                    142:                break;
                    143:        case 4: bpds->bpd_ty = (int)(bpp->rdb&DMASK);
                    144:                break;
                    145:         case 5: bpds->bpd_ty += (int)((bpp->rdb&DMASK)<<6);
                    146:                 if(bpds->bpd_tflags != bpds->bpd_cflags) wakeup(bpds);
                    147:                 if((bpds->bpd_cursor)&&(bpds->bpd_on))
                    148:                  { if(bpds->bpd_tx<bpds->bpd_x)
                    149:                        bpds->bpd_curx=(bpds->bpd_tx+1)/2;
                    150:                    else if(bpds->bpd_tx>bpds->bpd_x)
                    151:                        bpds->bpd_curx=(bpds->bpd_tx)/2;
                    152:                    if(bpds->bpd_ty<bpds->bpd_y)
                    153:                        bpds->bpd_cury=(bpds->bpd_ty+1)/2;
                    154:                    else if(bpds->bpd_ty>bpds->bpd_y)
                    155:                        bpds->bpd_cury=(bpds->bpd_ty)/2;
                    156: 
                    157:                    if (!bpds->bpd_noplot)
                    158:                         {
                    159:                                dx = bpds->bpd_x - bpds->bpd_tx;
                    160:                                if(dx < 0) dx = -dx;
                    161:                                dy = bpds->bpd_y - bpds->bpd_ty;
                    162:                                if(dy < 0) dy = -dy;
                    163:                                if(dx > 1 || dy > 1)
                    164:                                        omcur(dev,bpds->bpd_curx,bpds->bpd_cury);
                    165:                          }
                    166:                  }
                    167:                bpds->bpd_x=bpds->bpd_tx;
                    168:                bpds->bpd_y=bpds->bpd_ty;
                    169:                bpds->bpd_cflags=bpds->bpd_tflags;
                    170:                bpds->bpd_bn=0;
                    171:                break;
                    172:       }
                    173:     bpds->bpd_bn++;
                    174: }
                    175: 
                    176: bpdioctl(dev,cmd,addr,flag)
                    177: dev_t dev;
                    178: caddr_t addr;{
                    179:         register struct bpddevice *bpp;
                    180:         register struct uba_device *ui;
                    181:         register struct bpdparam *bpds;
                    182:         char c;
                    183:         ui=bpdinfo[minor(dev)];
                    184:         bpp=(struct bpddevice *)(ui->ui_addr);
                    185:         bpds= &bpdsoft[minor(dev)];
                    186:         switch(cmd){
                    187:         case CMOD:              /*send char. to change mode*/
                    188:                 c=fubyte(addr)&0177;
                    189:                 bpds->bpd_on=(c=='S')?0:1;
                    190:                 bpp->tdb=(short)c;
                    191:                 break;
                    192:         case STRM:              /*put driver into stream mode*/
                    193:                 bpds->bpd_stream=1;
                    194:                 break;
                    195:         case CURON:             /*turn cursor on*/
                    196:                 bpds->bpd_cursor=1;
                    197:                 break;
                    198:         case POINT:             /*turn off stream mode*/
                    199:                 bpds->bpd_stream=0;
                    200:                 break;
                    201:        case NOPLOT:            /*track without plotting on device*/
                    202:                bpds->bpd_noplot=1;
                    203:                break;
                    204:        case REPLOT:
                    205:                bpds->bpd_noplot=0;
                    206:                break;
                    207:                }
                    208:         }
                    209: 
                    210: bpdread(dev)
                    211: dev_t dev;{
                    212:         register struct bpdparam *bpds;
                    213:         register *dp= (int *)(u.u_base);
                    214:         bpds= &bpdsoft[minor(dev)];
                    215:         if(bpds->bpd_stream==0){
                    216:                 while(bpds->bpd_cflags) sleep(bpds,SLPRI);      /*wait for buttons up*/
                    217:                 while(!(bpds->bpd_cflags)) sleep(bpds,SLPRI);   /*wait for button down*/
                    218:                 }
                    219:         suword(dp++,bpds->bpd_x);
                    220:         suword(dp++,bpds->bpd_y);
                    221:         suword(dp,bpds->bpd_cflags);
                    222:         u.u_base=(caddr_t)dp;
                    223:         u.u_count=0;
                    224:         }

unix.superglobalmegacorp.com

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