Deleted Added
full compact
fdc.c (15148) fdc.c (15574)
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 * Copyright (c) 1993, 1994 by

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

38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 *
45 * from: @(#)fd.c 7.4 (Berkeley) 5/25/91
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 * Copyright (c) 1993, 1994 by

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

38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 *
45 * from: @(#)fd.c 7.4 (Berkeley) 5/25/91
46 * $Id: fd.c,v 1.86 1996/04/07 17:32:12 bde Exp $
46 * $Id: fd.c,v 1.87 1996/04/08 19:40:56 smpatel Exp $
47 *
48 */
49
50#include "ft.h"
51#if NFT < 1
52#undef NFDC
53#endif
54#include "fd.h"

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

576 fdc->flags |= FDC_ATTACHED;
577 fdc->dmachan = dev->id_drq;
578 /* Acquire the DMA channel forever, The driver will do the rest */
579 isa_dma_acquire(fdc->dmachan);
580 isa_dmainit(fdc->dmachan, 128 << 3 /* XXX max secsize */);
581 fdc->state = DEVIDLE;
582 /* reset controller, turn motor off, clear fdout mirror reg */
583 outb(fdc->baseport + FDOUT, ((fdc->fdout = 0)));
47 *
48 */
49
50#include "ft.h"
51#if NFT < 1
52#undef NFDC
53#endif
54#include "fd.h"

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

576 fdc->flags |= FDC_ATTACHED;
577 fdc->dmachan = dev->id_drq;
578 /* Acquire the DMA channel forever, The driver will do the rest */
579 isa_dma_acquire(fdc->dmachan);
580 isa_dmainit(fdc->dmachan, 128 << 3 /* XXX max secsize */);
581 fdc->state = DEVIDLE;
582 /* reset controller, turn motor off, clear fdout mirror reg */
583 outb(fdc->baseport + FDOUT, ((fdc->fdout = 0)));
584 TAILQ_INIT(&fdc->head);
584
585 /* check for each floppy drive */
586 for (fdup = isa_biotab_fdc; fdup->id_driver != 0; fdup++) {
587 if (fdup->id_iobase != dev->id_iobase)
588 continue;
589 fdu = fdup->id_unit;
590 fd = &fd_data[fdu];
591 if (fdu >= (NFD+NFT))

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

1121
1122
1123/****************************************************************************/
1124/* fdstrategy */
1125/****************************************************************************/
1126void
1127fdstrategy(struct buf *bp)
1128{
585
586 /* check for each floppy drive */
587 for (fdup = isa_biotab_fdc; fdup->id_driver != 0; fdup++) {
588 if (fdup->id_iobase != dev->id_iobase)
589 continue;
590 fdu = fdup->id_unit;
591 fd = &fd_data[fdu];
592 if (fdu >= (NFD+NFT))

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

1122
1123
1124/****************************************************************************/
1125/* fdstrategy */
1126/****************************************************************************/
1127void
1128fdstrategy(struct buf *bp)
1129{
1129 register struct buf *dp;
1130 long nblocks, blknum;
1131 int s;
1132 fdcu_t fdcu;
1133 fdu_t fdu;
1134 fdc_p fdc;
1135 fd_p fd;
1136 size_t fdblk;
1137

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

1182 } else {
1183 bp->b_error = ENOSPC;
1184 bp->b_flags |= B_ERROR;
1185 }
1186 goto bad;
1187 }
1188 bp->b_cylin = blknum / (fd->ft->sectrac * fd->ft->heads);
1189 bp->b_pblkno = bp->b_blkno;
1130 long nblocks, blknum;
1131 int s;
1132 fdcu_t fdcu;
1133 fdu_t fdu;
1134 fdc_p fdc;
1135 fd_p fd;
1136 size_t fdblk;
1137

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

1182 } else {
1183 bp->b_error = ENOSPC;
1184 bp->b_flags |= B_ERROR;
1185 }
1186 goto bad;
1187 }
1188 bp->b_cylin = blknum / (fd->ft->sectrac * fd->ft->heads);
1189 bp->b_pblkno = bp->b_blkno;
1190 dp = &(fdc->head);
1191 s = splbio();
1190 s = splbio();
1192 disksort(dp, bp);
1191 tqdisksort(&fdc->head, bp);
1193 untimeout(fd_turnoff, (caddr_t)fdu); /* a good idea */
1194 fdstart(fdcu);
1195 splx(s);
1196 return;
1197
1198bad:
1199 biodone(bp);
1200}

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

1222}
1223
1224static void
1225fd_timeout(void *arg1)
1226{
1227 fdcu_t fdcu = (fdcu_t)arg1;
1228 fdu_t fdu = fdc_data[fdcu].fdu;
1229 int baseport = fdc_data[fdcu].baseport;
1192 untimeout(fd_turnoff, (caddr_t)fdu); /* a good idea */
1193 fdstart(fdcu);
1194 splx(s);
1195 return;
1196
1197bad:
1198 biodone(bp);
1199}

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

