ch.c revision 1.13 1 1.13 mycroft /* $NetBSD: ch.c,v 1.13 1994/12/28 19:42:52 mycroft Exp $ */
2 1.8 cgd
3 1.1 cgd /*
4 1.6 mycroft * Copyright (c) 1994 Charles Hannum. All rights reserved.
5 1.6 mycroft *
6 1.6 mycroft * Redistribution and use in source and binary forms, with or without
7 1.6 mycroft * modification, are permitted provided that the following conditions
8 1.6 mycroft * are met:
9 1.6 mycroft * 1. Redistributions of source code must retain the above copyright
10 1.6 mycroft * notice, this list of conditions and the following disclaimer.
11 1.6 mycroft * 2. Redistributions in binary form must reproduce the above copyright
12 1.6 mycroft * notice, this list of conditions and the following disclaimer in the
13 1.6 mycroft * documentation and/or other materials provided with the distribution.
14 1.6 mycroft * 3. All advertising materials mentioning features or use of this software
15 1.6 mycroft * must display the following acknowledgement:
16 1.6 mycroft * This product includes software developed by Charles Hannum.
17 1.6 mycroft * 4. The name of the author may not be used to endorse or promote products
18 1.6 mycroft * derived from this software without specific prior written permission.
19 1.6 mycroft *
20 1.6 mycroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.6 mycroft * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.6 mycroft * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.6 mycroft * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.6 mycroft * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.6 mycroft * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.6 mycroft * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.6 mycroft * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.6 mycroft * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.6 mycroft * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 cgd */
31 1.1 cgd
32 1.6 mycroft /*
33 1.6 mycroft * Originally written by grefen@?????
34 1.6 mycroft * Based on scsi drivers by Julian Elischer (julian (at) tfs.com)
35 1.6 mycroft */
36 1.1 cgd
37 1.5 mycroft #include <sys/types.h>
38 1.1 cgd #include <sys/param.h>
39 1.1 cgd #include <sys/systm.h>
40 1.1 cgd #include <sys/errno.h>
41 1.1 cgd #include <sys/ioctl.h>
42 1.1 cgd #include <sys/buf.h>
43 1.1 cgd #include <sys/proc.h>
44 1.1 cgd #include <sys/user.h>
45 1.1 cgd #include <sys/chio.h>
46 1.6 mycroft #include <sys/device.h>
47 1.1 cgd
48 1.1 cgd #include <scsi/scsi_all.h>
49 1.1 cgd #include <scsi/scsi_changer.h>
50 1.1 cgd #include <scsi/scsiconf.h>
51 1.1 cgd
52 1.6 mycroft #define CHRETRIES 2
53 1.1 cgd
54 1.6 mycroft #define CHMODE(z) (minor(z) & 0x0f)
55 1.6 mycroft #define CHUNIT(z) (minor(z) >> 4)
56 1.1 cgd
57 1.13 mycroft struct ch_softc {
58 1.6 mycroft struct device sc_dev;
59 1.1 cgd
60 1.6 mycroft struct scsi_link *sc_link; /* all the inter level info */
61 1.13 mycroft u_int16_t chmo; /* Offset of first CHM */
62 1.13 mycroft u_int16_t chms; /* No. of CHM */
63 1.13 mycroft u_int16_t slots; /* No. of Storage Elements */
64 1.13 mycroft u_int16_t sloto; /* Offset of first SE */
65 1.13 mycroft u_int16_t imexs; /* No. of Import/Export Slots */
66 1.13 mycroft u_int16_t imexo; /* Offset of first IM/EX */
67 1.13 mycroft u_int16_t drives; /* No. of CTS */
68 1.13 mycroft u_int16_t driveo; /* Offset of first CTS */
69 1.13 mycroft u_int16_t rot; /* CHM can rotate */
70 1.13 mycroft u_long op_matrix; /* possible operations */
71 1.13 mycroft u_int16_t lsterr; /* details of lasterror */
72 1.6 mycroft u_char stor; /* posible Storage locations */
73 1.6 mycroft };
74 1.6 mycroft
75 1.13 mycroft int chmatch __P((struct device *, void *, void *));
76 1.6 mycroft void chattach __P((struct device *, struct device *, void *));
77 1.6 mycroft
78 1.6 mycroft struct cfdriver chcd = {
79 1.13 mycroft NULL, "ch", chmatch, chattach, DV_DULL, sizeof(struct ch_softc)
80 1.6 mycroft };
81 1.1 cgd
82 1.6 mycroft /*
83 1.6 mycroft * This driver is so simple it uses all the default services
84 1.6 mycroft */
85 1.6 mycroft struct scsi_device ch_switch = {
86 1.6 mycroft NULL,
87 1.6 mycroft NULL,
88 1.6 mycroft NULL,
89 1.6 mycroft NULL,
90 1.6 mycroft };
91 1.6 mycroft
92 1.13 mycroft struct scsi_inquiry_pattern ch_patterns[] = {
93 1.13 mycroft {T_CHANGER, T_REMOV,
94 1.13 mycroft "", "", ""},
95 1.13 mycroft };
96 1.13 mycroft
97 1.13 mycroft int
98 1.13 mycroft chmatch(parent, match, aux)
99 1.13 mycroft struct device *parent;
100 1.13 mycroft void *match, *aux;
101 1.13 mycroft {
102 1.13 mycroft struct cfdata *cf = match;
103 1.13 mycroft struct scsibus_attach_args *sa = aux;
104 1.13 mycroft int priority;
105 1.13 mycroft
106 1.13 mycroft (void)scsi_inqmatch(sa->sa_inqbuf,
107 1.13 mycroft (caddr_t)ch_patterns, sizeof(ch_patterns)/sizeof(ch_patterns[0]),
108 1.13 mycroft sizeof(ch_patterns[0]), &priority);
109 1.13 mycroft return (priority);
110 1.13 mycroft }
111 1.13 mycroft
112 1.6 mycroft /*
113 1.6 mycroft * The routine called by the low level scsi routine when it discovers
114 1.6 mycroft * a device suitable for this driver.
115 1.6 mycroft */
116 1.6 mycroft void
117 1.6 mycroft chattach(parent, self, aux)
118 1.6 mycroft struct device *parent, *self;
119 1.6 mycroft void *aux;
120 1.1 cgd {
121 1.13 mycroft struct ch_softc *ch = (void *)self;
122 1.13 mycroft struct scsibus_attach_args *sa = aux;
123 1.13 mycroft struct scsi_link *sc_link = sa->sa_sc_link;
124 1.1 cgd
125 1.6 mycroft SC_DEBUG(sc_link, SDEV_DB2, ("chattach: "));
126 1.1 cgd
127 1.6 mycroft /*
128 1.6 mycroft * Store information needed to contact our base driver
129 1.6 mycroft */
130 1.6 mycroft ch->sc_link = sc_link;
131 1.6 mycroft sc_link->device = &ch_switch;
132 1.11 mycroft sc_link->device_softc = ch;
133 1.13 mycroft sc_link->openings = 1;
134 1.6 mycroft
135 1.6 mycroft /*
136 1.6 mycroft * Use the subdriver to request information regarding
137 1.6 mycroft * the drive. We cannot use interrupts yet, so the
138 1.6 mycroft * request must specify this.
139 1.6 mycroft */
140 1.13 mycroft if (ch_mode_sense(ch, SCSI_AUTOCONF) != 0)
141 1.6 mycroft printf(": offline\n");
142 1.7 mycroft else
143 1.6 mycroft printf(": %d slot(s), %d drive(s), %d arm(s), %d i/e-slot(s)\n",
144 1.6 mycroft ch->slots, ch->drives, ch->chms, ch->imexs);
145 1.1 cgd }
146 1.1 cgd
147 1.6 mycroft /*
148 1.6 mycroft * open the device.
149 1.6 mycroft */
150 1.6 mycroft int
151 1.1 cgd chopen(dev)
152 1.6 mycroft dev_t dev;
153 1.1 cgd {
154 1.6 mycroft int error = 0;
155 1.6 mycroft int unit, mode;
156 1.13 mycroft struct ch_softc *ch;
157 1.6 mycroft struct scsi_link *sc_link;
158 1.6 mycroft
159 1.6 mycroft unit = CHUNIT(dev);
160 1.6 mycroft if (unit >= chcd.cd_ndevs)
161 1.6 mycroft return ENXIO;
162 1.6 mycroft ch = chcd.cd_devs[unit];
163 1.7 mycroft if (!ch)
164 1.6 mycroft return ENXIO;
165 1.6 mycroft
166 1.12 mycroft mode = CHMODE(dev);
167 1.6 mycroft sc_link = ch->sc_link;
168 1.6 mycroft
169 1.12 mycroft SC_DEBUG(sc_link, SDEV_DB1,
170 1.12 mycroft ("chopen: dev=0x%x (unit %d (of %d))\n", dev, unit, chcd.cd_ndevs));
171 1.12 mycroft
172 1.12 mycroft /*
173 1.12 mycroft * Only allow one at a time
174 1.12 mycroft */
175 1.12 mycroft if (sc_link->flags & SDEV_OPEN) {
176 1.12 mycroft printf("%s: already open\n", ch->sc_dev.dv_xname);
177 1.6 mycroft return EBUSY;
178 1.12 mycroft }
179 1.6 mycroft
180 1.6 mycroft /*
181 1.6 mycroft * Catch any unit attention errors.
182 1.6 mycroft */
183 1.13 mycroft if (error = scsi_test_unit_ready(sc_link, SCSI_IGNORE_MEDIA_CHANGE))
184 1.13 mycroft goto bad;
185 1.6 mycroft
186 1.13 mycroft sc_link->flags |= SDEV_OPEN; /* unit attn are now errors */
187 1.6 mycroft
188 1.6 mycroft /*
189 1.6 mycroft * Make sure data is loaded
190 1.6 mycroft */
191 1.13 mycroft if (error = ch_mode_sense(ch, 0)) {
192 1.6 mycroft printf("%s: offline\n", ch->sc_dev.dv_xname);
193 1.12 mycroft goto bad;
194 1.6 mycroft }
195 1.6 mycroft
196 1.12 mycroft SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n"));
197 1.6 mycroft return 0;
198 1.12 mycroft
199 1.12 mycroft bad:
200 1.12 mycroft sc_link->flags &= ~SDEV_OPEN;
201 1.12 mycroft return error;
202 1.6 mycroft }
203 1.6 mycroft
204 1.6 mycroft /*
205 1.6 mycroft * close the device.. only called if we are the LAST
206 1.6 mycroft * occurence of an open device
207 1.6 mycroft */
208 1.6 mycroft int
209 1.1 cgd chclose(dev)
210 1.6 mycroft dev_t dev;
211 1.1 cgd {
212 1.13 mycroft struct ch_softc *ch = chcd.cd_devs[CHUNIT(dev)];
213 1.6 mycroft
214 1.12 mycroft SC_DEBUG(ch->sc_link, SDEV_DB1, ("closing\n"));
215 1.12 mycroft ch->sc_link->flags &= ~SDEV_OPEN;
216 1.6 mycroft
217 1.6 mycroft return 0;
218 1.6 mycroft }
219 1.6 mycroft
220 1.6 mycroft /*
221 1.6 mycroft * Perform special action on behalf of the user
222 1.6 mycroft * Knows about the internals of this device
223 1.6 mycroft */
224 1.6 mycroft int
225 1.13 mycroft chioctl(dev, cmd, arg, mode, p)
226 1.6 mycroft dev_t dev;
227 1.10 cgd u_long cmd;
228 1.6 mycroft caddr_t arg;
229 1.6 mycroft int mode;
230 1.13 mycroft struct proc *p;
231 1.6 mycroft {
232 1.13 mycroft struct ch_softc *ch = chcd.cd_devs[CHUNIT(dev)];
233 1.6 mycroft struct scsi_link *sc_link = ch->sc_link;
234 1.6 mycroft int number;
235 1.7 mycroft int flags;
236 1.6 mycroft
237 1.6 mycroft /*
238 1.6 mycroft * Find the device that the user is talking about
239 1.6 mycroft */
240 1.6 mycroft flags = 0; /* give error messages, act on errors etc. */
241 1.6 mycroft
242 1.6 mycroft switch (cmd) {
243 1.6 mycroft case CHIOOP: {
244 1.6 mycroft struct chop *chop = (struct chop *) arg;
245 1.6 mycroft SC_DEBUG(sc_link, SDEV_DB2, ("[chtape_chop: %x]\n",
246 1.6 mycroft chop->ch_op));
247 1.6 mycroft
248 1.6 mycroft switch (chop->ch_op) {
249 1.6 mycroft case CHGETPARAM:
250 1.6 mycroft chop->u.getparam.chmo = ch->chmo;
251 1.6 mycroft chop->u.getparam.chms = ch->chms;
252 1.6 mycroft chop->u.getparam.sloto = ch->sloto;
253 1.6 mycroft chop->u.getparam.slots = ch->slots;
254 1.6 mycroft chop->u.getparam.imexo = ch->imexo;
255 1.6 mycroft chop->u.getparam.imexs = ch->imexs;
256 1.6 mycroft chop->u.getparam.driveo = ch->driveo;
257 1.6 mycroft chop->u.getparam.drives = ch->drives;
258 1.6 mycroft chop->u.getparam.rot = ch->rot;
259 1.6 mycroft chop->result = 0;
260 1.6 mycroft return 0;
261 1.6 mycroft break;
262 1.6 mycroft case CHPOSITION:
263 1.6 mycroft return ch_position(ch, &chop->result,
264 1.6 mycroft chop->u.position.chm, chop->u.position.to, flags);
265 1.6 mycroft case CHMOVE:
266 1.6 mycroft return ch_move(ch, &chop->result, chop->u.position.chm,
267 1.6 mycroft chop->u.move.from, chop->u.move.to, flags);
268 1.6 mycroft case CHGETELEM:
269 1.6 mycroft return ch_getelem(ch, &chop->result,
270 1.6 mycroft chop->u.get_elem_stat.type,
271 1.6 mycroft chop->u.get_elem_stat.from,
272 1.6 mycroft &chop->u.get_elem_stat.elem_data, flags);
273 1.6 mycroft default:
274 1.6 mycroft return EINVAL;
275 1.1 cgd }
276 1.6 mycroft }
277 1.1 cgd default:
278 1.13 mycroft return scsi_do_ioctl(sc_link, dev, cmd, arg, mode, p);
279 1.1 cgd }
280 1.6 mycroft #ifdef DIAGNOSTIC
281 1.6 mycroft panic("chioctl: impossible");
282 1.6 mycroft #endif
283 1.1 cgd }
284 1.1 cgd
285 1.6 mycroft int
286 1.6 mycroft ch_getelem(ch, stat, type, from, data, flags)
287 1.13 mycroft struct ch_softc *ch;
288 1.6 mycroft short *stat;
289 1.6 mycroft int type, from;
290 1.6 mycroft char *data;
291 1.6 mycroft int flags;
292 1.1 cgd {
293 1.1 cgd struct scsi_read_element_status scsi_cmd;
294 1.1 cgd char elbuf[32];
295 1.6 mycroft int error;
296 1.1 cgd
297 1.1 cgd bzero(&scsi_cmd, sizeof(scsi_cmd));
298 1.13 mycroft scsi_cmd.opcode = READ_ELEMENT_STATUS;
299 1.6 mycroft scsi_cmd.byte2 = type;
300 1.6 mycroft scsi_cmd.starting_element_addr[0] = (from >> 8) & 0xff;
301 1.6 mycroft scsi_cmd.starting_element_addr[1] = from & 0xff;
302 1.6 mycroft scsi_cmd.number_of_elements[1] = 1;
303 1.6 mycroft scsi_cmd.allocation_length[2] = 32;
304 1.6 mycroft
305 1.6 mycroft error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd,
306 1.6 mycroft sizeof(scsi_cmd), (u_char *) elbuf, 32, CHRETRIES, 100000, NULL,
307 1.6 mycroft SCSI_DATA_IN | flags);
308 1.6 mycroft if (error)
309 1.6 mycroft *stat = ch->lsterr;
310 1.6 mycroft else
311 1.6 mycroft *stat = 0;
312 1.6 mycroft bcopy(elbuf + 16, data, 16);
313 1.6 mycroft return error;
314 1.1 cgd }
315 1.1 cgd
316 1.6 mycroft int
317 1.6 mycroft ch_move(ch, stat, chm, from, to, flags)
318 1.13 mycroft struct ch_softc *ch;
319 1.6 mycroft short *stat;
320 1.6 mycroft int chm, from, to, flags;
321 1.1 cgd {
322 1.1 cgd struct scsi_move_medium scsi_cmd;
323 1.6 mycroft int error;
324 1.1 cgd
325 1.1 cgd bzero(&scsi_cmd, sizeof(scsi_cmd));
326 1.13 mycroft scsi_cmd.opcode = MOVE_MEDIUM;
327 1.6 mycroft scsi_cmd.transport_element_address[0] = (chm >> 8) & 0xff;
328 1.6 mycroft scsi_cmd.transport_element_address[1] = chm & 0xff;
329 1.6 mycroft scsi_cmd.source_address[0] = (from >> 8) & 0xff;
330 1.6 mycroft scsi_cmd.source_address[1] = from & 0xff;
331 1.6 mycroft scsi_cmd.destination_address[0] = (to >> 8) & 0xff;
332 1.6 mycroft scsi_cmd.destination_address[1] = to & 0xff;
333 1.6 mycroft scsi_cmd.invert = (chm & CH_INVERT) ? 1 : 0;
334 1.6 mycroft error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd,
335 1.6 mycroft sizeof(scsi_cmd), NULL, 0, CHRETRIES, 100000, NULL, flags);
336 1.6 mycroft if (error)
337 1.6 mycroft *stat = ch->lsterr;
338 1.6 mycroft else
339 1.6 mycroft *stat = 0;
340 1.6 mycroft return error;
341 1.1 cgd }
342 1.1 cgd
343 1.6 mycroft int
344 1.6 mycroft ch_position(ch, stat, chm, to, flags)
345 1.13 mycroft struct ch_softc *ch;
346 1.6 mycroft short *stat;
347 1.6 mycroft int chm, to, flags;
348 1.1 cgd {
349 1.1 cgd struct scsi_position_to_element scsi_cmd;
350 1.6 mycroft int error;
351 1.1 cgd
352 1.1 cgd bzero(&scsi_cmd, sizeof(scsi_cmd));
353 1.13 mycroft scsi_cmd.opcode = POSITION_TO_ELEMENT;
354 1.6 mycroft scsi_cmd.transport_element_address[0] = (chm >> 8) & 0xff;
355 1.6 mycroft scsi_cmd.transport_element_address[1] = chm & 0xff;
356 1.6 mycroft scsi_cmd.source_address[0] = (to >> 8) & 0xff;
357 1.6 mycroft scsi_cmd.source_address[1] = to & 0xff;
358 1.6 mycroft scsi_cmd.invert = (chm & CH_INVERT) ? 1 : 0;
359 1.6 mycroft error = scsi_scsi_cmd(ch->sc_link, (struct scsi_generic *) &scsi_cmd,
360 1.6 mycroft sizeof(scsi_cmd), NULL, 0, CHRETRIES, 100000, NULL, flags);
361 1.6 mycroft if (error)
362 1.6 mycroft *stat = ch->lsterr;
363 1.6 mycroft else
364 1.6 mycroft *stat = 0;
365 1.6 mycroft return error;
366 1.1 cgd }
367 1.1 cgd
368 1.1 cgd #ifdef __STDC__
369 1.6 mycroft #define b2tol(a) (((unsigned)(a##_1) << 8) | (unsigned)a##_0)
370 1.1 cgd #else
371 1.6 mycroft #define b2tol(a) (((unsigned)(a/**/_1) << 8) | (unsigned)a/**/_0)
372 1.1 cgd #endif
373 1.1 cgd
374 1.6 mycroft /*
375 1.6 mycroft * Get the scsi driver to send a full inquiry to the
376 1.6 mycroft * device and use the results to fill out the global
377 1.6 mycroft * parameter structure.
378 1.6 mycroft */
379 1.6 mycroft int
380 1.6 mycroft ch_mode_sense(ch, flags)
381 1.13 mycroft struct ch_softc *ch;
382 1.6 mycroft int flags;
383 1.1 cgd {
384 1.1 cgd struct scsi_mode_sense scsi_cmd;
385 1.6 mycroft u_char scsi_sense[128]; /* Can't use scsi_mode_sense_data because of
386 1.6 mycroft * missing block descriptor.
387 1.6 mycroft */
388 1.1 cgd u_char *b;
389 1.6 mycroft int i, l;
390 1.6 mycroft int error;
391 1.6 mycroft struct scsi_link *sc_link = ch->sc_link;
392 1.6 mycroft
393 1.6 mycroft /*
394 1.6 mycroft * First check if we have it all loaded
395 1.6 mycroft */
396 1.6 mycroft if (sc_link->flags & SDEV_MEDIA_LOADED)
397 1.6 mycroft return 0;
398 1.6 mycroft
399 1.6 mycroft /*
400 1.6 mycroft * First do a mode sense
401 1.6 mycroft */
402 1.6 mycroft bzero(&scsi_cmd, sizeof(scsi_cmd));
403 1.13 mycroft scsi_cmd.opcode = MODE_SENSE;
404 1.6 mycroft scsi_cmd.byte2 = SMS_DBD;
405 1.6 mycroft scsi_cmd.page = 0x3f; /* All Pages */
406 1.6 mycroft scsi_cmd.length = sizeof(scsi_sense);
407 1.6 mycroft
408 1.6 mycroft /*
409 1.6 mycroft * Read in the pages
410 1.6 mycroft */
411 1.13 mycroft if (error = scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd,
412 1.6 mycroft sizeof(scsi_cmd), (u_char *) &scsi_sense, sizeof(scsi_sense),
413 1.13 mycroft CHRETRIES, 5000, NULL, flags | SCSI_DATA_IN)) {
414 1.13 mycroft printf("%s: could not mode sense\n", ch->sc_dev.dv_xname);
415 1.6 mycroft return error;
416 1.6 mycroft }
417 1.6 mycroft
418 1.6 mycroft sc_link->flags |= SDEV_MEDIA_LOADED;
419 1.6 mycroft l = scsi_sense[0] - 3;
420 1.6 mycroft b = &scsi_sense[4];
421 1.6 mycroft
422 1.6 mycroft /*
423 1.6 mycroft * To avoid alignment problems
424 1.6 mycroft */
425 1.6 mycroft /* XXXX - FIX THIS FOR MSB */
426 1.6 mycroft #define p2copy(valp) (valp[1] | (valp[0]<<8)); valp+=2
427 1.6 mycroft #define p4copy(valp) (valp[3] | (valp[2]<<8) | (valp[1]<<16) | (valp[0]<<24)); valp+=4
428 1.1 cgd #if 0
429 1.6 mycroft printf("\nmode_sense %d\n", l);
430 1.6 mycroft for (i = 0; i < l + 4; i++)
431 1.6 mycroft printf("%x%c", scsi_sense[i], i % 8 == 7 ? '\n' : ':');
432 1.1 cgd printf("\n");
433 1.1 cgd #endif
434 1.6 mycroft for (i = 0; i < l;) {
435 1.6 mycroft u_char pc = (*b++) & 0x3f;
436 1.6 mycroft u_char pl = *b++;
437 1.6 mycroft u_char *bb = b;
438 1.6 mycroft switch (pc) {
439 1.6 mycroft case 0x1d:
440 1.6 mycroft ch->chmo = p2copy(bb);
441 1.6 mycroft ch->chms = p2copy(bb);
442 1.6 mycroft ch->sloto = p2copy(bb);
443 1.6 mycroft ch->slots = p2copy(bb);
444 1.6 mycroft ch->imexo = p2copy(bb);
445 1.6 mycroft ch->imexs = p2copy(bb);
446 1.6 mycroft ch->driveo = p2copy(bb);
447 1.6 mycroft ch->drives = p2copy(bb);
448 1.6 mycroft break;
449 1.6 mycroft case 0x1e:
450 1.6 mycroft ch->rot = *b & 0x1;
451 1.1 cgd break;
452 1.6 mycroft case 0x1f:
453 1.6 mycroft ch->stor = *b & 0xf;
454 1.6 mycroft bb += 2;
455 1.6 mycroft ch->stor = p4copy(bb);
456 1.1 cgd break;
457 1.1 cgd default:
458 1.6 mycroft break;
459 1.1 cgd }
460 1.6 mycroft b += pl;
461 1.6 mycroft i += pl + 2;
462 1.1 cgd }
463 1.6 mycroft SC_DEBUG(sc_link, SDEV_DB2,
464 1.6 mycroft (" cht(%d-%d)slot(%d-%d)imex(%d-%d)cts(%d-%d) %s rotate\n",
465 1.6 mycroft ch->chmo, ch->chms, ch->sloto, ch->slots, ch->imexo, ch->imexs,
466 1.6 mycroft ch->driveo, ch->drives, ch->rot ? "can" : "can't"));
467 1.6 mycroft return 0;
468 1.1 cgd }
469