pg.h 2.3 KB

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