Lines Matching refs:fd
148 void fdfinish(struct fd_softc *fd, struct buf *bp);
155 fdgetdisklabel(dev_t dev, struct fd_softc *fd, struct disklabel *lp, in fdgetdisklabel() argument
161 lp->d_secsize = FD_BSIZE(fd); in fdgetdisklabel()
162 lp->d_secpercyl = fd->sc_type->seccyl; in fdgetdisklabel()
163 lp->d_nsectors = fd->sc_type->sectrac; in fdgetdisklabel()
164 lp->d_ncylinders = fd->sc_type->tracks; in fdgetdisklabel()
165 lp->d_ntracks = fd->sc_type->heads; /* Go figure... */ in fdgetdisklabel()
166 DL_SETDSIZE(lp, fd->sc_type->size); in fdgetdisklabel()
247 struct fd_softc *fd = (void *)self; in fdattach() local
289 fd->sc_cylin = -1; in fdattach()
290 fd->sc_drive = drive; in fdattach()
291 fd->sc_deftype = type; in fdattach()
293 fdc->sc_link.fdlink.sc_fd[drive] = fd; in fdattach()
298 fd->sc_dk.dk_flags = DKF_NOLABELREAD; in fdattach()
299 fd->sc_dk.dk_name = fd->sc_dev.dv_xname; in fdattach()
300 bufq_init(&fd->sc_bufq, BUFQ_DEFAULT); in fdattach()
301 disk_attach(&fd->sc_dev, &fd->sc_dk); in fdattach()
304 timeout_set(&fd->fd_motor_on_to, fd_motor_on, fd); in fdattach()
305 timeout_set(&fd->fd_motor_off_to, fd_motor_off, fd); in fdattach()
306 timeout_set(&fd->fdtimeout_to, fdtimeout, fd); in fdattach()
312 struct fd_softc *fd = (void *)self; in fdactivate() local
313 struct fdc_softc *fdc = (void *)fd->sc_dev.dv_parent; in fdactivate()
319 timeout_del(&fd->fd_motor_on_to); in fdactivate()
320 timeout_del(&fd->fd_motor_off_to); in fdactivate()
321 timeout_del(&fd->fdtimeout_to); in fdactivate()
373 fd_dev_to_type(struct fd_softc *fd, dev_t dev) in fd_dev_to_type() argument
379 return type ? &fd_types[type - 1] : fd->sc_deftype; in fd_dev_to_type()
385 struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(bp->b_dev)]; in fdstrategy() local
388 int fd_bsize = FD_BSIZE(fd); in fdstrategy()
406 if (bp->b_blkno + sz > fd->sc_type->size * bf) { in fdstrategy()
407 sz = fd->sc_type->size * bf - bp->b_blkno; in fdstrategy()
425 (long long)fd->sc_blkno, sz); in fdstrategy()
429 bufq_queue(&fd->sc_bufq, bp); in fdstrategy()
433 timeout_del(&fd->fd_motor_off_to); /* a good idea */ in fdstrategy()
434 if (fd->sc_bp == NULL) in fdstrategy()
435 fdstart(fd); in fdstrategy()
438 struct fdc_softc *fdc = (void *)fd->sc_dev.dv_parent; in fdstrategy()
459 fdstart(struct fd_softc *fd) in fdstart() argument
461 struct fdc_softc *fdc = (void *)fd->sc_dev.dv_parent; in fdstart()
465 fd->sc_bp = bufq_dequeue(&fd->sc_bufq); in fdstart()
466 TAILQ_INSERT_TAIL(&fdc->sc_link.fdlink.sc_drives, fd, sc_drivechain); in fdstart()
474 fdfinish(struct fd_softc *fd, struct buf *bp) in fdfinish() argument
476 struct fdc_softc *fdc = (void *)fd->sc_dev.dv_parent; in fdfinish()
480 fd->sc_skip = 0; in fdfinish()
481 fd->sc_bp = bufq_dequeue(&fd->sc_bufq); in fdfinish()
489 if (TAILQ_NEXT(fd, sc_drivechain) != NULL && ++fd->sc_ops >= 8) { in fdfinish()
490 fd->sc_ops = 0; in fdfinish()
491 TAILQ_REMOVE(&fdc->sc_link.fdlink.sc_drives, fd, sc_drivechain); in fdfinish()
492 if (fd->sc_bp != NULL) { in fdfinish()
493 TAILQ_INSERT_TAIL(&fdc->sc_link.fdlink.sc_drives, fd, in fdfinish()
500 timeout_add_sec(&fd->fd_motor_off_to, 5); in fdfinish()
519 struct fd_softc *fd; in fd_set_motor() local
523 if ((fd = TAILQ_FIRST(&fdc->sc_link.fdlink.sc_drives)) != NULL) in fd_set_motor()
524 status = fd->sc_drive; in fd_set_motor()
530 if ((fd = fdc->sc_link.fdlink.sc_fd[n]) in fd_set_motor()
531 && (fd->sc_flags & FD_MOTOR)) in fd_set_motor()
539 struct fd_softc *fd = arg; in fd_motor_off() local
543 fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); in fd_motor_off()
544 fd_set_motor((struct fdc_softc *)fd->sc_dev.dv_parent, 0); in fd_motor_off()
551 struct fd_softc *fd = arg; in fd_motor_on() local
552 struct fdc_softc *fdc = (void *)fd->sc_dev.dv_parent; in fd_motor_on()
556 fd->sc_flags &= ~FD_MOTOR_WAIT; in fd_motor_on()
557 if ((TAILQ_FIRST(&fdc->sc_link.fdlink.sc_drives) == fd) in fd_motor_on()
567 struct fd_softc *fd; in fdopen() local
573 fd = fd_cd.cd_devs[unit]; in fdopen()
574 if (fd == 0) in fdopen()
576 type = fd_dev_to_type(fd, dev); in fdopen()
580 if ((fd->sc_flags & FD_OPEN) != 0 && in fdopen()
581 fd->sc_type != type) in fdopen()
584 fd->sc_type = type; in fdopen()
585 fd->sc_cylin = -1; in fdopen()
586 fd->sc_flags |= FD_OPEN; in fdopen()
591 if (fd->sc_dk.dk_openmask == 0) in fdopen()
592 fdgetdisklabel(dev, fd, fd->sc_dk.dk_label, 0); in fdopen()
598 fd->sc_dk.dk_copenmask |= pmask; in fdopen()
602 fd->sc_dk.dk_bopenmask |= pmask; in fdopen()
605 fd->sc_dk.dk_openmask = in fdopen()
606 fd->sc_dk.dk_copenmask | fd->sc_dk.dk_bopenmask; in fdopen()
614 struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)]; in fdclose() local
617 fd->sc_flags &= ~FD_OPEN; in fdclose()
618 fd->sc_opts &= ~FDOPT_NORETRY; in fdclose()
622 fd->sc_dk.dk_copenmask &= ~pmask; in fdclose()
626 fd->sc_dk.dk_bopenmask &= ~pmask; in fdclose()
629 fd->sc_dk.dk_openmask = in fdclose()
630 fd->sc_dk.dk_copenmask | fd->sc_dk.dk_bopenmask; in fdclose()
657 struct fd_softc *fd; in fdintr() local
669 fd = TAILQ_FIRST(&fdc->sc_link.fdlink.sc_drives); in fdintr()
670 if (fd == NULL) { in fdintr()
674 fd_bsize = FD_BSIZE(fd); in fdintr()
676 bp = fd->sc_bp; in fdintr()
678 fd->sc_ops = 0; in fdintr()
679 TAILQ_REMOVE(&fdc->sc_link.fdlink.sc_drives, fd, sc_drivechain); in fdintr()
687 (fd_bsize * fd->sc_type->seccyl); in fdintr()
692 fd->sc_skip = 0; in fdintr()
693 fd->sc_bcount = bp->b_bcount; in fdintr()
694 fd->sc_blkno = bp->b_blkno / (fd_bsize / DEV_BSIZE); in fdintr()
695 timeout_del(&fd->fd_motor_off_to); in fdintr()
696 if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) { in fdintr()
700 if ((fd->sc_flags & FD_MOTOR) == 0) { in fdintr()
703 fdc->sc_link.fdlink.sc_fd[fd->sc_drive ^ 1]; in fdintr()
708 fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT; in fdintr()
712 timeout_add_msec(&fd->fd_motor_on_to, 250); in fdintr()
721 if (fd->sc_cylin == cylin) in fdintr()
725 out_fdc(iot, ioh, fd->sc_type->steprate); in fdintr()
729 out_fdc(iot, ioh, fd->sc_drive); /* drive number */ in fdintr()
730 out_fdc(iot, ioh, cylin * fd->sc_type->step); in fdintr()
732 fd->sc_cylin = -1; in fdintr()
735 fd->sc_dk.dk_seek++; in fdintr()
736 disk_busy(&fd->sc_dk); in fdintr()
738 timeout_add_sec(&fd->fdtimeout_to, 4); in fdintr()
743 type = fd->sc_type; in fdintr()
745 fd->sc_skip = (char *)&(finfo->fd_formb_cylno(0)) - in fdintr()
747 sec = fd->sc_blkno % type->seccyl; in fdintr()
749 nblks = min(nblks, fd->sc_bcount / fd_bsize); in fdintr()
751 fd->sc_nblks = nblks; in fdintr()
752 fd->sc_nbytes = finfo ? bp->b_bcount : nblks * fd_bsize; in fdintr()
757 block = (fd->sc_cylin * type->heads + head) * type->sectrac + sec; in fdintr()
758 if (block != fd->sc_blkno) { in fdintr()
759 panic("fdintr: block %d != blkno %llu", block, fd->sc_blkno); in fdintr()
763 isadma_start(bp->b_data + fd->sc_skip, fd->sc_nbytes, in fdintr()
768 read ? "read" : "write", fd->sc_drive, fd->sc_cylin, head, in fdintr()
775 fdretry(fd); in fdintr()
778 out_fdc(iot, ioh, (head << 2) | fd->sc_drive); in fdintr()
788 out_fdc(iot, ioh, (head << 2) | fd->sc_drive); in fdintr()
789 out_fdc(iot, ioh, fd->sc_cylin); /* track */ in fdintr()
799 disk_busy(&fd->sc_dk); in fdintr()
802 timeout_add_sec(&fd->fdtimeout_to, 2); in fdintr()
806 timeout_del(&fd->fdtimeout_to); in fdintr()
813 disk_unbusy(&fd->sc_dk, 0, 0, 0); /* no data on seek */ in fdintr()
818 cyl != cylin * fd->sc_type->step) { in fdintr()
820 fdcstatus(&fd->sc_dev, 2, "seek failed"); in fdintr()
822 fdretry(fd); in fdintr()
825 fd->sc_cylin = cylin; in fdintr()
833 fdretry(fd); in fdintr()
837 timeout_del(&fd->fdtimeout_to); in fdintr()
839 disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid), in fdintr()
840 fd->sc_blkno, (bp->b_flags & B_READ)); in fdintr()
845 fdcstatus(&fd->sc_dev, 7, bp->b_flags & B_READ ? in fdintr()
848 (long long)fd->sc_blkno, fd->sc_nblks); in fdintr()
850 fdretry(fd); in fdintr()
857 fd->sc_skip / fd_bsize, (struct disklabel *)NULL); in fdintr()
862 fd->sc_blkno += fd->sc_nblks; in fdintr()
863 fd->sc_skip += fd->sc_nbytes; in fdintr()
864 fd->sc_bcount -= fd->sc_nbytes; in fdintr()
865 bp->b_resid -= fd->sc_nbytes; in fdintr()
866 if (!finfo && fd->sc_bcount > 0) { in fdintr()
867 cylin = fd->sc_blkno / fd->sc_type->seccyl; in fdintr()
870 fdfinish(fd, bp); in fdintr()
879 timeout_add_msec(&fd->fdtimeout_to, 500); in fdintr()
883 timeout_del(&fd->fdtimeout_to); in fdintr()
893 out_fdc(iot, ioh, fd->sc_drive); in fdintr()
895 timeout_add_sec(&fd->fdtimeout_to, 5); in fdintr()
899 timeout_del(&fd->fdtimeout_to); in fdintr()
909 fdcstatus(&fd->sc_dev, 2, "recalibrate failed"); in fdintr()
911 fdretry(fd); in fdintr()
914 fd->sc_cylin = 0; in fdintr()
918 if (fd->sc_flags & FD_MOTOR_WAIT) in fdintr()
923 fdcstatus(&fd->sc_dev, 0, "stray interrupt"); in fdintr()
936 struct fd_softc *fd = arg; in fdtimeout() local
937 struct fdc_softc *fdc = (void *)fd->sc_dev.dv_parent; in fdtimeout()
944 fdcstatus(&fd->sc_dev, 0, "timeout"); in fdtimeout()
946 if (fd->sc_bp != NULL) in fdtimeout()
956 fdretry(struct fd_softc *fd) in fdretry() argument
958 struct fdc_softc *fdc = (void *)fd->sc_dev.dv_parent; in fdretry()
959 struct buf *bp = fd->sc_bp; in fdretry()
961 if (fd->sc_opts & FDOPT_NORETRY) in fdretry()
982 fd->sc_skip / FD_BSIZE(fd), (struct disklabel *)NULL); in fdretry()
992 fdfinish(fd, bp); in fdretry()
1000 struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)]; in fdioctl() local
1012 fdgetdisklabel(dev, fd, lp, 0); in fdioctl()
1013 bcopy(lp, fd->sc_dk.dk_label, sizeof(*lp)); in fdioctl()
1018 fdgetdisklabel(dev, fd, (struct disklabel *)addr, 1); in fdioctl()
1022 *(struct disklabel *)addr = *(fd->sc_dk.dk_label); in fdioctl()
1026 ((struct partinfo *)addr)->disklab = fd->sc_dk.dk_label; in fdioctl()
1028 &fd->sc_dk.dk_label->d_partitions[FDPART(dev)]; in fdioctl()
1036 error = setdisklabel(fd->sc_dk.dk_label, in fdioctl()
1041 fdstrategy, fd->sc_dk.dk_label); in fdioctl()
1056 *(struct fd_type *)addr = *fd->sc_type; in fdioctl()
1060 *(int *)addr = fd->sc_opts; in fdioctl()
1064 fd->sc_opts = *(int *)addr; in fdioctl()
1080 struct fd_softc *fd = fd_cd.cd_devs[FDUNIT(dev)]; in fdformat() local
1081 struct fd_type *type = fd->sc_type; in fdformat()
1083 int fd_bsize = FD_BSIZE(fd); in fdformat()