1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* pg.h (c) 1998 Grant R. Guenther <grant@torque.net> 3607ca46eSDavid Howells Under the terms of the GNU General Public License 4607ca46eSDavid Howells 5607ca46eSDavid Howells 6607ca46eSDavid Howells pg.h defines the user interface to the generic ATAPI packet 7607ca46eSDavid Howells command driver for parallel port ATAPI devices (pg). The 8607ca46eSDavid Howells driver is loosely modelled after the generic SCSI driver, sg, 9607ca46eSDavid Howells although the actual interface is different. 10607ca46eSDavid Howells 11607ca46eSDavid Howells The pg driver provides a simple character device interface for 12607ca46eSDavid Howells sending ATAPI commands to a device. With the exception of the 13607ca46eSDavid Howells ATAPI reset operation, all operations are performed by a pair 14607ca46eSDavid Howells of read and write operations to the appropriate /dev/pgN device. 15607ca46eSDavid Howells A write operation delivers a command and any outbound data in 16607ca46eSDavid Howells a single buffer. Normally, the write will succeed unless the 17607ca46eSDavid Howells device is offline or malfunctioning, or there is already another 18607ca46eSDavid Howells command pending. If the write succeeds, it should be followed 19607ca46eSDavid Howells immediately by a read operation, to obtain any returned data and 20607ca46eSDavid Howells status information. A read will fail if there is no operation 21607ca46eSDavid Howells in progress. 22607ca46eSDavid Howells 23607ca46eSDavid Howells As a special case, the device can be reset with a write operation, 24607ca46eSDavid Howells and in this case, no following read is expected, or permitted. 25607ca46eSDavid Howells 26607ca46eSDavid Howells There are no ioctl() operations. Any single operation 27607ca46eSDavid Howells may transfer at most PG_MAX_DATA bytes. Note that the driver must 28607ca46eSDavid Howells copy the data through an internal buffer. In keeping with all 29607ca46eSDavid Howells current ATAPI devices, command packets are assumed to be exactly 30607ca46eSDavid Howells 12 bytes in length. 31607ca46eSDavid Howells 32607ca46eSDavid Howells To permit future changes to this interface, the headers in the 33607ca46eSDavid Howells read and write buffers contain a single character "magic" flag. 34607ca46eSDavid Howells Currently this flag must be the character "P". 35607ca46eSDavid Howells 36607ca46eSDavid Howells */ 37607ca46eSDavid Howells 38*3a4b46c3SMasahiro Yamada #ifndef _UAPI_LINUX_PG_H 39*3a4b46c3SMasahiro Yamada #define _UAPI_LINUX_PG_H 40*3a4b46c3SMasahiro Yamada 41607ca46eSDavid Howells #define PG_MAGIC 'P' 42607ca46eSDavid Howells #define PG_RESET 'Z' 43607ca46eSDavid Howells #define PG_COMMAND 'C' 44607ca46eSDavid Howells 45607ca46eSDavid Howells #define PG_MAX_DATA 32768 46607ca46eSDavid Howells 47607ca46eSDavid Howells struct pg_write_hdr { 48607ca46eSDavid Howells 49607ca46eSDavid Howells char magic; /* == PG_MAGIC */ 50607ca46eSDavid Howells char func; /* PG_RESET or PG_COMMAND */ 51607ca46eSDavid Howells int dlen; /* number of bytes expected to transfer */ 52607ca46eSDavid Howells int timeout; /* number of seconds before timeout */ 53607ca46eSDavid Howells char packet[12]; /* packet command */ 54607ca46eSDavid Howells 55607ca46eSDavid Howells }; 56607ca46eSDavid Howells 57607ca46eSDavid Howells struct pg_read_hdr { 58607ca46eSDavid Howells 59607ca46eSDavid Howells char magic; /* == PG_MAGIC */ 60607ca46eSDavid Howells char scsi; /* "scsi" status == sense key */ 61607ca46eSDavid Howells int dlen; /* size of device transfer request */ 62607ca46eSDavid Howells int duration; /* time in seconds command took */ 63607ca46eSDavid Howells char pad[12]; /* not used */ 64607ca46eSDavid Howells 65607ca46eSDavid Howells }; 66607ca46eSDavid Howells 67*3a4b46c3SMasahiro Yamada #endif /* _UAPI_LINUX_PG_H */ 68