Lines Matching refs:fd

215 CFATTACH_DECL_NEW(fd, sizeof(struct fd_softc),
272 void fdfinish(struct fd_softc *fd, struct buf *bp);
275 static void fd_set_geometry(struct fd_softc *fd);
320 struct fd_softc *fd; in fdcsuspend() local
326 if ((fd = fdc->sc_fd[drive]) == NULL) in fdcsuspend()
328 fd->sc_flags &= ~(FD_MOTOR|FD_MOTOR_WAIT); in fdcsuspend()
339 struct fd_softc *fd = device_private(child); in fdc_childdet() local
340 int drive = fd->sc_drive; in fdc_childdet()
342 KASSERT(fdc->sc_fd[drive] == fd); /* but the kid is not my son */ in fdc_childdet()
560 struct fd_softc *fd = device_private(self); in fdattach() local
565 fd->sc_dev = self; in fdattach()
567 callout_init(&fd->sc_motoron_ch, 0); in fdattach()
568 callout_init(&fd->sc_motoroff_ch, 0); in fdattach()
578 bufq_alloc(&fd->sc_q, "disksort", BUFQ_SORT_CYLINDER); in fdattach()
579 fd->sc_cylin = -1; in fdattach()
580 fd->sc_drive = drive; in fdattach()
581 fd->sc_deftype = type; in fdattach()
582 fdc->sc_fd[drive] = fd; in fdattach()
587 disk_init(&fd->sc_dk, device_xname(fd->sc_dev), &fddkdriver); in fdattach()
588 disk_attach(&fd->sc_dk); in fdattach()
593 fd->sc_roothook = in fdattach()
594 mountroothook_establish(fd_mountroot_hook, fd->sc_dev); in fdattach()
596 rnd_attach_source(&fd->rnd_source, device_xname(fd->sc_dev), in fdattach()
599 fd_set_geometry(fd); in fdattach()
608 struct fd_softc *fd = device_private(self); in fddetach() local
611 fd_motor_off(fd); in fddetach()
627 fd_set_geometry(fd); in fddetach()
630 rnd_detach_source(&fd->rnd_source); in fddetach()
632 disk_detach(&fd->sc_dk); in fddetach()
633 disk_destroy(&fd->sc_dk); in fddetach()
636 bufq_drain(fd->sc_q); in fddetach()
638 bufq_free(fd->sc_q); in fddetach()
640 callout_destroy(&fd->sc_motoroff_ch); in fddetach()
641 callout_destroy(&fd->sc_motoron_ch); in fddetach()
690 fd_dev_to_type(struct fd_softc *fd, dev_t dev) in fd_dev_to_type() argument
696 return type ? &fd_types[type - 1] : fd->sc_deftype; in fd_dev_to_type()
702 struct fd_softc *fd = device_lookup_private(&fd_cd, FDUNIT(bp->b_dev)); in fdstrategy() local
703 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); in fdstrategy()
720 if (bp->b_blkno + sz > fd->sc_type->size) { in fdstrategy()
721 sz = fd->sc_type->size - bp->b_blkno; in fdstrategy()
737 bp->b_blkno / (FDC_BSIZE / DEV_BSIZE) / fd->sc_type->seccyl; in fdstrategy()
742 (unsigned long long)fd->sc_blkno, bp->b_cylinder, sz); in fdstrategy()
747 bufq_put(fd->sc_q, bp); in fdstrategy()
748 callout_stop(&fd->sc_motoroff_ch); /* a good idea */ in fdstrategy()
749 if (fd->sc_active == 0) in fdstrategy()
750 fdstart(fd); in fdstrategy()
769 fdstart(struct fd_softc *fd) in fdstart() argument
771 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); in fdstart()
776 fd->sc_active = 1; in fdstart()
777 TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain); in fdstart()
785 fdfinish(struct fd_softc *fd, struct buf *bp) in fdfinish() argument
787 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); in fdfinish()
795 (void)bufq_get(fd->sc_q); in fdfinish()
796 if (TAILQ_NEXT(fd, sc_drivechain) && ++fd->sc_ops >= 8) { in fdfinish()
797 fd->sc_ops = 0; in fdfinish()
798 TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain); in fdfinish()
799 if (bufq_peek(fd->sc_q) != NULL) in fdfinish()
800 TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain); in fdfinish()
802 fd->sc_active = 0; in fdfinish()
804 bp->b_resid = fd->sc_bcount; in fdfinish()
805 fd->sc_skip = 0; in fdfinish()
807 rnd_add_uint32(&fd->rnd_source, bp->b_blkno); in fdfinish()
811 callout_reset(&fd->sc_motoroff_ch, 5 * hz, fd_motor_off, fd); in fdfinish()
832 struct fd_softc *fd; in fd_set_motor() local
836 if ((fd = TAILQ_FIRST(&fdc->sc_drives)) != NULL) in fd_set_motor()
837 status = fd->sc_drive; in fd_set_motor()
843 if ((fd = fdc->sc_fd[n]) && (fd->sc_flags & FD_MOTOR)) in fd_set_motor()
851 struct fd_softc *fd = arg; in fd_motor_off() local
854 fdc = device_private(device_parent(fd->sc_dev)); in fd_motor_off()
857 fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT); in fd_motor_off()
865 struct fd_softc *fd = arg; in fd_motor_on() local
866 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); in fd_motor_on()
869 fd->sc_flags &= ~FD_MOTOR_WAIT; in fd_motor_on()
870 if (TAILQ_FIRST(&fdc->sc_drives) == fd && fdc->sc_state == MOTORWAIT) in fd_motor_on()
924 struct fd_softc *fd; in fdopen() local
927 fd = device_lookup_private(&fd_cd, FDUNIT(dev)); in fdopen()
928 if (fd == NULL) in fdopen()
931 type = fd_dev_to_type(fd, dev); in fdopen()
935 if ((fd->sc_flags & FD_OPEN) != 0 && in fdopen()
936 memcmp(fd->sc_type, type, sizeof(*type))) in fdopen()
939 fd->sc_type_copy = *type; in fdopen()
940 fd->sc_type = &fd->sc_type_copy; in fdopen()
941 fd->sc_cylin = -1; in fdopen()
942 fd->sc_flags |= FD_OPEN; in fdopen()
944 fd_set_geometry(fd); in fdopen()
952 struct fd_softc *fd = in fdclose() local
955 fd->sc_flags &= ~FD_OPEN; in fdclose()
956 fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT); in fdclose()
1031 struct fd_softc *fd = TAILQ_FIRST(&fdc->sc_drives); in fdctimeout() local
1037 fdcstatus(fd->sc_dev, 0, "timeout"); in fdctimeout()
1039 if (bufq_peek(fd->sc_q) != NULL) in fdctimeout()
1053 struct fd_softc *fd; in fdcintr1() local
1072 fd = TAILQ_FIRST(&fdc->sc_drives); in fdcintr1()
1073 if (fd == NULL) { in fdcintr1()
1079 bp = bufq_peek(fd->sc_q); in fdcintr1()
1081 fd->sc_ops = 0; in fdcintr1()
1082 TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain); in fdcintr1()
1083 fd->sc_active = 0; in fdcintr1()
1093 fd->sc_skip = 0; in fdcintr1()
1094 fd->sc_bcount = bp->b_bcount; in fdcintr1()
1095 fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE); in fdcintr1()
1096 callout_stop(&fd->sc_motoroff_ch); in fdcintr1()
1097 if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) { in fdcintr1()
1101 if ((fd->sc_flags & FD_MOTOR) == 0) { in fdcintr1()
1103 struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1]; in fdcintr1()
1108 fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT; in fdcintr1()
1112 callout_reset(&fd->sc_motoron_ch, hz / 4, in fdcintr1()
1113 fd_motor_on, fd); in fdcintr1()
1122 if (fd->sc_cylin == bp->b_cylinder) in fdcintr1()
1126 out_fdc(iot, ioh, fd->sc_type->steprate); in fdcintr1()
1130 out_fdc(iot, ioh, fd->sc_drive); /* drive number */ in fdcintr1()
1131 out_fdc(iot, ioh, bp->b_cylinder * fd->sc_type->step); in fdcintr1()
1133 fd->sc_cylin = -1; in fdcintr1()
1136 iostat_seek(fd->sc_dk.dk_stats); in fdcintr1()
1137 disk_busy(&fd->sc_dk); in fdcintr1()
1144 type = fd->sc_type; in fdcintr1()
1146 fd->sc_skip = (char *)&(finfo->fd_formb_cylno(0)) - in fdcintr1()
1148 sec = fd->sc_blkno % type->seccyl; in fdcintr1()
1150 nblks = uimin(nblks, fd->sc_bcount / FDC_BSIZE); in fdcintr1()
1152 fd->sc_nblks = nblks; in fdcintr1()
1153 fd->sc_nbytes = finfo ? bp->b_bcount : nblks * FDC_BSIZE; in fdcintr1()
1159 block = (fd->sc_cylin * type->heads + head) in fdcintr1()
1161 if (block != fd->sc_blkno) { in fdcintr1()
1163 "%" PRId64 "\n", block, fd->sc_blkno); in fdcintr1()
1172 (char *)bp->b_data + fd->sc_skip, fd->sc_nbytes, in fdcintr1()
1177 read ? "read" : "write", fd->sc_drive, fd->sc_cylin, in fdcintr1()
1187 out_fdc(iot, ioh, (head << 2) | fd->sc_drive); in fdcintr1()
1197 out_fdc(iot, ioh, (head << 2) | fd->sc_drive); in fdcintr1()
1198 out_fdc(iot, ioh, fd->sc_cylin); /* track */ in fdcintr1()
1208 disk_busy(&fd->sc_dk); in fdcintr1()
1223 disk_unbusy(&fd->sc_dk, 0, 0); in fdcintr1()
1228 cyl != bp->b_cylinder * fd->sc_type->step) { in fdcintr1()
1230 fdcstatus(fd->sc_dev, 2, "seek failed"); in fdcintr1()
1235 fd->sc_cylin = bp->b_cylinder; in fdcintr1()
1250 disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid), in fdcintr1()
1256 fdcstatus(fd->sc_dev, 7, bp->b_flags & B_READ ? in fdcintr1()
1259 (unsigned long long)fd->sc_blkno, fd->sc_nblks); in fdcintr1()
1267 fd->sc_skip / FDC_BSIZE, NULL); in fdcintr1()
1271 fd->sc_blkno += fd->sc_nblks; in fdcintr1()
1272 fd->sc_skip += fd->sc_nbytes; in fdcintr1()
1273 fd->sc_bcount -= fd->sc_nbytes; in fdcintr1()
1274 if (!finfo && fd->sc_bcount > 0) { in fdcintr1()
1275 bp->b_cylinder = fd->sc_blkno / fd->sc_type->seccyl; in fdcintr1()
1278 fdfinish(fd, bp); in fdcintr1()
1301 out_fdc(iot, ioh, fd->sc_drive); in fdcintr1()
1317 fdcstatus(fd->sc_dev, 2, "recalibrate failed"); in fdcintr1()
1322 fd->sc_cylin = 0; in fdcintr1()
1326 if (fd->sc_flags & FD_MOTOR_WAIT) in fdcintr1()
1331 fdcstatus(fd->sc_dev, 0, "stray interrupt"); in fdcintr1()
1363 struct fd_softc *fd; in fdcretry() local
1366 fd = TAILQ_FIRST(&fdc->sc_drives); in fdcretry()
1367 bp = bufq_peek(fd->sc_q); in fdcretry()
1369 if (fd->sc_opts & FDOPT_NORETRY) in fdcretry()
1389 if ((fd->sc_opts & FDOPT_SILENT) == 0) { in fdcretry()
1391 fd->sc_skip / FDC_BSIZE, NULL); in fdcretry()
1396 fdfinish(fd, bp); in fdcretry()
1404 struct fd_softc *fd = in fdioctl() local
1409 struct disklabel *lp = fd->sc_dk.dk_label; in fdioctl()
1428 lp->d_nsectors = fd->sc_type->sectrac; in fdioctl()
1429 lp->d_ntracks = fd->sc_type->heads; in fdioctl()
1430 lp->d_ncylinders = fd->sc_type->cyls; in fdioctl()
1431 lp->d_secpercyl = fd->sc_type->seccyl; in fdioctl()
1432 lp->d_secperunit = fd->sc_type->size; in fdioctl()
1439 error = disk_ioctl(&fd->sc_dk, dev, cmd, addr, flag, l); in fdioctl()
1475 form_parms->nbps = 128 * (1 << fd->sc_type->secsize); in fdioctl()
1476 form_parms->ncyl = fd->sc_type->cyls; in fdioctl()
1477 form_parms->nspt = fd->sc_type->sectrac; in fdioctl()
1478 form_parms->ntrk = fd->sc_type->heads; in fdioctl()
1479 form_parms->stepspercyl = fd->sc_type->step; in fdioctl()
1480 form_parms->gaplen = fd->sc_type->gap2; in fdioctl()
1481 form_parms->fillbyte = fd->sc_type->fillbyte; in fdioctl()
1482 form_parms->interleave = fd->sc_type->interleave; in fdioctl()
1483 switch (fd->sc_type->rate) { in fdioctl()
1513 fd->sc_type->rate = FDC_500KBPS; in fdioctl()
1516 fd->sc_type->rate = FDC_300KBPS; in fdioctl()
1519 fd->sc_type->rate = FDC_250KBPS; in fdioctl()
1529 fd->sc_type->sectrac = form_parms->nspt; in fdioctl()
1532 fd->sc_type->heads = form_parms->ntrk; in fdioctl()
1533 fd->sc_type->seccyl = form_parms->nspt * form_parms->ntrk; in fdioctl()
1534 fd->sc_type->secsize = ffs(scratch)-1; in fdioctl()
1535 fd->sc_type->gap2 = form_parms->gaplen; in fdioctl()
1536 fd->sc_type->cyls = form_parms->ncyl; in fdioctl()
1537 fd->sc_type->size = fd->sc_type->seccyl * form_parms->ncyl * in fdioctl()
1539 fd->sc_type->step = form_parms->stepspercyl; in fdioctl()
1540 fd->sc_type->fillbyte = form_parms->fillbyte; in fdioctl()
1541 fd->sc_type->interleave = form_parms->interleave; in fdioctl()
1551 if (form_cmd->head >= fd->sc_type->heads || in fdioctl()
1552 form_cmd->cylinder >= fd->sc_type->cyls) { in fdioctl()
1559 fd_formb->transfer_rate = fd->sc_type->rate; in fdioctl()
1560 fd_formb->fd_formb_secshift = fd->sc_type->secsize; in fdioctl()
1561 fd_formb->fd_formb_nsecs = fd->sc_type->sectrac; in fdioctl()
1562 fd_formb->fd_formb_gaplen = fd->sc_type->gap2; in fdioctl()
1563 fd_formb->fd_formb_fillbyte = fd->sc_type->fillbyte; in fdioctl()
1570 j += fd->sc_type->interleave; in fdioctl()
1576 fd_formb->fd_formb_secsize(i) = fd->sc_type->secsize; in fdioctl()
1584 *(int *)addr = fd->sc_opts; in fdioctl()
1588 fd->sc_opts = *(int *)addr; in fdioctl()
1604 struct fd_softc *fd = in fdformat() local
1606 struct fd_type *type = fd->sc_type; in fdformat()
1665 fd_set_geometry(struct fd_softc *fd) in fd_set_geometry() argument
1669 fdt = fd->sc_type; in fd_set_geometry()
1671 fdt = fd->sc_deftype; in fd_set_geometry()
1676 struct disk_geom *dg = &fd->sc_dk.dk_geom; in fd_set_geometry()
1693 disk_set_info(fd->sc_dev, &fd->sc_dk, NULL); in fd_set_geometry()