chio.h revision 23452
1/*
2 * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 *    must display the following acknowledgements:
15 *	This product includes software developed by Jason R. Thorpe
16 *	for And Communications, http://www.and.com/
17 * 4. The name of the author may not be used to endorse or promote products
18 *    derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 *	$Id: chio.h,v 1.9 1997/02/22 09:44:56 peter Exp $
33 */
34
35#ifndef _SYS_CHIO_H_
36#define _SYS_CHIO_H_
37
38/*
39 * Element types.  Used as "to" and "from" type indicators in move
40 * and exchange operations.
41 *
42 * Note that code in sys/scsi/ch.c relies on these values (uses them
43 * as offsets in an array, and other evil), so don't muck with them
44 * unless you know what you're doing.
45 */
46#define CHET_MT		0	/* medium transport (picker) */
47#define CHET_ST		1	/* storage transport (slot) */
48#define CHET_IE		2	/* import/export (portal) */
49#define CHET_DT		3	/* data transfer (drive) */
50
51/*
52 * Structure used to execute a MOVE MEDIUM command.
53 */
54struct changer_move {
55	int	cm_fromtype;	/* element type to move from */
56	int	cm_fromunit;	/* logical unit of from element */
57	int	cm_totype;	/* element type to move to */
58	int	cm_tounit;	/* logical unit of to element */
59	int	cm_flags;	/* misc. flags */
60};
61
62/* cm_flags */
63#define CM_INVERT	0x01	/* invert media */
64
65/*
66 * Structure used to execute an EXCHANGE MEDIUM command.  In an
67 * exchange operation, the following steps occur:
68 *
69 *	- media from source is moved to first destination.
70 *
71 *	- media previously occupying first destination is moved
72 *	  to the second destination.
73 *
74 * The second destination may or may not be the same as the source.
75 * In the case of a simple exchange, the source and second destination
76 * are the same.
77 */
78struct changer_exchange {
79	int	ce_srctype;	/* element type of source */
80	int	ce_srcunit;	/* logical unit of source */
81	int	ce_fdsttype;	/* element type of first destination */
82	int	ce_fdstunit;	/* logical unit of first destination */
83	int	ce_sdsttype;	/* element type of second destination */
84	int	ce_sdstunit;	/* logical unit of second destination */
85	int	ce_flags;	/* misc. flags */
86};
87
88/* ce_flags */
89#define CE_INVERT1	0x01	/* invert media 1 */
90#define CE_INVERT2	0x02	/* invert media 2 */
91
92/*
93 * Structure used to execute a POSITION TO ELEMENT command.  This
94 * moves the current picker in front of the specified element.
95 */
96struct changer_position {
97	int	cp_type;	/* element type */
98	int	cp_unit;	/* logical unit of element */
99	int	cp_flags;	/* misc. flags */
100};
101
102/* cp_flags */
103#define CP_INVERT	0x01	/* invert picker */
104
105/*
106 * Data returned by CHIOGPARAMS.
107 */
108struct changer_params {
109	int	cp_curpicker;	/* current picker */
110	int	cp_npickers;	/* number of pickers */
111	int	cp_nslots;	/* number of slots */
112	int	cp_nportals;	/* number of import/export portals */
113	int	cp_ndrives;	/* number of drives */
114};
115
116/*
117 * Command used to get element status.
118 */
119struct changer_element_status {
120	int	ces_type;	/* element type */
121	u_int8_t *ces_data;	/* pre-allocated data storage */
122};
123
124/*
125 * Data returned by CHIOGSTATUS is an array of flags bytes.
126 * Not all flags have meaning for all element types.
127 */
128#define CESTATUS_FULL		0x01	/* element is full */
129#define CESTATUS_IMPEXP		0x02	/* media deposited by operator */
130#define CESTATUS_EXCEPT		0x04	/* element in abnormal state */
131#define CESTATUS_ACCESS		0x08	/* media accessible by picker */
132#define CESTATUS_EXENAB		0x10	/* element supports exporting */
133#define CESTATUS_INENAB		0x20	/* element supports importing */
134
135#define CESTATUS_PICKER_MASK	0x05	/* flags valid for pickers */
136#define CESTATUS_SLOT_MASK	0x0c	/* flags valid for slots */
137#define CESTATUS_PORTAL_MASK	0x3f	/* flags valid for portals */
138#define CESTATUS_DRIVE_MASK	0x0c	/* flags valid for drives */
139
140#define CESTATUS_BITS	\
141	"\20\6INEAB\5EXENAB\4ACCESS\3EXCEPT\2IMPEXP\1FULL"
142
143#define CHIOMOVE	_IOW('c', 0x01, struct changer_move)
144#define CHIOEXCHANGE	_IOW('c', 0x02, struct changer_exchange)
145#define CHIOPOSITION	_IOW('c', 0x03, struct changer_position)
146#define CHIOGPICKER	_IOR('c', 0x04, int)
147#define CHIOSPICKER	_IOW('c', 0x05, int)
148#define CHIOGPARAMS	_IOR('c', 0x06, struct changer_params)
149#define CHIOGSTATUS	_IOW('c', 0x08, struct changer_element_status)
150
151#endif /* _SYS_CHIO_H_ */
152