chio.h revision 23736
14Srgrimes/*
223452Sjoerg * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
323452Sjoerg * All rights reserved.
4624Srgrimes *
523452Sjoerg * Redistribution and use in source and binary forms, with or without
623452Sjoerg * modification, are permitted provided that the following conditions
723452Sjoerg * are met:
823452Sjoerg * 1. Redistributions of source code must retain the above copyright
923452Sjoerg *    notice, this list of conditions and the following disclaimer.
1023452Sjoerg * 2. Redistributions in binary form must reproduce the above copyright
1123452Sjoerg *    notice, this list of conditions and the following disclaimer in the
1223452Sjoerg *    documentation and/or other materials provided with the distribution.
1323452Sjoerg * 3. All advertising materials mentioning features or use of this software
1423452Sjoerg *    must display the following acknowledgements:
1523452Sjoerg *	This product includes software developed by Jason R. Thorpe
1623452Sjoerg *	for And Communications, http://www.and.com/
1723452Sjoerg * 4. The name of the author may not be used to endorse or promote products
1823452Sjoerg *    derived from this software without specific prior written permission.
1923452Sjoerg *
2023452Sjoerg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2123452Sjoerg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2223452Sjoerg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2323452Sjoerg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2423452Sjoerg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
2523452Sjoerg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2623452Sjoerg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2723452Sjoerg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2823452Sjoerg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2923452Sjoerg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3023452Sjoerg * SUCH DAMAGE.
3123452Sjoerg *
3223736Sjoerg *	$Id: chio.h,v 1.10 1997/03/06 15:36:45 joerg Exp $
334Srgrimes */
344Srgrimes
3523736Sjoerg#ifndef	_SYS_CHIO_H_
3623736Sjoerg#define	_SYS_CHIO_H_
3723452Sjoerg
3823736Sjoerg#ifndef KERNEL
3923736Sjoerg#include <sys/types.h>
4023736Sjoerg#endif
4123736Sjoerg#include <sys/ioccom.h>
4223736Sjoerg
4323452Sjoerg/*
4423452Sjoerg * Element types.  Used as "to" and "from" type indicators in move
4523452Sjoerg * and exchange operations.
4623452Sjoerg *
4723452Sjoerg * Note that code in sys/scsi/ch.c relies on these values (uses them
4823452Sjoerg * as offsets in an array, and other evil), so don't muck with them
4923452Sjoerg * unless you know what you're doing.
504Srgrimes */
5123452Sjoerg#define CHET_MT		0	/* medium transport (picker) */
5223452Sjoerg#define CHET_ST		1	/* storage transport (slot) */
5323452Sjoerg#define CHET_IE		2	/* import/export (portal) */
5423452Sjoerg#define CHET_DT		3	/* data transfer (drive) */
554Srgrimes
564Srgrimes/*
5723452Sjoerg * Structure used to execute a MOVE MEDIUM command.
584Srgrimes */
5923452Sjoergstruct changer_move {
6023452Sjoerg	int	cm_fromtype;	/* element type to move from */
6123452Sjoerg	int	cm_fromunit;	/* logical unit of from element */
6223452Sjoerg	int	cm_totype;	/* element type to move to */
6323452Sjoerg	int	cm_tounit;	/* logical unit of to element */
6423452Sjoerg	int	cm_flags;	/* misc. flags */
6523452Sjoerg};
664Srgrimes
6723452Sjoerg/* cm_flags */
6823452Sjoerg#define CM_INVERT	0x01	/* invert media */
6918444Sbde
7023452Sjoerg/*
7123452Sjoerg * Structure used to execute an EXCHANGE MEDIUM command.  In an
7223452Sjoerg * exchange operation, the following steps occur:
7323452Sjoerg *
7423452Sjoerg *	- media from source is moved to first destination.
7523452Sjoerg *
7623452Sjoerg *	- media previously occupying first destination is moved
7723452Sjoerg *	  to the second destination.
7823452Sjoerg *
7923452Sjoerg * The second destination may or may not be the same as the source.
8023452Sjoerg * In the case of a simple exchange, the source and second destination
8123452Sjoerg * are the same.
8223452Sjoerg */
8323452Sjoergstruct changer_exchange {
8423452Sjoerg	int	ce_srctype;	/* element type of source */
8523452Sjoerg	int	ce_srcunit;	/* logical unit of source */
8623452Sjoerg	int	ce_fdsttype;	/* element type of first destination */
8723452Sjoerg	int	ce_fdstunit;	/* logical unit of first destination */
8823452Sjoerg	int	ce_sdsttype;	/* element type of second destination */
8923452Sjoerg	int	ce_sdstunit;	/* logical unit of second destination */
9023452Sjoerg	int	ce_flags;	/* misc. flags */
9123452Sjoerg};
9218444Sbde
9323452Sjoerg/* ce_flags */
9423452Sjoerg#define CE_INVERT1	0x01	/* invert media 1 */
9523452Sjoerg#define CE_INVERT2	0x02	/* invert media 2 */
964Srgrimes
9723452Sjoerg/*
9823452Sjoerg * Structure used to execute a POSITION TO ELEMENT command.  This
9923452Sjoerg * moves the current picker in front of the specified element.
10023452Sjoerg */
10123452Sjoergstruct changer_position {
10223452Sjoerg	int	cp_type;	/* element type */
10323452Sjoerg	int	cp_unit;	/* logical unit of element */
10423452Sjoerg	int	cp_flags;	/* misc. flags */
1054Srgrimes};
1064Srgrimes
10723452Sjoerg/* cp_flags */
10823452Sjoerg#define CP_INVERT	0x01	/* invert picker */
1094Srgrimes
11023452Sjoerg/*
11123452Sjoerg * Data returned by CHIOGPARAMS.
11223452Sjoerg */
11323452Sjoergstruct changer_params {
11423452Sjoerg	int	cp_curpicker;	/* current picker */
11523452Sjoerg	int	cp_npickers;	/* number of pickers */
11623452Sjoerg	int	cp_nslots;	/* number of slots */
11723452Sjoerg	int	cp_nportals;	/* number of import/export portals */
11823452Sjoerg	int	cp_ndrives;	/* number of drives */
11923452Sjoerg};
1204Srgrimes
12123452Sjoerg/*
12223452Sjoerg * Command used to get element status.
12323452Sjoerg */
12423452Sjoergstruct changer_element_status {
12523452Sjoerg	int	ces_type;	/* element type */
12623452Sjoerg	u_int8_t *ces_data;	/* pre-allocated data storage */
12723452Sjoerg};
128785Srgrimes
12923452Sjoerg/*
13023452Sjoerg * Data returned by CHIOGSTATUS is an array of flags bytes.
13123452Sjoerg * Not all flags have meaning for all element types.
13223452Sjoerg */
13323452Sjoerg#define CESTATUS_FULL		0x01	/* element is full */
13423452Sjoerg#define CESTATUS_IMPEXP		0x02	/* media deposited by operator */
13523452Sjoerg#define CESTATUS_EXCEPT		0x04	/* element in abnormal state */
13623452Sjoerg#define CESTATUS_ACCESS		0x08	/* media accessible by picker */
13723452Sjoerg#define CESTATUS_EXENAB		0x10	/* element supports exporting */
13823452Sjoerg#define CESTATUS_INENAB		0x20	/* element supports importing */
13923452Sjoerg
14023452Sjoerg#define CESTATUS_PICKER_MASK	0x05	/* flags valid for pickers */
14123452Sjoerg#define CESTATUS_SLOT_MASK	0x0c	/* flags valid for slots */
14223452Sjoerg#define CESTATUS_PORTAL_MASK	0x3f	/* flags valid for portals */
14323452Sjoerg#define CESTATUS_DRIVE_MASK	0x0c	/* flags valid for drives */
14423452Sjoerg
14523452Sjoerg#define CESTATUS_BITS	\
14623452Sjoerg	"\20\6INEAB\5EXENAB\4ACCESS\3EXCEPT\2IMPEXP\1FULL"
14723452Sjoerg
14823452Sjoerg#define CHIOMOVE	_IOW('c', 0x01, struct changer_move)
14923452Sjoerg#define CHIOEXCHANGE	_IOW('c', 0x02, struct changer_exchange)
15023452Sjoerg#define CHIOPOSITION	_IOW('c', 0x03, struct changer_position)
15123452Sjoerg#define CHIOGPICKER	_IOR('c', 0x04, int)
15223452Sjoerg#define CHIOSPICKER	_IOW('c', 0x05, int)
15323452Sjoerg#define CHIOGPARAMS	_IOR('c', 0x06, struct changer_params)
15423452Sjoerg#define CHIOGSTATUS	_IOW('c', 0x08, struct changer_element_status)
15523452Sjoerg
15623736Sjoerg#endif /* !_SYS_CHIO_H_ */
157