Annotation of researchv10dc/cmd/worm/oscsi/wren/omode.c, revision 1.1

1.1     ! root        1: #include       <stdio.h>
        !             2: #include       "../scsi.h"
        !             3: #include       "../scsish.h"
        !             4: #include       "fns.h"
        !             5: 
        !             6: #define        SHORT(n)        ((ret.data[n]<<8)|(ret.data[n+1]))
        !             7: 
        !             8: static int
        !             9: er(int pcf, char *err)
        !            10: {
        !            11:        struct scsi_cmd cmd;
        !            12:        struct scsi_return ret;
        !            13:        int n;
        !            14:        static char *bit[8] = { "DCR", "DTE", "PER", "EEC", "RC", "TB", "ARRE", "AWRE" };
        !            15: 
        !            16:        set6(cmd, 0x1A, 0, (pcf<<6)|0x01, 0, 20, 0);
        !            17:        if(n = s_io(0, &cmd, 0, &ret, 20, err))
        !            18:                return(n);
        !            19:        printf("error recovery:\n\t");
        !            20:        for(n = 7; n >= 0; n--)
        !            21:                printf(" %s%s", (ret.data[14]&(1<<n))? "":"~", bit[n]);
        !            22:        printf("\n\t%d retries, max ecc span=%d\n", ret.data[15], ret.data[16]);
        !            23:        return(0);
        !            24: }
        !            25: 
        !            26: static int
        !            27: dr(int pcf, char *err)
        !            28: {
        !            29:        struct scsi_cmd cmd;
        !            30:        struct scsi_return ret;
        !            31:        int n;
        !            32: 
        !            33:        set6(cmd, 0x1A, 0, (pcf<<6)|0x02, 0, 24, 0);
        !            34:        if(n = s_io(0, &cmd, 0, &ret, 24, err))
        !            35:                return(n);
        !            36:        printf("disconnect/reconnect:\n");
        !            37:        printf("\tread reconnect=%d/256,", ret.data[14]);
        !            38:        printf(" write reconnect=%d/256\n", ret.data[15]);
        !            39:        return(0);
        !            40: }
        !            41: 
        !            42: static int
        !            43: fp(int pcf, char *err)
        !            44: {
        !            45:        struct scsi_cmd cmd;
        !            46:        struct scsi_return ret;
        !            47:        int n;
        !            48:        static char *bit[8] = { "", "", "", "INS", "SURF", "Remove", "HardSec", "SoftSec" };
        !            49: 
        !            50:        set6(cmd, 0x1A, 0, (pcf<<6)|0x03, 0, 36, 0);
        !            51:        if(n = s_io(0, &cmd, 0, &ret, 36, err))
        !            52:                return(n);
        !            53:        printf("format parameters:\n");
        !            54:        printf("\tsec=%dB, trk=%d secs, interleave=%d trk skew=%d cyl skew=%d\n",
        !            55:                SHORT(24), SHORT(22), SHORT(26), SHORT(28), SHORT(30));
        !            56:        printf("\t%d alt sec/%d alt trk per zone(=%d trks), %d alt trks per vol\n",
        !            57:                SHORT(16), SHORT(18), SHORT(14), SHORT(20));
        !            58:        printf("\tdrive type:");
        !            59:        for(n = 7; n >= 3; n--)
        !            60:                printf(" %s%s", (ret.data[32]&(1<<n))? "":"~", bit[n]);
        !            61:        printf("\n");
        !            62:        return(0);
        !            63: }
        !            64: 
        !            65: static int
        !            66: geom(int pcf, char *err)
        !            67: {
        !            68:        struct scsi_cmd cmd;
        !            69:        struct scsi_return ret;
        !            70:        int n;
        !            71: 
        !            72:        set6(cmd, 0x1A, 0, (pcf<<6)|0x04, 0, 32, 0);
        !            73:        if(n = s_io(0, &cmd, 0, &ret, 32, err))
        !            74:                return(n);
        !            75:        printf("drive geometry:\n\t%d cyls, %d heads\n",
        !            76:                (ret.data[14]<<16)|SHORT(15), ret.data[17]);
        !            77:        return(0);
        !            78: }
        !            79: 
        !            80: static int
        !            81: cc(int pcf, char *err)
        !            82: {
        !            83:        struct scsi_cmd cmd;
        !            84:        struct scsi_return ret;
        !            85:        int n;
        !            86:        static char *bit[8] = { "", "", "", "", "CacheEnable", "RSVD", "WIE", "RSVD" };
        !            87: 
        !            88:        set6(cmd, 0x1A, 0, (pcf<<6)|0x38, 0, 28, 0);
        !            89:        if(n = s_io(0, &cmd, 0, &ret, 28, err))
        !            90:                return(n);
        !            91:        printf("cache control:\n\t");
        !            92:        for(n = 7; n >= 4; n--)
        !            93:                printf(" %s%s", (ret.data[14]&(1<<n))? "":"~", bit[n]);
        !            94:        printf(", cache size=%d\n", ret.data[14]&0xF);
        !            95:        printf("\tprefetch: thr=%d max=%d(mult %d) min=%d(mult %d)\n",
        !            96:                ret.data[15], ret.data[16], ret.data[17], ret.data[18], ret.data[19]);
        !            97:        return(0);
        !            98: }
        !            99: 
        !           100: int
        !           101: wr_modesense(int niargs, int *iargs, int ncargs, char **cargs, char *err)
        !           102: {
        !           103:        int n;
        !           104: 
        !           105: #pragma ref ncargs
        !           106: #pragma ref cargs
        !           107: #pragma ref niargs
        !           108: #pragma ref iargs
        !           109: 
        !           110: #define        PCF     0       /* current values */
        !           111: 
        !           112:        printf("mode sense(%d,0):\n", s_id);
        !           113:        if(n = er(PCF, err))
        !           114:                return(n);
        !           115:        if(n = dr(PCF, err))
        !           116:                return(n);
        !           117:        if(n = fp(PCF, err))
        !           118:                return(n);
        !           119:        if(n = geom(PCF, err))
        !           120:                return(n);
        !           121:        if(n = cc(PCF, err))
        !           122:                return(n);
        !           123:        return(0);
        !           124: }
        !           125: 
        !           126: int
        !           127: wr_modeselect(int niargs, int *iargs, int ncargs, char **cargs, char *err)
        !           128: {
        !           129:        struct scsi_cmd cmd;
        !           130:        struct scsi_return ret;
        !           131:        int n;
        !           132: 
        !           133: #pragma ref niargs
        !           134: #pragma ref ncargs
        !           135: #pragma ref cargs
        !           136: 
        !           137:        printf("changing modes to ");
        !           138:        if((iargs[0] < 256) && (iargs[0] >= 0))
        !           139:                printf("er-param=%d(=#%x), ", iargs[0], iargs[0]);
        !           140:        if((iargs[1] < 256) && (iargs[1] >= 0))
        !           141:                printf("er-retries=%d, ", iargs[1]);
        !           142:        if((iargs[2] < 256) && (iargs[2] >= 0))
        !           143:                printf("read-recon=%d/256, ", iargs[2]);
        !           144:        if((iargs[3] < 256) && (iargs[3] >= 0))
        !           145:                printf("write-recon=%d/256, ", iargs[3]);
        !           146:        if((iargs[4] < 256) && (iargs[4] >= 0))
        !           147:                printf("cache %sable, ", iargs[4]?"en":"dis");
        !           148:        if((iargs[5] < 256) && (iargs[5] >= 0))
        !           149:                printf("cache threshold=%d, ", iargs[5]);
        !           150:        if((iargs[6] < 256) && (iargs[6] >= 0))
        !           151:                printf("cache max prefetch=%d, ", iargs[6]);
        !           152:        if((iargs[7] < 256) && (iargs[7] >= 0))
        !           153:                printf("cache size=%d, ", iargs[7]);
        !           154:        printf("\nsleep(10); kill me if you disagree\n");
        !           155:        fflush(stdout);
        !           156:        sleep(10);
        !           157:        /* do error recovery */
        !           158:        if(((iargs[0] < 256) && (iargs[0] >= 0)) || ((iargs[1] < 256) && (iargs[1] >= 0))){
        !           159:                set6(cmd, 0x1A, 0, (0<<6)|0x01, 0, 20, 0);
        !           160:                if(n = s_io(0, &cmd, 0, &ret, 20, err))
        !           161:                        return(n);
        !           162:                memcpy(cmd.data, ret.data, 20);
        !           163:                cmd.data[14] &= ~0x10;
        !           164:                if((iargs[0] < 256) && (iargs[0] >= 0))
        !           165:                        cmd.data[14] = iargs[0];
        !           166:                if((iargs[1] < 256) && (iargs[1] >= 0))
        !           167:                        cmd.data[15] = iargs[1];
        !           168:                set6(cmd, 0x15, 0x11, 0, 0, 20, 0);
        !           169:                if(n = s_io(0, &cmd, 20, &ret, 0, err))
        !           170:                        return(n);
        !           171:        }
        !           172:        /* reconnect */
        !           173:        if(((iargs[2] < 256) && (iargs[2] >= 0)) || ((iargs[3] < 256) && (iargs[3] >= 0))){
        !           174:                set6(cmd, 0x1A, 0, (0<<6)|0x02, 0, 24, 0);
        !           175:                if(n = s_io(0, &cmd, 0, &ret, 24, err))
        !           176:                        return(n);
        !           177:                memcpy(cmd.data, ret.data, 24);
        !           178:                if((iargs[3] < 256) && (iargs[3] >= 0))
        !           179:                        cmd.data[14] = iargs[3];
        !           180:                if((iargs[4] < 256) && (iargs[4] >= 0))
        !           181:                        cmd.data[15] = iargs[4];
        !           182:                set6(cmd, 0x15, 0x11, 0, 0, 24, 0);
        !           183:                if(n = s_io(0, &cmd, 24, &ret, 0, err))
        !           184:                        return(n);
        !           185:        }
        !           186:        /* do cache control */
        !           187:        if(((iargs[4] < 256) && (iargs[4] >= 0))
        !           188:                        || ((iargs[5] < 256) && (iargs[5] >= 0))
        !           189:                        || ((iargs[6] < 256) && (iargs[6] >= 0))
        !           190:                        || ((iargs[7] < 256) && (iargs[7] >= 0))){
        !           191:                set6(cmd, 0x1A, 0, (0<<6)|0x38, 0, 28, 0);
        !           192:                if(n = s_io(0, &cmd, 0, &ret, 28, err))
        !           193:                        return(n);
        !           194:                memcpy(cmd.data, ret.data, 28);
        !           195:                cmd.data[14] &= ~0x10;
        !           196:                if(iargs[4])
        !           197:                        cmd.data[14] |= 0x10;
        !           198:                if((iargs[7] < 256) && (iargs[7] >= 0)){
        !           199:                        cmd.data[14] &= 0xF0;
        !           200:                        cmd.data[14] |= iargs[7]&0xF;
        !           201:                }
        !           202:                if((iargs[5] < 256) && (iargs[5] >= 0))
        !           203:                        cmd.data[15] = iargs[5];
        !           204:                if((iargs[6] < 256) && (iargs[6] >= 0))
        !           205:                        cmd.data[16] = iargs[6];
        !           206:                set6(cmd, 0x15, 0x11, 0, 0, 28, 0);
        !           207:                if(n = s_io(0, &cmd, 28, &ret, 0, err))
        !           208:                        return(n);
        !           209:        }
        !           210:        return(0);
        !           211: }

unix.superglobalmegacorp.com

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