Lines Matching defs:fcp
109 #define KIOIP KSTAT_INTR_PTR(fcp->c_intrstat)
237 static int fdc_enhance_probe(struct fdcntlr *fcp);
357 struct fdcntlr *fcp;
365 if ((fcp = ddi_get_driver_private(dip)) == NULL)
390 cntlr = fcp->c_number;
397 (fcp->c_unit[FDUNIT(unit)])->fj_dip)
403 fjp = fcp->c_unit[FDUNIT(unit)];
407 fjp->fj_fdc = fcp;
408 fjp->fj_iblock = &fcp->c_iblock;
434 struct fdcntlr *fcp;
441 if (fcp = ddi_get_soft_state(fdc_state_head, (dev_t)arg)) {
442 *result = fcp->c_dip;
492 struct fdcntlr *fcp;
522 fcp = ddi_get_soft_state(fdc_state_head, ctlr);
524 for (unit = 0, fjp = (struct fcu_obj *)(fcp+1);
526 fcp->c_unit[unit] = fjp++;
528 fcp->c_dip = dip;
530 if (fdc_propinit1(fcp, cntlr_num) != DDI_SUCCESS)
534 if (ddi_get_iblock_cookie(dip, (uint_t)0, &fcp->c_iblock) !=
540 mutex_init(&fcp->c_lock, NULL, MUTEX_DRIVER, fcp->c_iblock);
545 (ddi_idevice_cookie_t *)0, fdc_intr, (caddr_t)fcp) !=
557 if (ddi_dmae_alloc(dip, fcp->c_dmachan, DDI_DMA_DONTWAIT, NULL)
560 fcp->c_dmachan);
566 mutex_init(&fcp->c_dorlock, NULL, MUTEX_DRIVER, fcp->c_iblock);
567 cv_init(&fcp->c_iocv, NULL, CV_DRIVER, fcp->c_iblock);
568 sema_init(&fcp->c_selsem, 1, NULL, SEMA_DRIVER, NULL);
571 fcp->c_intrstat = kstat_create("fdc", ctlr, name,
573 if (fcp->c_intrstat) {
574 kstat_install(fcp->c_intrstat);
577 ddi_set_driver_private(dip, fcp);
582 sema_p(&fcp->c_selsem);
583 mutex_enter(&fcp->c_lock);
584 fcp->c_csb.csb_xstate = FXS_RESET;
585 fcp->c_flags |= FCFLG_WAITING;
586 fdcquiesce(fcp);
589 fcp->c_mode = (inb(fcp->c_regbase + FCR_SRB) & 0x1c) ?
592 while (fcp->c_flags & FCFLG_WAITING) {
593 cv_wait(&fcp->c_iocv, &fcp->c_lock);
595 mutex_exit(&fcp->c_lock);
596 sema_v(&fcp->c_selsem);
598 fdc_propinit2(fcp);
605 fcp = ddi_get_driver_private(dip);
607 mutex_enter(&fcp->c_lock);
608 fcp->c_suspended = B_FALSE;
609 fcp->c_csb.csb_xstate = FXS_RESET;
610 fcp->c_flags |= FCFLG_WAITING;
611 fdcquiesce(fcp);
613 while (fcp->c_flags & FCFLG_WAITING) {
614 cv_wait(&fcp->c_iocv, &fcp->c_lock);
616 mutex_exit(&fcp->c_lock);
619 sema_v(&fcp->c_selsem);
631 ddi_remove_intr(dip, 0, fcp->c_iblock);
632 mutex_destroy(&fcp->c_lock);
639 fdc_propinit1(struct fdcntlr *fcp, int cntlr)
645 dip = fcp->c_dip;
651 fcp->c_regbase = (ushort_t)value;
660 fcp->c_dmachan = (ushort_t)value;
661 fcp->c_number = cntlr;
666 fdc_propinit2(struct fdcntlr *fcp)
673 dip = fcp->c_dip;
679 fcp->c_chip = value;
685 fcp->c_chip = i8272A;
686 (void) fdc_docmd(fcp, &versioncmd, 1);
691 if (!fdc_result(fcp, &result, 1) && result == 0x90) {
696 if (fdc_docmd(fcp, perpindcmd, 2) ||
697 fdc_docmd(fcp, configurecmd, 4))
702 (void) fdc_result(fcp, &result, 1);
710 if ((fcp->c_chip = fdc_enhance_probe(fcp)) == 0)
712 fcp->c_chip = i82077;
715 "chip", fcp->c_chip);
721 if (fcp->c_chip >= i82077 && fcp->c_mode == FDCMODE_30 &&
722 (inb(fcp->c_regbase + FCR_DIR) & 0x70) == 0)
729 outb(fcp->c_regbase + FCR_CCR, ccr);
731 if ((inb(fcp->c_regbase + FCR_DIR) &
733 fcp->c_mode = FDCMODE_AT;
738 fcp->c_mode = FDCMODE_AT;
739 outb(fcp->c_regbase + FCR_CCR, 0);
743 fdc_enhance_probe(struct fdcntlr *fcp)
759 (void) fdc_docmd(fcp, &nsccmd, 1);
764 if (!fdc_result(fcp, &result, 1) && result != S0_IVCMD) {
771 fcp->c_flags |= FCFLG_3DMODE;
777 save = inb(fcp->c_regbase + FCR_SRA);
784 outb(fcp->c_regbase + FCR_SRA, FSA_ENA5);
785 outb(fcp->c_regbase + FCR_SRA, FSA_ENA5);
788 outb(fcp->c_regbase + FCR_SRA, 0x0F);
789 if (inb(fcp->c_regbase + FCR_SRB) != 0x00)
792 outb(fcp->c_regbase + FCR_SRA, 0x0D);
793 if (inb(fcp->c_regbase + FCR_SRB) != 0x65)
796 outb(fcp->c_regbase + FCR_SRA, 0x0E);
797 result = inb(fcp->c_regbase + FCR_SRB);
804 fcp->c_flags |= FCFLG_3DMODE;
807 outb(fcp->c_regbase + FCR_SRA, FSA_DISB);
812 outb(fcp->c_regbase + FCR_SRA, FSA_ENA6);
813 outb(fcp->c_regbase + FCR_SRA, FSA_ENA6);
816 outb(fcp->c_regbase + FCR_SRA, 0x0F);
817 if (inb(fcp->c_regbase + FCR_SRB) != 0x00)
820 outb(fcp->c_regbase + FCR_SRA, 0x0D);
821 if (inb(fcp->c_regbase + FCR_SRB) != 0x66)
824 outb(fcp->c_regbase + FCR_SRA, 0x0E);
825 result = inb(fcp->c_regbase + FCR_SRB);
832 fcp->c_flags |= FCFLG_3DMODE;
835 outb(fcp->c_regbase + FCR_SRA, FSA_DISB);
838 outb(fcp->c_regbase + FCR_SRA, save);
846 struct fdcntlr *fcp;
853 fcp = ddi_get_driver_private(dip);
858 if ((fcp->c_unit[unit])->fj_dip) {
862 kstat_delete(fcp->c_intrstat);
863 fcp->c_intrstat = NULL;
864 ddi_remove_intr(fcp->c_dip, 0, fcp->c_iblock);
865 if (ddi_dmae_release(fcp->c_dip, fcp->c_dmachan) !=
869 (void*)fcp->c_dip, fcp->c_dmachan);
870 ddi_prop_remove_all(fcp->c_dip);
871 ddi_set_driver_private(fcp->c_dip, NULL);
873 mutex_destroy(&fcp->c_lock);
874 mutex_destroy(&fcp->c_dorlock);
875 cv_destroy(&fcp->c_iocv);
876 sema_destroy(&fcp->c_selsem);
889 sema_p(&fcp->c_selsem);
891 if (ddi_dmae_disable(fcp->c_dip, fcp->c_dmachan) !=
894 "dip %p, dmachan %x", (void *)fcp->c_dip,
895 fcp->c_dmachan);
897 sema_v(&fcp->c_selsem);
901 mutex_enter(&fcp->c_lock);
902 fcp->c_suspended = B_TRUE;
903 mutex_exit(&fcp->c_lock);
919 struct fdcntlr *fcp = fjp->fj_fdc;
923 if (fcp->c_curunit == unit) {
924 mutex_enter(&fcp->c_lock);
925 if (fcp->c_flags & FCFLG_WAITING) {
929 fdcquiesce(fcp);
930 fcp->c_csb.csb_xstate = FXS_RESET;
931 fcp->c_flags |= FCFLG_TIMEOUT;
932 if (ddi_dmae_stop(fcp->c_dip, fcp->c_dmachan) !=
937 (void*)fcp->c_dip, fcp->c_dmachan);
939 mutex_exit(&fcp->c_lock);
949 struct fdcntlr *fcp = fjp->fj_fdc;
951 (void) strncpy((char *)&dcp->dki_cname, ddi_get_name(fcp->c_dip),
955 dcp->dki_addr = fcp->c_regbase;
957 dcp->dki_prio = fcp->c_intprio;
958 dcp->dki_vec = fcp->c_intvec;
972 struct fdcntlr *fcp = fjp->fj_fdc;
977 sema_p(&fcp->c_selsem);
981 if (fcp->c_curunit != unit || !(fjp->fj_flags & FUNIT_CHAROK)) {
982 fcp->c_curunit = unit;
984 if (fdcspecify(fcp,
990 " head load time 40", (void*)fcp,
995 mutex_enter(&fcp->c_dorlock);
998 fcp->c_digout = (fcp->c_digout & ~FD_DRSEL) |
1000 outb(fcp->c_regbase + FCR_DOR, fcp->c_digout);
1007 if (fdcspdchange(fcp, fjp, fjp->fj_attr->fda_rotatespd)) {
1015 fcp->c_digout = (fcp->c_digout & ~FD_DRSEL) | (unit & FD_DRSEL);
1016 outb(fcp->c_regbase + FCR_DOR, fcp->c_digout);
1018 mutex_exit(&fcp->c_dorlock);
1019 fcp->c_csb.csb_drive = (uchar_t)unit;
1024 mutex_enter(&fcp->c_dorlock);
1026 fcp->c_digout |= FD_DRSEL;
1027 outb(fcp->c_regbase + FCR_DOR, fcp->c_digout);
1034 mutex_exit(&fcp->c_dorlock);
1037 sema_v(&fcp->c_selsem);
1055 struct fdcntlr *fcp = fjp->fj_fdc;
1061 if (fcp->c_curpcyl[unit])
1062 newcyl = fcp->c_curpcyl[unit] - 1;
1075 struct fdcntlr *fcp = fjp->fj_fdc;
1083 csb = &fcp->c_csb;
1106 if (rval = fdc_exec(fcp, 1, execflg))
1115 if (fdcsense_drv(fcp, unit))
1129 struct fdcntlr *fcp = fjp->fj_fdc;
1140 csb = &fcp->c_csb;
1176 if (ddi_dma_alloc_handle(fcp->c_dip, &fdc_dma_attr, DDI_DMA_SLEEP,
1220 rval = fdc_exec(fcp, 1, 1);
1248 struct fdcntlr *fcp = fjp->fj_fdc;
1262 csb = &fcp->c_csb;
1295 if (ddi_dma_alloc_handle(fcp->c_dip, &fdc_dma_attr, DDI_DMA_SLEEP,
1350 rval = fdc_exec(fcp, 1, 1);
1372 struct fdcntlr *fcp = fjp->fj_fdc;
1390 csb = &fcp->c_csb;
1465 if (ddi_dma_alloc_handle(fcp->c_dip, &fdc_dma_attr,
1536 rval_exec = fdc_exec(fcp, sleep, change);
1613 struct fdcntlr *fcp;
1617 fcp = ddi_get_soft_state(fdc_state_head, ctlr);
1619 if (fcp == NULL)
1626 struct fcu_obj *fjp = fcp->c_unit[unit];
1635 (void) ddi_dmae_disable(fcp->c_dip, fcp->c_dmachan);
1637 fcp->c_digout = (fcp->c_digout & (FD_DMTREN | FD_DRSEL)) | FD_ENABLE;
1638 outb(fcp->c_regbase + FCR_DOR, fcp->c_digout);
1640 fcp->c_digout |= FD_RSETZ;
1641 outb(fcp->c_regbase + FCR_DOR, fcp->c_digout);
1643 if (fcp->c_chip >= i82077) {
1649 if ((inb(fcp->c_regbase + FCR_MSR) &
1658 outb(fcp->c_regbase + FCR_DATA, *oplistp++);
1667 fdcquiesce(struct fdcntlr *fcp)
1671 FCERRPRINT(FDEP_L2, FDEM_RESE, (CE_NOTE, "fdcquiesce fcp %p",
1672 (void*)fcp));
1674 ASSERT(MUTEX_HELD(&fcp->c_lock));
1675 mutex_enter(&fcp->c_dorlock);
1677 if (ddi_dmae_stop(fcp->c_dip, fcp->c_dmachan) != DDI_SUCCESS)
1680 (void*)fcp->c_dip, fcp->c_dmachan);
1682 fcp->c_digout = (fcp->c_digout & (FD_DMTREN | FD_DRSEL)) | FD_ENABLE;
1683 outb(fcp->c_regbase + FCR_DOR, fcp->c_digout);
1685 fcp->c_digout |= FD_RSETZ;
1686 outb(fcp->c_regbase + FCR_DOR, fcp->c_digout);
1688 mutex_exit(&fcp->c_dorlock);
1691 fcp->fdstats.reset++;
1692 fcp->c_curunit = -1;
1694 fcp->c_curpcyl[unit] = -1;
1696 if (fcp->c_chip >= i82077) {
1697 (void) fdc_docmd(fcp, configurecmd, 4);
1705 fdcreadid(struct fdcntlr *fcp, struct fdcsb *csb)
1710 (void) fdc_docmd(fcp, readidcmd, 2);
1714 fdcseek(struct fdcntlr *fcp, int unit, int cyl)
1722 return (fdc_docmd(fcp, seekabscmd, 3));
1731 fdcsense_chng(struct fdcntlr *fcp, int unit)
1737 digital_input = inb(fcp->c_regbase + FCR_DIR);
1738 if (fcp->c_mode == FDCMODE_30)
1744 fdcsense_drv(struct fdcntlr *fcp, int unit)
1751 (void) fdc_docmd(fcp, sensedrvcmd, 2);
1756 if (rval = fdc_result(fcp, &senser, 1))
1759 fcp->c_unit[unit]->fj_flags |= FUNIT_WPROT;
1761 fcp->c_unit[unit]->fj_flags &= ~FUNIT_WPROT;
1767 fdcsense_int(struct fdcntlr *fcp, int *unitp, int *cylp)
1772 (void) fdc_docmd(fcp, &senseintcmd, 1);
1778 if (!(rval = fdc_result(fcp, senser, 2))) {
1790 fdcspecify(struct fdcntlr *fcp, int xferrate, int steprate, int hlt)
1795 encode(drate_mfm, xferrate, &fcp->c_config);
1796 outb(fcp->c_regbase + FCR_CCR, fcp->c_config);
1798 if (fcp->c_chip >= i82077) {
1810 (void) fdc_docmd(fcp, perpindcmd, 2);
1815 encode(step_rate, steprate, &fcp->c_hutsrt);
1816 specifycmd[1] = fcp->c_hutsrt |= 0x0F; /* use max head unload time */
1818 specifycmd[2] = fcp->c_hlt = hlt << 1; /* make room for DMA bit */
1819 return (fdc_docmd(fcp, specifycmd, 3));
1823 fdcspdchange(struct fdcntlr *fcp, struct fcu_obj *fjp, int rpm)
1832 if (((fcp->c_flags & FCFLG_DSOUT) == 0 && rpm <= fjp->fj_rotspd) ||
1833 ((fcp->c_flags & FCFLG_DSOUT) && (fjp->fj_flags & FUNIT_3DMODE) &&
1840 ASSERT(MUTEX_HELD(&fcp->c_dorlock));
1842 switch (fcp->c_chip) {
1854 retcode = (fcp->c_flags ^ FCFLG_DSOUT) ||
1856 fcp->c_flags |= FCFLG_DSOUT;
1860 fcp->c_flags &= ~FCFLG_DSOUT;
1864 if (retcode && (fcp->c_digout & FD_DRSEL) == fcp->c_curunit) {
1866 deselect = fcp->c_digout ^ FD_DRSEL;
1867 outb(fcp->c_regbase + FCR_DOR, deselect);
1870 (void) fdc_docmd(fcp, nscmodecmd, 5);
1887 retcode = (fcp->c_flags ^ FCFLG_DSOUT) ||
1889 fcp->c_flags |= FCFLG_DSOUT;
1894 fcp->c_flags &= ~FCFLG_DSOUT;
1898 if (retcode && (fcp->c_digout & FD_DRSEL) == fcp->c_curunit) {
1900 deselect = fcp->c_digout ^ FD_DRSEL;
1901 outb(fcp->c_regbase + FCR_DOR, deselect);
1903 save = inb(fcp->c_regbase + FCR_SRA);
1907 outb(fcp->c_regbase + FCR_SRA, enable_code);
1908 outb(fcp->c_regbase + FCR_SRA, enable_code);
1911 outb(fcp->c_regbase + FCR_SRA, FSA_CR5);
1912 enable_code = inb(fcp->c_regbase + FCR_SRB) & FSB_DSDEF;
1914 outb(fcp->c_regbase + FCR_SRB, enable_code | ds_code);
1917 outb(fcp->c_regbase + FCR_SRA, FSA_DISB);
1919 outb(fcp->c_regbase + FCR_SRA, save);
1924 outb(fcp->c_regbase + FCR_DOR, fcp->c_digout);
1931 struct fdcntlr *fcp = fjp->fj_fdc;
1937 ASSERT(MUTEX_HELD(&fcp->c_dorlock));
1938 old_mstate = fcp->c_mtrstate[unit];
1943 fcp->c_motort[unit] = 0;
1947 fcp->c_mtrstate[unit] = FMS_ON;
1950 fcp->c_motort[unit] = timeout(fdmotort, (void *)fjp,
1952 fcp->c_mtrstate[unit] = FMS_IDLE;
1955 fcp->c_digout &= ~motorbit;
1956 outb(fcp->c_regbase + FCR_DOR, fcp->c_digout);
1957 fcp->c_mtrstate[unit] = FMS_OFF;
1973 fcp->c_mtrstate[unit] = 86;
1974 mutex_exit(&fcp->c_dorlock);
1975 (void) untimeout(fcp->c_motort[unit]);
1976 mutex_enter(&fcp->c_dorlock);
1977 fcp->c_motort[unit] = 0;
1978 fcp->c_mtrstate[unit] = FMS_ON;
1981 fcp->c_digout |= motorbit;
1982 outb(fcp->c_regbase + FCR_DOR, fcp->c_digout);
1986 fcp->c_motort[unit] = timeout(fdmotort, (void *)fjp,
1990 fcp->c_mtrstate[unit] = FMS_START;
1998 if (fcp->c_motort[unit] != 0) {
1999 fcp->c_mtrstate[unit] = 86;
2000 mutex_exit(&fcp->c_dorlock);
2001 (void) untimeout(fcp->c_motort[unit]);
2002 mutex_enter(&fcp->c_dorlock);
2005 fcp->c_motort[unit] = timeout(fdmotort, (void *)fjp,
2007 fcp->c_mtrstate[unit] = FMS_START;
2011 if (fcp->c_motort[unit] == 0)
2012 fcp->c_motort[unit] = timeout(fdmotort, (void *)fjp,
2014 fcp->c_mtrstate[unit] = FMS_DELAY;
2020 fcp->c_mtrstate[unit] = 86;
2021 mutex_exit(&fcp->c_dorlock);
2022 (void) untimeout(fcp->c_motort[unit]);
2023 mutex_enter(&fcp->c_dorlock);
2027 fcp->c_motort[unit] = timeout(fdmotort, (void *)fjp,
2029 fcp->c_mtrstate[unit] = FMS_IDLE;
2032 fcp->c_mtrstate[unit] = FMS_KILLST;
2050 fcp->c_mtrstate[unit] = FMS_OFF;
2051 if (fcp->c_motort[unit] != 0) {
2052 mutex_exit(&fcp->c_dorlock);
2053 (void) untimeout(fcp->c_motort[unit]);
2054 mutex_enter(&fcp->c_dorlock);
2055 fcp->c_motort[unit] = 0;
2062 fcp->c_mtrstate[unit]));
2074 struct fdcntlr *fcp = fjp->fj_fdc;
2075 struct fdcsb *csb = &fcp->c_csb;
2080 mutex_enter(&fcp->c_dorlock);
2082 mutex_exit(&fcp->c_dorlock);
2086 mutex_enter(&fcp->c_lock);
2088 if ((fcp->c_flags & FCFLG_WAITING) &&
2089 fcp->c_mtrstate[unit] == FMS_ON &&
2092 newxstate = fdc_statemach(fcp);
2098 fcp->c_csb.csb_cmdstat = EIO;
2101 fcp->c_flags ^= FCFLG_WAITING;
2102 cv_signal(&fcp->c_iocv);
2104 mutex_exit(&fcp->c_lock);
2115 fdc_dmae_isr(struct fdcntlr *fcp)
2117 struct fdcsb *csb = &fcp->c_csb;
2154 fdc_exec(struct fdcntlr *fcp, int sleep, int change)
2163 mutex_enter(&fcp->c_lock);
2166 csb = &fcp->c_csb;
2168 fjp = fcp->c_unit[unit];
2191 mutex_exit(&fcp->c_lock);
2197 if (fcp->c_curunit != unit || !(fjp->fj_flags & FUNIT_CHAROK)) {
2198 fcp->c_curunit = unit;
2205 if (fdcspecify(fcp, fjp->fj_chars->fdc_transfer_rate,
2210 "head load time 40", (void*)fcp,
2214 mutex_enter(&fcp->c_dorlock);
2215 if (fdcspdchange(fcp, fjp, fjp->fj_attr->fda_rotatespd)) {
2222 mutex_exit(&fcp->c_dorlock);
2230 if (change && fdcsense_chng(fcp, unit)) {
2233 fcp->c_unit[unit]->fj_flags |= FUNIT_CHANGED;
2237 if (fdcheckdisk(fcp, unit)) {
2238 mutex_exit(&fcp->c_lock);
2249 mutex_enter(&fcp->c_dorlock);
2255 mutex_exit(&fcp->c_dorlock);
2263 fcp->fdstats.rd++;
2266 fcp->fdstats.wr++;
2269 fcp->fdstats.recal++;
2272 fcp->fdstats.form++;
2275 fcp->fdstats.other++;
2291 dmaereq.procparms = (void *)fcp;
2292 if (ddi_dmae_prog(fcp->c_dip, &dmaereq, &csb->csb_dmacookie,
2293 fcp->c_dmachan) != DDI_SUCCESS)
2296 (void*)fcp->c_dip, fcp->c_dmachan);
2299 if ((fdc_statemach(fcp) == FXS_DOWT) && !sleep) {
2304 mutex_exit(&fcp->c_lock);
2311 if (fdc_statemach(fcp) == -1) {
2312 mutex_exit(&fcp->c_lock);
2316 fcp->c_flags |= FCFLG_WAITING;
2320 while (fcp->c_flags & FCFLG_WAITING) {
2321 cv_wait(&fcp->c_iocv, &fcp->c_lock);
2334 if (fdrecover(fcp)) {
2335 mutex_exit(&fcp->c_lock);
2351 mutex_exit(&fcp->c_lock);
2359 mutex_exit(&fcp->c_lock);
2370 fdcheckdisk(struct fdcntlr *fcp, int unit)
2372 struct fdcsb *csb = &fcp->c_csb;
2378 ASSERT(MUTEX_HELD(&fcp->c_lock));
2382 if (fcp->c_curpcyl[unit])
2383 newcyl = fcp->c_curpcyl[unit] - 1;
2395 fcp->c_flags |= FCFLG_WAITING;
2397 if (fcp->c_mtrstate[unit] != FMS_ON && fcp->c_motort[unit] != 0)
2408 if (rval = fdcseek(fcp, unit, newcyl)) {
2414 fcp->c_flags ^= FCFLG_WAITING;
2421 while (fcp->c_flags & FCFLG_WAITING) {
2422 cv_wait(&fcp->c_iocv, &fcp->c_lock);
2428 if (rval = fdcsense_chng(fcp, unit)) {
2441 fdrecover(struct fdcntlr *fcp)
2444 struct fdcsb *csb = &fcp->c_csb;
2453 fjp = fcp->c_unit[unit];
2454 if (fcp->c_flags & FCFLG_TIMEOUT) {
2455 fcp->c_flags ^= FCFLG_TIMEOUT;
2463 fcp->c_curpcyl[unit] = -1;
2485 if (ddi_dmae_getcnt(fcp->c_dip, fcp->c_dmachan,
2490 (void*)fcp->c_dip, fcp->c_dmachan,
2526 fcp->fdstats.de++;
2528 fcp->fdstats.run++;
2530 fcp->fdstats.bfmt++;
2532 fcp->fdstats.to++;
2597 struct fdcntlr *fcp = (struct fdcntlr *)arg;
2608 csb = &fcp->c_csb;
2610 mutex_enter(&fcp->c_lock);
2611 if (fcp->c_suspended) {
2612 mutex_exit(&fcp->c_lock);
2620 state = inb(fcp->c_regbase + FCR_MSR);
2626 state = inb(fcp->c_regbase + FCR_MSR);
2642 (fcp->c_flags & FCFLG_WAITING) &&
2649 fcp->c_flags ^= FCFLG_WAITING;
2651 if ((newstate = fdc_statemach(fcp)) == -1) {
2653 fcp->c_flags |= FCFLG_WAITING;
2654 mutex_exit(&fcp->c_lock);
2658 if (fcp->c_intrstat)
2693 if (ddi_dmae_prog(fcp->c_dip, NULL,
2694 &csb->csb_dmacookie, fcp->c_dmachan) !=
2699 (void*)fcp->c_dip,
2700 fcp->c_dmachan);
2713 (void) fdc_statemach(fcp);
2719 fcp->c_flags |= FCFLG_WAITING;
2728 cv_signal(&fcp->c_iocv);
2732 fcp->c_flags |= FCFLG_WAITING;
2734 mutex_exit(&fcp->c_lock);
2739 (void) fdcsense_int(fcp, &drive, NULL);
2756 if (fcp->c_intrstat)
2758 mutex_exit(&fcp->c_lock);
2769 struct fdcntlr *fcp = (struct fdcntlr *)arg;
2772 mutex_enter(&fcp->c_lock);
2774 if (fcp->c_timeid == 0) {
2778 mutex_exit(&fcp->c_lock);
2782 if (fcp->c_flags & FCFLG_WAITING) {
2783 if (ddi_dmae_stop(fcp->c_dip, fcp->c_dmachan) != DDI_SUCCESS)
2786 (void*)fcp->c_dip, fcp->c_dmachan);
2787 csb = &fcp->c_csb;
2793 if (inb(fcp->c_regbase + FCR_MSR) != MS_RQM) {
2798 (void) fdc_statemach(fcp);
2805 fcp->c_timeid = 0;
2806 fcp->c_flags ^= FCFLG_WAITING;
2807 cv_signal(&fcp->c_iocv);
2810 fcp->c_flags |= FCFLG_TIMEOUT;
2814 fcp->c_csb.csb_drive));
2816 if (fcp->c_intrstat)
2818 mutex_exit(&fcp->c_lock);
2823 fdc_statemach(struct fdcntlr *fcp)
2826 struct fdcsb *csb = &fcp->c_csb;
2831 ASSERT(MUTEX_HELD(&fcp->c_lock));
2834 fjp = fcp->c_unit[unit];
2840 ASSERT(fcp->c_timeid == 0);
2844 fcp->c_timeid = timeout(fdwatch, (void *)fcp, time);
2846 if (fcp->c_mtrstate[unit] == FMS_START) {
2856 if (fcp->c_mtrstate[unit] != FMS_ON) {
2861 if (fcp->c_curpcyl[unit] != -1 && *csb->csb_cmd != FO_RECAL)
2864 if (fdc_docmd(fcp, recalcmd, 2) == -1) {
2866 fdcquiesce(fcp);
2871 fcp->c_sekdir[unit] = 0;
2880 fcp->c_curpcyl[unit] = 0;
2885 (void) fdc_docmd(fcp, &senseintcmd, 1);
2890 (void) fdc_result(fcp, csb->csb_rslt, 2);
2900 fdcquiesce(fcp);
2909 fcp->c_curpcyl[unit] = csb->csb_rslt[1];
2914 csb->csb_npcyl == fcp->c_curpcyl[unit])
2916 fcp->c_sekdir[unit] = csb->csb_npcyl - fcp->c_curpcyl[unit];
2920 (void) fdcseek(fcp, csb->csb_cmd[1], csb->csb_npcyl);
2929 ASSERT(fcp->c_timeid == 0);
2933 fcp->c_timeid = timeout(fdwatch, (void *)fcp, time);
2935 if (fcp->c_mtrstate[unit] != FMS_ON) {
2939 if ((csb->csb_npcyl == 0 || fcp->c_sekdir[unit] >= 0) &&
2944 (void) fdcseek(fcp, csb->csb_cmd[1], backoff);
2953 (void) fdc_docmd(fcp, &senseintcmd, 1);
2958 (void) fdc_result(fcp, csb->csb_rslt, 2);
2966 (void) fdcseek(fcp, csb->csb_cmd[1], csb->csb_npcyl);
2979 fcp->c_curpcyl[unit] = csb->csb_npcyl;
2984 (void) fdc_docmd(fcp, &senseintcmd, 1);
2989 (void) fdc_result(fcp, csb->csb_rslt, 2);
3002 fcp->c_curpcyl[unit] = csb->csb_rslt[1];
3004 mutex_enter(&fcp->c_dorlock);
3010 mutex_exit(&fcp->c_dorlock);
3019 fdcreadid(fcp, csb);
3024 (void) fdc_result(fcp, csb->csb_rslt, 7);
3040 ASSERT(fcp->c_timeid == 0);
3044 fcp->c_timeid = timeout(fdwatch, (void *)fcp, time);
3046 if (fdc_docmd(fcp, csb->csb_cmd, csb->csb_ncmds) == -1) {
3048 fdcquiesce(fcp);
3057 (void) fdc_result(fcp, csb->csb_rslt, csb->csb_nrslts);
3076 if (fcp->c_timeid != 0) {
3078 timeid = fcp->c_timeid;
3079 fcp->c_timeid = 0;
3080 mutex_exit(&fcp->c_lock);
3082 mutex_enter(&fcp->c_lock);
3087 fdcquiesce(fcp);
3088 fcp->c_timeid = timeout(fdwatch, (void *)fcp,
3095 (void) fdcsense_int(fcp, NULL, NULL);
3096 fcp->c_curpcyl[unit] = -1;
3098 if (fcp->c_timeid != 0) {
3100 timeid = fcp->c_timeid;
3101 fcp->c_timeid = 0;
3102 mutex_exit(&fcp->c_lock);
3104 mutex_enter(&fcp->c_lock);
3124 fdc_docmd(struct fdcntlr *fcp, uchar_t *oplistp, uchar_t count)
3137 if ((inb(fcp->c_regbase + FCR_MSR) & (MS_RQM|MS_DIO))
3148 outb(fcp->c_regbase + FCR_DATA, *oplistp++);
3163 fdc_result(struct fdcntlr *fcp, uchar_t *rsltp, uchar_t rcount)
3173 if ((inb(fcp->c_regbase + FCR_MSR) &
3184 *rsltp++ = inb(fcp->c_regbase + FCR_DATA);
3194 while ((inb(fcp->c_regbase + FCR_MSR) & MS_CB) && laxative--) {
3203 stat = inb(fcp->c_regbase + FCR_MSR) &
3224 (void) inb(fcp->c_regbase + FCR_DATA);