Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / libusal / pg.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 /*      pg.h (c) 1998  Grant R. Guenther <grant@torque.net>
14                        Under the terms of the GNU public license
15
16
17         pg.h defines the user interface to the generic ATAPI packet
18         command driver for parallel port ATAPI devices (pg). The
19         driver is loosely modelled after the generic SCSI driver, sg,
20         although the actual interface is different.
21
22         The pg driver provides a simple character device interface for
23         sending ATAPI commands to a device.  With the exception of the
24         ATAPI reset operation, all operations are performed by a pair
25         of read and write operations to the appropriate /dev/pgN device.
26         A write operation delivers a command and any outbound data in
27         a single buffer.  Normally, the write will succeed unless the
28         device is offline or malfunctioning, or there is already another
29         command pending.  If the write succeeds, it should be followed
30         immediately by a read operation, to obtain any returned data and
31         status information.  A read will fail if there is no operation
32         in progress.
33
34         As a special case, the device can be reset with a write operation,
35         and in this case, no following read is expected, or permitted.
36
37         There are no ioctl() operations.  Any single operation
38         may transfer at most PG_MAX_DATA bytes.  Note that the driver must
39         copy the data through an internal buffer.  In keeping with all
40         current ATAPI devices, command packets are assumed to be exactly
41         12 bytes in length.
42
43         To permit future changes to this interface, the headers in the
44         read and write buffers contain a single character "magic" flag.
45         Currently this flag must be the character "P".
46
47 */
48
49 #define PG_MAGIC        'P'
50 #define PG_RESET        'Z'
51 #define PG_COMMAND      'C'
52
53 #define PG_MAX_DATA     32768
54
55 struct pg_write_hdr {
56
57         char    magic;          /* == PG_MAGIC */
58         char    func;           /* PG_RESET or PG_COMMAND */
59         int     dlen;           /* number of bytes expected to transfer */
60         int     timeout;        /* number of seconds before timeout */
61         char    packet[12];     /* packet command */
62
63 };
64
65 struct pg_read_hdr {
66
67         char    magic;          /* == PG_MAGIC */
68         char    scsi;           /* "scsi" status == sense key */
69         int     dlen;           /* size of device transfer request */
70         int     duration;       /* time in seconds command took */
71         char    pad[12];        /* not used */
72
73 };
74
75 /* end of pg.h */