|
|
1.1 root 1: #include <stdio.h>
2: #include "../scsi.h"
3: #include "../scsish.h"
4: #include "fns.h"
5:
6: int
7: wr_modeselect(int niargs, int *iargs, int ncargs, char **cargs, char *err)
8: {
9: struct scsi_cmd cmd;
10: struct scsi_return ret;
11: int n;
12:
13: #pragma ref niargs
14: #pragma ref ncargs
15: #pragma ref cargs
16:
17: printf("changing modes to ");
18: if((iargs[0] < 256) && (iargs[0] >= 0))
19: printf("er-param=%d(=#%x), ", iargs[0], iargs[0]);
20: if((iargs[1] < 256) && (iargs[1] >= 0))
21: printf("er-retries=%d, ", iargs[1]);
22: if((iargs[2] < 256) && (iargs[2] >= 0))
23: printf("read-recon=%d/256, ", iargs[2]);
24: if((iargs[3] < 256) && (iargs[3] >= 0))
25: printf("write-recon=%d/256, ", iargs[3]);
26: if((iargs[4] < 256) && (iargs[4] >= 0))
27: printf("cache %sable, ", iargs[4]?"en":"dis");
28: if((iargs[5] < 256) && (iargs[5] >= 0))
29: printf("cache threshold=%d, ", iargs[5]);
30: if((iargs[6] < 256) && (iargs[6] >= 0))
31: printf("cache max prefetch=%d, ", iargs[6]);
32: if((iargs[7] < 256) && (iargs[7] >= 0))
33: printf("cache size=%d, ", iargs[7]);
34: printf("\nsleep(10); kill me if you disagree\n");
35: fflush(stdout);
36: sleep(10);
37: /* do error recovery */
38: if(((iargs[0] < 256) && (iargs[0] >= 0)) || ((iargs[1] < 256) && (iargs[1] >= 0))){
39: set6(cmd, 0x1A, 0, (0<<6)|0x01, 0, 20, 0);
40: if(n = s_io(0, &cmd, 0, &ret, 20, err))
41: return(n);
42: memcpy(cmd.data, ret.data, 20);
43: cmd.data[14] &= ~0x10;
44: if((iargs[0] < 256) && (iargs[0] >= 0))
45: cmd.data[14] = iargs[0];
46: if((iargs[1] < 256) && (iargs[1] >= 0))
47: cmd.data[15] = iargs[1];
48: set6(cmd, 0x15, 0x11, 0, 0, 20, 0);
49: if(n = s_io(0, &cmd, 20, &ret, 0, err))
50: return(n);
51: }
52: /* reconnect */
53: if(((iargs[2] < 256) && (iargs[2] >= 0)) || ((iargs[3] < 256) && (iargs[3] >= 0))){
54: set6(cmd, 0x1A, 0, (0<<6)|0x02, 0, 24, 0);
55: if(n = s_io(0, &cmd, 0, &ret, 24, err))
56: return(n);
57: memcpy(cmd.data, ret.data, 24);
58: if((iargs[3] < 256) && (iargs[3] >= 0))
59: cmd.data[14] = iargs[3];
60: if((iargs[4] < 256) && (iargs[4] >= 0))
61: cmd.data[15] = iargs[4];
62: set6(cmd, 0x15, 0x11, 0, 0, 24, 0);
63: if(n = s_io(0, &cmd, 24, &ret, 0, err))
64: return(n);
65: }
66: /* do cache control */
67: if(((iargs[4] < 256) && (iargs[4] >= 0))
68: || ((iargs[5] < 256) && (iargs[5] >= 0))
69: || ((iargs[6] < 256) && (iargs[6] >= 0))
70: || ((iargs[7] < 256) && (iargs[7] >= 0))){
71: set6(cmd, 0x1A, 0, (0<<6)|0x38, 0, 28, 0);
72: if(n = s_io(0, &cmd, 0, &ret, 28, err))
73: return(n);
74: memcpy(cmd.data, ret.data, 28);
75: cmd.data[14] &= ~0x10;
76: if(iargs[4])
77: cmd.data[14] |= 0x10;
78: if((iargs[7] < 256) && (iargs[7] >= 0)){
79: cmd.data[14] &= 0xF0;
80: cmd.data[14] |= iargs[7]&0xF;
81: }
82: if((iargs[5] < 256) && (iargs[5] >= 0))
83: cmd.data[15] = iargs[5];
84: if((iargs[6] < 256) && (iargs[6] >= 0))
85: cmd.data[16] = iargs[6];
86: set6(cmd, 0x15, 0x11, 0, 0, 28, 0);
87: if(n = s_io(0, &cmd, 28, &ret, 0, err))
88: return(n);
89: }
90: return(0);
91: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.