xref: /freebsd/share/man/man4/ch.4 (revision 23f282aa31e9b6fceacd449020e936e98d6f2298)
1.\" $FreeBSD$
2.\" Copyright (c) 1996
3.\"	Julian Elischer <julian@freebsd.org>.  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.\"
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.Dd May 14, 1998
28.Dt CH 4
29.Os FreeBSD
30.Sh NAME
31.Nm ch
32.Nd SCSI media-changer (juke box) driver
33.Sh SYNOPSIS
34.Cd device ch
35.Cd device ch1 target 4 unit 0
36.Sh DESCRIPTION
37The
38.Xr ch
39driver provides support for a
40.Em SCSI
41media changer.
42It allows many slots of media to be multiplexed between
43a number of drives.  The changer device may optionally be equipped
44with a bar code reader, which reads label informationen attached to
45the media.
46.Pp
47A SCSI adapter must also be separately configured into the system
48before a SCSI changer can be configured.
49.Pp
50As the SCSI adapter is probed during boot, the
51.Em SCSI
52bus is scanned for devices.
53Any devices found which answer as 'Changer'
54type devices will be 'attached' to the
55.Nm
56driver.
57In FreeBSD releases prior to 2.1, the first found will be attached as
58.Em ch0
59and the next,
60.Em ch1
61etc.
62Beginning in 2.1 it is possible to specify what ch unit a device should
63come on line as; refer to
64.Xr scsi 4
65for details on kernel configuration.
66.Pp
67
68.Sh KERNEL CONFIGURATION
69In configuring, if an optional
70.Ar count
71is given in the specification, that number of SCSI media changers
72are configured; Most storage for them is allocated only when found
73so a large number of configured devices is cheap.
74(once the first
75has included the driver).
76
77.Pp
78.Sh IOCTLS
79User mode programs communicate with the changer driver through a
80number of ioctls which are described below.  Changer element addresses
81used in the communcation between the kernel and the changer device are
82mapped to zero-based logical addresses.  Element types are specified
83as follows:
84.Bl -tag -width CHET_MT
85.It Dv CHET_MT
86Medium transport element (picker).
87.It Dv CHET_ST
88Storage element (slot).
89.It Dv CHET_IE
90Import/export element (portal).
91.It Dv CHET_DT
92Data transfer element (drive).
93.El
94.Pp
95The following
96.Xr ioctl 2
97calls apply to the changer.
98They are defined
99in the header file
100.Aq Pa sys/chio.h .
101.Pp
102.Bl -tag -width CHIOEXCHANGE
103.It Dv CHIOMOVE
104.Pq Li "struct changer_move"
105Move a medium from one element to another (\fBMOVE MEDIUM\fR) using
106the current picker.  The source and destination elements are specified
107in a changer_move structure, which includes at least the following
108fields:
109.Bd -literal -offset indent
110u_int cm_fromtype; /* element type to move from */
111u_int cm_fromunit; /* logical unit of from element */
112u_int cm_totype;   /* element type to move to */
113u_int cm_tounit;   /* logical unit of to element */
114u_int cm_flags;	   /* misc. flags */
115.Ed
116If the \fBCM_INVERT\fR in the \fBcm_flags\fR field is set, the medium
117changer is instructed to flip the medium while moving it.
118.It Dv CHIOEXCHANGE
119.Pq Li "struct changer_exchange"
120Move the medium located in the source element to the first destination
121element, and move the medium that had been in the first destination
122element to the second destination element.  In case of a simple
123exchange, the source and second destination elements should be the
124same.  The current picker is used to perform the operation.  The
125addresses of the affected elements is specified to the ioctl in a
126changer_exchange structure which includes at least the following
127fields:
128.Bd -literal -offset indent
129u_int ce_srctype;	 /* element type of source */
130u_int ce_srcunit;	 /* logical unit of source */
131u_int ce_fdsttype; /* element type of first destination */
132u_int ce_fdstunit; /* logical unit of first destination */
133u_int ce_sdsttype; /* element type of second destination */
134u_int ce_sdstunit; /* logical unit of second destination */
135u_int ce_flags;	 /* misc. flags */
136.Ed
137In \fBce_flags\fR, \fBCM_INVERT1\fR and/or \fBCM_INVERT2\fR may be set
138to flip the first or second medium during the exchange operation,
139respectively.
140.Pp
141\fIThis operation is untested.\fR
142.It Dv CHIOPOSITION
143.Pq Li "struct changer_position"
144Position the current picker in front of the specified element.  The
145element is specified with a changer_position structure, which includes
146at least the following elements:
147.Bd -literal -offset indent
148u_int cp_type;  /* element type */
149u_int cp_unit;  /* logical unit of element */
150u_int cp_flags; /* misc. flags */
151.Ed
152The \fBcp_flags\fR field may be set to \fBCP_INVERT\fR to invert the
153picker during the operation.
154.It Dv CHIOGPICKER
155.Pq Li "int"
156Return the logical address of the current picker.
157.It Dv CHIOSPICKER
158.Pq Li "int"
159Select the picker specified by the given logical address.
160.It Dv CHIOGPARAMS
161.Pq Li "struct changer_params"
162Return the configuration parameters for the media changer.  This ioctl
163fills the changer_params structure passed by the user with at least the
164following fields:
165.Bd -literal -offset indent
166u_int cp_npickers; /* number of pickers */
167u_int cp_nslots;   /* number of slots */
168u_int cp_nportals; /* number of import/export portals */
169u_int cp_ndrives;  /* number of drives */
170
171.Ed
172This call can be used by applications to query the dimensions of
173the jukebox before using the \fBCHIGSTATUS\fR
174ioctl to query the jukebox' status.
175.It Dv CHIOIELEM
176Perform the \fBINITIALIZE ELEMENT STATUS\fR call on the media changer
177device.  This forces the media changer to update it's internal status
178information with respect to loaded media.  It also scans any barcode
179labels provided that it has a label reader.  The
180.Nm
181driver's status is not affected by this call.
182.It Dv CHIOGSTATUS
183.Pq Li "struct changer_element_status_request"
184Perform the \fBREAD ELEMENT STATUS\fR call on the media changer
185device.  This call reads the element status information of the media
186changer and converts it to an array of \fBchanger_element_status\fR
187structures.
188.Pp
189With each call to
190.Dv CHIOGSTATUS
191, the status of one or more elements of one type may be queried.
192.Pp
193The application passes a changer_element_status_request structure to the
194.Nm
195driver which contains the following fields:
196.Bd -literal -offset indent
197u_int                          cesr_element_type;
198u_int                          cesr_element_base;
199u_int                          cesr_element_count;
200u_int                          cesr_flags;
201struct changer_element_status *cesr_element_status;
202
203.Ed
204This structure is read by the driver to determine the type, logical
205base address and number of elements for which information is to be
206returned in the array of changer_element_status structures pointed to
207by the cesr_element_status field.  The application must allocate enough
208memory for cesr_element_count status structures (see below).
209The cesr_flags can optionally be set to
210.Dv CESR_VOLTAGS
211to indicate that volume tag (bar code) information is to be read from
212the jukebox and returned.
213.Pp
214The cesr_element_base and cesr_element_count fields must be valid with
215respect to the physical configuration of the changer.  If they are
216not, the
217.Dv CHIOGSTATUS
218ioctl returns the
219.Er EINVAL
220error code.
221.Pp
222The information about the elements is returned in an array of
223changer_element_status structures.  This structure include at least
224the following fields:
225.Bd -literal -offset indent
226u_int            ces_addr;      /* element address in media changer */
227u_char           ces_flags;     /* see CESTATUS definitions below */
228u_char           ces_sensecode; /* additional sense code for element */
229u_char           ces_sensequal; /* additional sense code qualifier */
230u_char           ces_invert;    /* invert bit */
231u_char           ces_svalid;    /* source address (ces_source) valid */
232u_short          ces_source;    /* source address of medium */
233changer_voltag_t ces_pvoltag;   /* primary volume tag */
234changer_voltag_t ces_avoltag;   /* alternate volume tag */
235u_char           ces_idvalid;   /* ces_scsi_id is valid */
236u_char           ces_scsi_id;   /* SCSI id of element (if ces_idvalid is nonzero) */
237u_char           ces_lunvalid;  /* ces_scsi_lun is valid */
238u_char           ces_scsi_lun;  /* SCSI lun of elemtne (if ces_lunvalid is nonzero) */
239
240.Ed
241The ces_addr field contains the address of the element in the
242coordinate system of the media changer.  It is not used by the driver,
243and should be used for diagnostic purposes only.
244.Pp
245The following flags are defined for the \fBces_flags\fR field:
246.Bl -tag -width CESTATUS_IMPEXP
247.It Dv CESTATUS_FULL
248A medium is present.
249.It Dv CESTATUS_IMPEXP
250The medium has been deposited by the operator (and not by a picker).
251.It Dv CESTATUS_EXCEPT
252The element is in an exceptional state (e.g. invalid barcode label,
253barcode not yet scanned).
254.It Dv CESTATUS_ACCESS
255The element is accessible by the picker.
256.It Dv CESTATUS_EXENAB
257The element supports medium export.
258.It Dv CESTATUS_INENAB
259The element supports medium import.
260.El
261.Pp
262Note that not all flags are valid for all element types.
263.El
264.Sh NOTES
265This version of the
266.Nm
267driver has been tested with a DEC TZ875 (5 slot, one DLT drive) and a
268and a Breece Hill Q47 (60 slot, four DLT drives, barcode reader).
269.Pp
270Many of the features the
271.Nm
272driver supports are not thouroghly tested due to the fact that the
273devices available for testing do not support the necessary commands.
274This is true for alternate volume tags, media flipping, import/export
275element handling, multiple picker operation and other things.
276.Sh AUTHORS
277The
278.Nm
279driver was written by
280.An Jason R. Thorpe Aq thorpej@and.com
281for And Communications, http://www.and.com/.
282It was added to the system by
283.An Stefan Grefen Aq grefen@goofy.zdv.uni-mainz.de
284who apparently had such a device.
285It was ported to CAM by
286.An Kenneth Merry Aq ken@FreeBSD.org .
287It was updated to support volume tags by
288.An Hans Huebner Aq hans@artcom.de .
289.Sh FILES
290.Bl -tag -width /dev/ch[0-9] -compact
291.It Pa /dev/ch[0-9]
292device entries
293.El
294.Sh DIAGNOSTICS
295If the media changer does not support features requested by the
296.Nm
297driver, it will produce both console error messages and failure return
298codes to the ioctls described here.
299.Sh SEE ALSO
300.Xr chio 1 ,
301.Xr cd 4 ,
302.Xr sd 4 ,
303.Xr st 4
304.Sh HISTORY
305The
306.Nm
307driver appeared in 386BSD 0.1.
308