scsireq.h 4.6 KB

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