1221}
1222
1223static void
1224fd_timeout(void *arg1)
1225{
1226 fdcu_t fdcu = (fdcu_t)arg1;
1227 fdu_t fdu = fdc_data[fdcu].fdu;
1228 int baseport = fdc_data[fdcu].baseport;
1230 struct buf *dp, *bp;
1229 struct buf *bp;
1231 int s;
1232
1230 int s;
1231
1233 dp = &fdc_data[fdcu].head;
1234 bp = dp->b_actf;
1232 bp = TAILQ_FIRST(&fdc_data[fdcu].head);
1235
1236 /*
1237 * Due to IBM's brain-dead design, the FDC has a faked ready
1238 * signal, hardwired to ready == true. Thus, any command
1239 * issued if there's no diskette in the drive will _never_
1240 * complete, and must be aborted by resetting the FDC.
1241 * Many thanks, Big Blue!
1242 */

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

1309\***********************************************************************/
1310static int
1311fdstate(fdcu_t fdcu, fdc_p fdc)
1312{
1313 int read, format, head, sec = 0, sectrac, st0, cyl, st3;
1314 unsigned long blknum;
1315 fdu_t fdu = fdc->fdu;
1316 fd_p fd;
1233
1234 /*
1235 * Due to IBM's brain-dead design, the FDC has a faked ready
1236 * signal, hardwired to ready == true. Thus, any command
1237 * issued if there's no diskette in the drive will _never_
1238 * complete, and must be aborted by resetting the FDC.
1239 * Many thanks, Big Blue!
1240 */

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

1307\***********************************************************************/
1308static int
1309fdstate(fdcu_t fdcu, fdc_p fdc)
1310{
1311 int read, format, head, sec = 0, sectrac, st0, cyl, st3;
1312 unsigned long blknum;
1313 fdu_t fdu = fdc->fdu;
1314 fd_p fd;
1317 register struct buf *dp, *bp;
1315 register struct buf *bp;
1318 struct fd_formb *finfo = NULL;
1319 size_t fdblk;
1320
1316 struct fd_formb *finfo = NULL;
1317 size_t fdblk;
1318
1321 dp = &(fdc->head);
1322 bp = dp->b_actf;
1323 if(!bp)
1324 {
1319 bp = TAILQ_EMPTY(&fdc->head);
1320 if(!bp) {
1325 /***********************************************\
1326 * nothing left for this controller to do *
1327 * Force into the IDLE state, *
1328 \***********************************************/
1329 fdc->state = DEVIDLE;
1330 if(fdc->fd)
1331 {
1332 printf("fd%d: unexpected valid fd pointer\n",

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

1614 (blknum / (fd->ft->sectrac * fd->ft->heads));
1615 fdc->state = DOSEEK;
1616 }
1617 else
1618 {
1619 /* ALL DONE */
1620 fd->skip = 0;
1621 bp->b_resid = 0;
1321 /***********************************************\
1322 * nothing left for this controller to do *
1323 * Force into the IDLE state, *
1324 \***********************************************/
1325 fdc->state = DEVIDLE;
1326 if(fdc->fd)
1327 {
1328 printf("fd%d: unexpected valid fd pointer\n",

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

1610 (blknum / (fd->ft->sectrac * fd->ft->heads));
1611 fdc->state = DOSEEK;
1612 }
1613 else
1614 {
1615 /* ALL DONE */
1616 fd->skip = 0;
1617 bp->b_resid = 0;
1622 dp->b_actf = bp->b_actf;
1618 TAILQ_REMOVE(&fdc->head, bp, b_act);
1623 biodone(bp);
1624 fdc->fd = (fd_p) 0;
1625 fdc->fdu = -1;
1626 fdc->state = FINDWORK;
1627 }
1628 return(1);
1629 case RESETCTLR:
1630 fdc_reset(fdc);

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

1722 return(1); /* Come back immediatly to new state */
1723}
1724
1725static int
1726retrier(fdcu)
1727 fdcu_t fdcu;
1728{
1729 fdc_p fdc = fdc_data + fdcu;
1619 biodone(bp);
1620 fdc->fd = (fd_p) 0;
1621 fdc->fdu = -1;
1622 fdc->state = FINDWORK;
1623 }
1624 return(1);
1625 case RESETCTLR:
1626 fdc_reset(fdc);

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

1718 return(1); /* Come back immediatly to new state */
1719}
1720
1721static int
1722retrier(fdcu)
1723 fdcu_t fdcu;
1724{
1725 fdc_p fdc = fdc_data + fdcu;
1730 register struct buf *dp, *bp;
1726 register struct buf *bp;
1731
1727
1732 dp = &(fdc->head);
1733 bp = dp->b_actf;
1728 bp = TAILQ_FIRST(&fdc->head);
1734
1735 if(fd_data[FDUNIT(minor(bp->b_dev))].options & FDOPT_NORETRY)
1736 goto fail;
1737 switch(fdc->retry)
1738 {
1739 case 0: case 1: case 2:
1740 fdc->state = SEEKCOMPLETE;
1741 break;

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

1769 fdc->status[5]);
1770 }
1771 else
1772 printf(" (No status)\n");
1773 }
1774 bp->b_flags |= B_ERROR;
1775 bp->b_error = EIO;
1776 bp->b_resid = bp->b_bcount - fdc->fd->skip;
1729
1730 if(fd_data[FDUNIT(minor(bp->b_dev))].options & FDOPT_NORETRY)
1731 goto fail;
1732 switch(fdc->retry)
1733 {
1734 case 0: case 1: case 2:
1735 fdc->state = SEEKCOMPLETE;
1736 break;

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

1764 fdc->status[5]);
1765 }
1766 else
1767 printf(" (No status)\n");
1768 }
1769 bp->b_flags |= B_ERROR;
1770 bp->b_error = EIO;
1771 bp->b_resid = bp->b_bcount - fdc->fd->skip;
1777 dp->b_actf = bp->b_actf;
1772 TAILQ_REMOVE(&fdc->head, bp, b_act);
1778 fdc->fd->skip = 0;
1779 biodone(bp);
1780 fdc->state = FINDWORK;
1781 fdc->fd = (fd_p) 0;
1782 fdc->fdu = -1;
1783 /* XXX abort current command, if any. */
1784 return(1);
1785 }

--- 220 unchanged lines hidden ---
1773 fdc->fd->skip = 0;
1774 biodone(bp);
1775 fdc->state = FINDWORK;
1776 fdc->fd = (fd_p) 0;
1777 fdc->fdu = -1;
1778 /* XXX abort current command, if any. */
1779 return(1);
1780 }

--- 220 unchanged lines hidden ---