osst.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:24k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

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