Home | History | Annotate | Download | only in mainbus

Lines Matching defs:fdc

180 CFATTACH_DECL_NEW(fdc, sizeof(struct fdc_softc),
304 void fd_set_motor(struct fdc_softc *fdc, int reset);
307 int fdcresult(struct fdc_softc *fdc);
309 void fdcstart(struct fdc_softc *fdc);
314 void fdcretry(struct fdc_softc *fdc);
327 if (pa->pa_name && strcmp(pa->pa_name, "fdc") != 0)
366 * the drive). If `fdc' is not NULL, the drive was found but was not
372 fdprint(void *aux, const char *fdc)
376 if (!fdc)
384 struct fdc_softc *fdc = device_private(self);
397 fdc->sc_dev = self;
398 fdc->sc_iot = iot;
399 fdc->sc_ioh = ioh;
401 fdc->sc_drq = pa->pa_iobase + pa->pa_offset + pa->pa_drq;
402 fdc->sc_state = DEVIDLE;
403 TAILQ_INIT(&fdc->sc_drives);
407 callout_init(&fdc->sc_timo_ch, 0);
408 callout_init(&fdc->sc_intr_ch, 0);
410 fdc->sc_ih = intr_claim(pa->pa_irq, IPL_BIO, "fdc", fdcintr, fdc);
411 if (!fdc->sc_ih)
420 if (device_unit(fdc->sc_dev) == 0)
430 fa.fa_deftype = fd_nvtotype(device_xname(fdc->sc_dev),
441 struct fdc_softc *fdc = device_private(parent);
444 bus_space_tag_t iot = fdc->sc_iot;
445 bus_space_handle_t ioh = fdc->sc_ioh;
471 n = fdcresult(fdc);
477 printf(" %x", fdc->sc_status[i]);
484 if (n != 2 || (fdc->sc_status[0] & 0xf8) != 0x20)
496 struct fdc_softc *fdc = device_private(parent);
519 fdc->sc_fd[drive] = fd;
536 fd_nvtotype(const char *fdc, int nvraminfo, int drive)
552 fdc, drive, type);
619 struct fdc_softc *fdc =
621 if (fdc->sc_state == DEVIDLE) {
623 fdcstart(fdc);
639 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
640 int active = fdc->sc_drives.tqh_first != 0;
644 TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
648 fdcstart(fdc);
654 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
665 TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
667 TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
677 fdc->sc_state = DEVIDLE;
695 fd_set_motor(struct fdc_softc *fdc, int reset)
701 if ((fd = fdc->sc_drives.tqh_first) != NULL)
708 if ((fd = fdc->sc_fd[n]) && (fd->sc_flags & FD_MOTOR))
710 bus_space_write_2(fdc->sc_iot, fdc->sc_ioh, fdout, status);
729 struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
734 if ((fdc->sc_drives.tqh_first == fd) && (fdc->sc_state == MOTORWAIT))
735 (void) fdcintr(fdc);
740 fdcresult(struct fdc_softc *fdc)
742 bus_space_tag_t iot = fdc->sc_iot;
743 bus_space_handle_t ioh = fdc->sc_ioh;
754 if (n >= sizeof(fdc->sc_status)) {
758 fdc->sc_status[n++] =
818 fdcstart(struct fdc_softc *fdc)
824 if (fdc->sc_state != DEVIDLE) {
829 (void) fdcintr(fdc);
833 fdcpstatus(int n, struct fdc_softc *fdc)
842 snprintb(bits, sizeof(bits), NE7_ST0BITS, fdc->sc_status[0]);
843 printf(" (st0 %s cyl %d)\n", bits, fdc->sc_status[1]);
846 snprintb(bits, sizeof(bits), NE7_ST0BITS, fdc->sc_status[0]);
848 snprintb(bits, sizeof(bits), NE7_ST1BITS, fdc->sc_status[1]);
850 snprintb(bits, sizeof(bits), NE7_ST2BITS, fdc->sc_status[2]);
853 fdc->sc_status[3], fdc->sc_status[4], fdc->sc_status[5]);
866 struct fdc_softc *fdc = device_private(device_parent(dv));
869 out_fdc(fdc->sc_iot, fdc->sc_ioh, NE7CMD_SENSEI);
870 (void) fdcresult(fdc);
875 fdcpstatus(n, fdc);
881 struct fdc_softc *fdc = arg;
882 struct fd_softc *fd = fdc->sc_drives.tqh_first;
887 log(LOG_ERR,"fdctimeout: state %d\n", fdc->sc_state);
892 fdc->sc_state++;
894 fdc->sc_state = DEVIDLE;
896 (void) fdcintr(fdc);
914 struct fdc_softc *fdc = arg;
915 #define st0 fdc->sc_status[0]
916 #define cyl fdc->sc_status[1]
919 bus_space_tag_t iot = fdc->sc_iot;
920 bus_space_handle_t ioh = fdc->sc_ioh;
927 fd = fdc->sc_drives.tqh_first;
929 fdc->sc_state = DEVIDLE;
937 TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
945 switch (fdc->sc_state) {
947 fdc->sc_errors = 0;
953 fdc->sc_state = MOTORWAIT;
958 struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1];
964 fd_set_motor(fdc, 0);
965 fdc->sc_state = MOTORWAIT;
972 fd_set_motor(fdc, 0);
995 fdc->sc_state = SEEKWAIT;
1000 callout_reset(&fdc->sc_timo_ch, 4 * hz, fdctimeout, fdc);
1031 fdc->sc_fh.fh_func = floppy_read_fiq;
1032 fdc->sc_fh.fh_size = floppy_read_fiq_end -
1035 fdc->sc_fh.fh_func = floppy_write_fiq;
1036 fdc->sc_fh.fh_size = floppy_read_fiq_end -
1039 fdc->sc_fh.fh_flags = 0;
1040 fdc->sc_fh.fh_regs = &fdc->sc_fr;
1041 fdc->sc_fr.fr_r9 = IOMD_BASE + (IOMD_FIQRQ << 2);
1042 fdc->sc_fr.fr_r10 = fd->sc_nbytes;
1043 fdc->sc_fr.fr_r11 =
1045 fdc->sc_fr.fr_r12 = fdc->sc_drq;
1047 printf("fdc-doio:r9=%x r10=%x r11=%x r12=%x data=%x skip=%x\n",
1048 fdc->sc_fr.fr_r9, fdc->sc_fr.fr_r10, fdc->sc_fr.fr_r11,
1049 fdc->sc_fr.fr_r12, (u_int)bp->b_data, fd->sc_skip);
1051 if (fiq_claim(&fdc->sc_fh) == -1)
1053 device_xname(fdc->sc_dev));
1064 fdc->sc_errors = 4;
1065 fdcretry(fdc);
1087 fdc->sc_state = IOCOMPLETE;
1092 callout_reset(&fdc->sc_timo_ch, 2 * hz, fdctimeout, fdc);
1096 callout_stop(&fdc->sc_timo_ch);
1097 fdc->sc_state = SEEKCOMPLETE;
1100 callout_reset(&fdc->sc_intr_ch, hz / 50, fdcpseudointr, fdc);
1110 if (fdcresult(fdc) != 2 || (st0 & 0xf8) != 0x20 ||
1115 fdcretry(fdc);
1122 fiq_release(&fdc->sc_fh);
1127 fdcretry(fdc);
1131 callout_stop(&fdc->sc_timo_ch);
1136 if (fdcresult(fdc) != 7 || (st0 & 0xf8) != 0) {
1137 fiq_release(&fdc->sc_fh);
1145 fdcretry(fdc);
1148 fiq_release(&fdc->sc_fh);
1150 if (fdc->sc_errors) {
1156 fdc->sc_errors = 0;
1170 fd_set_motor(fdc, 1);
1172 fd_set_motor(fdc, 0);
1173 fdc->sc_state = RESETCOMPLETE;
1174 callout_reset(&fdc->sc_timo_ch, hz / 2, fdctimeout, fdc);
1178 callout_stop(&fdc->sc_timo_ch);
1182 (void) fdcresult(fdc);
1189 fdc->sc_state = RECALWAIT;
1190 callout_reset(&fdc->sc_timo_ch, 5 * hz, fdctimeout, fdc);
1194 callout_stop(&fdc->sc_timo_ch);
1195 fdc->sc_state = RECALCOMPLETE;
1198 callout_reset(&fdc->sc_intr_ch, hz / 30, fdcpseudointr, fdc);
1204 if (fdcresult(fdc) != 2 || (st0 & 0xf8) != 0x20 || cyl != 0) {
1208 fdcretry(fdc);
1231 fdcretry(struct fdc_softc *fdc)
1236 fd = fdc->sc_drives.tqh_first;
1241 switch (fdc->sc_errors) {
1244 fdc->sc_state = DOSEEK;
1249 fdc->sc_state = DORECAL;
1254 fdc->sc_state = DORESET;
1263 fdcpstatus(7, fdc);
1269 fdc->sc_errors++;