usb_scsi.h 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  1. /*
  2. * Apache NuttX
  3. * Copyright 2020 The Apache Software Foundation
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. #ifndef __INCLUDE_NUTTX_SCSI_H
  8. #define __INCLUDE_NUTTX_SCSI_H
  9. /****************************************************************************
  10. * Included Files
  11. ****************************************************************************/
  12. #include <stdint.h>
  13. /****************************************************************************
  14. * Pre-processor Definitions
  15. ****************************************************************************/
  16. /* SCSI commands ************************************************************/
  17. #define SCSI_CMD_TESTUNITREADY 0x00
  18. #define SCSI_CMD_REZEROUNIT 0x01
  19. #define SCSI_CMD_REQUESTSENSE 0x03
  20. #define SCSI_CMD_FORMAT_UNIT 0x04
  21. #define SCSI_CMD_REASSIGNBLOCKS 0x07
  22. #define SCSI_CMD_READ6 0x08
  23. #define SCSI_CMD_WRITE6 0x0a
  24. #define SCSI_CMD_SEEK6 0x0b
  25. #define SCSI_CMD_SPACE6 0x11
  26. #define SCSI_CMD_INQUIRY 0x12
  27. #define SCSI_CMD_MODESELECT6 0x15
  28. #define SCSI_CMD_RESERVE6 0x16
  29. #define SCSI_CMD_RELEASE6 0x17
  30. #define SCSI_CMD_COPY 0x18
  31. #define SCSI_CMD_MODESENSE6 0x1a
  32. #define SCSI_CMD_STARTSTOPUNIT 0x1b
  33. #define SCSI_CMD_RECEIVEDIAGNOSTICRESULTS 0x1c
  34. #define SCSI_CMD_SENDDIAGNOSTIC 0x1d
  35. #define SCSI_CMD_PREVENTMEDIAREMOVAL 0x1e
  36. #define SCSI_CMD_READFORMATCAPACITIES 0x23
  37. #define SCSI_CMD_READCAPACITY10 0x25
  38. #define SCSI_CMD_READ10 0x28
  39. #define SCSI_CMD_WRITE10 0x2a
  40. #define SCSI_CMD_SEEK10 0x2b
  41. #define SCSI_CMD_WRITEANDVERIFY 0x2e
  42. #define SCSI_CMD_VERIFY10 0x2f
  43. #define SCSI_CMD_SEARCHDATAHIGH 0x30
  44. #define SCSI_CMD_SEARCHDATAEQUAL 0x31
  45. #define SCSI_CMD_SEARCHDATALOW 0x32
  46. #define SCSI_CMD_SETLIMITS10 0x33
  47. #define SCSI_CMD_PREFETCH10 0x34
  48. #define SCSI_CMD_SYNCHCACHE10 0x35
  49. #define SCSI_CMD_LOCKCACHE 0x36
  50. #define SCSI_CMD_READDEFECTDATA10 0x37
  51. #define SCSI_CMD_COMPARE 0x39
  52. #define SCSI_CMD_COPYANDVERIFY 0x3a
  53. #define SCSI_CMD_WRITEBUFFER 0x3b
  54. #define SCSI_CMD_READBUFFER 0x3c
  55. #define SCSI_CMD_READLONG10 0x3e
  56. #define SCSI_CMD_WRITELONG10 0x3f
  57. #define SCSI_CMD_CHANGEDEFINITION 0x40
  58. #define SCSI_CMD_WRITESAME10 0x41
  59. #define SCSI_CMD_LOGSELECT 0x4c
  60. #define SCSI_CMD_LOGSENSE 0x4d
  61. #define SCSI_CMD_XDWRITE10 0x50
  62. #define SCSI_CMD_XPWRITE10 0x51
  63. #define SCSI_CMD_XDREAD10 0x52
  64. #define SCSI_CMD_MODESELECT10 0x55
  65. #define SCSI_CMD_RESERVE10 0x56
  66. #define SCSI_CMD_RELEASE10 0x57
  67. #define SCSI_CMD_MODESENSE10 0x5a
  68. #define SCSI_CMD_PERSISTENTRESERVEIN 0x5e
  69. #define SCSI_CMD_PERSISTENTRESERVEOUT 0x5f
  70. #define SCSI_CMD_32 0x7f
  71. #define SCSI_CMD_XDWRITEEXTENDED 0x80
  72. #define SCSI_CMD_REBUILD 0x82
  73. #define SCSI_CMD_REGENERATE 0x82
  74. #define SCSI_CMD_EXTENDEDCOPY 0x83
  75. #define SCSI_CMD_COPYRESULTS 0x84
  76. #define SCSI_CMD_ACCESSCONTROLIN 0x86
  77. #define SCSI_CMD_ACCESSCONTROLOUT 0x87
  78. #define SCSI_CMD_READ16 0x88
  79. #define SCSI_CMD_WRITE16 0x8a
  80. #define SCSI_CMD_READATTRIBUTE 0x8c
  81. #define SCSI_CMD_WRITEATTRIBUTE 0x8d
  82. #define SCSI_CMD_WRITEANDVERIFY16 0x8e
  83. #define SCSI_CMD_PREFETCH16 0x90
  84. #define SCSI_CMD_SYNCHCACHE16 0x91
  85. #define SCSI_CMD_LOCKUNLOCKACACHE 0x92
  86. #define SCSI_CMD_WRITESAME16 0x93
  87. #define SCSI_CMD_READCAPACITY16 0x9e
  88. #define SCSI_CMD_READLONG16 0x9e
  89. #define SCSI_CMD_WRITELONG106 0x9f
  90. #define SCSI_CMD_REPORTLUNS 0xa0
  91. #define SCSI_CMD_MAINTENANCEIN 0xa3
  92. #define SCSI_CMD_MAINTENANCEOUT 0xa4
  93. #define SCSI_CMD_MOVEMEDIUM 0xa5
  94. #define SCSI_CMD_MOVEMEDIUMATTACHED 0xa7
  95. #define SCSI_CMD_READ12 0xa8
  96. #define SCSI_CMD_WRITE12 0xaa
  97. #define SCSI_CMD_READMEDIASERIALNUMBER 0xab
  98. #define SCSI_CMD_WRITEANDVERIFY12 0xae
  99. #define SCSI_CMD_VERIFY12 0xaf
  100. #define SCSI_CMD_SETLIMITS12 0xb3
  101. #define SCSI_CMD_READELEMENTSTATUS 0xb4
  102. #define SCSI_CMD_READDEFECTDATA12 0xb7
  103. #define SCSI_CMD_REDUNDANCYGROUPIN 0xba
  104. #define SCSI_CMD_REDUNDANCYGROUPOUT 0xbb
  105. #define SCSI_CMD_SPAREIN 0xbc
  106. #define SCSI_CMD_SPAREOUT 0xbd
  107. #define SCSI_CMD_VOLUMESETIN 0xbe
  108. #define SCSI_CMD_VOLUMESETOUT 0xbf
  109. /* Common SCSI KCQ values (sense Key/additional sense Code/ASC Qualifier) ***
  110. *
  111. * 0xnn0386 Write Fault Data Corruption
  112. * 0xnn0500 Illegal request
  113. * 0xnn0600 Unit attention
  114. * 0xnn0700 Data protect
  115. * 0xnn0800 LUN communication failure
  116. * 0xnn0801 LUN communication timeout
  117. * 0xnn0802 LUN communication parity error
  118. * 0xnn0803 LUN communication CRC error
  119. * 0xnn0900 vendor specific sense key
  120. * 0xnn0901 servo fault
  121. * 0xnn0904 head select fault
  122. * 0xnn0a00 error log overflow
  123. * 0xnn0b00 aborted command
  124. * 0xnn0c00 write error
  125. * 0xnn0c02 write error - auto-realloc failed
  126. * 0xnn0e00 data miscompare
  127. * 0xnn1200 address mark not founf for ID field
  128. * 0xnn1400 logical block not found
  129. * 0xnn1500 random positioning error
  130. * 0xnn1501 mechanical positioning error
  131. * 0xnn1502 positioning error detected by read of medium
  132. * 0xnn2700 write protected
  133. * 0xnn2900 POR or bus reset occurred
  134. * 0xnn3101 format failed
  135. * 0xnn3191 format corrupted
  136. * 0xnn3201 defect list update error
  137. * 0xnn3202 no spares available
  138. * 0xnn3501 unspecified enclosure services failure
  139. * 0xnn3700 parameter rounded
  140. * 0xnn3d00 invalid bits in identify message
  141. * 0xnn3e00 LUN not self-configured yet
  142. * 0xnn4001 DRAM parity error
  143. * 0xnn4002 DRAM parity error
  144. * 0xnn4200 power-on or self-test failure
  145. * 0xnn4c00 LUN failed self-configuration
  146. * 0xnn5c00 RPL status change
  147. * 0xnn5c01 spindles synchronized
  148. * 0xnn5c02 spindles not synchronized
  149. * 0xnn6500 voltage fault
  150. * 0xnn8000 general firmware error
  151. */
  152. /* No sense KCQ values */
  153. #define SCSI_KCQ_NOSENSE 0x000000 /* No error */
  154. #define SCSI_KCQ_PFATHRESHOLDREACHED 0x005c00 /* No sense - PFA threshold reached */
  155. /* Soft error KCQ values */
  156. #define SCSI_KCQSE_RWENOINDEX 0x010100 /* Recovered Write error - no index */
  157. #define SCSI_KCQSE_RECOVEREDNOSEEKCOMPLETION 0x010200 /* Recovered no seek completion */
  158. #define SCSI_KCQSE_RWEWRITEFAULT 0x010300 /* Recovered Write error - write fault */
  159. #define SCSI_KCQSE_TRACKFOLLOWINGERROR 0x010900 /* Track following error */
  160. #define SCSI_KCQSE_TEMPERATUREWARNING 0x010b01 /* Temperature warning */
  161. #define SCSI_KCQSE_RWEWARREALLOCATED 0x010c01 /* Recovered Write error with auto-realloc - reallocated */
  162. #define SCSI_KCQSE_RWERECOMMENDREASSIGN 0x010c03 /* Recovered Write error - recommend reassign */
  163. #define SCSI_KCQSE_RDWOEUSINGPREVLBI 0x011201 /* Recovered data without ECC using prev logical block ID */
  164. #define SCSI_KCQSE_RDWEUSINGPREVLBI 0x011202 /* Recovered data with ECC using prev logical block ID */
  165. #define SCSI_KCQSE_RECOVEREDRECORDNOTFOUND 0x011401 /* Recovered Record Not Found */
  166. #define SCSI_KCQSE_RWEDSME 0x011600 /* Recovered Write error - Data Sync Mark Error */
  167. #define SCSI_KCQSE_RWEDSEDATAREWRITTEN 0x011601 /* Recovered Write error - Data Sync Error - data rewritten */
  168. #define SCSI_KCQSE_RWEDSERECOMMENDREWRITE 0x011602 /* Recovered Write error - Data Sync Error - recommend rewrite */
  169. #define SCSI_KCQSE_RWEDSEDATAAUTOREALLOCATED 0x011603 /* Recovered Write error - Data Sync Error - data auto-reallocated */
  170. #define SCSI_KCQSE_RWEDSERECOMMENDREASSIGNMENT 0x011604 /* Recovered Write error - Data Sync Error - recommend reassignment */
  171. #define SCSI_KCQSE_RDWNECORRECTIONAPPLIED 0x011700 /* Recovered data with no error correction applied */
  172. #define SCSI_KCQSE_RREWITHRETRIES 0x011701 /* Recovered Read error - with retries */
  173. #define SCSI_KCQSE_RDUSINGPOSITIVEOFFSET 0x011702 /* Recovered data using positive offset */
  174. #define SCSI_KCQSE_RDUSINGNEGATIVEOFFSET 0x011703 /* Recovered data using negative offset */
  175. #define SCSI_KCQSE_RDUSINGPREVIOUSLBI 0x011705 /* Recovered data using previous logical block ID */
  176. #define SCSI_KCQSE_RREWOEAUTOREALLOCATED 0x011706 /* Recovered Read error - without ECC, auto reallocated */
  177. #define SCSI_KCQSE_RREWOERECOMMENDREASSIGN 0x011707 /* Recovered Read error - without ECC, recommend reassign */
  178. #define SCSI_KCQSE_RREWOERECOMMENDREWRITE 0x011708 /* Recovered Read error - without ECC, recommend rewrite */
  179. #define SCSI_KCQSE_RREWOEDATAREWRITTEN 0x011709 /* Recovered Read error - without ECC, data rewritten */
  180. #define SCSI_KCQSE_RREWE 0x011800 /* Recovered Read error - with ECC */
  181. #define SCSI_KCQSE_RDWEANDRETRIES 0x011801 /* Recovered data with ECC and retries */
  182. #define SCSI_KCQSE_RREWEAUTOREALLOCATED 0x011802 /* Recovered Read error - with ECC, auto reallocated */
  183. #define SCSI_KCQSE_RREWERECOMMENDREASSIGN 0x011805 /* Recovered Read error - with ECC, recommend reassign */
  184. #define SCSI_KCQSE_RDUSINGECCANDOFFSETS 0x011806 /* Recovered data using ECC and offsets */
  185. #define SCSI_KCQSE_RREWEDATAREWRITTEN 0x011807 /* Recovered Read error - with ECC, data rewritten */
  186. #define SCSI_KCQSE_DLNOTFOUND 0x011c00 /* Defect List not found */
  187. #define SCSI_KCQSE_PRIMARYDLNOTFOUND 0x011c01 /* Primary defect list not found */
  188. #define SCSI_KCQSE_GROWNDLNOTFOUND 0x011c02 /* Grown defect list not found */
  189. #define SCSI_KCQSE_PARTIALDLTRANSFERRED 0x011f00 /* Partial defect list transferred */
  190. #define SCSI_KCQSE_INTERNALTARGETFAILURE 0x014400 /* Internal target failure */
  191. #define SCSI_KCQSE_PFATHRESHOLDREACHED 0x015d00 /* PFA threshold reached */
  192. #define SCSI_KCQSE_PFATESTWARNING 0x015dff /* PFA test warning */
  193. #define SCSI_KCQSE_INTERNALLOGICFAILURE 0x018100 /* Internal logic failure */
  194. /* Not Ready / Diagnostic Failure KCQ values */
  195. #define SCSI_KCQNR_CAUSENOTREPORTABLE 0x020400 /* Not Ready - Cause not reportable. */
  196. #define SCSI_KCQNR_BECOMINGREADY 0x020401 /* Not Ready - becoming ready */
  197. #define SCSI_KCQNR_NEEDINITIALIZECOMMAND 0x020402 /* Not Ready - need initialize command (start unit) */
  198. #define SCSI_KCQNR_MANUALINTERVENTIONREQUIRED 0x020403 /* Not Ready - manual intervention required */
  199. #define SCSI_KCQNR_FORMATINPROGRESS 0x020404 /* Not Ready - format in progress */
  200. #define SCSI_KCQNR_SELFTESTINPROGRESS 0x020409 /* Not Ready - self-test in progress */
  201. #define SCSI_KCQNR_MEDIUMFORMATCORRUPTED 0x023100 /* Not Ready - medium format corrupted */
  202. #define SCSI_KCQNR_FORMATCOMMANDFAILED 0x023101 /* Not Ready - format command failed */
  203. #define SCSI_KCQNR_ESUNAVAILABLE 0x023502 /* Not Ready - enclosure services unavailable */
  204. #define SCSI_KCQNR_MEDIANOTPRESENT 0x023a00 /* Not Ready - media not present */
  205. #define SCSI_KCQDF_BRINGUPFAILORDEGRADEDMODE 0x024080 /* Diagnostic Failure - bring-up fail or degraded mode */
  206. #define SCSI_KCQDF_HARDDISKCONTROLLER 0x024081 /* Diagnostic Failure - Hard Disk Controller */
  207. #define SCSI_KCQDF_RAMMICROCODENOTLOADED 0x024085 /* Diagnostic Failure - RAM microcode not loaded */
  208. #define SCSI_KCQDF_RROCALIBRATION 0x024090 /* Diagnostic Failure - RRO Calibration */
  209. #define SCSI_KCQDF_CHANNELCALIBRATION 0x024091 /* Diagnostic Failure - Channel Calibration */
  210. #define SCSI_KCQDF_HEADLOAD 0x024092 /* Diagnostic Failure - Head Load */
  211. #define SCSI_KCQDF_WRITEAE 0x024093 /* Diagnostic Failure - Write AE */
  212. #define SCSI_KCQDF_12VOVERCURRENT 0x024094 /* Diagnostic Failure - 12V over current */
  213. #define SCSI_KCQDF_OTHERSPINDLEFAILURE 0x024095 /* Diagnostic Failure - Other spindle failure */
  214. #define SCSI_KCQDF_SELFRESET 0x0240b0 /* Diagnostic Failure - self-reset */
  215. #define SCSI_KCQDF_CONFIGNOTLOADED 0x024c00 /* Diagnostic Failure - config not loaded */
  216. /* Medium error KCQ values */
  217. #define SCSI_KCQME_WRITEFAULT 0x030300 /* Medium Error - write fault */
  218. #define SCSI_KCQME_WRITEFAULTAUTOREALLOCFAILED 0x030c02 /* Medium Error - write error - auto-realloc failed */
  219. #define SCSI_KCQME_WRITERTLIMITEXCEEDED 0x030cbb /* Medium Error - write recovery time limit exceeded */
  220. #define SCSI_KCQME_IDCRCERROR 0x031000 /* Medium Error - ID CRC error */
  221. #define SCSI_KCQME_UNRRE1 0x031100 /* Medium Error - unrecovered read error */
  222. #define SCSI_KCQME_READRETRIESEXHAUSTED 0x031101 /* Medium Error - read retries exhausted */
  223. #define SCSI_KCQME_ERRORTOOLONGTOCORRECT 0x031102 /* Medium Error - error too long to correct */
  224. #define SCSI_KCQME_UREAUTOREALLOCFAILED 0x031104 /* Medium Error - unrecovered read error - auto re-alloc failed */
  225. #define SCSI_KCQME_URERECOMMENDREASSIGN 0x03110b /* Medium Error - unrecovered read error - recommend reassign */
  226. #define SCSI_KCQME_READRTLIMITEXCEEDED 0x0311ff /* Medium Error - read recovery time limit exceeded */
  227. #define SCSI_KCQME_RECORDNOTFOUND 0x031401 /* Medium Error - record not found */
  228. #define SCSI_KCQME_DSME 0x031600 /* Medium Error - Data Sync Mark error */
  229. #define SCSI_KCQME_DSERECOMMENDREASSIGN 0x031604 /* Medium Error - Data Sync Error - recommend reassign */
  230. #define SCSI_KCQME_DLE 0x031900 /* Medium Error - defect list error */
  231. #define SCSI_KCQME_DLNOTAVAILABLE 0x031901 /* Medium Error - defect list not available */
  232. #define SCSI_KCQME_DLEINPRIMARYLIST 0x031902 /* Medium Error - defect list error in primary list */
  233. #define SCSI_KCQME_DLEINGROWNLIST 0x031903 /* Medium Error - defect list error in grown list */
  234. #define SCSI_KCQME_FEWERTHAN50PCTDLCOPIES 0x03190e /* Medium Error - fewer than 50% defect list copies */
  235. #define SCSI_KCQME_MEDIUMFORMATCORRUPTED 0x033100 /* Medium Error - medium format corrupted */
  236. #define SCSI_KCQME_FORMATCOMMANDFAILED 0x033101 /* Medium Error - format command failed */
  237. #define SCSI_KCQME_DATAAUTOREALLOCATED 0x038000 /* Medium Error - data auto-reallocated */
  238. /* Hardware Error KCQ values */
  239. #define SCSI_KCQHE_NOINDEXORSECTOR 0x040100 /* Hardware Error - no index or sector */
  240. #define SCSI_KCQHE_NOSEEKCOMPLETE 0x040200 /* Hardware Error - no seek complete */
  241. #define SCSI_KCQHE_WRITEFAULT 0x040300 /* Hardware Error - write fault */
  242. #define SCSI_KCQHE_COMMUNICATIONFAILURE 0x040800 /* Hardware Error - communication failure */
  243. #define SCSI_KCQHE_TRACKFOLLOWINGERROR 0x040900 /* Hardware Error - track following error */
  244. #define SCSI_KCQHE_UREINRESERVEDAREA 0x041100 /* Hardware Error - unrecovered read error in reserved area */
  245. #define SCSI_KCQHE_DSMEINRESERVEDAREA 0x041600 /* Hardware Error - Data Sync Mark error in reserved area */
  246. #define SCSI_KCQHE_DLE 0x041900 /* Hardware Error - defect list error */
  247. #define SCSI_KCQHE_DLEINPRIMARYLIST 0x041902 /* Hardware Error - defect list error in Primary List */
  248. #define SCSI_KCQHE_DLEINGROWNLIST 0x041903 /* Hardware Error - defect list error in Grown List */
  249. #define SCSI_KCQHE_REASSIGNFAILED 0x043100 /* Hardware Error - reassign failed */
  250. #define SCSI_KCQHE_NODEFECTSPAREAVAILABLE 0x043200 /* Hardware Error - no defect spare available */
  251. #define SCSI_KCQHE_UNSUPPORTEDENCLOSUREFUNCTION 0x043501 /* Hardware Error - unsupported enclosure function */
  252. #define SCSI_KCQHE_ESUNAVAILABLE 0x043502 /* Hardware Error - enclosure services unavailable */
  253. #define SCSI_KCQHE_ESTRANSFERFAILURE 0x043503 /* Hardware Error - enclosure services transfer failure */
  254. #define SCSI_KCQHE_ESREFUSED 0x043504 /* Hardware Error - enclosure services refused */
  255. #define SCSI_KCQHE_SELFTESTFAILED 0x043e03 /* Hardware Error - self-test failed */
  256. #define SCSI_KCQHE_UNABLETOUPDATESELFTEST 0x043e04 /* Hardware Error - unable to update self-test */
  257. #define SCSI_KCQHE_DMDIAGNOSTICFAIL 0x044080 /* Hardware Error - Degrade Mode. Diagnostic Fail */
  258. #define SCSI_KCQHE_DMHWERROR 0x044081 /* Hardware Error - Degrade Mode. H/W Error */
  259. #define SCSI_KCQHE_DMRAMMICROCODENOTLOADED 0x044085 /* Hardware Error - Degrade Mode. RAM microcode not loaded */
  260. #define SCSI_KCQHE_SEEKTESTFAILURE 0x044090 /* Hardware Error - seek test failure */
  261. #define SCSI_KCQHE_READWRITETESTFAILURE 0x0440a0 /* Hardware Error - read/write test failure */
  262. #define SCSI_KCQHE_DEVICESELFRESET 0x0440b0 /* Hardware Error - device self-reset */
  263. #define SCSI_KCQHE_COMPONENTMISMATCH 0x0440d0 /* Hardware Error - component mismatch */
  264. #define SCSI_KCQHE_INTERNALTARGETFAILURE 0x044400 /* Hardware Error - internal target failure */
  265. #define SCSI_KCQHE_INTERNALLOGICERROR 0x048100 /* Hardware Error - internal logic error */
  266. #define SCSI_KCQHE_COMMANDTIMEOUT 0x048200 /* Hardware Error - command timeout */
  267. /* Illegal Request KCQ values */
  268. #define SCSI_KCQIR_PARMLISTLENGTHERROR 0x051a00 /* Illegal Request - parm list length error */
  269. #define SCSI_KCQIR_INVALIDCOMMAND 0x052000 /* Illegal Request - invalid/unsupported command code */
  270. #define SCSI_KCQIR_LBAOUTOFRANGE 0x052100 /* Illegal Request - LBA out of range */
  271. #define SCSI_KCQIR_INVALIDFIELDINCBA 0x052400 /* Illegal Request - invalid field in CDB (Command Descriptor Block) */
  272. #define SCSI_KCQIR_INVALIDLUN 0x052500 /* Illegal Request - invalid LUN */
  273. #define SCSI_KCQIR_INVALIDFIELDSINPARMLIST 0x052600 /* Illegal Request - invalid fields in parm list */
  274. #define SCSI_KCQIR_PARAMETERNOTSUPPORTED 0x052601 /* Illegal Request - parameter not supported */
  275. #define SCSI_KCQIR_INVALIDPARMVALUE 0x052602 /* Illegal Request - invalid parm value */
  276. #define SCSI_KCQIR_IFPTHRESHOLDPARAMETER 0x052603 /* Illegal Request - invalid field parameter - threshold parameter */
  277. #define SCSI_KCQIR_INVALIDRELEASEOFPR 0x052604 /* Illegal Request - invalid release of persistent reservation */
  278. #define SCSI_KCQIR_IFPTMSFIRMWARETAG 0x052697 /* Illegal Request - invalid field parameter - TMS firmware tag */
  279. #define SCSI_KCQIR_IFPCHECKSUM 0x052698 /* Illegal Request - invalid field parameter - check sum */
  280. #define SCSI_KCQIR_IFPFIRMWARETAG 0x052699 /* Illegal Request - invalid field parameter - firmware tag */
  281. #define SCSI_KCQIR_COMMANDSEQUENCEERROR 0x052c00 /* Illegal Request - command sequence error */
  282. #define SCSI_KCQIR_UNSUPPORTEDENCLOSUREFUNCTION 0x053501 /* Illegal Request - unsupported enclosure function */
  283. #define SCSI_KCQIR_SAVINGPARMSNOTSUPPORTED 0x053900 /* Illegal Request - Saving parameters not supported */
  284. #define SCSI_KCQIR_INVALIDMESSAGE 0x054900 /* Illegal Request - invalid message */
  285. #define SCSI_KCQIR_MEDIALOADOREJECTFAILED 0x055300 /* Illegal Request - media load or eject failed */
  286. #define SCSI_KCQIR_UNLOADTAPEFAILURE 0x055301 /* Illegal Request - unload tape failure */
  287. #define SCSI_KCQIR_MEDIUMREMOVALPREVENTED 0x055302 /* Illegal Request - medium removal prevented */
  288. #define SCSI_KCQIR_SYSTEMRESOURCEFAILURE 0x055500 /* Illegal Request - system resource failure */
  289. #define SCSI_KCQIR_SYSTEMBUFFERFULL 0x055501 /* Illegal Request - system buffer full */
  290. #define SCSI_KCQIR_INSUFFICIENTRR 0x055504 /* Illegal Request - Insufficient Registration Resources */
  291. /* Unit Attention KCQ values */
  292. #define SCSI_KCQUA_NOTREADYTOTRANSITION 0x062800 /* Unit Attention - not-ready to ready transition (format complete) */
  293. #define SCSI_KCQUA_DEVICERESETOCCURRED 0x062900 /* Unit Attention - POR or device reset occurred */
  294. #define SCSI_KCQUA_POROCCURRED 0x062901 /* Unit Attention - POR occurred */
  295. #define SCSI_KCQUA_SCSIBUSRESETOCCURRED 0x062902 /* Unit Attention - SCSI bus reset occurred */
  296. #define SCSI_KCQUA_TARGETRESETOCCURRED 0x062903 /* Unit Attention - TARGET RESET occurred */
  297. #define SCSI_KCQUA_SELFINITIATEDRESETOCCURRED 0x062904 /* Unit Attention - self-initiated-reset occurred */
  298. #define SCSI_KCQUA_TRANSCEIVERMODECHANGETOSE 0x062905 /* Unit Attention - transceiver mode change to SE */
  299. #define SCSI_KCQUA_TRANSCEIVERMODECHANGETOLVD 0x062906 /* Unit Attention - transceiver mode change to LVD */
  300. #define SCSI_KCQUA_PARAMETERSCHANGED 0x062a00 /* Unit Attention - parameters changed */
  301. #define SCSI_KCQUA_MODEPARAMETERSCHANGED 0x062a01 /* Unit Attention - mode parameters changed */
  302. #define SCSI_KCQUA_LOGSELECTPARMSCHANGED 0x062a02 /* Unit Attention - log select parms changed */
  303. #define SCSI_KCQUA_RESERVATIONSPREEMPTED 0x062a03 /* Unit Attention - Reservations pre-empted */
  304. #define SCSI_KCQUA_RESERVATIONSRELEASED 0x062a04 /* Unit Attention - Reservations released */
  305. #define SCSI_KCQUA_REGISTRATIONSPREEMPTED 0x062a05 /* Unit Attention - Registrations pre-empted */
  306. #define SCSI_KCQUA_COMMANDSCLEARED 0x062f00 /* Unit Attention - commands cleared by another initiator */
  307. #define SCSI_KCQUA_OPERATINGCONDITIONSCHANGED 0x063f00 /* Unit Attention - target operating conditions have changed */
  308. #define SCSI_KCQUA_MICROCODECHANGED 0x063f01 /* Unit Attention - microcode changed */
  309. #define SCSI_KCQUA_CHANGEDOPERATINGDEFINITION 0x063f02 /* Unit Attention - changed operating definition */
  310. #define SCSI_KCQUA_INQUIRYPARAMETERSCHANGED 0x063f03 /* Unit Attention - inquiry parameters changed */
  311. #define SCSI_KCQUA_DEVICEIDENTIFIERCHANGED 0x063f05 /* Unit Attention - device identifier changed */
  312. #define SCSI_KCQUA_INVALIDAPMPARAMETERS 0x063f90 /* Unit Attention - invalid APM parameters */
  313. #define SCSI_KCQUA_WORLDWIDENAMEMISMATCH 0x063f91 /* Unit Attention - world-wide name mismatch */
  314. #define SCSI_KCQUA_PFATHRESHOLDREACHED 0x065d00 /* Unit Attention - PFA threshold reached */
  315. #define SCSI_KCQUA_PFATHRESHOLDEXCEEDED 0x065dff /* Unit Attention - PFA threshold exceeded */
  316. /* Write Protect KCQ values */
  317. #define SCSI_KCQWP_COMMANDNOTALLOWED 0x072700 /* Write Protect - command not allowed */
  318. /* Aborted Command KCQ values */
  319. #define SCSI_KCQAC_NOADDITIONALSENSECODE 0x0b0000 /* Aborted Command - no additional sense code */
  320. #define SCSI_KCQAC_SYNCDATATRANSFERERROR 0x0b1b00 /* Aborted Command - sync data transfer error (extra ACK) */
  321. #define SCSI_KCQAC_UNSUPPORTEDLUN 0x0b2500 /* Aborted Command - unsupported LUN */
  322. #define SCSI_KCQAC_ECHOBUFFEROVERWRITTEN 0x0b3f0f /* Aborted Command - echo buffer overwritten */
  323. #define SCSI_KCQAC_MESSAGEREJECTERROR 0x0b4300 /* Aborted Command - message reject error */
  324. #define SCSI_KCQAC_INTERNALTARGETFAILURE 0x0b4400 /* Aborted Command - internal target failure */
  325. #define SCSI_KCQAC_SELECTIONFAILURE 0x0b4500 /* Aborted Command - Selection/Reselection failure */
  326. #define SCSI_KCQAC_SCSIPARITYERROR 0x0b4700 /* Aborted Command - SCSI parity error */
  327. #define SCSI_KCQAC_INITIATORDETECTEDERRORECEIVED 0x0b4800 /* Aborted Command - initiator-detected error message received */
  328. #define SCSI_KCQAC_ILLEGALMESSAGE 0x0b4900 /* Aborted Command - inappropriate/illegal message */
  329. #define SCSI_KCQAC_DATAPHASEERROR 0x0b4b00 /* Aborted Command - data phase error */
  330. #define SCSI_KCQAC_OVERLAPPEDCOMMANDSATTEMPTED 0x0b4e00 /* Aborted Command - overlapped commands attempted */
  331. #define SCSI_KCQAC_LOOPINITIALIZATION 0x0b4f00 /* Aborted Command - due to loop initialization */
  332. /* Other KCQ values: */
  333. #define SCSO_KCQOTHER_MISCOMPARE 0x0e1d00 /* Miscompare - during verify byte check operation */
  334. /* SSCSI Status Codes *******************************************************/
  335. #define SCSI_STATUS_OK 0x00 /* OK */
  336. #define SCSI_STATUS_CHECKCONDITION 0x02 /* Check condition */
  337. #define SCSI_STATUS_CONDITIONMET 0x04 /* Condition met */
  338. #define SCSI_STATUS_BUSY 0x08 /* Busy */
  339. #define SCSI_STATUS_INTERMEDIATE 0x10 /* Intermediate */
  340. #define SCSI_STATUS_DATAOVERUNDERRUN 0x12 /* Data Under/Over Run? */
  341. #define SCSI_STATUS_INTERMEDIATECONDITIONMET 0x14 /* Intermediate - Condition met */
  342. #define SCSI_STATUS_RESERVATIONCONFLICT 0x18 /* Reservation conflict */
  343. #define SCSI_STATUS_COMMANDTERMINATED 0x22 /* Command terminated */
  344. #define SCSI_STATUS_QUEUEFULL 0x28 /* Queue (task set) full */
  345. #define SCSI_STATUS_ACAACTIVE 0x30 /* ACA active */
  346. #define SCSI_STATUS_TASKABORTED 0x40 /* Task aborted */
  347. /* Definitions for selected SCSI commands ***********************************/
  348. /* Inquiry */
  349. #define SCSICMD_INQUIRYFLAGS_EVPD 0x01 /* Bit 0: EVPD */
  350. /* Bits 5-7: Peripheral Qualifier */
  351. #define SCSIRESP_INQUIRYPQ_CONNECTED 0x00 /* 000: Device is connected */
  352. #define SCSIRESP_INQUIRYPQ_NOTCONNECTED 0x20 /* 001: Device is NOT connected */
  353. #define SCSIRESP_INQUIRYPQ_NOTCAPABLE 0x60 /* 011: LUN not supported */
  354. /* Bits 0-4: Peripheral Device */
  355. #define SCSIRESP_INQUIRYPD_DIRECTACCESS 0x00 /* Direct-access block device */
  356. #define SCSIRESP_INQUIRYPD_SEQUENTIALACCESS 0x01 /* Sequential-access block device */
  357. #define SCSIRESP_INQUIRYPD_PRINTER 0x02 /* Printer device */
  358. #define SCSIRESP_INQUIRYPD_PROCESSOR 0x03 /* Processor device */
  359. #define SCSIRESP_INQUIRYPD_WRONCE 0x04 /* Write once device */
  360. #define SCSIRESP_INQUIRYPD_CDDVD 0x05 /* CD/DVD device */
  361. #define SCSIRESP_INQUIRYPD_SCANNER 0x06 /* Scanner device (obsolete) */
  362. #define SCSIRESP_INQUIRYPD_OPTICAL 0x07 /* Optical memory device */
  363. #define SCSIRESP_INQUIRYPD_MEDIUMCHANGER 0x08 /* Medium changer device (Jukebox) */
  364. #define SCSIRESP_INQUIRYPD_COMMUNICATIONS 0x09 /* Communications device (obsolete) */
  365. #define SCSIRESP_INQUIRYPD_STORAGEARRAY 0x0c /* Storage array controller device */
  366. #define SCSIRESP_INQUIRYPD_ENCLOSURESERVICES 0x0d /* Enclosure services device */
  367. #define SCSIRESP_INQUIRYPD_RBC 0x0e /* Simplified direct-access device */
  368. #define SCSIRESP_INQUIRYPD_OCRW 0x0f /* Optical reader/writer device */
  369. #define SCSIRESP_INQUIRYPD_BCC 0x10 /* Bridge controller commands */
  370. #define SCSIRESP_INQUIRYPD_OSD 0x11 /* Object-based storage device */
  371. #define SCSIRESP_INQUIRYPD_ADC 0x12 /* Automation/drive interface */
  372. #define SCSIRESP_INQUIRYPD_WKLU 0x1e /* Well-known logical unit */
  373. #define SCSIRESP_INQUIRYPD_UNKNOWN 0x1f /* Direct-access block device */
  374. #define SCSIRESP_INQUIRYFLAGS1_RMB 0x80 /* Bit 7: RMB */
  375. #define SCSIRESP_INQUIRYFLAGS2_NORMACA 0x20 /* Bit 5: NormACA */
  376. #define SCSIRESP_INQUIRYFLAGS2_HISUP 0x10 /* Bit 4: HiSup */
  377. #define SCSIRESP_INQUIRYFLAGS2_FMTMASK 0x0f /* Bits 0-3: Response data format */
  378. #define SCSIRESP_INQUIRYFLAGS3_SCCS 0x80 /* Bit 8: SCCS */
  379. #define SCSIRESP_INQUIRYFLAGS3_ACC 0x40 /* Bit 7: ACC */
  380. #define SCSIRESP_INQUIRYFLAGS3_TPGSMASK 0x30 /* Bits 4-5: TPGS */
  381. #define SCSIRESP_INQUIRYFLAGS3_3PC 0x08 /* Bit 3: 3PC */
  382. #define SCSIRESP_INQUIRYFLAGS3_PROTECT 0x01 /* Bit 0: Protect */
  383. #define SCSIRESP_INQUIRYFLAGS4_BQUE 0x80 /* Bit 7: BQue */
  384. #define SCSIRESP_INQUIRYFLAGS4_ENCSERV 0x40 /* Bit 6: EncServ */
  385. #define SCSIRESP_INQUIRYFLAGS4_VS 0x20 /* Bit 5: VS */
  386. #define SCSIRESP_INQUIRYFLAGS4_MULTIP 0x10 /* Bit 4: MultIP */
  387. #define SCSIRESP_INQUIRYFLAGS4_MCHNGR 0x08 /* Bit 3: MChngr */
  388. #define SCSIRESP_INQUIRYFLAGS4_ADDR16 0x01 /* Bit 0: Addr16 */
  389. #define SCSIRESP_INQUIRYFLAGS5_WBUS16 0x20 /* Bit 5: WBus16 */
  390. #define SCSIRESP_INQUIRYFLAGS5_SYNC 0x10 /* Bit 4: SYNC */
  391. #define SCSIRESP_INQUIRYFLAGS5_LINKED 0x08 /* Bit 3: LINKED */
  392. #define SCSIRESP_INQUIRYFLAGS5_CMDQUEUE 0x02 /* Bit 1: CmdQue */
  393. #define SCSIRESP_INQUIRYFLAGS5_VS 0x01 /* Bit 0: VS */
  394. #define SCSIRESP_INQUIRYFLAGS6_CLOCKINGMASK 0xc0 /* Bits 2-3: Clocking */
  395. #define SCSIRESP_INQUIRYFLAGS6_QAS 0x02 /* Bit 1: QAS */
  396. #define SCSIRESP_INQUIRYFLAGS6_IUS 0x01 /* Bit 0: IUS */
  397. /* Sense data */
  398. /* Sense data response codes */
  399. #define SCSIRESP_SENSEDATA_CURRENTFIXED 0x70 /* Byte 1 is always the response code */
  400. #define SCSIRESP_SENSEDATA_DEFERREDFIXED 0x71
  401. #define SCSIRESP_SENSEDATA_CURRENTDESC 0x72
  402. #define SCSIRESP_SENSEDATA_DEFERREDDESC 0x73
  403. #define SCSIRESP_SENSEDATA_RESPVALID 0x80
  404. /* Fixed sense data flags */
  405. #define SCSIRESP_SENSEDATA_FILEMARK 0x80 /* Bit 7: FileMark */
  406. #define SCSIRESP_SENSEDATA_EOM 0x40 /* Bit 6: EOM */
  407. #define SCSIRESP_SENSEDATA_ILI 0x20 /* Bit 5: ILI */
  408. #define SCSIRESP_SENSEDATA_SENSEKEYMASK 0x0f /* Bits 0-3: Sense key */
  409. #define SCSIRESP_SENSEDATA_NOSENSE 0x00 /* Nothing to be reported */
  410. #define SCSIRESP_SENSEDATA_RECOVEREDERROR 0x01 /* Successful after recovery action */
  411. #define SCSIRESP_SENSEDATA_NOTREADY 0x02 /* Logical unit is not accessible */
  412. #define SCSIRESP_SENSEDATA_MEDIUMERROR 0x03 /* Error possibly caused by flaw in medium */
  413. #define SCSIRESP_SENSEDATA_HARDWAREERROR 0x04 /* Non-recoverable hardware error */
  414. #define SCSIRESP_SENSEDATA_ILLEGALREQUEST 0x05 /* Error in received request */
  415. #define SCSIRESP_SENSEDATA_UNITATTENTION 0x06 /* Unit attention condition */
  416. #define SCSIRESP_SENSEDATA_DATAPROTECT 0x07 /* Action failed, medium protected */
  417. #define SCSIRESP_SENSEDATA_BLANKCHECK 0x08 /* Encountered blank media */
  418. #define SCSIRESP_SENSEDATA_VENDORSPECIFIC 0x09 /* Vendor specific condition */
  419. #define SCSIRESP_SENSEDATA_ABORTEDCOMMAND 0x0b /* Command was aborted */
  420. #define SCSIRESP_SENSEDATA_KEYVALID 0x80 /* Sense-specific data valid */
  421. /* Mode Select 6 */
  422. #define SCSICMD_MODESELECT6_PF 0x10 /* Bit 4: PF */
  423. #define SCSICMD_MODESELECT6_SP 0x01 /* Bit 0: SP */
  424. /* Mode Sense 6 */
  425. #define SCSICMD_MODESENSE6_DBD 0x08 /* Bit 3: PF */
  426. #define SCSICMD_MODESENSE_PCMASK 0xc0 /* Bits 6-7: Page control (PC) */
  427. #define SCSICMD_MODESENSE_PCCURRENT 0x00 /* Current values */
  428. #define SCSICMD_MODESENSE_PCCHANGEABLE 0x40 /* Changeable values */
  429. #define SCSICMD_MODESENSE_PCDEFAULT 0x80 /* Default values */
  430. #define SCSICMD_MODESENSE_PCSAVED 0xc0 /* Saved values */
  431. #define SCSICMD_MODESENSE_PGCODEMASK 0x3f /* Bits 0-5: Page code */
  432. #define SCSICMD_MODESENSE6_PCDEFAULT 0x80 /* Default values */
  433. /* Direct-access device page codes */
  434. #define SCSIRESP_MODESENSE_PGCCODE_VENDOR 0x00 /* Vendor-specific */
  435. #define SCSIRESP_MODESENSE_PGCCODE_RWERROR 0x01 /* Read/Write error recovery mode page */
  436. #define SCSIRESP_MODESENSE_PGCCODE_RECONNECT 0x02 /* Disconnect-reconnect mode page */
  437. #define SCSIRESP_MODESENSE_PGCCODE_FORMATDEV 0x03 /* Format device mode page (obsolete) */
  438. #define SCSIRESP_MODESENSE_PGCCODE_RIGID 0x04 /* Rigid disk geometry mode page (obsolete) */
  439. #define SCSIRESP_MODESENSE_PGCCODE_FLEXIBLE 0x05 /* Flexible disk geometry mode page (obsolete) */
  440. #define SCSIRESP_MODESENSE_PGCCODE_VERIFY 0x07 /* Verify error recovery mode page */
  441. #define SCSIRESP_MODESENSE_PGCCODE_CACHING 0x08 /* Caching mode page */
  442. #define SCSIRESP_MODESENSE_PGCCODE_CONTROL 0x0a /* Control mode page (0x0a/0x00) */
  443. #define SCSIRESP_MODESENSE_PGCCODE_CONTROLEXT 0x0a /* Control extension mode page (0x0a/0x01) */
  444. #define SCSIRESP_MODESENSE_PGCCODE_MEDIUMTYPES 0x0b /* Medum types supported mode page (obsolete) */
  445. #define SCSIRESP_MODESENSE_PGCCODE_NP 0x0c /* Notch and partition mode page (obsolete) */
  446. #define SCSIRESP_MODESENSE_PGCCODE_XOR 0x10 /* XOR control mode page */
  447. #define SCSIRESP_MODESENSE_PGCCODE_ES 0x14 /* Enclosure services mode page */
  448. #define SCSIRESP_MODESENSE_PGCCODE_PSLUN 0x18 /* Protocol-specific LUN mode page */
  449. #define SCSIRESP_MODESENSE_PGCCODE_PSPORT 0x19 /* Protocol-specific port mode page */
  450. #define SCSIRESP_MODESENSE_PGCCODE_POWER 0x1a /* Power condition mode page */
  451. #define SCSIRESP_MODESENSE_PGCCODE_IE 0x1c /* Informational exceptions control mode page (0x1c/0x00) */
  452. #define SCSIRESP_MODESENSE_PGCCODE_BC 0x1c /* Background control mode page (0x1c/0x01) */
  453. #define SCSIRESP_MODESENSE_PGCCODE_RETURNALL 0x3f /* Return all mode pages */
  454. /* Direct-access caching mode page */
  455. #define SCSIRESP_CACHINGMODEPG_PS 0x80 /* Byte 0, Bit 7: PS */
  456. #define SCSIRESP_CACHINGMODEPG_SPF 0x60 /* Byte 0, Bit 6: SPF */
  457. #define SCSIRESP_CACHINGMODEPG_IC 0x80 /* Byte 2, Bit 7: IC */
  458. #define SCSIRESP_CACHINGMODEPG_ABPF 0x40 /* Byte 2, Bit 6: ABPF */
  459. #define SCSIRESP_CACHINGMODEPG_CAP 0x20 /* Byte 2, Bit 5: CAP */
  460. #define SCSIRESP_CACHINGMODEPG_DISC 0x10 /* Byte 2, Bit 4: DISC */
  461. #define SCSIRESP_CACHINGMODEPG_SIZE 0x08 /* Byte 2, Bit 3: SIZE */
  462. #define SCSIRESP_CACHINGMODEPG_WCE 0x04 /* Byte 2, Bit 2: Write cache enable (WCE) */
  463. #define SCSIRESP_CACHINGMODEPG_MF 0x02 /* Byte 2, Bit 1: MF */
  464. #define SCSIRESP_CACHINGMODEPG_RCD 0x01 /* Byte 2, Bit 0: Read cache disable (RCD) */
  465. #define SCSIRESP_MODEPARMHDR_DAPARM_WP 0x80 /* Bit 7: WP (Direct-access block devices only) */
  466. #define SCSIRESP_MODEPARMHDR_DAPARM_DBPFUA 0x10 /* Bit 4: DBOFUA (Direct-access block devices only) */
  467. #define SCSIRESP_PAGEFMT_PS 0x80 /* Bit 7: PS */
  468. #define SCSIRESP_PAGEFMT_SPF 0x40 /* Bit 6: SPF */
  469. #define SCSIRESP_PAGEFMT_PGCODEMASK 0x3f /* Bits 0-5: Page code */
  470. /* Prevent / Allow Medium Removal */
  471. #define SCSICMD_PREVENTMEDIUMREMOVAL_TRANSPORT 0x01 /* Removal prohibited from data transport */
  472. #define SCSICMD_PREVENTMEDIUMREMOVAL_MCHANGER 0x02 /* Removal prohibited from medium changer */
  473. /* Read format capacities */
  474. #define SCIRESP_RDFMTCAPACITIES_UNFORMATED 0x01 /* Unformatted media */
  475. #define SCIRESP_RDFMTCAPACITIES_FORMATED 0x02 /* Formatted media */
  476. #define SCIRESP_RDFMTCAPACITIES_NOMEDIA 0x03 /* No media */
  477. /* Read 6 */
  478. #define SCSICMD_READ6_MSLBAMASK 0x1f
  479. /* Write 6 */
  480. #define SCSICMD_WRITE6_MSLBAMASK 0x1f
  481. /* Mode Select 10 */
  482. #define SCSICMD_MODESELECT10_PF 0x10 /* Bit 4: PF */
  483. #define SCSICMD_MODESELECT10_SP 0x01 /* Bit 0: SP */
  484. /* Mode Sense 10 */
  485. #define SCSICMD_MODESENSE10_LLBAA 0x10 /* Bit 4: LLBAA */
  486. #define SCSICMD_MODESENSE10_DBD 0x08 /* Bit 3: PF */
  487. /* Read 10 */
  488. #define SCSICMD_READ10FLAGS_RDPROTECTMASK 0xe0
  489. #define SCSICMD_READ10FLAGS_DPO 0x10 /* Disable Page Out */
  490. #define SCSICMD_READ10FLAGS_FUA 0x08
  491. #define SCSICMD_READ10FLAGS_FUANV 0x02
  492. /* Write 10 */
  493. #define SCSICMD_WRITE10FLAGS_WRPROTECTMASK 0xe0
  494. #define SCSICMD_WRITE10FLAGS_DPO 0x10 /* Disable Page Out */
  495. #define SCSICMD_WRITE10FLAGS_FUA 0x08
  496. #define SCSICMD_WRITE10FLAGS_FUANV 0x02
  497. /* Verify 10 */
  498. #define SCSICMD_VERIFY10_VRPROTECTMASK 0xe0 /* Byte 1: Bits 5-7: VRPROTECT */
  499. #define SCSICMD_VERIFY10_DPO 0x10 /* Byte 1: Bit 4: Disable Page Out (DPO) */
  500. #define SCSICMD_VERIFY10_BYTCHK 0x02 /* Byte 1: Bit 2: BytChk */
  501. /* Read 12 */
  502. #define SCSICMD_READ12FLAGS_RDPROTECTMASK 0xe0
  503. #define SCSICMD_READ12FLAGS_DPO 0x10 /* Disable Page Out */
  504. #define SCSICMD_READ12FLAGS_FUA 0x08
  505. #define SCSICMD_READ12FLAGS_FUANV 0x02
  506. /* Write 12 */
  507. #define SCSICMD_WRITE12FLAGS_WRPROTECTMASK 0xe0
  508. #define SCSICMD_WRITE12FLAGS_DPO 0x10 /* Disable Page Out */
  509. #define SCSICMD_WRITE12FLAGS_FUA 0x08
  510. #define SCSICMD_WRITE12FLAGS_FUANV 0x02
  511. /* Verify 12 */
  512. #define SCSICMD_VERIFY12_VRPROTECTMASK 0xe0 /* Byte 1: Bits 5-7: VRPROTECT */
  513. #define SCSICMD_VERIFY12_DPO 0x10 /* Byte 1: Bit 4: Disable Page Out (DPO) */
  514. #define SCSICMD_VERIFY12_BYTCHK 0x02 /* Byte 1: Bit 2: BytChk */
  515. /****************************************************************************
  516. * Public Types
  517. ****************************************************************************/
  518. /* Format structures for selected SCSI primary commands */
  519. #define SCSICMD_TESTUNITREADY_SIZEOF 6
  520. struct scsicmd_requestsense_s
  521. {
  522. uint8_t opcode; /* 0: 0x03 */
  523. uint8_t flags; /* 1: See SCSICMD_REQUESTSENSE_FLAGS_* */
  524. uint8_t reserved[2]; /* 2-3: Reserved */
  525. uint8_t alloclen; /* 4: Allocation length */
  526. uint8_t control; /* 5: Control */
  527. };
  528. #define SCSICMD_REQUESTSENSE_SIZEOF 6
  529. #define SCSICMD_REQUESTSENSE_MSSIZEOF 12 /* MS-Windows REQUEST SENSE with cbw->cdblen == 12 */
  530. struct scsiresp_fixedsensedata_s
  531. {
  532. uint8_t code; /* 0: Response code See SCSIRESP_SENSEDATA_*FIXED defns */
  533. uint8_t obsolete; /* 1: */
  534. uint8_t flags; /* 2: See SCSIRESP_SENSEDATA_* definitions */
  535. uint8_t info[4]; /* 3-6: Information */
  536. uint8_t len; /* 7: Additional length */
  537. uint8_t cmdinfo[4]; /* 8-11: Command-specific information */
  538. uint8_t code2; /* 12: Additional sense code */
  539. uint8_t qual2; /* 13: Additional sense code qualifier */
  540. uint8_t fru; /* 14: Field replacement unit code */
  541. uint8_t key[3]; /* 15-17: Sense key specific */
  542. /* 18-: Additional bytes may follow */
  543. };
  544. #define SCSIRESP_FIXEDSENSEDATA_SIZEOF 18 /* Minimum size */
  545. struct scscicmd_inquiry_s
  546. {
  547. uint8_t opcode; /* 0: 0x12 */
  548. uint8_t flags; /* 1: See SCSICMD_INQUIRY_FLAGS_* */
  549. uint8_t pagecode; /* 2: Page code */
  550. uint8_t alloclen[2]; /* 3-4: Allocation length */
  551. uint8_t control; /* 5: Control */
  552. };
  553. #define SCSICMD_INQUIRY_SIZEOF 6
  554. struct scsiresp_inquiry_s
  555. {
  556. /* Mandatory */
  557. uint8_t qualtype; /* 0: Bits 5-7: Peripheral qualifier; Bits 0-4: Peripheral device type */
  558. uint8_t flags1; /* 1: See SCSIRESP_INQUIRY_FLAGS1_* */
  559. uint8_t version; /* 2: Version */
  560. uint8_t flags2; /* 3: See SCSIRESP_INQUIRY_FLAGS2_* */
  561. uint8_t len; /* 4: Additional length */
  562. uint8_t flags3; /* 5: See SCSIRESP_INQUIRY_FLAGS3_* */
  563. uint8_t flags4; /* 6: See SCSIRESP_INQUIRY_FLAGS4_* */
  564. uint8_t flags5; /* 7: See SCSIRESP_INQUIRY_FLAGS5_* */
  565. uint8_t vendorid[8]; /* 8-15: T10 Vendor Identification */
  566. uint8_t productid[16]; /* 16-31: Product Identification */
  567. uint8_t revision[4]; /* 32-35: Product Revision Level */
  568. /* Optional */
  569. uint8_t vendor[20]; /* 36-55: Vendor specific */
  570. uint8_t flags6; /* 56: See SCSIRESP_INQUIRY_FLAGS6_* */
  571. uint8_t reserved1; /* 57: Reserved */
  572. uint8_t version1[2]; /* 58-59: Version Descriptor 1 */
  573. uint8_t version2[2]; /* 60-61: Version Descriptor 2 */
  574. uint8_t version3[2]; /* 62-63: Version Descriptor 3 */
  575. uint8_t version4[2]; /* 64-65: Version Descriptor 4 */
  576. uint8_t version5[2]; /* 66-67: Version Descriptor 5 */
  577. uint8_t version6[2]; /* 68-69: Version Descriptor 6 */
  578. uint8_t version7[2]; /* 70-71: Version Descriptor 7 */
  579. uint8_t version8[2]; /* 72-73: Version Descriptor 8 */
  580. uint8_t reserved2[22]; /* 74-95: Reserved */
  581. /* 96-: Vendor-specific parameters may follow */
  582. };
  583. #define SCSIRESP_INQUIRY_SIZEOF 36 /* Minimum size */
  584. struct scsicmd_modeselect6_s
  585. {
  586. uint8_t opcode; /* 0x15 */
  587. uint8_t flags; /* 1: See SCSICMD_MODESELECT6_FLAGS_* */
  588. uint8_t reserved[2]; /* 2-3: Reserved */
  589. uint8_t plen; /* 4: Parameter list length */
  590. uint8_t control; /* 5: Control */
  591. };
  592. #define SCSICMD_MODESELECT6_SIZEOF 6
  593. struct scsicmd_modesense6_s
  594. {
  595. uint8_t opcode; /* 0x1a */
  596. uint8_t flags; /* 1: See SCSICMD_MODESENSE6_FLAGS_* */
  597. uint8_t pcpgcode; /* 2: Bits 6-7: PC, bits 0-5: page code */
  598. uint8_t subpgcode; /* 3: subpage code */
  599. uint8_t alloclen; /* 4: Allocation length */
  600. uint8_t control; /* 5: Control */
  601. };
  602. #define SCSICMD_MODESENSE6_SIZEOF 6
  603. struct scsiresp_modeparameterhdr6_s
  604. {
  605. uint8_t mdlen; /* 0: Mode data length */
  606. uint8_t type; /* 1: Medium type */
  607. uint8_t param; /* 2: Device-specific parameter */
  608. uint8_t bdlen; /* 3: Block descriptor length */
  609. };
  610. #define SCSIRESP_MODEPARAMETERHDR6_SIZEOF 4
  611. struct scsiresp_blockdesc_s
  612. {
  613. uint8_t density; /* 0: density code */
  614. uint8_t nblocks[3]; /* 1-3: Number of blocks */
  615. uint8_t reserved; /* 4: reserved */
  616. uint8_t blklen[3]; /* 5-7: Block len */
  617. };
  618. #define SCSIRESP_BLOCKDESC_SIZEOF 8
  619. struct scsiresp_pageformat_s
  620. {
  621. uint8_t pgcode; /* 0: See SCSIRESP_PAGEFMT_* definitions */
  622. uint8_t pglen; /* 1: Page length (n-1) */
  623. uint8_t parms[1]; /* 2-n: Mode parameters */
  624. };
  625. struct scsiresp_subpageformat_s
  626. {
  627. uint8_t pgcode; /* 0: See SCSIRESP_PAGEFMT_* definitions */
  628. uint8_t subpgcode; /* 1: sub-page code */
  629. uint8_t pglen[2]; /* 2-3: Page length (n-3) */
  630. uint8_t parms[1]; /* 4-n: Mode parameters */
  631. };
  632. struct scsiresp_cachingmodepage_s
  633. {
  634. uint8_t pgcode; /* 0: Bit 7: PS; Bit 6: SPF, Bits 0-5: page code == 8 */
  635. uint8_t len; /* 1: Page length (18) */
  636. uint8_t flags1; /* 2: See SCSIRESP_CACHINGMODEPG_* definitions */
  637. uint8_t priority; /* 3: Bits 4-7: Demand read retention priority; Bits 0-3: Write retention priority */
  638. uint8_t dpflen[2]; /* 4-5: Disable prefetch transfer length */
  639. uint8_t minpf[2]; /* 6-7: Minimum pre-fetch */
  640. uint8_t maxpf[2]; /* 8-9: Maximum pre-fetch */
  641. uint8_t maxpfc[2]; /* 10-11: Maximum pref-fetch ceiling */
  642. uint8_t flags2; /* 12: See SCSIRESP_CACHINGMODEPG_* definitions */
  643. uint8_t nsegments; /* 13: Number of cache segments */
  644. uint8_t segsize[2]; /* 14-15: Cache segment size */
  645. uint8_t reserved; /* 16: Reserved */
  646. uint8_t obsolete[3]; /* 17-19: Obsolete */
  647. };
  648. /* Format structures for selected SCSI block commands */
  649. struct scsicmd_read6_s
  650. {
  651. uint8_t opcode; /* 0: 0x08 */
  652. uint8_t mslba; /* 1: Bits 5-7: reserved; Bits 0-6: MS Logical Block Address (LBA) */
  653. uint8_t lslba[2]; /* 2-3: LS Logical Block Address (LBA) */
  654. uint8_t xfrlen; /* 4: Transfer length (in contiguous logical blocks) */
  655. uint8_t control; /* 5: Control */
  656. };
  657. #define SCSICMD_READ6_SIZEOF 6
  658. struct scsicmd_write6_s
  659. {
  660. uint8_t opcode; /* 0: 0x0a */
  661. uint8_t mslba; /* 1: Bits 5-7: reserved; Bits 0-6: MS Logical Block Address (LBA) */
  662. uint8_t lslba[2]; /* 2-3: LS Logical Block Address (LBA) */
  663. uint8_t xfrlen; /* 4: Transfer length (in contiguous logical blocks) */
  664. uint8_t control; /* 5: Control */
  665. };
  666. #define SCSICMD_WRITE6_SIZEOF 6
  667. struct scsicmd_startstopunit_s
  668. {
  669. uint8_t opcode; /* 0: 0x1b */
  670. uint8_t immed; /* 1: Bits 2-7: Reserved, Bit 0: Immed */
  671. uint8_t reserved; /* 2: reserved */
  672. uint8_t pcm; /* 3: Bits 4-7: Reserved, Bits 0-3: Power condition modifier */
  673. uint8_t pc; /* 4: Bits 4-7: Power condition, Bit 2: NO_FLUSH, Bit 1: LOEJ, Bit 0: START */
  674. uint8_t control; /* 5: Control */
  675. };
  676. #define SCSICMD_STARTSTOPUNIT_SIZEOF 6
  677. struct scsicmd_preventmediumremoval_s
  678. {
  679. uint8_t opcode; /* 0: 0x1e */
  680. uint8_t reserved[3]; /* 1-3: Reserved */
  681. uint8_t prevent; /* 4: Bits 2-7: Reserved, Bits 0:1: prevent */
  682. uint8_t control; /* 5: Control */
  683. };
  684. #define SCSICMD_PREVENTMEDIUMREMOVAL_SIZEOF 6
  685. struct scsicmd_readformatcapcacities_s
  686. {
  687. uint8_t opcode; /* 0: 0x23 */
  688. uint8_t reserved[6]; /* 1-6: Reserved */
  689. uint8_t alloclen[2]; /* 7-8: Allocation length */
  690. uint8_t control; /* 9: Control */
  691. };
  692. #define SCSICMD_READFORMATCAPACITIES_SIZEOF 10
  693. struct scsiresp_readformatcapacities_s
  694. {
  695. /* Current capacity header */
  696. uint8_t reserved[3]; /* 0-2: Reserved */
  697. uint8_t listlen; /* 3: Capacity list length */
  698. /* Current/Maximum Capacity Descriptor (actually a separate structure) */
  699. uint8_t nblocks[4]; /* 4-7: Number of blocks */
  700. uint8_t type; /* 8: Bits 2-7: Reserved, Bits 0-1: Descriptor type */
  701. uint8_t blocklen[3]; /* 9-11: Block length */
  702. };
  703. #define SCSIRESP_READFORMATCAPACITIES_SIZEOF 12
  704. #define SCSIRESP_CURRCAPACITYDESC_SIZEOF 8
  705. struct scsiresp_formattedcapacitydesc_s
  706. {
  707. uint8_t nblocks[4]; /* 0-3: Number of blocks */
  708. uint8_t type; /* 4: Bits 2-7: Type, bits 0-1, reserved */
  709. uint8_t param[3]; /* 5-7: Type dependent parameter */
  710. };
  711. #define SCSIRESP_FORMATTEDCAPACITYDESC_SIZEOF 8
  712. struct scsicmd_readcapacity10_s
  713. {
  714. uint8_t opcode; /* 0: 0x25 */
  715. uint8_t reserved1; /* 1: Bits 1-7: Reserved, Bit 0: Obsolete */
  716. uint8_t lba[4]; /* 2-5: Logical block address (LBA) */
  717. uint8_t reserved2[2]; /* 6-7: Reserved */
  718. uint8_t pmi; /* 8: Bits 1-7 Reserved; Bit 0: PMI */
  719. uint8_t control; /* 9: Control */
  720. };
  721. #define SCSICMD_READCAPACITY10_SIZEOF 10
  722. struct scsiresp_readcapacity10_s
  723. {
  724. uint8_t lba[4]; /* 0-3: Returned logical block address (LBA) */
  725. uint8_t blklen[4]; /* 4-7: Logical block length (in bytes) */
  726. };
  727. #define SCSIRESP_READCAPACITY10_SIZEOF 8
  728. struct scsicmd_read10_s
  729. {
  730. uint8_t opcode; /* 0: 0x28 */
  731. uint8_t flags; /* 1: See SCSICMD_READ10FLAGS_* */
  732. uint8_t lba[4]; /* 2-5: Logical Block Address (LBA) */
  733. uint8_t groupno; /* 6: Bits 5-7: reserved; Bits 0-6: group number */
  734. uint8_t xfrlen[2]; /* 7-8: Transfer length (in contiguous logical blocks) */
  735. uint8_t control; /* 9: Control */
  736. };
  737. #define SCSICMD_READ10_SIZEOF 10
  738. struct scsicmd_write10_s
  739. {
  740. uint8_t opcode; /* 0: 0x2a */
  741. uint8_t flags; /* 1: See SCSICMD_WRITE10FLAGS_* */
  742. uint8_t lba[4]; /* 2-5: Logical Block Address (LBA) */
  743. uint8_t groupno; /* 6: Bits 5-7: reserved; Bits 0-6: group number */
  744. uint8_t xfrlen[2]; /* 7-8: Transfer length (in contiguous logical blocks) */
  745. uint8_t control; /* 9: Control */
  746. };
  747. #define SCSICMD_WRITE10_SIZEOF 10
  748. struct scsicmd_verify10_s
  749. {
  750. uint8_t opcode; /* 0: 0x2f */
  751. uint8_t flags; /* 1: See SCSICMD_VERIFY10_* definitions */
  752. uint8_t lba[4]; /* 2-5: Logical block address (LBA) */
  753. uint8_t groupno; /* 6: Bit 7: restricted; Bits 5-6: Reserved, Bits 0-4: Group number */
  754. uint8_t len[2]; /* 7-8: Verification length (in blocks) */
  755. uint8_t control; /* 9: Control */
  756. };
  757. #define SCSICMD_VERIFY10_SIZEOF 10
  758. struct scsicmd_synchronizecache10_s
  759. {
  760. uint8_t opcode; /* 0: 0x35 */
  761. uint8_t flags; /* 1: See SCSICMD_SYNCHRONIZECACHE10_* definitions */
  762. uint8_t lba[4]; /* 2-5: Logical block address (LBA) */
  763. uint8_t groupno; /* 6: Bit 7: restricted; Bits 5-6: Reserved, Bits 0-4: Group number */
  764. uint8_t len[2]; /* 7-8: Number of logical blocks */
  765. uint8_t control; /* 9: Control */
  766. };
  767. #define SCSICMD_SYNCHRONIZECACHE10_SIZEOF 10
  768. struct scsicmd_modeselect10_s
  769. {
  770. uint8_t opcode; /* 0: 0x55 */
  771. uint8_t flags; /* 1: See SCSICMD_MODESELECT10_FLAGS_* */
  772. uint8_t reserved[5]; /* 2-6: Reserved */
  773. uint8_t parmlen[2]; /* 7-8: Parameter list length */
  774. uint8_t control; /* 9: Control */
  775. };
  776. #define SCSICMD_MODESELECT10_SIZEOF 10
  777. struct scsiresp_modeparameterhdr10_s
  778. {
  779. uint8_t mdlen[2]; /* 0-1: Mode data length */
  780. uint8_t type; /* 2: Medium type */
  781. uint8_t param; /* 3: Device-specific parameter */
  782. uint8_t reserved[2]; /* 4-5: reserved */
  783. uint8_t bdlen[2]; /* 6-7: Block descriptor length */
  784. };
  785. #define SCSIRESP_MODEPARAMETERHDR10_SIZEOF 8
  786. struct scsicmd_modesense10_s
  787. {
  788. uint8_t opcode; /* O: 0x5a */
  789. uint8_t flags; /* 1: See SCSICMD_MODESENSE10_FLAGS_* */
  790. uint8_t pcpgcode; /* 2: Bits 6-7: PC, bits 0-5: page code */
  791. uint8_t subpgcode; /* 3: subpage code */
  792. uint8_t reserved[3]; /* 4-6: reserved */
  793. uint8_t alloclen[2]; /* 7-8: Allocation length */
  794. uint8_t control; /* 9: Control */
  795. };
  796. #define SCSICMD_MODESENSE10_SIZEOF 10
  797. struct scsicmd_readcapacity16_s
  798. {
  799. uint8_t opcode; /* 0: 0x9e */
  800. uint8_t action; /* 1: Bits 5-7: Reserved, Bits 0-4: Service action */
  801. uint8_t lba[8]; /* 2-9: Logical block address (LBA) */
  802. uint8_t len[4]; /* 10-13: Allocation length */
  803. uint8_t reserved; /* 14: Reserved */
  804. uint8_t control; /* 15: Control */
  805. };
  806. #define SCSICMD_READCAPACITY16_SIZEOF 16
  807. struct scsicmd_read12_s
  808. {
  809. uint8_t opcode; /* 0: 0xa8 */
  810. uint8_t flags; /* 1: See SCSICMD_READ12FLAGS_* */
  811. uint8_t lba[4]; /* 2-5: Logical Block Address (LBA) */
  812. uint8_t xfrlen[4]; /* 6-9: Transfer length (in contiguous logical blocks) */
  813. uint8_t groupno; /* 10: Bit 7: restricted; Bits 5-6: reserved; Bits 0-6: group number */
  814. uint8_t control; /* 11: Control */
  815. };
  816. #define SCSICMD_READ12_SIZEOF 12
  817. struct scsicmd_write12_s
  818. {
  819. uint8_t opcode; /* 0: 0xaa */
  820. uint8_t flags; /* 1: See SCSICMD_WRITE12FLAGS_* */
  821. uint8_t lba[4]; /* 2-5: Logical Block Address (LBA) */
  822. uint8_t xfrlen[4]; /* 6-9: Transfer length (in contiguous logical blocks) */
  823. uint8_t groupno; /* 10: Bit 7: restricted; Bits 5-6: reserved; Bits 0-6: group number */
  824. uint8_t control; /* 11: Control */
  825. };
  826. #define SCSICMD_WRITE12_SIZEOF 12
  827. struct scsicmd_verify12_s
  828. {
  829. uint8_t opcode; /* 0: 0xaf */
  830. uint8_t flags; /* 1: See SCSICMD_VERIFY12_* definitions */
  831. uint8_t lba[4]; /* 2-5: Logical block address (LBA) */
  832. uint8_t len[4]; /* 6-9: Verification length */
  833. uint8_t groupno; /* 10: Bit 7: restricted; Bits 5-6: Reserved, Bits 0-4: Group number */
  834. uint8_t control; /* 11: Control */
  835. };
  836. #define SCSICMD_VERIFY12_SIZEOF 12
  837. /****************************************************************************
  838. * Public Functions Definitions
  839. ****************************************************************************/
  840. #undef EXTERN
  841. #if defined(__cplusplus)
  842. #define EXTERN extern "C"
  843. extern "C"
  844. {
  845. #else
  846. #define EXTERN extern
  847. #endif
  848. #undef EXTERN
  849. #if defined(__cplusplus)
  850. }
  851. #endif
  852. #endif /* __INCLUDE_NUTTX_SCSI_H */