fdc.c (fb35bd37f2d9aef376adf273319baba432bd9329) fdc.c (3fef646ef00efd3261063b8840753dc6000c1495)
1/*
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Don Ahn.
7 *
8 * Libretto PCMCIA floppy support by David Horwitt (dhorwitt@ucsd.edu)

--- 83 unchanged lines hidden (view full) ---

92
93/* internally used only, not really from CMOS: */
94#define RTCFDT_144M_PRETENDED 0x1000
95
96/* error returns for fd_cmd() */
97#define FD_FAILED -1
98#define FD_NOT_VALID -2
99#define FDC_ERRMAX 100 /* do not log more */
1/*
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Don Ahn.
7 *
8 * Libretto PCMCIA floppy support by David Horwitt (dhorwitt@ucsd.edu)

--- 83 unchanged lines hidden (view full) ---

92
93/* internally used only, not really from CMOS: */
94#define RTCFDT_144M_PRETENDED 0x1000
95
96/* error returns for fd_cmd() */
97#define FD_FAILED -1
98#define FD_NOT_VALID -2
99#define FDC_ERRMAX 100 /* do not log more */
100/*
101 * Stop retrying after this many DMA overruns. Since each retry takes
102 * one revolution, with 300 rpm., 25 retries take approximately 10
103 * seconds which the read attempt will block in case the DMA overrun
104 * is persistent.
105 */
106#define FDC_DMAOV_MAX 25
100
101#define NUMTYPES 17
102#define NUMDENS (NUMTYPES - 7)
103
104#define NO_TYPE 0 /* must match NO_TYPE in ft.c */
105#define FD_1720 1
106#define FD_1480 2
107#define FD_1440 3

--- 1338 unchanged lines hidden (view full) ---

1446 )
1447 return(ENXIO);
1448 break;
1449 }
1450 }
1451 }
1452 fd->ft = fd_types + type - 1;
1453 fd->flags |= FD_OPEN;
107
108#define NUMTYPES 17
109#define NUMDENS (NUMTYPES - 7)
110
111#define NO_TYPE 0 /* must match NO_TYPE in ft.c */
112#define FD_1720 1
113#define FD_1480 2
114#define FD_1440 3

--- 1338 unchanged lines hidden (view full) ---

1453 )
1454 return(ENXIO);
1455 break;
1456 }
1457 }
1458 }
1459 fd->ft = fd_types + type - 1;
1460 fd->flags |= FD_OPEN;
1461 /*
1462 * Clearing the DMA overrun counter at open time is a bit messy.
1463 * Since we're only managing one counter per controller, opening
1464 * the second drive could mess it up. Anyway, if the DMA overrun
1465 * condition is really persistent, it will eventually time out
1466 * still. OTOH, clearing it here will ensure we'll at least start
1467 * trying again after a previous (maybe even long ago) failure.
1468 * Also, this is merely a stop-gap measure only that should not
1469 * happen during normal operation, so we can tolerate it to be a
1470 * bit sloppy about this.
1471 */
1472 fdc->dma_overruns = 0;
1454
1455 return 0;
1456}
1457
1458int
1459fdclose(dev_t dev, int flags, int mode, struct proc *p)
1460{
1461 fdu_t fdu = FDUNIT(minor(dev));

--- 566 unchanged lines hidden (view full) ---

2028 case IOTIMEDOUT:
2029 if (!rdsectid && !(fdc->flags & FDC_NODMA))
2030 isa_dmadone(idf, bp->bio_data + fd->skip,
2031 format ? bp->bio_bcount : fdblk, fdc->dmachan);
2032 if (fdc->status[0] & NE7_ST0_IC) {
2033 if ((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT
2034 && fdc->status[1] & NE7_ST1_OR) {
2035 /*
1473
1474 return 0;
1475}
1476
1477int
1478fdclose(dev_t dev, int flags, int mode, struct proc *p)
1479{
1480 fdu_t fdu = FDUNIT(minor(dev));

--- 566 unchanged lines hidden (view full) ---

2047 case IOTIMEDOUT:
2048 if (!rdsectid && !(fdc->flags & FDC_NODMA))
2049 isa_dmadone(idf, bp->bio_data + fd->skip,
2050 format ? bp->bio_bcount : fdblk, fdc->dmachan);
2051 if (fdc->status[0] & NE7_ST0_IC) {
2052 if ((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT
2053 && fdc->status[1] & NE7_ST1_OR) {
2054 /*
2036 * DMA overrun. Someone hogged the bus
2037 * and didn't release it in time for the
2038 * next FDC transfer.
2039 * Just restart it, don't increment retry
2040 * count. (vak)
2041 */
2042 fdc->state = SEEKCOMPLETE;
2043 return (1);
2055 * DMA overrun. Someone hogged the bus and
2056 * didn't release it in time for the next
2057 * FDC transfer.
2058 *
2059 * We normally restart this without bumping
2060 * the retry counter. However, in case
2061 * something is seriously messed up (like
2062 * broken hardware), we rather limit the
2063 * number of retries so the IO operation
2064 * doesn't block indefinately.
2065 */
2066 if (fdc->dma_overruns++ < FDC_DMAOV_MAX) {
2067 fdc->state = SEEKCOMPLETE;
2068 return (1);
2069 } /* else fall through */
2044 }
2070 }
2045 else if((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_IV
2071 if((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_IV
2046 && fdc->retry < 6)
2047 fdc->retry = 6; /* force a reset */
2048 else if((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT
2049 && fdc->status[2] & NE7_ST2_WC
2050 && fdc->retry < 3)
2051 fdc->retry = 3; /* force recalibrate */
2052 return (retrier(fdc));
2053 }
2054 /* All OK */
2055 if (rdsectid) {
2056 /* copy out ID field contents */
2057 idp = (struct fdc_readid *)bp->bio_data;
2058 idp->cyl = fdc->status[3];
2059 idp->head = fdc->status[4];
2060 idp->sec = fdc->status[5];
2061 idp->secshift = fdc->status[6];
2062 }
2072 && fdc->retry < 6)
2073 fdc->retry = 6; /* force a reset */
2074 else if((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT
2075 && fdc->status[2] & NE7_ST2_WC
2076 && fdc->retry < 3)
2077 fdc->retry = 3; /* force recalibrate */
2078 return (retrier(fdc));
2079 }
2080 /* All OK */
2081 if (rdsectid) {
2082 /* copy out ID field contents */
2083 idp = (struct fdc_readid *)bp->bio_data;
2084 idp->cyl = fdc->status[3];
2085 idp->head = fdc->status[4];
2086 idp->sec = fdc->status[5];
2087 idp->secshift = fdc->status[6];
2088 }
2089 /* Operation successful, retry DMA overruns again next time. */
2090 fdc->dma_overruns = 0;
2063 fd->skip += fdblk;
2064 if (!rdsectid && !format && fd->skip < bp->bio_bcount) {
2065 /* set up next transfer */
2066 fdc->state = DOSEEK;
2067 } else {
2068 /* ALL DONE */
2069 fd->skip = 0;
2070 bp->bio_resid = 0;

--- 355 unchanged lines hidden ---
2091 fd->skip += fdblk;
2092 if (!rdsectid && !format && fd->skip < bp->bio_bcount) {
2093 /* set up next transfer */
2094 fdc->state = DOSEEK;
2095 } else {
2096 /* ALL DONE */
2097 fd->skip = 0;
2098 bp->bio_resid = 0;

--- 355 unchanged lines hidden ---