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