osst.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. * $Header: /cvsroot/osst/Driver/osst.h,v 1.16 2005/01/01 21:13:35 wriede Exp $
  3. */
  4. #include <asm/byteorder.h>
  5. #include <linux/completion.h>
  6. #include <linux/mutex.h>
  7. /* FIXME - rename and use the following two types or delete them!
  8. * and the types really should go to st.h anyway...
  9. * INQUIRY packet command - Data Format (From Table 6-8 of QIC-157C)
  10. */
  11. typedef struct {
  12. unsigned device_type :5; /* Peripheral Device Type */
  13. unsigned reserved0_765 :3; /* Peripheral Qualifier - Reserved */
  14. unsigned reserved1_6t0 :7; /* Reserved */
  15. unsigned rmb :1; /* Removable Medium Bit */
  16. unsigned ansi_version :3; /* ANSI Version */
  17. unsigned ecma_version :3; /* ECMA Version */
  18. unsigned iso_version :2; /* ISO Version */
  19. unsigned response_format :4; /* Response Data Format */
  20. unsigned reserved3_45 :2; /* Reserved */
  21. unsigned reserved3_6 :1; /* TrmIOP - Reserved */
  22. unsigned reserved3_7 :1; /* AENC - Reserved */
  23. u8 additional_length; /* Additional Length (total_length-4) */
  24. u8 rsv5, rsv6, rsv7; /* Reserved */
  25. u8 vendor_id[8]; /* Vendor Identification */
  26. u8 product_id[16]; /* Product Identification */
  27. u8 revision_level[4]; /* Revision Level */
  28. u8 vendor_specific[20]; /* Vendor Specific - Optional */
  29. u8 reserved56t95[40]; /* Reserved - Optional */
  30. /* Additional information may be returned */
  31. } idetape_inquiry_result_t;
  32. /*
  33. * READ POSITION packet command - Data Format (From Table 6-57)
  34. */
  35. typedef struct {
  36. unsigned reserved0_10 :2; /* Reserved */
  37. unsigned bpu :1; /* Block Position Unknown */
  38. unsigned reserved0_543 :3; /* Reserved */
  39. unsigned eop :1; /* End Of Partition */
  40. unsigned bop :1; /* Beginning Of Partition */
  41. u8 partition; /* Partition Number */
  42. u8 reserved2, reserved3; /* Reserved */
  43. u32 first_block; /* First Block Location */
  44. u32 last_block; /* Last Block Location (Optional) */
  45. u8 reserved12; /* Reserved */
  46. u8 blocks_in_buffer[3]; /* Blocks In Buffer - (Optional) */
  47. u32 bytes_in_buffer; /* Bytes In Buffer (Optional) */
  48. } idetape_read_position_result_t;
  49. /*
  50. * Follows structures which are related to the SELECT SENSE / MODE SENSE
  51. * packet commands.
  52. */
  53. #define COMPRESSION_PAGE 0x0f
  54. #define COMPRESSION_PAGE_LENGTH 16
  55. #define CAPABILITIES_PAGE 0x2a
  56. #define CAPABILITIES_PAGE_LENGTH 20
  57. #define TAPE_PARAMTR_PAGE 0x2b
  58. #define TAPE_PARAMTR_PAGE_LENGTH 16
  59. #define NUMBER_RETRIES_PAGE 0x2f
  60. #define NUMBER_RETRIES_PAGE_LENGTH 4
  61. #define BLOCK_SIZE_PAGE 0x30
  62. #define BLOCK_SIZE_PAGE_LENGTH 4
  63. #define BUFFER_FILLING_PAGE 0x33
  64. #define BUFFER_FILLING_PAGE_LENGTH 4
  65. #define VENDOR_IDENT_PAGE 0x36
  66. #define VENDOR_IDENT_PAGE_LENGTH 8
  67. #define LOCATE_STATUS_PAGE 0x37
  68. #define LOCATE_STATUS_PAGE_LENGTH 0
  69. #define MODE_HEADER_LENGTH 4
  70. /*
  71. * REQUEST SENSE packet command result - Data Format.
  72. */
  73. typedef struct {
  74. unsigned error_code :7; /* Current of deferred errors */
  75. unsigned valid :1; /* The information field conforms to QIC-157C */
  76. u8 reserved1 :8; /* Segment Number - Reserved */
  77. unsigned sense_key :4; /* Sense Key */
  78. unsigned reserved2_4 :1; /* Reserved */
  79. unsigned ili :1; /* Incorrect Length Indicator */
  80. unsigned eom :1; /* End Of Medium */
  81. unsigned filemark :1; /* Filemark */
  82. u32 information __attribute__ ((packed));
  83. u8 asl; /* Additional sense length (n-7) */
  84. u32 command_specific; /* Additional command specific information */
  85. u8 asc; /* Additional Sense Code */
  86. u8 ascq; /* Additional Sense Code Qualifier */
  87. u8 replaceable_unit_code; /* Field Replaceable Unit Code */
  88. unsigned sk_specific1 :7; /* Sense Key Specific */
  89. unsigned sksv :1; /* Sense Key Specific information is valid */
  90. u8 sk_specific2; /* Sense Key Specific */
  91. u8 sk_specific3; /* Sense Key Specific */
  92. u8 pad[2]; /* Padding to 20 bytes */
  93. } idetape_request_sense_result_t;
  94. /*
  95. * Mode Parameter Header for the MODE SENSE packet command
  96. */
  97. typedef struct {
  98. u8 mode_data_length; /* Length of the following data transfer */
  99. u8 medium_type; /* Medium Type */
  100. u8 dsp; /* Device Specific Parameter */
  101. u8 bdl; /* Block Descriptor Length */
  102. } osst_mode_parameter_header_t;
  103. /*
  104. * Mode Parameter Block Descriptor the MODE SENSE packet command
  105. *
  106. * Support for block descriptors is optional.
  107. */
  108. typedef struct {
  109. u8 density_code; /* Medium density code */
  110. u8 blocks[3]; /* Number of blocks */
  111. u8 reserved4; /* Reserved */
  112. u8 length[3]; /* Block Length */
  113. } osst_parameter_block_descriptor_t;
  114. /*
  115. * The Data Compression Page, as returned by the MODE SENSE packet command.
  116. */
  117. typedef struct {
  118. #if defined(__BIG_ENDIAN_BITFIELD)
  119. unsigned ps :1;
  120. unsigned reserved0 :1; /* Reserved */
  121. unsigned page_code :6; /* Page Code - Should be 0xf */
  122. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  123. unsigned page_code :6; /* Page Code - Should be 0xf */
  124. unsigned reserved0 :1; /* Reserved */
  125. unsigned ps :1;
  126. #else
  127. #error "Please fix <asm/byteorder.h>"
  128. #endif
  129. u8 page_length; /* Page Length - Should be 14 */
  130. #if defined(__BIG_ENDIAN_BITFIELD)
  131. unsigned dce :1; /* Data Compression Enable */
  132. unsigned dcc :1; /* Data Compression Capable */
  133. unsigned reserved2 :6; /* Reserved */
  134. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  135. unsigned reserved2 :6; /* Reserved */
  136. unsigned dcc :1; /* Data Compression Capable */
  137. unsigned dce :1; /* Data Compression Enable */
  138. #else
  139. #error "Please fix <asm/byteorder.h>"
  140. #endif
  141. #if defined(__BIG_ENDIAN_BITFIELD)
  142. unsigned dde :1; /* Data Decompression Enable */
  143. unsigned red :2; /* Report Exception on Decompression */
  144. unsigned reserved3 :5; /* Reserved */
  145. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  146. unsigned reserved3 :5; /* Reserved */
  147. unsigned red :2; /* Report Exception on Decompression */
  148. unsigned dde :1; /* Data Decompression Enable */
  149. #else
  150. #error "Please fix <asm/byteorder.h>"
  151. #endif
  152. u32 ca; /* Compression Algorithm */
  153. u32 da; /* Decompression Algorithm */
  154. u8 reserved[4]; /* Reserved */
  155. } osst_data_compression_page_t;
  156. /*
  157. * The Medium Partition Page, as returned by the MODE SENSE packet command.
  158. */
  159. typedef struct {
  160. #if defined(__BIG_ENDIAN_BITFIELD)
  161. unsigned ps :1;
  162. unsigned reserved1_6 :1; /* Reserved */
  163. unsigned page_code :6; /* Page Code - Should be 0x11 */
  164. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  165. unsigned page_code :6; /* Page Code - Should be 0x11 */
  166. unsigned reserved1_6 :1; /* Reserved */
  167. unsigned ps :1;
  168. #else
  169. #error "Please fix <asm/byteorder.h>"
  170. #endif
  171. u8 page_length; /* Page Length - Should be 6 */
  172. u8 map; /* Maximum Additional Partitions - Should be 0 */
  173. u8 apd; /* Additional Partitions Defined - Should be 0 */
  174. #if defined(__BIG_ENDIAN_BITFIELD)
  175. unsigned fdp :1; /* Fixed Data Partitions */
  176. unsigned sdp :1; /* Should be 0 */
  177. unsigned idp :1; /* Should be 0 */
  178. unsigned psum :2; /* Should be 0 */
  179. unsigned reserved4_012 :3; /* Reserved */
  180. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  181. unsigned reserved4_012 :3; /* Reserved */
  182. unsigned psum :2; /* Should be 0 */
  183. unsigned idp :1; /* Should be 0 */
  184. unsigned sdp :1; /* Should be 0 */
  185. unsigned fdp :1; /* Fixed Data Partitions */
  186. #else
  187. #error "Please fix <asm/byteorder.h>"
  188. #endif
  189. u8 mfr; /* Medium Format Recognition */
  190. u8 reserved[2]; /* Reserved */
  191. } osst_medium_partition_page_t;
  192. /*
  193. * Capabilities and Mechanical Status Page
  194. */
  195. typedef struct {
  196. #if defined(__BIG_ENDIAN_BITFIELD)
  197. unsigned reserved1_67 :2;
  198. unsigned page_code :6; /* Page code - Should be 0x2a */
  199. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  200. unsigned page_code :6; /* Page code - Should be 0x2a */
  201. unsigned reserved1_67 :2;
  202. #else
  203. #error "Please fix <asm/byteorder.h>"
  204. #endif
  205. u8 page_length; /* Page Length - Should be 0x12 */
  206. u8 reserved2, reserved3;
  207. #if defined(__BIG_ENDIAN_BITFIELD)
  208. unsigned reserved4_67 :2;
  209. unsigned sprev :1; /* Supports SPACE in the reverse direction */
  210. unsigned reserved4_1234 :4;
  211. unsigned ro :1; /* Read Only Mode */
  212. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  213. unsigned ro :1; /* Read Only Mode */
  214. unsigned reserved4_1234 :4;
  215. unsigned sprev :1; /* Supports SPACE in the reverse direction */
  216. unsigned reserved4_67 :2;
  217. #else
  218. #error "Please fix <asm/byteorder.h>"
  219. #endif
  220. #if defined(__BIG_ENDIAN_BITFIELD)
  221. unsigned reserved5_67 :2;
  222. unsigned qfa :1; /* Supports the QFA two partition formats */
  223. unsigned reserved5_4 :1;
  224. unsigned efmt :1; /* Supports ERASE command initiated formatting */
  225. unsigned reserved5_012 :3;
  226. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  227. unsigned reserved5_012 :3;
  228. unsigned efmt :1; /* Supports ERASE command initiated formatting */
  229. unsigned reserved5_4 :1;
  230. unsigned qfa :1; /* Supports the QFA two partition formats */
  231. unsigned reserved5_67 :2;
  232. #else
  233. #error "Please fix <asm/byteorder.h>"
  234. #endif
  235. #if defined(__BIG_ENDIAN_BITFIELD)
  236. unsigned cmprs :1; /* Supports data compression */
  237. unsigned ecc :1; /* Supports error correction */
  238. unsigned reserved6_45 :2; /* Reserved */
  239. unsigned eject :1; /* The device can eject the volume */
  240. unsigned prevent :1; /* The device defaults in the prevent state after power up */
  241. unsigned locked :1; /* The volume is locked */
  242. unsigned lock :1; /* Supports locking the volume */
  243. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  244. unsigned lock :1; /* Supports locking the volume */
  245. unsigned locked :1; /* The volume is locked */
  246. unsigned prevent :1; /* The device defaults in the prevent state after power up */
  247. unsigned eject :1; /* The device can eject the volume */
  248. unsigned reserved6_45 :2; /* Reserved */
  249. unsigned ecc :1; /* Supports error correction */
  250. unsigned cmprs :1; /* Supports data compression */
  251. #else
  252. #error "Please fix <asm/byteorder.h>"
  253. #endif
  254. #if defined(__BIG_ENDIAN_BITFIELD)
  255. unsigned blk32768 :1; /* slowb - the device restricts the byte count for PIO */
  256. /* transfers for slow buffer memory ??? */
  257. /* Also 32768 block size in some cases */
  258. unsigned reserved7_3_6 :4;
  259. unsigned blk1024 :1; /* Supports 1024 bytes block size */
  260. unsigned blk512 :1; /* Supports 512 bytes block size */
  261. unsigned reserved7_0 :1;
  262. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  263. unsigned reserved7_0 :1;
  264. unsigned blk512 :1; /* Supports 512 bytes block size */
  265. unsigned blk1024 :1; /* Supports 1024 bytes block size */
  266. unsigned reserved7_3_6 :4;
  267. unsigned blk32768 :1; /* slowb - the device restricts the byte count for PIO */
  268. /* transfers for slow buffer memory ??? */
  269. /* Also 32768 block size in some cases */
  270. #else
  271. #error "Please fix <asm/byteorder.h>"
  272. #endif
  273. __be16 max_speed; /* Maximum speed supported in KBps */
  274. u8 reserved10, reserved11;
  275. __be16 ctl; /* Continuous Transfer Limit in blocks */
  276. __be16 speed; /* Current Speed, in KBps */
  277. __be16 buffer_size; /* Buffer Size, in 512 bytes */
  278. u8 reserved18, reserved19;
  279. } osst_capabilities_page_t;
  280. /*
  281. * Block Size Page
  282. */
  283. typedef struct {
  284. #if defined(__BIG_ENDIAN_BITFIELD)
  285. unsigned ps :1;
  286. unsigned reserved1_6 :1;
  287. unsigned page_code :6; /* Page code - Should be 0x30 */
  288. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  289. unsigned page_code :6; /* Page code - Should be 0x30 */
  290. unsigned reserved1_6 :1;
  291. unsigned ps :1;
  292. #else
  293. #error "Please fix <asm/byteorder.h>"
  294. #endif
  295. u8 page_length; /* Page Length - Should be 2 */
  296. u8 reserved2;
  297. #if defined(__BIG_ENDIAN_BITFIELD)
  298. unsigned one :1;
  299. unsigned reserved2_6 :1;
  300. unsigned record32_5 :1;
  301. unsigned record32 :1;
  302. unsigned reserved2_23 :2;
  303. unsigned play32_5 :1;
  304. unsigned play32 :1;
  305. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  306. unsigned play32 :1;
  307. unsigned play32_5 :1;
  308. unsigned reserved2_23 :2;
  309. unsigned record32 :1;
  310. unsigned record32_5 :1;
  311. unsigned reserved2_6 :1;
  312. unsigned one :1;
  313. #else
  314. #error "Please fix <asm/byteorder.h>"
  315. #endif
  316. } osst_block_size_page_t;
  317. /*
  318. * Tape Parameters Page
  319. */
  320. typedef struct {
  321. #if defined(__BIG_ENDIAN_BITFIELD)
  322. unsigned ps :1;
  323. unsigned reserved1_6 :1;
  324. unsigned page_code :6; /* Page code - Should be 0x2b */
  325. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  326. unsigned page_code :6; /* Page code - Should be 0x2b */
  327. unsigned reserved1_6 :1;
  328. unsigned ps :1;
  329. #else
  330. #error "Please fix <asm/byteorder.h>"
  331. #endif
  332. u8 reserved2;
  333. u8 density;
  334. u8 reserved3,reserved4;
  335. __be16 segtrk;
  336. __be16 trks;
  337. u8 reserved5,reserved6,reserved7,reserved8,reserved9,reserved10;
  338. } osst_tape_paramtr_page_t;
  339. /* OnStream definitions */
  340. #define OS_CONFIG_PARTITION (0xff)
  341. #define OS_DATA_PARTITION (0)
  342. #define OS_PARTITION_VERSION (1)
  343. /*
  344. * partition
  345. */
  346. typedef struct os_partition_s {
  347. __u8 partition_num;
  348. __u8 par_desc_ver;
  349. __be16 wrt_pass_cntr;
  350. __be32 first_frame_ppos;
  351. __be32 last_frame_ppos;
  352. __be32 eod_frame_ppos;
  353. } os_partition_t;
  354. /*
  355. * DAT entry
  356. */
  357. typedef struct os_dat_entry_s {
  358. __be32 blk_sz;
  359. __be16 blk_cnt;
  360. __u8 flags;
  361. __u8 reserved;
  362. } os_dat_entry_t;
  363. /*
  364. * DAT
  365. */
  366. #define OS_DAT_FLAGS_DATA (0xc)
  367. #define OS_DAT_FLAGS_MARK (0x1)
  368. typedef struct os_dat_s {
  369. __u8 dat_sz;
  370. __u8 reserved1;
  371. __u8 entry_cnt;
  372. __u8 reserved3;
  373. os_dat_entry_t dat_list[16];
  374. } os_dat_t;
  375. /*
  376. * Frame types
  377. */
  378. #define OS_FRAME_TYPE_FILL (0)
  379. #define OS_FRAME_TYPE_EOD (1 << 0)
  380. #define OS_FRAME_TYPE_MARKER (1 << 1)
  381. #define OS_FRAME_TYPE_HEADER (1 << 3)
  382. #define OS_FRAME_TYPE_DATA (1 << 7)
  383. /*
  384. * AUX
  385. */
  386. typedef struct os_aux_s {
  387. __be32 format_id; /* hardware compatibility AUX is based on */
  388. char application_sig[4]; /* driver used to write this media */
  389. __be32 hdwr; /* reserved */
  390. __be32 update_frame_cntr; /* for configuration frame */
  391. __u8 frame_type;
  392. __u8 frame_type_reserved;
  393. __u8 reserved_18_19[2];
  394. os_partition_t partition;
  395. __u8 reserved_36_43[8];
  396. __be32 frame_seq_num;
  397. __be32 logical_blk_num_high;
  398. __be32 logical_blk_num;
  399. os_dat_t dat;
  400. __u8 reserved188_191[4];
  401. __be32 filemark_cnt;
  402. __be32 phys_fm;
  403. __be32 last_mark_ppos;
  404. __u8 reserved204_223[20];
  405. /*
  406. * __u8 app_specific[32];
  407. *
  408. * Linux specific fields:
  409. */
  410. __be32 next_mark_ppos; /* when known, points to next marker */
  411. __be32 last_mark_lbn; /* storing log_blk_num of last mark is extends ADR spec */
  412. __u8 linux_specific[24];
  413. __u8 reserved_256_511[256];
  414. } os_aux_t;
  415. #define OS_FM_TAB_MAX 1024
  416. typedef struct os_fm_tab_s {
  417. __u8 fm_part_num;
  418. __u8 reserved_1;
  419. __u8 fm_tab_ent_sz;
  420. __u8 reserved_3;
  421. __be16 fm_tab_ent_cnt;
  422. __u8 reserved6_15[10];
  423. __be32 fm_tab_ent[OS_FM_TAB_MAX];
  424. } os_fm_tab_t;
  425. typedef struct os_ext_trk_ey_s {
  426. __u8 et_part_num;
  427. __u8 fmt;
  428. __be16 fm_tab_off;
  429. __u8 reserved4_7[4];
  430. __be32 last_hlb_hi;
  431. __be32 last_hlb;
  432. __be32 last_pp;
  433. __u8 reserved20_31[12];
  434. } os_ext_trk_ey_t;
  435. typedef struct os_ext_trk_tb_s {
  436. __u8 nr_stream_part;
  437. __u8 reserved_1;
  438. __u8 et_ent_sz;
  439. __u8 reserved3_15[13];
  440. os_ext_trk_ey_t dat_ext_trk_ey;
  441. os_ext_trk_ey_t qfa_ext_trk_ey;
  442. } os_ext_trk_tb_t;
  443. typedef struct os_header_s {
  444. char ident_str[8];
  445. __u8 major_rev;
  446. __u8 minor_rev;
  447. __be16 ext_trk_tb_off;
  448. __u8 reserved12_15[4];
  449. __u8 pt_par_num;
  450. __u8 pt_reserved1_3[3];
  451. os_partition_t partition[16];
  452. __be32 cfg_col_width;
  453. __be32 dat_col_width;
  454. __be32 qfa_col_width;
  455. __u8 cartridge[16];
  456. __u8 reserved304_511[208];
  457. __be32 old_filemark_list[16680/4]; /* in ADR 1.4 __u8 track_table[16680] */
  458. os_ext_trk_tb_t ext_track_tb;
  459. __u8 reserved17272_17735[464];
  460. os_fm_tab_t dat_fm_tab;
  461. os_fm_tab_t qfa_fm_tab;
  462. __u8 reserved25960_32767[6808];
  463. } os_header_t;
  464. /*
  465. * OnStream ADRL frame
  466. */
  467. #define OS_FRAME_SIZE (32 * 1024 + 512)
  468. #define OS_DATA_SIZE (32 * 1024)
  469. #define OS_AUX_SIZE (512)
  470. //#define OSST_MAX_SG 2
  471. /* The OnStream tape buffer descriptor. */
  472. struct osst_buffer {
  473. unsigned char in_use;
  474. unsigned char dma; /* DMA-able buffer */
  475. int buffer_size;
  476. int buffer_blocks;
  477. int buffer_bytes;
  478. int read_pointer;
  479. int writing;
  480. int midlevel_result;
  481. int syscall_result;
  482. struct osst_request *last_SRpnt;
  483. struct st_cmdstatus cmdstat;
  484. struct rq_map_data map_data;
  485. unsigned char *b_data;
  486. os_aux_t *aux; /* onstream AUX structure at end of each block */
  487. unsigned short use_sg; /* zero or number of s/g segments for this adapter */
  488. unsigned short sg_segs; /* number of segments in s/g list */
  489. unsigned short orig_sg_segs; /* number of segments allocated at first try */
  490. struct scatterlist sg[1]; /* MUST BE last item */
  491. } ;
  492. /* The OnStream tape drive descriptor */
  493. struct osst_tape {
  494. struct scsi_driver *driver;
  495. unsigned capacity;
  496. struct scsi_device *device;
  497. struct mutex lock; /* for serialization */
  498. struct completion wait; /* for SCSI commands */
  499. struct osst_buffer * buffer;
  500. /* Drive characteristics */
  501. unsigned char omit_blklims;
  502. unsigned char do_auto_lock;
  503. unsigned char can_bsr;
  504. unsigned char can_partitions;
  505. unsigned char two_fm;
  506. unsigned char fast_mteom;
  507. unsigned char restr_dma;
  508. unsigned char scsi2_logical;
  509. unsigned char default_drvbuffer; /* 0xff = don't touch, value 3 bits */
  510. unsigned char pos_unknown; /* after reset position unknown */
  511. int write_threshold;
  512. int timeout; /* timeout for normal commands */
  513. int long_timeout; /* timeout for commands known to take long time*/
  514. /* Mode characteristics */
  515. struct st_modedef modes[ST_NBR_MODES];
  516. int current_mode;
  517. /* Status variables */
  518. int partition;
  519. int new_partition;
  520. int nbr_partitions; /* zero until partition support enabled */
  521. struct st_partstat ps[ST_NBR_PARTITIONS];
  522. unsigned char dirty;
  523. unsigned char ready;
  524. unsigned char write_prot;
  525. unsigned char drv_write_prot;
  526. unsigned char in_use;
  527. unsigned char blksize_changed;
  528. unsigned char density_changed;
  529. unsigned char compression_changed;
  530. unsigned char drv_buffer;
  531. unsigned char density;
  532. unsigned char door_locked;
  533. unsigned char rew_at_close;
  534. unsigned char inited;
  535. int block_size;
  536. int min_block;
  537. int max_block;
  538. int recover_count; /* from tape opening */
  539. int abort_count;
  540. int write_count;
  541. int read_count;
  542. int recover_erreg; /* from last status call */
  543. /*
  544. * OnStream specific data
  545. */
  546. int os_fw_rev; /* the firmware revision * 10000 */
  547. unsigned char raw; /* flag OnStream raw access (32.5KB block size) */
  548. unsigned char poll; /* flag that this drive needs polling (IDE|firmware) */
  549. unsigned char frame_in_buffer; /* flag that the frame as per frame_seq_number
  550. * has been read into STp->buffer and is valid */
  551. int frame_seq_number; /* logical frame number */
  552. int logical_blk_num; /* logical block number */
  553. unsigned first_frame_position; /* physical frame to be transferred to/from host */
  554. unsigned last_frame_position; /* physical frame to be transferd to/from tape */
  555. int cur_frames; /* current number of frames in internal buffer */
  556. int max_frames; /* max number of frames in internal buffer */
  557. char application_sig[5]; /* application signature */
  558. unsigned char fast_open; /* flag that reminds us we didn't check headers at open */
  559. unsigned short wrt_pass_cntr; /* write pass counter */
  560. int update_frame_cntr; /* update frame counter */
  561. int onstream_write_error; /* write error recovery active */
  562. int header_ok; /* header frame verified ok */
  563. int linux_media; /* reading linux-specifc media */
  564. int linux_media_version;
  565. os_header_t * header_cache; /* cache is kept for filemark positions */
  566. int filemark_cnt;
  567. int first_mark_ppos;
  568. int last_mark_ppos;
  569. int last_mark_lbn; /* storing log_blk_num of last mark is extends ADR spec */
  570. int first_data_ppos;
  571. int eod_frame_ppos;
  572. int eod_frame_lfa;
  573. int write_type; /* used in write error recovery */
  574. int read_error_frame; /* used in read error recovery */
  575. unsigned long cmd_start_time;
  576. unsigned long max_cmd_time;
  577. #if DEBUG
  578. unsigned char write_pending;
  579. int nbr_finished;
  580. int nbr_waits;
  581. unsigned char last_cmnd[6];
  582. unsigned char last_sense[16];
  583. #endif
  584. struct gendisk *drive;
  585. } ;
  586. /* scsi tape command */
  587. struct osst_request {
  588. unsigned char cmd[MAX_COMMAND_SIZE];
  589. unsigned char sense[SCSI_SENSE_BUFFERSIZE];
  590. int result;
  591. struct osst_tape *stp;
  592. struct completion *waiting;
  593. struct bio *bio;
  594. };
  595. /* Values of write_type */
  596. #define OS_WRITE_DATA 0
  597. #define OS_WRITE_EOD 1
  598. #define OS_WRITE_NEW_MARK 2
  599. #define OS_WRITE_LAST_MARK 3
  600. #define OS_WRITE_HEADER 4
  601. #define OS_WRITE_FILLER 5
  602. /* Additional rw state */
  603. #define OS_WRITING_COMPLETE 3