Lines Matching refs:fd

528 	struct fd_softc		*fd   = device_private(self);  in fdattach()  local
533 fd->sc_dev = self; in fdattach()
534 callout_init(&fd->sc_motoron_ch, 0); in fdattach()
535 callout_init(&fd->sc_motoroff_ch, 0); in fdattach()
545 bufq_alloc(&fd->sc_q, "disksort", BUFQ_SORT_CYLINDER); in fdattach()
546 fd->sc_cylin = -1; in fdattach()
547 fd->sc_drive = drive; in fdattach()
548 fd->sc_deftype = type; in fdattach()
549 fdc->sc_fd[drive] = fd; in fdattach()
554 disk_init(&fd->sc_dk, device_xname(self), &fddkdriver); in fdattach()
555 disk_attach(&fd->sc_dk); in fdattach()
558 fd->sc_sdhook = shutdownhook_establish(fd_motor_off, fd); in fdattach()
596 fd_dev_to_type(struct fd_softc *fd, dev_t dev) in fd_dev_to_type() argument
602 return type ? &fd_types[type - 1] : fd->sc_deftype; in fd_dev_to_type()
608 struct fd_softc *fd = device_lookup_private(&hdfd_cd, FDUNIT(bp->b_dev)); in fdstrategy() local
626 if (bp->b_blkno + sz > fd->sc_type->size) { in fdstrategy()
627 sz = fd->sc_type->size - bp->b_blkno; in fdstrategy()
642 bp->b_cylinder = bp->b_blkno / (FDC_BSIZE/DEV_BSIZE) / fd->sc_type->seccyl; in fdstrategy()
646 " %d\n", bp->b_blkno, bp->b_bcount, (long)fd->sc_blkno, in fdstrategy()
652 bufq_put(fd->sc_q, bp); in fdstrategy()
653 callout_stop(&fd->sc_motoroff_ch); /* a good idea */ in fdstrategy()
654 if (fd->sc_active == 0) in fdstrategy()
655 fdstart(fd); in fdstrategy()
660 fdc = device_private(device_parent(fd->sc_dev)); in fdstrategy()
677 fdstart(struct fd_softc *fd) in fdstart() argument
679 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); in fdstart()
683 fd->sc_active = 1; in fdstart()
684 TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain); in fdstart()
692 fdfinish(struct fd_softc *fd, struct buf *bp) in fdfinish() argument
694 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); in fdfinish()
702 (void)bufq_get(fd->sc_q); in fdfinish()
703 if (fd->sc_drivechain.tqe_next && ++fd->sc_ops >= 8) { in fdfinish()
704 fd->sc_ops = 0; in fdfinish()
705 TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain); in fdfinish()
706 if (bufq_peek(fd->sc_q) != NULL) in fdfinish()
707 TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain); in fdfinish()
709 fd->sc_active = 0; in fdfinish()
711 bp->b_resid = fd->sc_bcount; in fdfinish()
712 fd->sc_skip = 0; in fdfinish()
716 callout_reset(&fd->sc_motoroff_ch, 5 * hz, fd_motor_off, fd); in fdfinish()
737 struct fd_softc *fd; in fd_set_motor() local
741 if ((fd = fdc->sc_drives.tqh_first) != NULL) in fd_set_motor()
742 status = fd->sc_drive; in fd_set_motor()
748 if ((fd = fdc->sc_fd[n]) && (fd->sc_flags & FD_MOTOR)) in fd_set_motor()
756 struct fd_softc *fd = arg; in fd_motor_off() local
757 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); in fd_motor_off()
761 fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); in fd_motor_off()
769 struct fd_softc *fd = arg; in fd_motor_on() local
770 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); in fd_motor_on()
774 fd->sc_flags &= ~FD_MOTOR_WAIT; in fd_motor_on()
775 if ((fdc->sc_drives.tqh_first == fd) && (fdc->sc_state == MOTORWAIT)) in fd_motor_on()
821 struct fd_softc *fd; in fdopen() local
824 fd = device_lookup_private(&hdfd_cd, FDUNIT(dev)); in fdopen()
825 if (fd == NULL) in fdopen()
827 type = fd_dev_to_type(fd, dev); in fdopen()
831 if ((fd->sc_flags & FD_OPEN) != 0 && in fdopen()
832 fd->sc_type != type) in fdopen()
835 fd->sc_type = type; in fdopen()
836 fd->sc_cylin = -1; in fdopen()
837 fd->sc_flags |= FD_OPEN; in fdopen()
838 fdgetdisklabel(fd, dev); in fdopen()
846 struct fd_softc *fd = device_lookup_private(&hdfd_cd, FDUNIT(dev)); in fdclose() local
848 fd->sc_flags &= ~(FD_OPEN|FD_HAVELAB); in fdclose()
849 fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT); in fdclose()
920 struct fd_softc *fd = fdc->sc_drives.tqh_first; in fdctimeout() local
924 fdcstatus(fd->sc_dev, 0, "timeout"); in fdctimeout()
926 if (bufq_peek(fd->sc_q) != NULL) in fdctimeout()
954 struct fd_softc *fd; in fdcintr() local
962 fd = fdc->sc_drives.tqh_first; in fdcintr()
963 if (fd == NULL) { in fdcintr()
969 bp = bufq_peek(fd->sc_q); in fdcintr()
971 fd->sc_ops = 0; in fdcintr()
972 TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain); in fdcintr()
973 fd->sc_active = 0; in fdcintr()
984 fd->sc_skip = 0; in fdcintr()
985 fd->sc_bcount = bp->b_bcount; in fdcintr()
986 fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE); in fdcintr()
987 callout_stop(&fd->sc_motoroff_ch); in fdcintr()
988 if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) { in fdcintr()
992 if ((fd->sc_flags & FD_MOTOR) == 0) { in fdcintr()
994 struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1]; in fdcintr()
999 fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT; in fdcintr()
1003 callout_reset(&fd->sc_motoron_ch, hz / 4, in fdcintr()
1004 fd_motor_on, fd); in fdcintr()
1013 if (fd->sc_cylin == bp->b_cylinder) in fdcintr()
1017 out_fdc(fd->sc_type->steprate); in fdcintr()
1023 out_fdc(fd->sc_drive); /* drive number */ in fdcintr()
1024 out_fdc(bp->b_cylinder * fd->sc_type->step); in fdcintr()
1026 fd->sc_cylin = -1; in fdcintr()
1029 iostat_seek(fd->sc_dk.dk_stats); in fdcintr()
1030 disk_busy(&fd->sc_dk); in fdcintr()
1038 fd->sc_skip = (char *)&(finfo->fd_formb_cylno(0)) - in fdcintr()
1041 type = fd->sc_type; in fdcintr()
1042 sec = fd->sc_blkno % type->seccyl; in fdcintr()
1046 nblks = uimin(nblks, fd->sc_bcount / FDC_BSIZE); in fdcintr()
1048 fd->sc_nblks = nblks; in fdcintr()
1049 fd->sc_nbytes = finfo ? bp->b_bcount : nblks * FDC_BSIZE; in fdcintr()
1054 block = (fd->sc_cylin * type->heads + head) in fdcintr()
1056 if (block != fd->sc_blkno) { in fdcintr()
1058 block, fd->sc_blkno); in fdcintr()
1070 fddmaaddr = (char *)bp->b_data + fd->sc_skip; in fdcintr()
1071 fddmalen = fd->sc_nbytes; in fdcintr()
1077 fd->sc_drive, fd->sc_cylin, head, sec, nblks); in fdcintr()
1088 out_fdc((head << 2) | fd->sc_drive); in fdcintr()
1098 out_fdc((head << 2) | fd->sc_drive); in fdcintr()
1099 out_fdc(fd->sc_cylin); /* track */ in fdcintr()
1109 disk_busy(&fd->sc_dk); in fdcintr()
1124 disk_unbusy(&fd->sc_dk, 0, 0); in fdcintr()
1129 cyl != bp->b_cylinder * fd->sc_type->step) { in fdcintr()
1131 fdcstatus(fd->sc_dev, 2, "seek failed"); in fdcintr()
1136 fd->sc_cylin = bp->b_cylinder; in fdcintr()
1149 disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid), in fdcintr()
1162 fdcstatus(fd->sc_dev, 7, bp->b_flags & B_READ ? in fdcintr()
1165 fd->sc_blkno, fd->sc_nblks); in fdcintr()
1172 fd->sc_skip / FDC_BSIZE, (struct disklabel *)NULL); in fdcintr()
1177 fd->sc_blkno += fd->sc_nblks; in fdcintr()
1178 fd->sc_skip += fd->sc_nbytes; in fdcintr()
1179 fd->sc_bcount -= fd->sc_nbytes; in fdcintr()
1180 if (!finfo && fd->sc_bcount > 0) { in fdcintr()
1181 bp->b_cylinder = fd->sc_blkno / fd->sc_type->seccyl; in fdcintr()
1184 fdfinish(fd, bp); in fdcintr()
1209 out_fdc(fd->sc_drive); in fdcintr()
1225 fdcstatus(fd->sc_dev, 2, "recalibrate failed"); in fdcintr()
1230 fd->sc_cylin = 0; in fdcintr()
1234 if (fd->sc_flags & FD_MOTOR_WAIT) in fdcintr()
1239 fdcstatus(fd->sc_dev, 0, "stray interrupt"); in fdcintr()
1253 struct fd_softc *fd; in fdcretry() local
1256 fd = fdc->sc_drives.tqh_first; in fdcretry()
1257 bp = bufq_peek(fd->sc_q); in fdcretry()
1259 if (fd->sc_opts & FDOPT_NORETRY) in fdcretry()
1280 if ((fd->sc_opts & FDOPT_SILENT) == 0) { in fdcretry()
1282 fd->sc_skip / FDC_BSIZE, in fdcretry()
1287 fdfinish(fd, bp); in fdcretry()
1295 struct fd_softc *fd; in fdioctl() local
1305 fd = device_lookup_private(&hdfd_cd, FDUNIT(dev)); in fdioctl()
1310 fdgetdisklabel(fd, dev); in fdioctl()
1314 error = disk_ioctl(&fd->sc_dk, RAW_PART, cmd, addr, flag, l); in fdioctl()
1330 fd->sc_flags &= ~FD_HAVELAB; /* Invalid */ in fdioctl()
1342 form_parms->nbps = 128 * (1 << fd->sc_type->secsize); in fdioctl()
1343 form_parms->ncyl = fd->sc_type->tracks; in fdioctl()
1344 form_parms->nspt = fd->sc_type->sectrac; in fdioctl()
1345 form_parms->ntrk = fd->sc_type->heads; in fdioctl()
1346 form_parms->stepspercyl = fd->sc_type->step; in fdioctl()
1347 form_parms->gaplen = fd->sc_type->gap2; in fdioctl()
1348 form_parms->fillbyte = fd->sc_type->fillbyte; in fdioctl()
1349 form_parms->interleave = fd->sc_type->interleave; in fdioctl()
1350 switch (fd->sc_type->rate) { in fdioctl()
1383 fd->sc_type->rate = FDC_500KBPS; in fdioctl()
1386 fd->sc_type->rate = FDC_300KBPS; in fdioctl()
1389 fd->sc_type->rate = FDC_250KBPS; in fdioctl()
1392 fd->sc_type->rate = FDC_125KBPS; in fdioctl()
1402 fd->sc_type->sectrac = form_parms->nspt; in fdioctl()
1405 fd->sc_type->heads = form_parms->ntrk; in fdioctl()
1406 fd->sc_type->seccyl = form_parms->nspt * form_parms->ntrk; in fdioctl()
1407 fd->sc_type->secsize = ffs(scratch)-1; in fdioctl()
1408 fd->sc_type->gap2 = form_parms->gaplen; in fdioctl()
1409 fd->sc_type->tracks = form_parms->ncyl; in fdioctl()
1410 fd->sc_type->size = fd->sc_type->seccyl * form_parms->ncyl * in fdioctl()
1412 fd->sc_type->step = form_parms->stepspercyl; in fdioctl()
1413 fd->sc_type->fillbyte = form_parms->fillbyte; in fdioctl()
1414 fd->sc_type->interleave = form_parms->interleave; in fdioctl()
1424 if (form_cmd->head >= fd->sc_type->heads || in fdioctl()
1425 form_cmd->cylinder >= fd->sc_type->tracks) { in fdioctl()
1432 fd_formb->transfer_rate = fd->sc_type->rate; in fdioctl()
1433 fd_formb->fd_formb_secshift = fd->sc_type->secsize; in fdioctl()
1434 fd_formb->fd_formb_nsecs = fd->sc_type->sectrac; in fdioctl()
1435 fd_formb->fd_formb_gaplen = fd->sc_type->gap2; in fdioctl()
1436 fd_formb->fd_formb_fillbyte = fd->sc_type->fillbyte; in fdioctl()
1443 j += fd->sc_type->interleave; in fdioctl()
1449 fd_formb->fd_formb_secsize(i) = fd->sc_type->secsize; in fdioctl()
1457 *(int *)addr = fd->sc_opts; in fdioctl()
1461 fd->sc_opts = *(int *)addr; in fdioctl()
1478 struct fd_softc *fd = device_lookup_private(&hdfd_cd, FDUNIT(dev)); in fdformat() local
1479 struct fd_type *type = fd->sc_type; in fdformat()
1535 fdgetdisklabel(struct fd_softc *fd, dev_t dev) in fdgetdisklabel() argument
1540 if (fd->sc_flags & FD_HAVELAB) in fdgetdisklabel()
1543 lp = fd->sc_dk.dk_label; in fdgetdisklabel()
1548 lp->d_secpercyl = fd->sc_type->seccyl; in fdgetdisklabel()
1551 lp->d_secperunit = fd->sc_type->size; in fdgetdisklabel()
1557 fdgetdefaultlabel(fd, lp, RAW_PART); in fdgetdisklabel()
1558 fd->sc_flags |= FD_HAVELAB; in fdgetdisklabel()
1560 if ((FDC_BSIZE * fd->sc_type->size) in fdgetdisklabel()
1567 lp->d_secpercyl = fd->sc_type->seccyl; in fdgetdisklabel()
1570 lp->d_secperunit = fd->sc_type->size; in fdgetdisklabel()
1579 fdgetdefaultlabel(struct fd_softc *fd, struct disklabel *lp, int part) in fdgetdefaultlabel() argument
1583 lp->d_secsize = 128 * (1 << fd->sc_type->secsize); in fdgetdefaultlabel()
1584 lp->d_ntracks = fd->sc_type->heads; in fdgetdefaultlabel()
1585 lp->d_nsectors = fd->sc_type->sectrac; in fdgetdefaultlabel()
1587 lp->d_ncylinders = fd->sc_type->size / lp->d_secpercyl; in fdgetdefaultlabel()
1588 lp->d_secperunit = fd->sc_type->size; in fdgetdefaultlabel()