pg.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* pg.h (c) 1998 Grant R. Guenther <grant@torque.net>
  2. Under the terms of the GNU General Public License
  3. pg.h defines the user interface to the generic ATAPI packet
  4. command driver for parallel port ATAPI devices (pg). The
  5. driver is loosely modelled after the generic SCSI driver, sg,
  6. although the actual interface is different.
  7. The pg driver provides a simple character device interface for
  8. sending ATAPI commands to a device. With the exception of the
  9. ATAPI reset operation, all operations are performed by a pair
  10. of read and write operations to the appropriate /dev/pgN device.
  11. A write operation delivers a command and any outbound data in
  12. a single buffer. Normally, the write will succeed unless the
  13. device is offline or malfunctioning, or there is already another
  14. command pending. If the write succeeds, it should be followed
  15. immediately by a read operation, to obtain any returned data and
  16. status information. A read will fail if there is no operation
  17. in progress.
  18. As a special case, the device can be reset with a write operation,
  19. and in this case, no following read is expected, or permitted.
  20. There are no ioctl() operations. Any single operation
  21. may transfer at most PG_MAX_DATA bytes. Note that the driver must
  22. copy the data through an internal buffer. In keeping with all
  23. current ATAPI devices, command packets are assumed to be exactly
  24. 12 bytes in length.
  25. To permit future changes to this interface, the headers in the
  26. read and write buffers contain a single character "magic" flag.
  27. Currently this flag must be the character "P".
  28. */
  29. #define PG_MAGIC 'P'
  30. #define PG_RESET 'Z'
  31. #define PG_COMMAND 'C'
  32. #define PG_MAX_DATA 32768
  33. struct pg_write_hdr {
  34. char magic; /* == PG_MAGIC */
  35. char func; /* PG_RESET or PG_COMMAND */
  36. int dlen; /* number of bytes expected to transfer */
  37. int timeout; /* number of seconds before timeout */
  38. char packet[12]; /* packet command */
  39. };
  40. struct pg_read_hdr {
  41. char magic; /* == PG_MAGIC */
  42. char scsi; /* "scsi" status == sense key */
  43. int dlen; /* size of device transfer request */
  44. int duration; /* time in seconds command took */
  45. char pad[12]; /* not used */
  46. };
  47. /* end of pg.h */