scsi_changer.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. /* $OpenBSD: scsi_changer.h,v 1.6 2015/06/07 19:13:27 krw Exp $ */
  2. /* $NetBSD: scsi_changer.h,v 1.7 1996/04/03 00:25:48 thorpej Exp $ */
  3. /*
  4. * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
  5. * All rights reserved.
  6. *
  7. * Partially based on an autochanger driver written by Stefan Grefen
  8. * and on an autochanger driver written by the Systems Programming Group
  9. * at the University of Utah Computer Science Department.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. * 3. All advertising materials mentioning features or use of this software
  20. * must display the following acknowledgements:
  21. * This product includes software developed by Jason R. Thorpe
  22. * for And Communications, http://www.and.com/
  23. * 4. The name of the author may not be used to endorse or promote products
  24. * derived from this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  27. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  28. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  29. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  30. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  31. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  32. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  33. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  34. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36. * SUCH DAMAGE.
  37. */
  38. /*
  39. * SCSI changer interface description
  40. */
  41. /*
  42. * Partially derived from software written by Stefan Grefen
  43. * (grefen@goofy.zdv.uni-mainz.de soon grefen@convex.com)
  44. * based on the SCSI System by written Julian Elischer (julian@tfs.com)
  45. * for TRW Financial Systems.
  46. *
  47. * TRW Financial Systems, in accordance with their agreement with Carnegie
  48. * Mellon University, makes this software available to CMU to distribute
  49. * or use in any manner that they see fit as long as this message is kept with
  50. * the software. For this reason TFS also grants any other persons or
  51. * organisations permission to use or modify this software.
  52. *
  53. * TFS supplies this software to be publicly redistributed
  54. * on the understanding that TFS is not responsible for the correct
  55. * functioning of this software in any circumstances.
  56. *
  57. * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
  58. */
  59. #ifndef _SCSI_SCSI_CHANGER_H
  60. #define _SCSI_SCSI_CHANGER_H 1
  61. /*
  62. * SCSI command format
  63. */
  64. /*
  65. * Exchange the medium in the source element with the medium
  66. * located at the destination element.
  67. */
  68. struct scsi_exchange_medium {
  69. u_int8_t opcode;
  70. #define EXCHANGE_MEDIUM 0xa6
  71. u_int8_t byte2;
  72. u_int8_t tea[2]; /* transport element address */
  73. u_int8_t src[2]; /* source address */
  74. u_int8_t fdst[2]; /* first destination address */
  75. u_int8_t sdst[2]; /* second destination address */
  76. u_int8_t flags;
  77. #define EXCHANGE_MEDIUM_INV1 0x01
  78. #define EXCHANGE_MEDIUM_INV2 0x02
  79. u_int8_t control;
  80. };
  81. /*
  82. * Cause the medium changer to check all elements for medium and any
  83. * other status relevant to the element.
  84. */
  85. struct scsi_initialize_elememt_status {
  86. u_int8_t opcode;
  87. #define INITIALIZE_ELEMENT_STATUS 0x07
  88. u_int8_t byte2;
  89. u_int8_t reserved[3];
  90. u_int8_t control;
  91. };
  92. /*
  93. * Request the changer to move a unit of media from the source element
  94. * to the destination element.
  95. */
  96. struct scsi_move_medium {
  97. u_int8_t opcode;
  98. #define MOVE_MEDIUM 0xa5
  99. u_int8_t byte2;
  100. u_int8_t tea[2]; /* transport element address */
  101. u_int8_t src[2]; /* source element address */
  102. u_int8_t dst[2]; /* destination element address */
  103. u_int8_t reserved[2];
  104. u_int8_t flags;
  105. #define MOVE_MEDIUM_INVERT 0x01
  106. u_int8_t control;
  107. };
  108. /*
  109. * Position the specified transport element (picker) in front of
  110. * the destination element specified.
  111. */
  112. struct scsi_position_to_element {
  113. u_int8_t opcode;
  114. #define POSITION_TO_ELEMENT 0x2b
  115. u_int8_t byte2;
  116. u_int8_t tea[2]; /* transport element address */
  117. u_int8_t dst[2]; /* destination element address */
  118. u_int8_t reserved[2];
  119. u_int8_t flags;
  120. #define POSITION_TO_ELEMENT_INVERT 0x01
  121. u_int8_t control;
  122. };
  123. /*
  124. * Request that the changer report the status of its internal elements.
  125. */
  126. struct scsi_read_element_status {
  127. u_int8_t opcode;
  128. #define READ_ELEMENT_STATUS 0xb8
  129. u_int8_t byte2;
  130. #define READ_ELEMENT_STATUS_VOLTAG 0x10 /* report volume tag info */
  131. /* ...next 4 bits are an element type code... */
  132. u_int8_t sea[2]; /* starting element address */
  133. u_int8_t count[2]; /* number of elements */
  134. u_int8_t reserved0;
  135. u_int8_t len[3]; /* length of data buffer */
  136. u_int8_t reserved1;
  137. u_int8_t control;
  138. };
  139. struct scsi_request_volume_element_address {
  140. u_int8_t opcode;
  141. #define REQUEST_VOLUME_ELEMENT_ADDRESS 0xb5
  142. u_int8_t byte2;
  143. #define REQUEST_VOLUME_ELEMENT_ADDRESS_VOLTAG 0x10
  144. /* ...next 4 bits are an element type code... */
  145. u_int8_t eaddr[2]; /* element address */
  146. u_int8_t count[2]; /* number of elements */
  147. u_int8_t reserved0;
  148. u_int8_t len[3]; /* length of data buffer */
  149. u_int8_t reserved1;
  150. u_int8_t control;
  151. };
  152. /* XXX scsi_release */
  153. /*
  154. * Data returned by READ ELEMENT STATUS consists of an 8-byte header
  155. * followed by one or more read_element_status_pages.
  156. */
  157. struct read_element_status_header {
  158. u_int8_t fear[2]; /* first element address reported */
  159. u_int8_t count[2]; /* number of elements available */
  160. u_int8_t reserved;
  161. u_int8_t nbytes[3]; /* byte count of all pages */
  162. };
  163. struct read_element_status_page_header {
  164. u_int8_t type; /* element type code; see type codes below */
  165. u_int8_t flags;
  166. #define READ_ELEMENT_STATUS_AVOLTAG 0x40
  167. #define READ_ELEMENT_STATUS_PVOLTAG 0x80
  168. u_int8_t edl[2]; /* element descriptor length */
  169. u_int8_t reserved;
  170. u_int8_t nbytes[3]; /* byte count of all descriptors */
  171. };
  172. /*
  173. * Format of a volume tag
  174. */
  175. struct volume_tag {
  176. u_int8_t vif[32]; /* volume identification field */
  177. u_int8_t reserved[2];
  178. u_int8_t vsn[2]; /* volume sequence number */
  179. };
  180. struct read_element_status_descriptor {
  181. u_int8_t eaddr[2]; /* element address */
  182. u_int8_t flags1;
  183. #define READ_ELEMENT_STATUS_FULL 0x01
  184. #define READ_ELEMENT_STATUS_IMPEXP 0x02
  185. #define READ_ELEMENT_STATUS_EXCEPT 0x04
  186. #define READ_ELEMENT_STATUS_ACCESS 0x08
  187. #define READ_ELEMENT_STATUS_EXENAB 0x10
  188. #define READ_ELEMENT_STATUS_INENAB 0x20
  189. #define READ_ELEMENT_STATUS_MT_MASK1 0x05
  190. #define READ_ELEMENT_STATUS_ST_MASK1 0x0c
  191. #define READ_ELEMENT_STATUS_IE_MASK1 0x3f
  192. #define READ_ELEMENT_STATUS_DT_MASK1 0x0c
  193. u_int8_t reserved0;
  194. u_int8_t sense_code;
  195. u_int8_t sense_qual;
  196. /*
  197. * dt_scsi_flags and dt_scsi_addr are valid only on data transport
  198. * elements. These bytes are undefined for all other element types.
  199. */
  200. u_int8_t dt_scsi_flags;
  201. #define READ_ELEMENT_STATUS_DT_LUNMASK 0x07
  202. #define READ_ELEMENT_STATUS_DT_LUVALID 0x10
  203. #define READ_ELEMENT_STATUS_DT_IDVALID 0x20
  204. #define READ_ELEMENT_STATUS_DT_NOTBUS 0x80
  205. u_int8_t dt_scsi_addr;
  206. u_int8_t reserved1;
  207. u_int8_t flags2;
  208. #define READ_ELEMENT_STATUS_INVERT 0x40
  209. #define READ_ELEMENT_STATUS_SVALID 0x80
  210. u_int8_t ssea[2]; /* source storage element address */
  211. /*
  212. * bytes 12-47: Primary volume tag information.
  213. * (field omitted if PVOLTAG = 0)
  214. *
  215. * bytes 48-83: Alternate volume tag information.
  216. * (field omitted if AVOLTAG = 0)
  217. */
  218. struct volume_tag pvoltag; /* omitted if PVOLTAG == 0 */
  219. struct volume_tag avoltag; /* omitted if AVOLTAG == 0 */
  220. /*
  221. * bytes 84-87: Reserved (moved up if either of the above fields
  222. * are omitted)
  223. *
  224. * bytes 88-end: Vendor-specific: (moved up if either of the
  225. * above fields are missing)
  226. */
  227. };
  228. /* XXX add data returned by REQUEST VOLUME ELEMENT ADDRESS */
  229. /* Element type codes */
  230. #define ELEMENT_TYPE_MASK 0x0f /* Note: these aren't bits */
  231. #define ELEMENT_TYPE_ALL 0x00
  232. #define ELEMENT_TYPE_MT 0x01
  233. #define ELEMENT_TYPE_ST 0x02
  234. #define ELEMENT_TYPE_IE 0x03
  235. #define ELEMENT_TYPE_DT 0x04
  236. /*
  237. * XXX The following definitions should be common to all SCSI device types.
  238. */
  239. #define PGCODE_MASK 0x3f /* valid page number bits in pg_code */
  240. #define PGCODE_PS 0x80 /* indicates page is savable */
  241. /*
  242. * Device capabilities page.
  243. *
  244. * This page defines characteristics of the elemenet types in the
  245. * medium changer device.
  246. *
  247. * Note in the definitions below, the following abbreviations are
  248. * used:
  249. * MT Medium transport element (picker)
  250. * ST Storage transport element (slot)
  251. * IE Import/export element (portal)
  252. * DT Data transfer element (tape/disk drive)
  253. */
  254. struct page_device_capabilities {
  255. u_int8_t pg_code; /* page code (0x1f) */
  256. u_int8_t pg_length; /* page length (0x12) */
  257. /*
  258. * The STOR_xx bits indicate that an element of a given
  259. * type may provide independent storage for a unit of
  260. * media. The top four bits of this value are reserved.
  261. */
  262. u_int8_t stor;
  263. #define STOR_MT 0x01
  264. #define STOR_ST 0x02
  265. #define STOR_IE 0x04
  266. #define STOR_DT 0x08
  267. u_int8_t reserved0;
  268. /*
  269. * The MOVE_TO_yy bits indicate the changer supports
  270. * moving a unit of medium from an element of a given type to an
  271. * element of type yy. This is used to determine if a given
  272. * MOVE MEDIUM command is legal. The top four bits of each
  273. * of these values are reserved.
  274. */
  275. u_int8_t move_from_mt;
  276. u_int8_t move_from_st;
  277. u_int8_t move_from_ie;
  278. u_int8_t move_from_dt;
  279. #define MOVE_TO_MT 0x01
  280. #define MOVE_TO_ST 0x02
  281. #define MOVE_TO_IE 0x04
  282. #define MOVE_TO_DT 0x08
  283. u_int8_t reserved1[2];
  284. /*
  285. * Similar to above, but for EXCHANGE MEDIUM.
  286. */
  287. u_int8_t exchange_with_mt;
  288. u_int8_t exchange_with_st;
  289. u_int8_t exchange_with_ie;
  290. u_int8_t exchange_with_dt;
  291. #define EXCHANGE_WITH_MT 0x01
  292. #define EXCHANGE_WITH_ST 0x02
  293. #define EXCHANGE_WITH_IE 0x04
  294. #define EXCHANGE_WITH_DT 0x08
  295. };
  296. /*
  297. * Medium changer elemement address assignment page.
  298. *
  299. * Some of these fields can be a little confusing, so an explanation
  300. * is in order.
  301. *
  302. * Each component within a a medium changer apparatus is called an
  303. * "element".
  304. *
  305. * The "medium transport element address" is the address of the first
  306. * picker (robotic arm). "Number of medium transport elements" tells
  307. * us how many pickers exist in the changer.
  308. *
  309. * The "first storage element address" is the address of the first
  310. * slot in the tape or disk magazine. "Number of storage elements" tells
  311. * us how many slots exist in the changer.
  312. *
  313. * The "first import/export element address" is the address of the first
  314. * medium portal accessible both by the medium changer and an outside
  315. * human operator. This is where the changer might deposit tapes destined
  316. * for some vault. The "number of import/export elements" tells us
  317. * not many of these portals exist in the changer. NOTE: this number may
  318. * be 0.
  319. *
  320. * The "first data transfer element address" is the address of the first
  321. * tape or disk drive in the changer. "Number of data transfer elements"
  322. * tells us how many drives exist in the changer.
  323. */
  324. struct page_element_address_assignment {
  325. u_int8_t pg_code; /* page code (0x1d) */
  326. u_int8_t pg_length; /* page length (0x12) */
  327. /* Medium transport element address */
  328. u_int8_t mtea[2];
  329. /* Number of medium transport elements */
  330. u_int8_t nmte[2];
  331. /* First storage element address */
  332. u_int8_t fsea[2];
  333. /* Number of storage elements */
  334. u_int8_t nse[2];
  335. /* First import/export element address */
  336. u_int8_t fieea[2];
  337. /* Number of import/export elements */
  338. u_int8_t niee[2];
  339. /* First data transfer element address */
  340. u_int8_t fdtea[2];
  341. /* Number of data trafer elements */
  342. u_int8_t ndte[2];
  343. u_int8_t reserved[2];
  344. };
  345. /*
  346. * Transport geometry parameters page.
  347. *
  348. * Defines whether each medium transport element is a member of a set of
  349. * elements that share a common robotics subsystem and whether the element
  350. * is capable of media rotation. One transport geometry descriptor is
  351. * transferred for each medium transport element, beginning with the first
  352. * medium transport element (other than the default transport element address
  353. * of 0).
  354. */
  355. struct page_transport_geometry_parameters {
  356. u_int8_t pg_code; /* page code (0x1e) */
  357. u_int8_t pg_length; /* page length; variable */
  358. /* Transport geometry descriptor(s) are here. */
  359. u_int8_t misc;
  360. #define CAN_ROTATE 0x01
  361. /* Member number in transport element set. */
  362. u_int8_t member;
  363. };
  364. #endif /* _SCSI_SCSI_CHANGER_H */