Added patch headers.
[linux-flexiantxendom0-3.2.10.git] / include / xen / interface / io / cdromif.h
1 /******************************************************************************
2  * cdromif.h
3  *
4  * Shared definitions between backend driver and Xen guest Virtual CDROM
5  * block device.
6  *
7  * Copyright (c) 2008, Pat Campell  plc@novell.com
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this source file (the "Software"), to deal in the Software without
11  * restriction, including without limitation the rights to use, copy, modify,
12  * merge, publish, distribute, sublicense, and/or sell copies of the Software,
13  * and to permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25  * IN THE SOFTWARE.
26  */
27
28 #ifndef __XEN_PUBLIC_IO_CDROMIF_H__
29 #define __XEN_PUBLIC_IO_CDROMIF_H__
30
31 /*
32  * Queries backend for CDROM support
33  */
34 #define XEN_TYPE_CDROM_SUPPORT         _IO('c', 1)
35
36 struct xen_cdrom_support
37 {
38         uint32_t type;
39         int8_t ret;                  /* returned, 0 succeded, -1 error */
40         int8_t err;                  /* returned, backend errno */
41         int8_t supported;            /* returned, 1 supported */
42 };
43
44 /*
45  * Opens backend device, returns drive geometry or
46  * any encountered errors
47  */
48 #define XEN_TYPE_CDROM_OPEN            _IO('c', 2)
49
50 struct xen_cdrom_open
51 {
52         uint32_t type;
53         int8_t ret;
54         int8_t err;
55         int8_t pad;
56         int8_t media_present;        /* returned */
57         uint32_t sectors;            /* returned */
58         uint32_t sector_size;        /* returned */
59         int32_t payload_offset;      /* offset to backend node name payload */
60 };
61
62 /*
63  * Queries backend for media changed status
64  */
65 #define XEN_TYPE_CDROM_MEDIA_CHANGED   _IO('c', 3)
66
67 struct xen_cdrom_media_changed
68 {
69         uint32_t type;
70         int8_t ret;
71         int8_t err;
72         int8_t media_changed;        /* returned */
73 };
74
75 /*
76  * Sends vcd generic CDROM packet to backend, followed
77  * immediately by the vcd_generic_command payload
78  */
79 #define XEN_TYPE_CDROM_PACKET          _IO('c', 4)
80
81 struct xen_cdrom_packet
82 {
83         uint32_t type;
84         int8_t ret;
85         int8_t err;
86         int8_t pad[2];
87         int32_t payload_offset;      /* offset to vcd_generic_command payload */
88 };
89
90 /* CDROM_PACKET_COMMAND, payload for XEN_TYPE_CDROM_PACKET */
91 struct vcd_generic_command
92 {
93         uint8_t  cmd[CDROM_PACKET_SIZE];
94         uint8_t  pad[4];
95         uint32_t buffer_offset;
96         uint32_t buflen;
97         int32_t  stat;
98         uint32_t sense_offset;
99         uint8_t  data_direction;
100         uint8_t  pad1[3];
101         int32_t  quiet;
102         int32_t  timeout;
103 };
104
105 union xen_block_packet
106 {
107         uint32_t type;
108         struct xen_cdrom_support xcs;
109         struct xen_cdrom_open xco;
110         struct xen_cdrom_media_changed xcmc;
111         struct xen_cdrom_packet xcp;
112 };
113
114 #define PACKET_PAYLOAD_OFFSET (sizeof(struct xen_cdrom_packet))
115 #define PACKET_SENSE_OFFSET (PACKET_PAYLOAD_OFFSET + sizeof(struct vcd_generic_command))
116 #define PACKET_BUFFER_OFFSET (PACKET_SENSE_OFFSET + sizeof(struct request_sense))
117 #define MAX_PACKET_DATA (PAGE_SIZE - sizeof(struct xen_cdrom_packet) - \
118             sizeof(struct vcd_generic_command) - sizeof(struct request_sense))
119
120 #endif