1 /* $NetBSD: rf.c,v 1.34 2019/10/29 03:49:59 christos Exp $ */ 2 /* 3 * Copyright (c) 2002 Jochen Kunz. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 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 * 3. The name of Jochen Kunz may not be used to endorse or promote 15 * products derived from this software without specific prior 16 * written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY JOCHEN KUNZ 19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JOCHEN KUNZ 22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 /* 32 TODO: 33 - Better LBN bound checking, block padding for SD disks. 34 - Formatting / "Set Density" 35 - Better error handling / detailed error reason reporting. 36 */ 37 38 #include <sys/cdefs.h> 39 __KERNEL_RCSID(0, "$NetBSD: rf.c,v 1.34 2019/10/29 03:49:59 christos Exp $"); 40 41 /* autoconfig stuff */ 42 #include <sys/param.h> 43 #include <sys/device.h> 44 #include <sys/conf.h> 45 #include "locators.h" 46 #include "ioconf.h" 47 48 /* bus_space / bus_dma */ 49 #include <sys/bus.h> 50 51 /* UniBus / QBus specific stuff */ 52 #include <dev/qbus/ubavar.h> 53 54 /* disk interface */ 55 #include <sys/types.h> 56 #include <sys/disklabel.h> 57 #include <sys/disk.h> 58 59 /* general system data and functions */ 60 #include <sys/systm.h> 61 #include <sys/ioctl.h> 62 #include <sys/ioccom.h> 63 64 /* physio / buffer handling */ 65 #include <sys/buf.h> 66 #include <sys/bufq.h> 67 68 /* tsleep / sleep / wakeup */ 69 #include <sys/proc.h> 70 /* hz for above */ 71 #include <sys/kernel.h> 72 73 /* bitdefinitions for RX211 */ 74 #include <dev/qbus/rfreg.h> 75 76 77 #define RFS_DENS 0x0001 /* single or double density */ 78 #define RFS_AD 0x0002 /* density auto detect */ 79 #define RFS_NOTINIT 0x0000 /* not initialized */ 80 #define RFS_PROBING 0x0010 /* density detect / verify started */ 81 #define RFS_FBUF 0x0020 /* Fill Buffer */ 82 #define RFS_EBUF 0x0030 /* Empty Buffer */ 83 #define RFS_WSEC 0x0040 /* Write Sector */ 84 #define RFS_RSEC 0x0050 /* Read Sector */ 85 #define RFS_SMD 0x0060 /* Set Media Density */ 86 #define RFS_RSTAT 0x0070 /* Read Status */ 87 #define RFS_WDDS 0x0080 /* Write Deleted Data Sector */ 88 #define RFS_REC 0x0090 /* Read Error Code */ 89 #define RFS_IDLE 0x00a0 /* controller is idle */ 90 #define RFS_CMDS 0x00f0 /* command mask */ 91 #define RFS_OPEN_A 0x0100 /* partition a open */ 92 #define RFS_OPEN_B 0x0200 /* partition b open */ 93 #define RFS_OPEN_C 0x0400 /* partition c open */ 94 #define RFS_OPEN_MASK 0x0f00 /* mask for open partitions */ 95 #define RFS_OPEN_SHIFT 8 /* to shift 1 to get RFS_OPEN_A */ 96 #define RFS_SETCMD(rf, state) ((rf) = ((rf) & ~RFS_CMDS) | (state)) 97 98 99 100 /* autoconfig stuff */ 101 static int rfc_match(device_t, cfdata_t, void *); 102 static void rfc_attach(device_t, device_t, void *); 103 static int rf_match(device_t, cfdata_t, void *); 104 static void rf_attach(device_t, device_t, void *); 105 static int rf_print(void *, const char *); 106 107 /* device interface functions / interface to disk(9) */ 108 dev_type_open(rfopen); 109 dev_type_close(rfclose); 110 dev_type_read(rfread); 111 dev_type_write(rfwrite); 112 dev_type_ioctl(rfioctl); 113 dev_type_strategy(rfstrategy); 114 dev_type_dump(rfdump); 115 dev_type_size(rfsize); 116 117 118 /* Entries in block and character major device number switch table. */ 119 const struct bdevsw rf_bdevsw = { 120 .d_open = rfopen, 121 .d_close = rfclose, 122 .d_strategy = rfstrategy, 123 .d_ioctl = rfioctl, 124 .d_dump = rfdump, 125 .d_psize = rfsize, 126 .d_discard = nodiscard, 127 .d_flag = D_DISK 128 }; 129 130 const struct cdevsw rf_cdevsw = { 131 .d_open = rfopen, 132 .d_close = rfclose, 133 .d_read = rfread, 134 .d_write = rfwrite, 135 .d_ioctl = rfioctl, 136 .d_stop = nostop, 137 .d_tty = notty, 138 .d_poll = nopoll, 139 .d_mmap = nommap, 140 .d_kqfilter = nokqfilter, 141 .d_discard = nodiscard, 142 .d_flag = D_DISK 143 }; 144 145 146 147 struct rfc_softc { 148 device_t sc_dev; /* common device data */ 149 device_t sc_childs[2]; /* child devices */ 150 struct evcnt sc_intr_count; /* Interrupt counter for statistics */ 151 struct buf *sc_curbuf; /* buf that is currently in work */ 152 bus_space_tag_t sc_iot; /* bus_space I/O tag */ 153 bus_space_handle_t sc_ioh; /* bus_space I/O handle */ 154 bus_dma_tag_t sc_dmat; /* bus_dma DMA tag */ 155 bus_dmamap_t sc_dmam; /* bus_dma DMA map */ 156 void *sc_bufidx; /* current position in buffer data */ 157 int sc_curchild; /* child whos bufq is in work */ 158 int sc_bytesleft; /* bytes left to transfer */ 159 u_int8_t type; /* controller type, 1 or 2 */ 160 }; 161 162 163 164 CFATTACH_DECL_NEW( 165 rfc, 166 sizeof(struct rfc_softc), 167 rfc_match, 168 rfc_attach, 169 NULL, 170 NULL 171 ); 172 173 174 175 struct rf_softc { 176 device_t sc_dev; /* common device data */ 177 struct disk sc_disk; /* common disk device data */ 178 struct rfc_softc *sc_rfc; /* our parent */ 179 struct bufq_state *sc_bufq; /* queue of pending transfers */ 180 int sc_state; /* state of drive */ 181 u_int8_t sc_dnum; /* drive number, 0 or 1 */ 182 }; 183 184 185 186 CFATTACH_DECL_NEW( 187 rf, 188 sizeof(struct rf_softc), 189 rf_match, 190 rf_attach, 191 NULL, 192 NULL 193 ); 194 195 196 197 struct rfc_attach_args { 198 u_int8_t type; /* controller type, 1 or 2 */ 199 u_int8_t dnum; /* drive number, 0 or 1 */ 200 }; 201 202 203 204 const struct dkdriver rfdkdriver = { 205 .d_strategy = rfstrategy 206 }; 207 208 209 210 /* helper functions */ 211 int rfc_sendcmd(struct rfc_softc *, int, int, int); 212 struct rf_softc* get_new_buf( struct rfc_softc *); 213 static void rfc_intr(void *); 214 215 216 217 /* 218 * Issue a reset command to the controller and look for the bits in 219 * RX2CS and RX2ES. 220 * RX2CS_RX02 and / or RX2CS_DD can be set, 221 * RX2ES has to be set, all other bits must be 0 222 */ 223 int 224 rfc_match(device_t parent, cfdata_t match, void *aux) 225 { 226 struct uba_attach_args *ua = aux; 227 int i; 228 229 /* Issue reset command. */ 230 bus_space_write_2(ua->ua_iot, ua->ua_ioh, RX2CS, RX2CS_INIT); 231 /* Wait for the controller to become ready, that is when 232 * RX2CS_DONE, RX2ES_RDY and RX2ES_ID are set. */ 233 for (i = 0 ; i < 20 ; i++) { 234 if ((bus_space_read_2(ua->ua_iot, ua->ua_ioh, RX2CS) 235 & RX2CS_DONE) != 0 236 && (bus_space_read_2(ua->ua_iot, ua->ua_ioh, RX2ES) 237 & (RX2ES_RDY | RX2ES_ID)) != 0) 238 break; 239 DELAY(100000); /* wait 100ms */ 240 } 241 /* 242 * Give up if the timeout has elapsed 243 * and the controller is not ready. 244 */ 245 if (i >= 20) 246 return(0); 247 /* 248 * Issue a Read Status command with interrupt enabled. 249 * The uba(4) driver wants to catch the interrupt to get the 250 * interrupt vector and level of the device 251 */ 252 bus_space_write_2(ua->ua_iot, ua->ua_ioh, RX2CS, 253 RX2CS_RSTAT | RX2CS_IE); 254 /* 255 * Wait for command to finish, ignore errors and 256 * abort if the controller does not respond within the timeout 257 */ 258 for (i = 0 ; i < 20 ; i++) { 259 if ((bus_space_read_2(ua->ua_iot, ua->ua_ioh, RX2CS) 260 & (RX2CS_DONE | RX2CS_IE)) != 0 261 && (bus_space_read_2(ua->ua_iot, ua->ua_ioh, RX2ES) 262 & RX2ES_RDY) != 0 ) 263 return(1); 264 DELAY(100000); /* wait 100ms */ 265 } 266 return(0); 267 } 268 269 270 271 /* #define RX02_PROBE 1 */ 272 #ifdef RX02_PROBE 273 /* 274 * Probe the density of an inserted floppy disk. 275 * This is done by reading a sector from disk. 276 * Return -1 on error, 0 on SD and 1 on DD. 277 */ 278 int rfcprobedens(struct rfc_softc *, int); 279 int 280 rfcprobedens(struct rfc_softc *rfc_sc, int dnum) 281 { 282 int dens_flag; 283 int i; 284 285 dens_flag = 0; 286 do { 287 bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS, 288 RX2CS_RSEC | (dens_flag == 0 ? 0 : RX2CS_DD) 289 | (dnum == 0 ? 0 : RX2CS_US)); 290 /* 291 * Transfer request set? 292 * Wait 50us, the controller needs this time to setle 293 */ 294 DELAY(50); 295 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) 296 & RX2CS_TR) == 0) { 297 printf("%s: did not respond to Read Sector CMD(1)\n", 298 device_xname(rfc_sc->sc_dev)); 299 return(-1); 300 } 301 bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2SA, 1); 302 /* Wait 50us, the controller needs this time to setle */ 303 DELAY(50); 304 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) 305 & RX2CS_TR) == 0) { 306 printf("%s: did not respond to Read Sector CMD(2)\n", 307 device_xname(rfc_sc->sc_dev)); 308 return(-1); 309 } 310 bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2TA, 1); 311 /* Wait for the command to finish */ 312 for (i = 0 ; i < 200 ; i++) { 313 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, 314 RX2CS) & RX2CS_DONE) != 0) 315 break; 316 DELAY(10000); /* wait 10ms */ 317 } 318 if (i >= 200) { 319 printf("%s: did not respond to Read Sector CMD(3)\n", 320 device_xname(rfc_sc->sc_dev)); 321 return(-1); 322 } 323 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) 324 & RX2CS_ERR) == 0) 325 return(dens_flag); 326 } while (rfc_sc->type == 2 && dens_flag++ == 0); 327 return(-1); 328 } 329 #endif /* RX02_PROBE */ 330 331 332 333 void 334 rfc_attach(device_t parent, device_t self, void *aux) 335 { 336 struct rfc_softc *rfc_sc = device_private(self); 337 struct uba_attach_args *ua = aux; 338 struct rfc_attach_args rfc_aa; 339 int i; 340 341 rfc_sc->sc_dev = self; 342 rfc_sc->sc_iot = ua->ua_iot; 343 rfc_sc->sc_ioh = ua->ua_ioh; 344 rfc_sc->sc_dmat = ua->ua_dmat; 345 rfc_sc->sc_curbuf = NULL; 346 /* Tell the QBus busdriver about our interrupt handler. */ 347 uba_intr_establish(ua->ua_icookie, ua->ua_cvec, rfc_intr, rfc_sc, 348 &rfc_sc->sc_intr_count); 349 /* Attach to the interrupt counter, see evcnt(9) */ 350 evcnt_attach_dynamic(&rfc_sc->sc_intr_count, EVCNT_TYPE_INTR, 351 ua->ua_evcnt, device_xname(rfc_sc->sc_dev), "intr"); 352 /* get a bus_dma(9) handle */ 353 i = bus_dmamap_create(rfc_sc->sc_dmat, RX2_BYTE_DD, 1, RX2_BYTE_DD, 0, 354 BUS_DMA_ALLOCNOW, &rfc_sc->sc_dmam); 355 if (i != 0) { 356 printf("rfc_attach: Error creating bus dma map: %d\n", i); 357 return; 358 } 359 360 /* Issue reset command. */ 361 bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS, RX2CS_INIT); 362 /* 363 * Wait for the controller to become ready, that is when 364 * RX2CS_DONE, RX2ES_RDY and RX2ES_ID are set. 365 */ 366 for (i = 0 ; i < 20 ; i++) { 367 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) 368 & RX2CS_DONE) != 0 369 && (bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2ES) 370 & (RX2ES_RDY | RX2ES_ID)) != 0) 371 break; 372 DELAY(100000); /* wait 100ms */ 373 } 374 /* 375 * Give up if the timeout has elapsed 376 * and the controller is not ready. 377 */ 378 if (i >= 20) { 379 printf(": did not respond to INIT CMD\n"); 380 return; 381 } 382 /* Is ths a RX01 or a RX02? */ 383 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) 384 & RX2CS_RX02) != 0) { 385 rfc_sc->type = 2; 386 rfc_aa.type = 2; 387 } else { 388 rfc_sc->type = 1; 389 rfc_aa.type = 1; 390 } 391 printf(": RX0%d\n", rfc_sc->type); 392 393 #ifndef RX02_PROBE 394 /* 395 * Bouth disk drievs and the controller are one physical unit. 396 * If we found the controller, there will be bouth disk drievs. 397 * So attach them. 398 */ 399 rfc_aa.dnum = 0; 400 rfc_sc->sc_childs[0] = config_found(rfc_sc->sc_dev, &rfc_aa, rf_print); 401 rfc_aa.dnum = 1; 402 rfc_sc->sc_childs[1] = config_found(rfc_sc->sc_dev, &rfc_aa, rf_print); 403 #else /* RX02_PROBE */ 404 /* 405 * There are clones of the DEC RX system with standard shugart 406 * interface. In this case we can not be sure that there are 407 * bouth disk drievs. So we want to do a detection of attached 408 * drives. This is done by reading a sector from disk. This means 409 * that there must be a formatted disk in the drive at boot time. 410 * This is bad, but I did not find another way to detect the 411 * (non)existence of a floppy drive. 412 */ 413 if (rfcprobedens(rfc_sc, 0) >= 0) { 414 rfc_aa.dnum = 0; 415 rfc_sc->sc_childs[0] = config_found(rfc_sc->sc_dev, &rfc_aa, 416 rf_print); 417 } else 418 rfc_sc->sc_childs[0] = NULL; 419 if (rfcprobedens(rfc_sc, 1) >= 0) { 420 rfc_aa.dnum = 1; 421 rfc_sc->sc_childs[1] = config_found(rfc_sc->sc_dev, &rfc_aa, 422 rf_print); 423 } else 424 rfc_sc->sc_childs[1] = NULL; 425 #endif /* RX02_PROBE */ 426 return; 427 } 428 429 430 431 int 432 rf_match(device_t parent, cfdata_t match, void *aux) 433 { 434 struct rfc_attach_args *rfc_aa = aux; 435 436 /* 437 * Only attach if the locator is wildcarded or 438 * if the specified locator addresses the current device. 439 */ 440 if (match->cf_loc[RFCCF_DRIVE] == RFCCF_DRIVE_DEFAULT || 441 match->cf_loc[RFCCF_DRIVE] == rfc_aa->dnum) 442 return(1); 443 return(0); 444 } 445 446 447 448 void 449 rf_attach(device_t parent, device_t self, void *aux) 450 { 451 struct rf_softc *rf_sc = device_private(self); 452 struct rfc_softc *rfc_sc = device_private(parent); 453 struct rfc_attach_args *rfc_aa = (struct rfc_attach_args *)aux; 454 struct disklabel *dl; 455 456 rf_sc->sc_dev = self; 457 rf_sc->sc_rfc = rfc_sc; 458 rf_sc->sc_dnum = rfc_aa->dnum; 459 rf_sc->sc_state = 0; 460 disk_init(&rf_sc->sc_disk, device_xname(rf_sc->sc_dev), &rfdkdriver); 461 disk_attach(&rf_sc->sc_disk); 462 dl = rf_sc->sc_disk.dk_label; 463 dl->d_type = DKTYPE_FLOPPY; /* drive type */ 464 dl->d_magic = DISKMAGIC; /* the magic number */ 465 dl->d_magic2 = DISKMAGIC; 466 dl->d_typename[0] = 'R'; 467 dl->d_typename[1] = 'X'; 468 dl->d_typename[2] = '0'; 469 dl->d_typename[3] = rfc_sc->type == 1 ? '1' : '2'; /* type name */ 470 dl->d_typename[4] = '\0'; 471 dl->d_secsize = DEV_BSIZE; /* bytes per sector */ 472 /* 473 * Fill in some values to have a initialized data structure. Some 474 * values will be reset by rfopen() depending on the actual density. 475 */ 476 dl->d_nsectors = RX2_SECTORS; /* sectors per track */ 477 dl->d_ntracks = 1; /* tracks per cylinder */ 478 dl->d_ncylinders = RX2_TRACKS; /* cylinders per unit */ 479 dl->d_secpercyl = RX2_SECTORS; /* sectors per cylinder */ 480 dl->d_secperunit = RX2_SECTORS * RX2_TRACKS; /* sectors per unit */ 481 dl->d_rpm = 360; /* rotational speed */ 482 dl->d_interleave = 1; /* hardware sector interleave */ 483 /* number of partitions in following */ 484 dl->d_npartitions = MAXPARTITIONS; 485 dl->d_bbsize = 0; /* size of boot area at sn0, bytes */ 486 dl->d_sbsize = 0; /* max size of fs superblock, bytes */ 487 /* number of sectors in partition */ 488 dl->d_partitions[0].p_size = 501; 489 dl->d_partitions[0].p_offset = 0; /* starting sector */ 490 dl->d_partitions[0].p_fsize = 0; /* fs basic fragment size */ 491 dl->d_partitions[0].p_fstype = 0; /* fs type */ 492 dl->d_partitions[0].p_frag = 0; /* fs fragments per block */ 493 dl->d_partitions[1].p_size = RX2_SECTORS * RX2_TRACKS / 2; 494 dl->d_partitions[1].p_offset = 0; /* starting sector */ 495 dl->d_partitions[1].p_fsize = 0; /* fs basic fragment size */ 496 dl->d_partitions[1].p_fstype = 0; /* fs type */ 497 dl->d_partitions[1].p_frag = 0; /* fs fragments per block */ 498 dl->d_partitions[2].p_size = RX2_SECTORS * RX2_TRACKS; 499 dl->d_partitions[2].p_offset = 0; /* starting sector */ 500 dl->d_partitions[2].p_fsize = 0; /* fs basic fragment size */ 501 dl->d_partitions[2].p_fstype = 0; /* fs type */ 502 dl->d_partitions[2].p_frag = 0; /* fs fragments per block */ 503 bufq_alloc(&rf_sc->sc_bufq, "disksort", BUFQ_SORT_CYLINDER); 504 printf("\n"); 505 return; 506 } 507 508 509 510 int 511 rf_print(void *aux, const char *name) 512 { 513 struct rfc_attach_args *rfc_aa = aux; 514 515 if (name != NULL) 516 aprint_normal("RX0%d at %s", rfc_aa->type, name); 517 aprint_normal(" drive %d", rfc_aa->dnum); 518 return(UNCONF); 519 } 520 521 522 523 /* Send a command to the controller */ 524 int 525 rfc_sendcmd(struct rfc_softc *rfc_sc, int cmd, int data1, int data2) 526 { 527 528 /* Write command to CSR. */ 529 bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS, cmd); 530 /* Wait 50us, the controller needs this time to setle. */ 531 DELAY(50); 532 /* Write parameter 1 to DBR */ 533 if ((cmd & RX2CS_MASK) != RX2CS_RSTAT) { 534 /* Transfer request set? */ 535 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) 536 & RX2CS_TR) == 0) { 537 printf("%s: did not respond to CMD %x (1)\n", 538 device_xname(rfc_sc->sc_dev), cmd); 539 return(-1); 540 } 541 bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2DB, 542 data1); 543 } 544 /* Write parameter 2 to DBR */ 545 if ((cmd & RX2CS_MASK) <= RX2CS_RSEC || 546 (cmd & RX2CS_MASK) == RX2CS_WDDS) { 547 /* Wait 50us, the controller needs this time to setle. */ 548 DELAY(50); 549 /* Transfer request set? */ 550 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2CS) 551 & RX2CS_TR) == 0) { 552 printf("%s: did not respond to CMD %x (2)\n", 553 device_xname(rfc_sc->sc_dev), cmd); 554 return(-1); 555 } 556 bus_space_write_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, RX2DB, 557 data2); 558 } 559 return(1); 560 } 561 562 563 564 void 565 rfstrategy(struct buf *buf) 566 { 567 struct rf_softc *rf_sc; 568 struct rfc_softc *rfc_sc; 569 int s; 570 571 if ((rf_sc = device_lookup_private(&rf_cd, DISKUNIT(buf->b_dev))) == NULL) { 572 buf->b_error = ENXIO; 573 biodone(buf); 574 return; 575 } 576 rfc_sc = rf_sc->sc_rfc; 577 /* We are going to operate on a non-open dev? PANIC! */ 578 if ((rf_sc->sc_state & (1 << (DISKPART(buf->b_dev) + RFS_OPEN_SHIFT))) 579 == 0) 580 panic("rfstrategy: can not operate on non-open drive %s " 581 "partition %"PRIu32, device_xname(rf_sc->sc_dev), 582 DISKPART(buf->b_dev)); 583 if (buf->b_bcount == 0) { 584 biodone(buf); 585 return; 586 } 587 /* 588 * bufq_put() operates on b_rawblkno. rfstrategy() gets 589 * only b_blkno that is partition relative. As a floppy does not 590 * have partitions b_rawblkno == b_blkno. 591 */ 592 buf->b_rawblkno = buf->b_blkno; 593 /* 594 * from sys/kern/subr_disk.c: 595 * Seek sort for disks. We depend on the driver which calls us using 596 * b_resid as the current cylinder number. 597 */ 598 s = splbio(); 599 if (rfc_sc->sc_curbuf == NULL) { 600 rfc_sc->sc_curchild = rf_sc->sc_dnum; 601 rfc_sc->sc_curbuf = buf; 602 rfc_sc->sc_bufidx = buf->b_data; 603 rfc_sc->sc_bytesleft = buf->b_bcount; 604 rfc_intr(rfc_sc); 605 } else { 606 buf->b_resid = buf->b_blkno / RX2_SECTORS; 607 bufq_put(rf_sc->sc_bufq, buf); 608 buf->b_resid = 0; 609 } 610 splx(s); 611 } 612 613 /* 614 * Look if there is another buffer in the bufferqueue of this drive 615 * and start to process it if there is one. 616 * If the bufferqueue is empty, look at the bufferqueue of the other drive 617 * that is attached to this controller. 618 * Start procesing the bufferqueue of the other drive if it isn't empty. 619 * Return a pointer to the softc structure of the drive that is now 620 * ready to process a buffer or NULL if there is no buffer in either queues. 621 */ 622 struct rf_softc* 623 get_new_buf( struct rfc_softc *rfc_sc) 624 { 625 struct rf_softc *rf_sc; 626 struct rf_softc *other_drive; 627 628 rf_sc = device_private(rfc_sc->sc_childs[rfc_sc->sc_curchild]); 629 rfc_sc->sc_curbuf = bufq_get(rf_sc->sc_bufq); 630 if (rfc_sc->sc_curbuf != NULL) { 631 rfc_sc->sc_bufidx = rfc_sc->sc_curbuf->b_data; 632 rfc_sc->sc_bytesleft = rfc_sc->sc_curbuf->b_bcount; 633 } else { 634 RFS_SETCMD(rf_sc->sc_state, RFS_IDLE); 635 other_drive = device_private( 636 rfc_sc->sc_childs[ rfc_sc->sc_curchild == 0 ? 1 : 0]); 637 if (other_drive != NULL 638 && bufq_peek(other_drive->sc_bufq) != NULL) { 639 rfc_sc->sc_curchild = rfc_sc->sc_curchild == 0 ? 1 : 0; 640 rf_sc = other_drive; 641 rfc_sc->sc_curbuf = bufq_get(rf_sc->sc_bufq); 642 rfc_sc->sc_bufidx = rfc_sc->sc_curbuf->b_data; 643 rfc_sc->sc_bytesleft = rfc_sc->sc_curbuf->b_bcount; 644 } else 645 return(NULL); 646 } 647 return(rf_sc); 648 } 649 650 651 652 void 653 rfc_intr(void *intarg) 654 { 655 struct rfc_softc *rfc_sc = intarg; 656 struct rf_softc *rf_sc; 657 int i; 658 659 rf_sc = device_private(rfc_sc->sc_childs[rfc_sc->sc_curchild]); 660 for (;;) { 661 /* 662 * First clean up from previous command... 663 */ 664 switch (rf_sc->sc_state & RFS_CMDS) { 665 case RFS_PROBING: /* density detect / verify started */ 666 disk_unbusy(&rf_sc->sc_disk, 0, 1); 667 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, 668 RX2CS) & RX2CS_ERR) == 0) { 669 RFS_SETCMD(rf_sc->sc_state, RFS_IDLE); 670 wakeup(rf_sc); 671 } else { 672 if (rfc_sc->type == 2 673 && (rf_sc->sc_state & RFS_DENS) == 0 674 && (rf_sc->sc_state & RFS_AD) != 0) { 675 /* retry at DD */ 676 rf_sc->sc_state |= RFS_DENS; 677 disk_busy(&rf_sc->sc_disk); 678 if (rfc_sendcmd(rfc_sc, RX2CS_RSEC 679 | RX2CS_IE | RX2CS_DD | 680 (rf_sc->sc_dnum == 0 ? 0 : 681 RX2CS_US), 1, 1) < 0) { 682 disk_unbusy(&rf_sc->sc_disk, 683 0, 1); 684 RFS_SETCMD(rf_sc->sc_state, 685 RFS_NOTINIT); 686 wakeup(rf_sc); 687 } 688 } else { 689 printf("%s: density error.\n", 690 device_xname(rf_sc->sc_dev)); 691 RFS_SETCMD(rf_sc->sc_state,RFS_NOTINIT); 692 wakeup(rf_sc); 693 } 694 } 695 return; 696 case RFS_IDLE: /* controller is idle */ 697 if (rfc_sc->sc_curbuf->b_bcount 698 % ((rf_sc->sc_state & RFS_DENS) == 0 699 ? RX2_BYTE_SD : RX2_BYTE_DD) != 0) { 700 /* 701 * can only handle blocks that are a multiple 702 * of the physical block size 703 */ 704 rfc_sc->sc_curbuf->b_error = EIO; 705 } 706 RFS_SETCMD(rf_sc->sc_state, (rfc_sc->sc_curbuf->b_flags 707 & B_READ) != 0 ? RFS_RSEC : RFS_FBUF); 708 break; 709 case RFS_RSEC: /* Read Sector */ 710 disk_unbusy(&rf_sc->sc_disk, 0, 1); 711 /* check for errors */ 712 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, 713 RX2CS) & RX2CS_ERR) != 0) { 714 /* should do more verbose error reporting */ 715 printf("rfc_intr: Error reading secotr: %x\n", 716 bus_space_read_2(rfc_sc->sc_iot, 717 rfc_sc->sc_ioh, RX2ES) ); 718 rfc_sc->sc_curbuf->b_error = EIO; 719 } 720 RFS_SETCMD(rf_sc->sc_state, RFS_EBUF); 721 break; 722 case RFS_WSEC: /* Write Sector */ 723 i = (rf_sc->sc_state & RFS_DENS) == 0 724 ? RX2_BYTE_SD : RX2_BYTE_DD; 725 disk_unbusy(&rf_sc->sc_disk, i, 0); 726 /* check for errors */ 727 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, 728 RX2CS) & RX2CS_ERR) != 0) { 729 /* should do more verbose error reporting */ 730 printf("rfc_intr: Error writing secotr: %x\n", 731 bus_space_read_2(rfc_sc->sc_iot, 732 rfc_sc->sc_ioh, RX2ES) ); 733 rfc_sc->sc_curbuf->b_error = EIO; 734 break; 735 } 736 if (rfc_sc->sc_bytesleft > i) { 737 rfc_sc->sc_bytesleft -= i; 738 rfc_sc->sc_bufidx = 739 (char *)rfc_sc->sc_bufidx + i; 740 } else { 741 biodone(rfc_sc->sc_curbuf); 742 rf_sc = get_new_buf( rfc_sc); 743 if (rf_sc == NULL) 744 return; 745 } 746 RFS_SETCMD(rf_sc->sc_state, 747 (rfc_sc->sc_curbuf->b_flags & B_READ) != 0 748 ? RFS_RSEC : RFS_FBUF); 749 break; 750 case RFS_FBUF: /* Fill Buffer */ 751 disk_unbusy(&rf_sc->sc_disk, 0, 0); 752 bus_dmamap_unload(rfc_sc->sc_dmat, rfc_sc->sc_dmam); 753 /* check for errors */ 754 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, 755 RX2CS) & RX2CS_ERR) != 0) { 756 /* should do more verbose error reporting */ 757 printf("rfc_intr: Error while DMA: %x\n", 758 bus_space_read_2(rfc_sc->sc_iot, 759 rfc_sc->sc_ioh, RX2ES)); 760 rfc_sc->sc_curbuf->b_error = EIO; 761 } 762 RFS_SETCMD(rf_sc->sc_state, RFS_WSEC); 763 break; 764 case RFS_EBUF: /* Empty Buffer */ 765 i = (rf_sc->sc_state & RFS_DENS) == 0 766 ? RX2_BYTE_SD : RX2_BYTE_DD; 767 disk_unbusy(&rf_sc->sc_disk, i, 1); 768 bus_dmamap_unload(rfc_sc->sc_dmat, rfc_sc->sc_dmam); 769 /* check for errors */ 770 if ((bus_space_read_2(rfc_sc->sc_iot, rfc_sc->sc_ioh, 771 RX2CS) & RX2CS_ERR) != 0) { 772 /* should do more verbose error reporting */ 773 printf("rfc_intr: Error while DMA: %x\n", 774 bus_space_read_2(rfc_sc->sc_iot, 775 rfc_sc->sc_ioh, RX2ES)); 776 rfc_sc->sc_curbuf->b_error = EIO; 777 break; 778 } 779 if (rfc_sc->sc_bytesleft > i) { 780 rfc_sc->sc_bytesleft -= i; 781 rfc_sc->sc_bufidx = 782 (char *)rfc_sc->sc_bufidx + i; 783 } else { 784 biodone(rfc_sc->sc_curbuf); 785 rf_sc = get_new_buf( rfc_sc); 786 if (rf_sc == NULL) 787 return; 788 } 789 RFS_SETCMD(rf_sc->sc_state, 790 (rfc_sc->sc_curbuf->b_flags & B_READ) != 0 791 ? RFS_RSEC : RFS_FBUF); 792 break; 793 case RFS_NOTINIT: /* Device is not open */ 794 case RFS_SMD: /* Set Media Density */ 795 case RFS_RSTAT: /* Read Status */ 796 case RFS_WDDS: /* Write Deleted Data Sector */ 797 case RFS_REC: /* Read Error Code */ 798 default: 799 panic("Impossible state in rfc_intr(1): 0x%x\n", 800 rf_sc->sc_state & RFS_CMDS); 801 } 802 803 if (rfc_sc->sc_curbuf->b_error != 0) { 804 /* 805 * An error occurred while processing this buffer. 806 * Finish it and try to get a new buffer to process. 807 * Return if there are no buffers in the queues. 808 * This loops until the queues are empty or a new 809 * action was successfully scheduled. 810 */ 811 rfc_sc->sc_curbuf->b_resid = rfc_sc->sc_bytesleft; 812 rfc_sc->sc_curbuf->b_error = EIO; 813 biodone(rfc_sc->sc_curbuf); 814 rf_sc = get_new_buf( rfc_sc); 815 if (rf_sc == NULL) 816 return; 817 continue; 818 } 819 820 /* 821 * ... then initiate next command. 822 */ 823 switch (rf_sc->sc_state & RFS_CMDS) { 824 case RFS_EBUF: /* Empty Buffer */ 825 i = bus_dmamap_load(rfc_sc->sc_dmat, rfc_sc->sc_dmam, 826 rfc_sc->sc_bufidx, (rf_sc->sc_state & RFS_DENS) == 0 827 ? RX2_BYTE_SD : RX2_BYTE_DD, 828 rfc_sc->sc_curbuf->b_proc, BUS_DMA_NOWAIT); 829 if (i != 0) { 830 printf("rfc_intr: Error loading dmamap: %d\n", 831 i); 832 rfc_sc->sc_curbuf->b_error = EIO; 833 break; 834 } 835 disk_busy(&rf_sc->sc_disk); 836 if (rfc_sendcmd(rfc_sc, RX2CS_EBUF | RX2CS_IE 837 | ((rf_sc->sc_state & RFS_DENS) == 0 ? 0 : RX2CS_DD) 838 | (rf_sc->sc_dnum == 0 ? 0 : RX2CS_US) 839 | ((rfc_sc->sc_dmam->dm_segs[0].ds_addr 840 & 0x30000) >>4), ((rf_sc->sc_state & RFS_DENS) == 0 841 ? RX2_BYTE_SD : RX2_BYTE_DD) / 2, 842 rfc_sc->sc_dmam->dm_segs[0].ds_addr & 0xffff) < 0) { 843 disk_unbusy(&rf_sc->sc_disk, 0, 1); 844 rfc_sc->sc_curbuf->b_error = EIO; 845 bus_dmamap_unload(rfc_sc->sc_dmat, 846 rfc_sc->sc_dmam); 847 } 848 break; 849 case RFS_FBUF: /* Fill Buffer */ 850 i = bus_dmamap_load(rfc_sc->sc_dmat, rfc_sc->sc_dmam, 851 rfc_sc->sc_bufidx, (rf_sc->sc_state & RFS_DENS) == 0 852 ? RX2_BYTE_SD : RX2_BYTE_DD, 853 rfc_sc->sc_curbuf->b_proc, BUS_DMA_NOWAIT); 854 if (i != 0) { 855 printf("rfc_intr: Error loading dmamap: %d\n", 856 i); 857 rfc_sc->sc_curbuf->b_error = EIO; 858 break; 859 } 860 disk_busy(&rf_sc->sc_disk); 861 if (rfc_sendcmd(rfc_sc, RX2CS_FBUF | RX2CS_IE 862 | ((rf_sc->sc_state & RFS_DENS) == 0 ? 0 : RX2CS_DD) 863 | (rf_sc->sc_dnum == 0 ? 0 : RX2CS_US) 864 | ((rfc_sc->sc_dmam->dm_segs[0].ds_addr 865 & 0x30000)>>4), ((rf_sc->sc_state & RFS_DENS) == 0 866 ? RX2_BYTE_SD : RX2_BYTE_DD) / 2, 867 rfc_sc->sc_dmam->dm_segs[0].ds_addr & 0xffff) < 0) { 868 disk_unbusy(&rf_sc->sc_disk, 0, 0); 869 rfc_sc->sc_curbuf->b_error = EIO; 870 bus_dmamap_unload(rfc_sc->sc_dmat, 871 rfc_sc->sc_dmam); 872 } 873 break; 874 case RFS_WSEC: /* Write Sector */ 875 i = (rfc_sc->sc_curbuf->b_bcount - rfc_sc->sc_bytesleft 876 + rfc_sc->sc_curbuf->b_blkno * DEV_BSIZE) / 877 ((rf_sc->sc_state & RFS_DENS) == 0 878 ? RX2_BYTE_SD : RX2_BYTE_DD); 879 if (i > RX2_TRACKS * RX2_SECTORS) { 880 rfc_sc->sc_curbuf->b_error = EIO; 881 break; 882 } 883 disk_busy(&rf_sc->sc_disk); 884 if (rfc_sendcmd(rfc_sc, RX2CS_WSEC | RX2CS_IE 885 | (rf_sc->sc_dnum == 0 ? 0 : RX2CS_US) 886 | ((rf_sc->sc_state& RFS_DENS) == 0 ? 0 : RX2CS_DD), 887 i % RX2_SECTORS + 1, i / RX2_SECTORS) < 0) { 888 disk_unbusy(&rf_sc->sc_disk, 0, 0); 889 rfc_sc->sc_curbuf->b_error = EIO; 890 } 891 break; 892 case RFS_RSEC: /* Read Sector */ 893 i = (rfc_sc->sc_curbuf->b_bcount - rfc_sc->sc_bytesleft 894 + rfc_sc->sc_curbuf->b_blkno * DEV_BSIZE) / 895 ((rf_sc->sc_state & RFS_DENS) == 0 896 ? RX2_BYTE_SD : RX2_BYTE_DD); 897 if (i > RX2_TRACKS * RX2_SECTORS) { 898 rfc_sc->sc_curbuf->b_error = EIO; 899 break; 900 } 901 disk_busy(&rf_sc->sc_disk); 902 if (rfc_sendcmd(rfc_sc, RX2CS_RSEC | RX2CS_IE 903 | (rf_sc->sc_dnum == 0 ? 0 : RX2CS_US) 904 | ((rf_sc->sc_state& RFS_DENS) == 0 ? 0 : RX2CS_DD), 905 i % RX2_SECTORS + 1, i / RX2_SECTORS) < 0) { 906 disk_unbusy(&rf_sc->sc_disk, 0, 1); 907 rfc_sc->sc_curbuf->b_error = EIO; 908 } 909 break; 910 case RFS_NOTINIT: /* Device is not open */ 911 case RFS_PROBING: /* density detect / verify started */ 912 case RFS_IDLE: /* controller is idle */ 913 case RFS_SMD: /* Set Media Density */ 914 case RFS_RSTAT: /* Read Status */ 915 case RFS_WDDS: /* Write Deleted Data Sector */ 916 case RFS_REC: /* Read Error Code */ 917 default: 918 panic("Impossible state in rfc_intr(2): 0x%x\n", 919 rf_sc->sc_state & RFS_CMDS); 920 } 921 922 if (rfc_sc->sc_curbuf->b_error != 0) { 923 /* 924 * An error occurred while processing this buffer. 925 * Finish it and try to get a new buffer to process. 926 * Return if there are no buffers in the queues. 927 * This loops until the queues are empty or a new 928 * action was successfully scheduled. 929 */ 930 rfc_sc->sc_curbuf->b_resid = rfc_sc->sc_bytesleft; 931 rfc_sc->sc_curbuf->b_error = EIO; 932 biodone(rfc_sc->sc_curbuf); 933 rf_sc = get_new_buf( rfc_sc); 934 if (rf_sc == NULL) 935 return; 936 continue; 937 } 938 break; 939 } 940 return; 941 } 942 943 944 945 int 946 rfdump(dev_t dev, daddr_t blkno, void *va, size_t size) 947 { 948 949 /* A 0.5MB floppy is much to small to take a system dump... */ 950 return(ENXIO); 951 } 952 953 954 955 int 956 rfsize(dev_t dev) 957 { 958 959 return(-1); 960 } 961 962 963 964 int 965 rfopen(dev_t dev, int oflags, int devtype, struct lwp *l) 966 { 967 struct rf_softc *rf_sc; 968 struct rfc_softc *rfc_sc; 969 struct disklabel *dl; 970 971 if ((rf_sc = device_lookup_private(&rf_cd, DISKUNIT(dev))) == NULL) 972 return ENXIO; 973 974 rfc_sc = rf_sc->sc_rfc; 975 dl = rf_sc->sc_disk.dk_label; 976 switch (DISKPART(dev)) { 977 case 0: /* Part. a is single density. */ 978 /* opening in single and double density is senseless */ 979 if ((rf_sc->sc_state & RFS_OPEN_B) != 0 ) 980 return(ENXIO); 981 rf_sc->sc_state &= ~RFS_DENS; 982 rf_sc->sc_state &= ~RFS_AD; 983 rf_sc->sc_state |= RFS_OPEN_A; 984 break; 985 case 1: /* Part. b is double density. */ 986 /* 987 * Opening a single density only drive in double 988 * density or simultaneous opening in single and 989 * double density is senseless. 990 */ 991 if (rfc_sc->type == 1 992 || (rf_sc->sc_state & RFS_OPEN_A) != 0 ) 993 return(ENXIO); 994 rf_sc->sc_state |= RFS_DENS; 995 rf_sc->sc_state &= ~RFS_AD; 996 rf_sc->sc_state |= RFS_OPEN_B; 997 break; 998 case 2: /* Part. c is auto density. */ 999 rf_sc->sc_state |= RFS_AD; 1000 rf_sc->sc_state |= RFS_OPEN_C; 1001 break; 1002 default: 1003 return(ENXIO); 1004 break; 1005 } 1006 if ((rf_sc->sc_state & RFS_CMDS) == RFS_NOTINIT) { 1007 rfc_sc->sc_curchild = rf_sc->sc_dnum; 1008 /* 1009 * Controller is idle and density is not detected. 1010 * Start a density probe by issuing a read sector command 1011 * and sleep until the density probe finished. 1012 * Due to this it is imposible to open unformatted media. 1013 * As the RX02/02 is not able to format its own media, 1014 * media must be purchased preformatted. fsck DEC makreting! 1015 */ 1016 RFS_SETCMD(rf_sc->sc_state, RFS_PROBING); 1017 disk_busy(&rf_sc->sc_disk); 1018 if (rfc_sendcmd(rfc_sc, RX2CS_RSEC | RX2CS_IE 1019 | (rf_sc->sc_dnum == 0 ? 0 : RX2CS_US) 1020 | ((rf_sc->sc_state & RFS_DENS) == 0 ? 0 : RX2CS_DD), 1021 1, 1) < 0) { 1022 rf_sc->sc_state = 0; 1023 return(ENXIO); 1024 } 1025 /* wait max. 2 sec for density probe to finish */ 1026 if (tsleep(rf_sc, PRIBIO | PCATCH, "density probe", 2 * hz) 1027 != 0 || (rf_sc->sc_state & RFS_CMDS) == RFS_NOTINIT) { 1028 /* timeout elapsed and / or something went wrong */ 1029 rf_sc->sc_state = 0; 1030 return(ENXIO); 1031 } 1032 } 1033 /* disklabel. We use different fake geometries for SD and DD. */ 1034 if ((rf_sc->sc_state & RFS_DENS) == 0) { 1035 dl->d_nsectors = 10; /* sectors per track */ 1036 dl->d_secpercyl = 10; /* sectors per cylinder */ 1037 dl->d_ncylinders = 50; /* cylinders per unit */ 1038 dl->d_secperunit = 501; /* sectors per unit */ 1039 /* number of sectors in partition */ 1040 dl->d_partitions[2].p_size = 500; 1041 } else { 1042 dl->d_nsectors = RX2_SECTORS / 2; /* sectors per track */ 1043 dl->d_secpercyl = RX2_SECTORS / 2; /* sectors per cylinder */ 1044 dl->d_ncylinders = RX2_TRACKS; /* cylinders per unit */ 1045 /* sectors per unit */ 1046 dl->d_secperunit = RX2_SECTORS * RX2_TRACKS / 2; 1047 /* number of sectors in partition */ 1048 dl->d_partitions[2].p_size = RX2_SECTORS * RX2_TRACKS / 2; 1049 } 1050 return(0); 1051 } 1052 1053 1054 1055 int 1056 rfclose(dev_t dev, int fflag, int devtype, struct lwp *l) 1057 { 1058 struct rf_softc *rf_sc = device_lookup_private(&rf_cd, DISKUNIT(dev)); 1059 1060 if ((rf_sc->sc_state & 1 << (DISKPART(dev) + RFS_OPEN_SHIFT)) == 0) 1061 panic("rfclose: can not close non-open drive %s " 1062 "partition %"PRIu32, device_xname(rf_sc->sc_dev), DISKPART(dev)); 1063 else 1064 rf_sc->sc_state &= ~(1 << (DISKPART(dev) + RFS_OPEN_SHIFT)); 1065 if ((rf_sc->sc_state & RFS_OPEN_MASK) == 0) 1066 rf_sc->sc_state = 0; 1067 return(0); 1068 } 1069 1070 1071 1072 int 1073 rfread(dev_t dev, struct uio *uio, int ioflag) 1074 { 1075 1076 return(physio(rfstrategy, NULL, dev, B_READ, minphys, uio)); 1077 } 1078 1079 1080 1081 int 1082 rfwrite(dev_t dev, struct uio *uio, int ioflag) 1083 { 1084 1085 return(physio(rfstrategy, NULL, dev, B_WRITE, minphys, uio)); 1086 } 1087 1088 1089 1090 int 1091 rfioctl(dev_t dev, u_long cmd, void *data, int fflag, struct lwp *l) 1092 { 1093 struct rf_softc *rf_sc = device_lookup_private(&rf_cd, DISKUNIT(dev)); 1094 int error; 1095 1096 /* We are going to operate on a non-open dev? PANIC! */ 1097 if ((rf_sc->sc_state & 1 << (DISKPART(dev) + RFS_OPEN_SHIFT)) == 0) 1098 panic("rfioctl: can not operate on non-open drive %s " 1099 "partition %"PRIu32, device_xname(rf_sc->sc_dev), DISKPART(dev)); 1100 error = disk_ioctl(&rf_sc->sc_disk, dev, cmd, data, fflag, l); 1101 if (error != EPASSTHROUGH) 1102 return error; 1103 1104 switch (cmd) { 1105 /* get and set disklabel; DIOCGPARTINFO used internally */ 1106 case DIOCSDINFO: /* set */ 1107 return(0); 1108 case DIOCWDINFO: /* set, update disk */ 1109 return(0); 1110 /* do format operation, read or write */ 1111 case DIOCRFORMAT: 1112 break; 1113 case DIOCWFORMAT: 1114 break; 1115 1116 case DIOCSSTEP: /* set step rate */ 1117 break; 1118 case DIOCSRETRIES: /* set # of retries */ 1119 break; 1120 case DIOCKLABEL: /* keep/drop label on close? */ 1121 break; 1122 case DIOCWLABEL: /* write en/disable label */ 1123 break; 1124 1125 /* case DIOCSBAD: / * set kernel dkbad */ 1126 break; /* */ 1127 case DIOCEJECT: /* eject removable disk */ 1128 break; 1129 case ODIOCEJECT: /* eject removable disk */ 1130 break; 1131 case DIOCLOCK: /* lock/unlock pack */ 1132 break; 1133 1134 /* get default label, clear label */ 1135 case DIOCGDEFLABEL: 1136 break; 1137 case DIOCCLRLABEL: 1138 break; 1139 default: 1140 return(ENOTTY); 1141 } 1142 1143 return(ENOTTY); 1144 } 1145