1 /* this file is also included by usb/disk and cdfs */ 2 typedef struct Umsc Umsc; 3 #pragma incomplete Umsc 4 5 enum { /* fundamental constants/defaults */ 6 NTargetID = 8, /* number of target IDs */ 7 CtlrID = 7, /* default controller target ID */ 8 MaxDirData = 255, /* max. direct data returned */ 9 LBsize = 512, /* default logical-block size */ 10 }; 11 12 typedef struct { 13 uchar *p; 14 long count; 15 uchar write; 16 } ScsiPtr; 17 18 typedef struct { 19 int flags; 20 char *unit; /* unit directory */ 21 int lun; 22 ulong lbsize; 23 ulong offset; /* in blocks of lbsize bytes */ 24 int fd; 25 Umsc *umsc; /* lun */ 26 ScsiPtr cmd; 27 ScsiPtr data; 28 int status; /* returned status */ 29 uchar sense[MaxDirData]; /* returned sense data */ 30 uchar inquiry[MaxDirData]; /* returned inquiry data */ 31 int readblock; /* flag: read a block since open */ 32 } ScsiReq; 33 34 enum { /* software flags */ 35 Fopen = 0x0001, /* open */ 36 Fseqdev = 0x0002, /* sequential-access device */ 37 Fwritten = 0x0004, /* device written */ 38 Fronly = 0x0008, /* device is read-only */ 39 Fwormdev = 0x0010, /* write-once read-multiple device */ 40 Fprintdev = 0x0020, /* printer */ 41 Fbfixed = 0x0040, /* fixed block size */ 42 Fchanger = 0x0080, /* medium-changer device */ 43 Finqok = 0x0100, /* inquiry data is OK */ 44 Fmode6 = 0x0200, /* use 6-byte modeselect */ 45 Frw10 = 0x0400, /* use 10-byte read/write */ 46 Fusb = 0x0800, /* USB transparent scsi */ 47 }; 48 49 enum { 50 STnomem =-4, /* buffer allocation failed */ 51 STharderr =-3, /* controller error of some kind */ 52 STtimeout =-2, /* bus timeout */ 53 STok = 0, /* good */ 54 STcheck = 0x02, /* check condition */ 55 STcondmet = 0x04, /* condition met/good */ 56 STbusy = 0x08, /* busy */ 57 STintok = 0x10, /* intermediate/good */ 58 STintcondmet = 0x14, /* intermediate/condition met/good */ 59 STresconf = 0x18, /* reservation conflict */ 60 STterminated = 0x22, /* command terminated */ 61 STqfull = 0x28, /* queue full */ 62 }; 63 64 enum { /* status */ 65 Status_SD = 0x80, /* sense-data available */ 66 Status_SW = 0x83, /* internal software error */ 67 Status_BADARG = 0x84, /* bad argument to request */ 68 Status_RO = 0x85, /* device is read-only */ 69 }; 70 71 enum { 72 /* sense data byte 0 */ 73 Sd0valid = 0x80, /* valid sense data present */ 74 75 /* sense data byte 2 */ 76 /* incorrect-length indicator, difference in bytes 3—6 */ 77 Sd2ili = 0x20, 78 Sd2eom = 0x40, /* end of medium (tape) */ 79 Sd2filemark = 0x80, /* at a filemark (tape) */ 80 81 /* command byte 1 */ 82 Cmd1fixed = 1, /* use fixed-length blocks */ 83 Cmd1sili = 2, /* don't set Sd2ili */ 84 85 /* limit of block #s in 24-bit ccbs */ 86 Max24off = (1<<21) - 1, /* 2ⁱ - 1 */ 87 88 /* mode pages */ 89 Allmodepages = 0x3F, 90 }; 91 92 /* p arguments should be of type uchar* */ 93 #define GETBELONG(p) ((ulong)(p)[0]<<24 | (ulong)(p)[1]<<16 | (p)[2]<<8 | (p)[3]) 94 #define PUTBELONG(p, ul) ((p)[0] = (ul)>>24, (p)[1] = (ul)>>16, \ 95 (p)[2] = (ul)>>8, (p)[3] = (ul)) 96 #define GETBE24(p) ((ulong)(p)[0]<<16 | (p)[1]<<8 | (p)[2]) 97 #define PUTBE24(p, ul) ((p)[0] = (ul)>>16, (p)[1] = (ul)>>8, (p)[2] = (ul)) 98 99 extern long maxiosize; 100 101 long SRready(ScsiReq*); 102 long SRrewind(ScsiReq*); 103 long SRreqsense(ScsiReq*); 104 long SRformat(ScsiReq*); 105 long SRrblimits(ScsiReq*, uchar*); 106 long SRread(ScsiReq*, void*, long); 107 long SRwrite(ScsiReq*, void*, long); 108 long SRseek(ScsiReq*, long, int); 109 long SRfilemark(ScsiReq*, ulong); 110 long SRspace(ScsiReq*, uchar, long); 111 long SRinquiry(ScsiReq*); 112 long SRmodeselect6(ScsiReq*, uchar*, long); 113 long SRmodeselect10(ScsiReq*, uchar*, long); 114 long SRmodesense6(ScsiReq*, uchar, uchar*, long); 115 long SRmodesense10(ScsiReq*, uchar, uchar*, long); 116 long SRstart(ScsiReq*, uchar); 117 long SRrcapacity(ScsiReq*, uchar*); 118 119 long SRblank(ScsiReq*, uchar, uchar); /* MMC CD-R/CD-RW commands */ 120 long SRsynccache(ScsiReq*); 121 long SRTOC(ScsiReq*, void*, int, uchar, uchar); 122 long SRrdiscinfo(ScsiReq*, void*, int); 123 long SRrtrackinfo(ScsiReq*, void*, int, int); 124 125 long SRcdpause(ScsiReq*, int); /* MMC CD audio commands */ 126 long SRcdstop(ScsiReq*); 127 long SRcdload(ScsiReq*, int, int); 128 long SRcdplay(ScsiReq*, int, long, long); 129 long SRcdstatus(ScsiReq*, uchar*, int); 130 long SRgetconf(ScsiReq*, uchar*, int); 131 132 /* old CD-R/CD-RW commands */ 133 long SRfwaddr(ScsiReq*, uchar, uchar, uchar, uchar*); 134 long SRtreserve(ScsiReq*, long); 135 long SRtinfo(ScsiReq*, uchar, uchar*); 136 long SRwtrack(ScsiReq*, void*, long, uchar, uchar); 137 long SRmload(ScsiReq*, uchar); 138 long SRfixation(ScsiReq*, uchar); 139 140 long SReinitialise(ScsiReq*); /* CHANGER commands */ 141 long SRestatus(ScsiReq*, uchar, uchar*, int); 142 long SRmmove(ScsiReq*, int, int, int, int); 143 144 long SRrequest(ScsiReq*); 145 int SRclose(ScsiReq*); 146 int SRopenraw(ScsiReq*, char*); 147 int SRopen(ScsiReq*, char*); 148 149 void makesense(ScsiReq*); 150 151 long umsrequest(struct Umsc*, ScsiPtr*, ScsiPtr*, int*); 152