1 /*- 2 * Copyright (c) 1998 - 2006 S�ren Schmidt <sos@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 * $FreeBSD: src/sys/dev/ata/atapi-tape.h,v 1.24 2006/01/05 21:27:19 sos Exp $ 27 * $DragonFly: src/sys/dev/disk/nata/atapi-tape.h,v 1.1 2006/12/04 14:40:37 tgen Exp $ 28 */ 29 30 #include <sys/param.h> 31 #include <sys/devicestat.h> 32 33 /* ATAPI tape drive Capabilities and Mechanical Status Page */ 34 struct ast_cappage { 35 /* mode page data header */ 36 u_int8_t data_length; /* total length of data */ 37 u_int8_t medium_type; /* medium type (if any) */ 38 u_int8_t reserved :4; 39 u_int8_t mode :3; /* buffering mode */ 40 u_int8_t write_protect :1; /* media is writeprotected */ 41 u_int8_t blk_desc_len; /* block Descriptor Length */ 42 43 /* capabilities page */ 44 u_int8_t page_code :6; 45 #define ATAPI_TAPE_CAP_PAGE 0x2a 46 47 u_int8_t reserved0_6 :1; 48 u_int8_t ps :1; /* parameters saveable */ 49 u_int8_t page_length; /* page Length == 0x12 */ 50 u_int8_t reserved2; 51 u_int8_t reserved3; 52 u_int8_t readonly :1; /* read Only Mode */ 53 u_int8_t reserved4_1234 :4; 54 u_int8_t reverse :1; /* supports reverse direction */ 55 u_int8_t reserved4_67 :2; 56 u_int8_t reserved5_012 :3; 57 u_int8_t eformat :1; /* supports ERASE formatting */ 58 u_int8_t reserved5_4 :1; 59 u_int8_t qfa :1; /* supports QFA formats */ 60 u_int8_t reserved5_67 :2; 61 u_int8_t lock :1; /* supports locking media */ 62 u_int8_t locked :1; /* the media is locked */ 63 u_int8_t prevent :1; /* defaults to prevent state */ 64 u_int8_t eject :1; /* supports eject */ 65 u_int8_t disconnect :1; /* can break request > ctl */ 66 u_int8_t reserved6_5 :1; 67 u_int8_t ecc :1; /* supports error correction */ 68 u_int8_t compress :1; /* supports data compression */ 69 u_int8_t reserved7_0 :1; 70 u_int8_t blk512 :1; /* supports 512b block size */ 71 u_int8_t blk1024 :1; /* supports 1024b block size */ 72 u_int8_t reserved7_3456 :4; 73 u_int8_t blk32k :1; /* supports 32kb block size */ 74 u_int16_t max_speed; /* supported speed in KBps */ 75 u_int16_t max_defects; /* max stored defect entries */ 76 u_int16_t ctl; /* continuous transfer limit */ 77 u_int16_t speed; /* current Speed, in KBps */ 78 u_int16_t buffer_size; /* buffer Size, in 512 bytes */ 79 u_int8_t reserved18; 80 u_int8_t reserved19; 81 }; 82 83 /* ATAPI OnStream ADR data transfer mode page (ADR unique) */ 84 struct ast_transferpage { 85 /* mode page data header */ 86 u_int8_t data_length; /* total length of data */ 87 u_int8_t medium_type; /* medium type (if any) */ 88 u_int8_t dsp; /* device specific parameter */ 89 u_int8_t blk_desc_len; /* block Descriptor Length */ 90 91 /* data transfer page */ 92 u_int8_t page_code :6; 93 #define ATAPI_TAPE_TRANSFER_PAGE 0x30 94 95 u_int8_t reserved0_6 :1; 96 u_int8_t ps :1; /* parameters saveable */ 97 u_int8_t page_length; /* page Length == 0x02 */ 98 u_int8_t reserved2; 99 u_int8_t read32k :1; /* 32k blk size (data only) */ 100 u_int8_t read32k5 :1; /* 32.5k blk size (data&AUX) */ 101 u_int8_t reserved3_23 :2; 102 u_int8_t write32k :1; /* 32k blk size (data only) */ 103 u_int8_t write32k5 :1; /* 32.5k blk size (data&AUX) */ 104 u_int8_t reserved3_6 :1; 105 u_int8_t streaming :1; /* streaming mode enable */ 106 }; 107 108 /* ATAPI OnStream ADR vendor identification mode page (ADR unique) */ 109 struct ast_identifypage { 110 /* mode page data header */ 111 u_int8_t data_length; /* total length of data */ 112 u_int8_t medium_type; /* medium type (if any) */ 113 u_int8_t dsp; /* device specific parameter */ 114 u_int8_t blk_desc_len; /* block Descriptor Length */ 115 116 /* data transfer page */ 117 u_int8_t page_code :6; 118 #define ATAPI_TAPE_IDENTIFY_PAGE 0x36 119 120 u_int8_t reserved0_6 :1; 121 u_int8_t ps :1; /* parameters saveable */ 122 u_int8_t page_length; /* page Length == 0x06 */ 123 u_int8_t ident[4]; /* host id string */ 124 u_int8_t reserved6; 125 u_int8_t reserved7; 126 }; 127 128 /* ATAPI read position structure */ 129 struct ast_readposition { 130 u_int8_t reserved0_05 :6; 131 u_int8_t eop :1; /* end of partition */ 132 u_int8_t bop :1; /* beginning of partition */ 133 u_int8_t reserved1; 134 u_int8_t reserved2; 135 u_int8_t reserved3; 136 u_int32_t host; /* frame address in buffer */ 137 u_int32_t tape; /* frame address on tape */ 138 u_int8_t reserved12; 139 u_int8_t reserved13; 140 u_int8_t reserved14; 141 u_int8_t blks_in_buf; /* blocks in buffer */ 142 u_int8_t reserved16; 143 u_int8_t reserved17; 144 u_int8_t reserved18; 145 u_int8_t reserved19; 146 }; 147 148 struct ast_softc { 149 int flags; /* device state flags */ 150 #define F_CTL_WARN 0x0001 /* warned about CTL wrong? */ 151 #define F_WRITEPROTECT 0x0002 /* media is writeprotected */ 152 #define F_DATA_WRITTEN 0x0004 /* data has been written */ 153 #define F_FM_WRITTEN 0x0008 /* filemark has been written */ 154 #define F_ONSTREAM 0x0100 /* OnStream ADR device */ 155 156 int blksize; /* block size (512 | 1024) */ 157 struct atapi_params *param; /* drive parameters table */ 158 struct ast_cappage cap; /* capabilities page info */ 159 struct devstat stats; /* devstat entry */ 160 cdev_t cdev1, cdev2; /* device place holders */ 161 }; 162