2 * Copyright (c) 1998 - 2005 Søren Schmidt <sos@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 /* ATAPI tape drive Capabilities and Mechanical Status Page */
33 /* mode page data header */
34 u_int8_t data_length; /* total length of data */
35 u_int8_t medium_type; /* medium type (if any) */
37 u_int8_t mode :3; /* buffering mode */
38 u_int8_t write_protect :1; /* media is writeprotected */
39 u_int8_t blk_desc_len; /* block Descriptor Length */
41 /* capabilities page */
42 u_int8_t page_code :6;
43 #define ATAPI_TAPE_CAP_PAGE 0x2a
45 u_int8_t reserved0_6 :1;
46 u_int8_t ps :1; /* parameters saveable */
47 u_int8_t page_length; /* page Length == 0x12 */
50 u_int8_t readonly :1; /* read Only Mode */
51 u_int8_t reserved4_1234 :4;
52 u_int8_t reverse :1; /* supports reverse direction */
53 u_int8_t reserved4_67 :2;
54 u_int8_t reserved5_012 :3;
55 u_int8_t eformat :1; /* supports ERASE formatting */
56 u_int8_t reserved5_4 :1;
57 u_int8_t qfa :1; /* supports QFA formats */
58 u_int8_t reserved5_67 :2;
59 u_int8_t lock :1; /* supports locking media */
60 u_int8_t locked :1; /* the media is locked */
61 u_int8_t prevent :1; /* defaults to prevent state */
62 u_int8_t eject :1; /* supports eject */
63 u_int8_t disconnect :1; /* can break request > ctl */
64 u_int8_t reserved6_5 :1;
65 u_int8_t ecc :1; /* supports error correction */
66 u_int8_t compress :1; /* supports data compression */
67 u_int8_t reserved7_0 :1;
68 u_int8_t blk512 :1; /* supports 512b block size */
69 u_int8_t blk1024 :1; /* supports 1024b block size */
70 u_int8_t reserved7_3456 :4;
71 u_int8_t blk32k :1; /* supports 32kb block size */
72 u_int16_t max_speed; /* supported speed in KBps */
73 u_int16_t max_defects; /* max stored defect entries */
74 u_int16_t ctl; /* continuous transfer limit */
75 u_int16_t speed; /* current Speed, in KBps */
76 u_int16_t buffer_size; /* buffer Size, in 512 bytes */
81 /* ATAPI OnStream ADR data transfer mode page (ADR unique) */
82 struct ast_transferpage {
83 /* mode page data header */
84 u_int8_t data_length; /* total length of data */
85 u_int8_t medium_type; /* medium type (if any) */
86 u_int8_t dsp; /* device specific parameter */
87 u_int8_t blk_desc_len; /* block Descriptor Length */
89 /* data transfer page */
90 u_int8_t page_code :6;
91 #define ATAPI_TAPE_TRANSFER_PAGE 0x30
93 u_int8_t reserved0_6 :1;
94 u_int8_t ps :1; /* parameters saveable */
95 u_int8_t page_length; /* page Length == 0x02 */
97 u_int8_t read32k :1; /* 32k blk size (data only) */
98 u_int8_t read32k5 :1; /* 32.5k blk size (data&AUX) */
99 u_int8_t reserved3_23 :2;
100 u_int8_t write32k :1; /* 32k blk size (data only) */
101 u_int8_t write32k5 :1; /* 32.5k blk size (data&AUX) */
102 u_int8_t reserved3_6 :1;
103 u_int8_t streaming :1; /* streaming mode enable */
106 /* ATAPI OnStream ADR vendor identification mode page (ADR unique) */
107 struct ast_identifypage {
108 /* mode page data header */
109 u_int8_t data_length; /* total length of data */
110 u_int8_t medium_type; /* medium type (if any) */
111 u_int8_t dsp; /* device specific parameter */
112 u_int8_t blk_desc_len; /* block Descriptor Length */
114 /* data transfer page */
115 u_int8_t page_code :6;
116 #define ATAPI_TAPE_IDENTIFY_PAGE 0x36
118 u_int8_t reserved0_6 :1;
119 u_int8_t ps :1; /* parameters saveable */
120 u_int8_t page_length; /* page Length == 0x06 */
121 u_int8_t ident[4]; /* host id string */
126 /* ATAPI read position structure */
127 struct ast_readposition {
128 u_int8_t reserved0_05 :6;
129 u_int8_t eop :1; /* end of partition */
130 u_int8_t bop :1; /* beginning of partition */
134 u_int32_t host; /* frame address in buffer */
135 u_int32_t tape; /* frame address on tape */
139 u_int8_t blks_in_buf; /* blocks in buffer */
147 int flags; /* device state flags */
148 #define F_CTL_WARN 0x0001 /* warned about CTL wrong? */
149 #define F_WRITEPROTECT 0x0002 /* media is writeprotected */
150 #define F_DATA_WRITTEN 0x0004 /* data has been written */
151 #define F_FM_WRITTEN 0x0008 /* filemark has been written */
152 #define F_ONSTREAM 0x0100 /* OnStream ADR device */
154 int blksize; /* block size (512 | 1024) */
155 struct atapi_params *param; /* drive parameters table */
156 struct ast_cappage cap; /* capabilities page info */
157 struct devstat *stats; /* devstat entry */
158 struct cdev *dev1, *dev2; /* device place holders */