Annotation of 43BSDTahoe/cci/dr11/dstat.c, revision 1.1.1.1

1.1       root        1: 
                      2: #include <stdio.h>
                      3: #include <sys/types.h>
                      4: #include <sys/buf.h>
                      5: #include <sys/drreg.h>
                      6: #include <sys/ioctl.h>
                      7: 
                      8: struct dr11io drio;
                      9: 
                     10: /*
                     11:  *     usage: dstat [-l] [-t second] [unitno]
                     12: */
                     13: main(argc,argv)
                     14: long argc;
                     15: char *argv[];
                     16: {      register long fd;
                     17:        long loop = 0;
                     18:        long cmd = 0, unit = 0;
                     19:        char *DR11 = "/dev/dr11";
                     20: 
                     21:        fd = open(DR11,2);
                     22:        if (fd == -1) {
                     23:                fprintf(stderr,"\ndstat: cannot open %s, ",DR11);
                     24:                perror("");
                     25:                exit(1);
                     26:        }
                     27:        if (argc > 1) { 
                     28:                if (argc > 5) {
                     29:                        usage();
                     30:                        exit(0);
                     31:                }
                     32:                for (argc--,argv++;argc;argc--, argv++) {
                     33:                        if (argv[0][0]=='-')  {
                     34:                                switch (argv[0][1]) {
                     35:                                        case 'l':
                     36:                                                cmd = 1;   /* lpback test */
                     37:                                                break;
                     38:                                        case 't':
                     39:                                                sscanf(argv[1],"%ld",&loop);
                     40:                                                argc--; argv++;
                     41:                                                break;
                     42:                                        default:
                     43:                                                usage();
                     44:                                                exit(0);
                     45:                                }
                     46:                        }
                     47:                        else {
                     48:                                sscanf(argv[0],"%ld",&unit);
                     49:                        }
                     50:                }
                     51:                drio.arg[0] = unit;
                     52:        }
                     53:        if (cmd)
                     54:                lpback(fd,unit,loop);
                     55:        else
                     56:                stat(fd,unit,loop);
                     57:        close(fd);
                     58: }
                     59: 
                     60: stat(fd,unit,loop)
                     61: register long fd,unit,loop;
                     62: {      register long err;
                     63: 
                     64: again:
                     65:        drio.arg[0] = unit;
                     66:        err = ioctl(fd,DR11STAT,(caddr_t)&drio);
                     67:        if (err) {
                     68:                fprintf(stderr,"\ndstat: cannot ioctl unit %d",unit);
                     69:                perror(" ");
                     70:                exit(0);
                     71:        }
                     72:        prdrio(&drio,unit);
                     73:        if (loop > 0) {
                     74:                sleep(loop);
                     75:                goto again;
                     76:        }
                     77: }
                     78: 
                     79: lpback(fd,unit,loop)
                     80: register long fd,unit,loop;
                     81: {
                     82: 
                     83: lpagain:
                     84:        lptest(fd,unit);
                     85:        if (loop > 0) {
                     86:                sleep(loop);
                     87:                goto lpagain;
                     88:        }
                     89: }
                     90: 
                     91: lptest(fd,unit)
                     92: register long fd,unit;
                     93: {      register long err;
                     94: 
                     95:        drio.arg[0] = unit;
                     96:        err = ioctl(fd,DR11STAT,(caddr_t)&drio);
                     97:        if (err) {
                     98:                fprintf(stderr,"\ndstat: cannot ioctl unit %d",unit);
                     99:                perror(" ");
                    100:                exit(0);
                    101:        }
                    102:        prdrio(&drio,unit);
                    103: 
                    104:        printf("\n ---- Perform loopback test ----");
                    105:        drio.arg[0] = unit;
                    106:        ioctl(fd,DR11LOOP,(caddr_t)&drio);
                    107:        printf("\n Done....");
                    108: 
                    109:        drio.arg[0] = unit;
                    110:        ioctl(fd,DR11STAT,(caddr_t)&drio);
                    111:        prdrio(&drio,unit);
                    112: }
                    113: 
                    114: 
                    115: prdrio(drio,unit)
                    116: struct dr11io *drio;
                    117: long unit;
                    118: {
                    119:        printf("\n\t------------- DR11 unit %ld Status ------------",unit);
                    120:        printf("\n\t  dr_flags  CSR   istat  idata  modvec  dmacnt  hiadr  loadr");
                    121:        printf("\n\t    %04lx    %04lx  %04lx   %04lx   %04lx    %04ld    %04lx   %04lx",
                    122:                drio->arg[0],drio->arg[1],drio->arg[2],drio->arg[3] & 0xffff,
                    123:                drio->arg[4],drio->arg[5],drio->arg[6],drio->arg[7]);
                    124:        printf("\n");
                    125: }
                    126: 
                    127: usage()
                    128: {
                    129:        printf("\nusage: dstat [-l] [unit] [second]");
                    130:        printf("\n\t-l: do loopback test");
                    131:        printf("\n\tunit: controller no");
                    132:        printf("\n\tsecond: interval to perform command");
                    133: }

unix.superglobalmegacorp.com

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