home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / f / ftp-102.zip / ftape-1.02 / driver / fdtape-io.h < prev    next >
C/C++ Source or Header  |  1992-10-12  |  8KB  |  261 lines

  1. /* Floppy tape drive control.
  2.    Copyright (C) 1992 David L. Brown, Jr.
  3.  
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; see the file COPYING.  If not, write to
  16. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. /*
  19.  * fdtape-io.h,v 1.10 1992/10/13 01:44:24 dbrown Exp
  20.  *
  21.  * fdtape-io.h,v
  22.  * Revision 1.10  1992/10/13  01:44:24  dbrown
  23.  * Added FSF copyright.
  24.  *
  25.  * Revision 1.9  1992/10/12  05:12:20  dbrown
  26.  * Added ioctl to set drive data rate.
  27.  *
  28.  * Revision 1.8  1992/10/10  03:19:19  dbrown
  29.  * Added write error handling so that errors and their location can be
  30.  * passed back to the user.
  31.  *
  32.  * Revision 1.7  1992/10/09  05:53:26  dbrown
  33.  * Read is reliable.  Write is flaky and can't handle errors.
  34.  *
  35.  * Revision 1.6  1992/10/09  00:35:56  dbrown
  36.  * Initial writing of full write.  Untested.
  37.  *
  38.  * Revision 1.5  1992/10/08  23:45:10  dbrown
  39.  * Read now does a copyout instead of using mapped buffers.  Before, read
  40.  * didn't have any control of when the user would actually get the data
  41.  * out of the buffer.  If the user delayed, then that data could be
  42.  * overwritten with the read from tape.
  43.  *
  44.  * Revision 1.4  1992/10/08  04:52:23  dbrown
  45.  * First attempt to add streaming read.  Doesn't really work and panics
  46.  * periodically.
  47.  *
  48.  * Revision 1.3  1992/10/04  23:10:04  dbrown
  49.  * Added facilities for performing seek test.
  50.  *
  51.  * Revision 1.2  1992/10/04  21:45:50  dbrown
  52.  * Now supports non-streaming, single sector reads.
  53.  *
  54.  * Revision 1.1  1992/10/03  22:20:19  dbrown
  55.  * Copied originally from old fdtape driver.
  56.  *
  57.  */
  58.  
  59. #ifndef _FDTAPE_H_
  60. #define _FDTAPE_H_
  61.  
  62. #ifndef __STDC__
  63. #error Need support for non-ansi C.
  64. #endif
  65.  
  66. /* Reset the tape drive. */
  67.  
  68. #define FDT_RESET    _IO ('z', 0)
  69.  
  70. /* Report drive status.  Returns the status as an integer. */
  71.  
  72. #define FDT_REPORT_STATUS    _IOR ('z', 1, int)
  73.  
  74. /* Status bits. */
  75.  
  76. #define FDT_READY    0x01    /* Drive is ready. */
  77. #define FDT_ERROR    0x02    /* Error detected, must read error
  78.                    code to clear. */
  79. #define FDT_CARTRIDGE_PRESENT \
  80.             0x04    /* Tape is present. */
  81. #define FDT_WRITE_PROTECT 0x08
  82. #define FDT_NEW_CARTRIDGE \
  83.             0x10    /* New cartridge has been inserted.
  84.                    Must read error code to clear. */
  85. #define FDT_REFERENCED    0x20    /* Cartridge appears to have been
  86.                    formatted. */
  87. #define FDT_AT_BOT    0x40    /* At beginning of tape. */
  88. #define FDT_AT_EOT    0x80    /* At end of tape. */
  89.  
  90. /* Report drive error code.  There is an error code and the associated
  91.    QIC command that caused it. */
  92.  
  93. struct fdt_error {
  94.   int error;
  95.   int command;
  96. };
  97.  
  98. #define FDT_REPORT_ERROR_CODE    _IOR ('z', 2, struct fdt_error)
  99.  
  100. /* Report the drive configuration. */
  101.  
  102. #define FDT_REPORT_CONFIGURATION _IOR ('z', 3, int)
  103.  
  104. #define FDT_CONF_RATE_MASK    0x18
  105. #define FDT_CONF_RATE_250    0x00
  106. #define FDT_CONF_RATE_500    0x10
  107. #define FDT_CONF_RATE_1000    0x18
  108. #define FDT_CONF_EXTRA_LENGTH    0x40
  109. #define FDT_CONF_QIC_80        0x80
  110.  
  111. /* Report the drive ROM version. */
  112.  
  113. #define FDT_REPORT_ROM_VERSION    _IOR ('z', 4, int)
  114.  
  115. /* Report the unit vendor ID. */
  116.  
  117. #define FDT_REPORT_VENDOR_ID    _IOR ('z', 5, int)
  118.  
  119. /* Various seeks. */
  120.  
  121. #define FDT_SEEK_TO_END        _IO ('z', 6)
  122. #define FDT_SEEK_TO_BEGINNING    _IO ('z', 7)
  123. #define FDT_SEEK_FORWARD    _IOW ('z', 8, int)
  124. #define FDT_SEEK_REVERSE    _IOW ('z', 9, int)
  125.  
  126. #define FDT_STOP_TAPE        _IO ('z', 10)
  127.  
  128. /* Temporary operations until this is moved completely into the
  129.    driver. */
  130.  
  131. #define FDT_LOGICAL_FORWARD    _IO ('z', 200)
  132. #define FDT_PAUSE        _IO ('z', 201)
  133. #define FDT_SEEK_TO_TRACK    _IOW ('z', 202, int)
  134.  
  135. struct _fdt_id {
  136.   int cylinder;
  137.   int head;
  138.   int sector;
  139. };
  140.  
  141. #define FDT_READ_ID        _IOR ('z', 203, struct _fdt_id)
  142.  
  143. struct _fdt_find_me {
  144.   int segment;
  145.   int first_segment;
  146.   int actual_segment;
  147.   int result;
  148. };
  149.  
  150. #define FDT_FIND_ME        _IOWR ('z', 204, struct _fdt_find_me)
  151.  
  152. /* The read and write requests have an error mask.  Each bit starting
  153.    from the lowest bit correspond to each sector in the segment.  Any
  154.    bits that are set in the error mask will not be read from or
  155.    written to the tape.  The data should be packed in around these
  156.    missing sectors.  For example, if sector number 3 (the forth one)
  157.    is bad, the error_mask will be 0x00000008.  There will only be 29K
  158.    of data with sector 4 immediately following sector number 2. */
  159.  
  160. /* Before any reading and writing can occur, the bad sector table for
  161.    the current track must be given to the driver. */
  162.  
  163. struct error_map {
  164.   int count;
  165.   unsigned long *error_masks;
  166. };
  167.  
  168. #define FDT_SUBMIT_ERROR_MAP    _IOW ('z', 11, struct error_map)
  169.  
  170. /* Read data from the tape.  Reads the specified segment.  Assmes that
  171.    the tape is already positioned properly.  actual_segment returns
  172.    the result code.  -3 indicates a read error.  -2 is end of tape
  173.    reached.  -1 indicates data has been properly read.  Any value >= 0
  174.    indicates that this numbered segment just passed under the tape
  175.    head instead of the desired value.  [Design a better interface
  176.    here.] */
  177.  
  178. struct tape_read {
  179.   int segment;            /* In:  Segment to read. */
  180.   int count;            /* In:  Hint of number of segments
  181.                    we're going to read. */
  182.   int actual_segment;        /* Out: Error or segment read. */
  183.   char *buffer;            /* In: 32k buffer to place data into. */
  184.   unsigned long error_bits;    /* Out: Bits indicating read error.
  185.                    These bits correspond to the blocks
  186.                    in the segment _after_ the blocks
  187.                    have been packed from the
  188.                    error_mask. */
  189. };
  190.  
  191. #define FDT_READ        _IOWR ('z', 12, struct tape_read)
  192.  
  193. /* Write data to the tape.  Writes the specified segment.  Assumes
  194.    that the tape is already positioned properly.  actual_segment
  195.    returns the result code.  -3 indicates a write error.  -2 is end of
  196.    tape.  -1 is proper write.  Any value >= 0 indicates that this
  197.    numbered segment just passed under the tape head instead of the
  198.    desired segment. */
  199.  
  200. struct tape_write {
  201.   int segment;            /* In:  Segment to read. */
  202.   int actual_segment;        /* Out: Error or segment read. */
  203.   char *buffer;            /* In:  Buffer to write.  Must be
  204.                    32768 bytes long */
  205.   int error_location;        /* Out: What segment was being written
  206.                    when the error occurred? */
  207. };
  208.  
  209. #define FDT_WRITE        _IOWR ('z', 13, struct tape_write)
  210.  
  211. /* Inform driver that writes are done and wait for tape to stop
  212.    writing.  The integer is the actual segment as an error result from
  213.    previous writing. */
  214.  
  215. struct write_cease {
  216.   int actual_segment;        /* Actual segment written (-1 is ok). */
  217.   int error_location;        /* What segment was being written when
  218.                    the error occurred? */
  219. };
  220. #define FDT_CEASE_WRITING    _IOR ('z', 15, struct write_cease)
  221.  
  222. /* Set the track length in segments. */
  223.  
  224. #define FDT_SET_TRACK_LENGTH    _IOW ('z', 14, int)
  225.  
  226. /* Stop reading. */
  227.  
  228. #define FDT_READ_STOP        _IO ('z', 16)
  229.  
  230. /* Set data rate. */
  231.  
  232. #define FDT_RATE_250 250
  233. #define FDT_RATE_500 500
  234.  
  235. #define FDT_SET_DATA_RATE    _IOW ('z', 17, int)
  236.  
  237. #if 0
  238. #define FDT_SLEEP        _IOW ('z', 14, int)
  239. #endif
  240.  
  241. /* Bits in the QIC status register. */
  242.  
  243. #define QIC_STATUS_READY    0x01 /* Drive is ready or idle. */
  244. #define QIC_STATUS_ERROR    0x02 /* Error detected. */
  245. #define QIC_STATUS_CARTRIDGE_PRESENT 0x04
  246. #define QIC_STATUS_WRITE_PROTECT 0x08
  247. #define QIC_STATUS_NEW_CARTRIDGE 0x10 /* New cartridge inserted, must
  248.                      read error status to clear. */
  249. #define QIC_STATUS_REFERENCED    0x20 /* Cartridge appears to have been
  250.                     formatted. */
  251. #define QIC_STATUS_AT_BOT    0x40 /* Cartridge is at physical
  252.                     beginning of tape. */
  253. #define QIC_STATUS_AT_EOT    0x80 /* Cartridge is at physical end
  254.                     of tape. */
  255.  
  256. /* Configuration bits. */
  257. #define QIC_CONFIG_LONG        0x40 /* Extra Length Tape Detected */
  258. #define QIC_CONFIG_80        0x80 /* QIC-80 detected. */
  259.  
  260. #endif _FDTAPE_H_
  261.