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