aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/chio.h
diff options
context:
space:
mode:
authorJoerg Wunsch <joerg@FreeBSD.org>1997-03-06 15:36:45 +0000
committerJoerg Wunsch <joerg@FreeBSD.org>1997-03-06 15:36:45 +0000
commitf357773315e493977021da874fd25bbae48b909b (patch)
tree3d0c15b5f3dff4b73ad7783feb2b1ec79a85c829 /sys/sys/chio.h
parenta88f199c8046c73bdb5f0eb25c3591125f194bd3 (diff)
downloadsrc-f357773315e493977021da874fd25bbae48b909b.tar.gz
src-f357773315e493977021da874fd25bbae48b909b.zip
Merge Jason Thorpe's updated changer stuff into the actual system.
Many things have been changing in the kernel since mid-1996, so there's quite some amount of diffs here already. It compiles, but i cannot test it anywhere here. 2.2 candidate? Closes PR # 1201.
Notes
Notes: svn path=/head/; revision=23452
Diffstat (limited to 'sys/sys/chio.h')
-rw-r--r--sys/sys/chio.h215
1 files changed, 134 insertions, 81 deletions
diff --git a/sys/sys/chio.h b/sys/sys/chio.h
index 2ff6eff5e04c..4affe23cb26d 100644
--- a/sys/sys/chio.h
+++ b/sys/sys/chio.h
@@ -1,98 +1,151 @@
/*
- * 16 Feb 93 Julian Elischer ADDED for SCSI system
+ * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
+ * All rights reserved.
*
- * $Id$
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgements:
+ * This product includes software developed by Jason R. Thorpe
+ * for And Communications, http://www.and.com/
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: chio.h,v 1.9 1997/02/22 09:44:56 peter Exp $
*/
-/* This is a "converted" mtio.h from 386BSD
- Stefan Grefen grefen@goofy.zdv.uni-mainz.de
+#ifndef _SYS_CHIO_H_
+#define _SYS_CHIO_H_
+
+/*
+ * Element types. Used as "to" and "from" type indicators in move
+ * and exchange operations.
+ *
+ * Note that code in sys/scsi/ch.c relies on these values (uses them
+ * as offsets in an array, and other evil), so don't muck with them
+ * unless you know what you're doing.
*/
+#define CHET_MT 0 /* medium transport (picker) */
+#define CHET_ST 1 /* storage transport (slot) */
+#define CHET_IE 2 /* import/export (portal) */
+#define CHET_DT 3 /* data transfer (drive) */
/*
- * Structures and definitions for changer io control commands
+ * Structure used to execute a MOVE MEDIUM command.
+ */
+struct changer_move {
+ int cm_fromtype; /* element type to move from */
+ int cm_fromunit; /* logical unit of from element */
+ int cm_totype; /* element type to move to */
+ int cm_tounit; /* logical unit of to element */
+ int cm_flags; /* misc. flags */
+};
+
+/* cm_flags */
+#define CM_INVERT 0x01 /* invert media */
+
+/*
+ * Structure used to execute an EXCHANGE MEDIUM command. In an
+ * exchange operation, the following steps occur:
+ *
+ * - media from source is moved to first destination.
+ *
+ * - media previously occupying first destination is moved
+ * to the second destination.
+ *
+ * The second destination may or may not be the same as the source.
+ * In the case of a simple exchange, the source and second destination
+ * are the same.
*/
+struct changer_exchange {
+ int ce_srctype; /* element type of source */
+ int ce_srcunit; /* logical unit of source */
+ int ce_fdsttype; /* element type of first destination */
+ int ce_fdstunit; /* logical unit of first destination */
+ int ce_sdsttype; /* element type of second destination */
+ int ce_sdstunit; /* logical unit of second destination */
+ int ce_flags; /* misc. flags */
+};
-#ifndef _SYS_CHIO_H_
-#define _SYS_CHIO_H_
+/* ce_flags */
+#define CE_INVERT1 0x01 /* invert media 1 */
+#define CE_INVERT2 0x02 /* invert media 2 */
-#ifndef KERNEL
-#include <sys/types.h>
-#endif
-#include <sys/ioccom.h>
+/*
+ * Structure used to execute a POSITION TO ELEMENT command. This
+ * moves the current picker in front of the specified element.
+ */
+struct changer_position {
+ int cp_type; /* element type */
+ int cp_unit; /* logical unit of element */
+ int cp_flags; /* misc. flags */
+};
-#define CH_INVERT 0x10000
-#define CH_ADDR_MASK 0xffff
-struct chop {
- short ch_op; /* operations defined below */
- short result; /* The result */
- union {
- struct {
- int chm; /* Transport element */
- int from;
- int to;
- } move;
- struct {
- int chm; /* Transport element */
- int to;
- } position;
- struct {
- short chmo; /* Offset of first CHM */
- short chms; /* No. of CHM */
- short slots; /* No. of Storage Elements */
- short sloto; /* Offset of first SE */
- short imexs; /* No. of Import/Export Slots */
- short imexo; /* Offset of first IM/EX */
- short drives; /* No. of CTS */
- short driveo; /* Offset of first CTS */
- short rot; /* CHM can rotate */
- } getparam;
- struct {
- int type;
-#define CH_CHM 1
-#define CH_STOR 2
-#define CH_IMEX 3
-#define CH_CTS 4
- int from;
- struct {
- u_char elema_1;
- u_char elema_0;
- u_char full:1;
- u_char rsvd:1;
- u_char except:1;
- u_char :5;
- u_char rsvd2;
- union {
- struct {
- u_char add_sense_code;
- u_char add_sense_code_qualifier;
- } specs;
- short add_sense;
-/* WARNING LSB only */
-#define CH_CHOLDER 0x0290 /* Cartridge holder is missing */
-#define CH_STATUSQ 0x0390 /* Status is questionable */
-#define CH_CTS_CLOSED 0x0490 /* CTS door is closed */
+/* cp_flags */
+#define CP_INVERT 0x01 /* invert picker */
- } ch_add_sense;
- u_char rsvd3[3];
- u_char :6;
- u_char invert:1;
- u_char svalid:1;
- u_char source_1;
- u_char source_0;
- u_char rsvd4[4];
- } elem_data;
- } get_elem_stat;
- } u;
+/*
+ * Data returned by CHIOGPARAMS.
+ */
+struct changer_params {
+ int cp_curpicker; /* current picker */
+ int cp_npickers; /* number of pickers */
+ int cp_nslots; /* number of slots */
+ int cp_nportals; /* number of import/export portals */
+ int cp_ndrives; /* number of drives */
};
-/* operations */
-#define CHMOVE 1
-#define CHPOSITION 2
-#define CHGETPARAM 3
-#define CHGETELEM 4
+/*
+ * Command used to get element status.
+ */
+struct changer_element_status {
+ int ces_type; /* element type */
+ u_int8_t *ces_data; /* pre-allocated data storage */
+};
+
+/*
+ * Data returned by CHIOGSTATUS is an array of flags bytes.
+ * Not all flags have meaning for all element types.
+ */
+#define CESTATUS_FULL 0x01 /* element is full */
+#define CESTATUS_IMPEXP 0x02 /* media deposited by operator */
+#define CESTATUS_EXCEPT 0x04 /* element in abnormal state */
+#define CESTATUS_ACCESS 0x08 /* media accessible by picker */
+#define CESTATUS_EXENAB 0x10 /* element supports exporting */
+#define CESTATUS_INENAB 0x20 /* element supports importing */
+
+#define CESTATUS_PICKER_MASK 0x05 /* flags valid for pickers */
+#define CESTATUS_SLOT_MASK 0x0c /* flags valid for slots */
+#define CESTATUS_PORTAL_MASK 0x3f /* flags valid for portals */
+#define CESTATUS_DRIVE_MASK 0x0c /* flags valid for drives */
+#define CESTATUS_BITS \
+ "\20\6INEAB\5EXENAB\4ACCESS\3EXCEPT\2IMPEXP\1FULL"
-/* Changer IO control command */
-#define CHIOOP _IOWR('c', 1, struct chop) /* do a mag tape op */
+#define CHIOMOVE _IOW('c', 0x01, struct changer_move)
+#define CHIOEXCHANGE _IOW('c', 0x02, struct changer_exchange)
+#define CHIOPOSITION _IOW('c', 0x03, struct changer_position)
+#define CHIOGPICKER _IOR('c', 0x04, int)
+#define CHIOSPICKER _IOW('c', 0x05, int)
+#define CHIOGPARAMS _IOR('c', 0x06, struct changer_params)
+#define CHIOGSTATUS _IOW('c', 0x08, struct changer_element_status)
-#endif /* !_SYS_CHIO_H_ */
+#endif /* _SYS_CHIO_H_ */