fdc.c (39187) | fdc.c (39228) |
---|---|
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.120 1998/07/29 13:00:40 bde Exp $ | 46 * $Id: fd.c,v 1.121 1998/09/14 19:56:39 sos Exp $ |
47 * 48 */ 49 50#include "ft.h" 51#if NFT < 1 52#undef NFDC 53#endif 54#include "fd.h" --- 6 unchanged lines hidden (view full) --- 61#include <sys/systm.h> 62#include <sys/kernel.h> 63#include <sys/conf.h> 64#include <sys/fcntl.h> 65#include <machine/clock.h> 66#include <machine/ioctl_fd.h> 67#include <sys/disklabel.h> 68#include <sys/buf.h> | 47 * 48 */ 49 50#include "ft.h" 51#if NFT < 1 52#undef NFDC 53#endif 54#include "fd.h" --- 6 unchanged lines hidden (view full) --- 61#include <sys/systm.h> 62#include <sys/kernel.h> 63#include <sys/conf.h> 64#include <sys/fcntl.h> 65#include <machine/clock.h> 66#include <machine/ioctl_fd.h> 67#include <sys/disklabel.h> 68#include <sys/buf.h> |
69#include <sys/devicestat.h> |
|
69#include <sys/malloc.h> 70#include <sys/proc.h> 71#include <sys/syslog.h> | 70#include <sys/malloc.h> 71#include <sys/proc.h> 72#include <sys/syslog.h> |
72#ifdef notyet 73#include <sys/dkstat.h> 74#endif | |
75#include <i386/isa/isa.h> 76#include <i386/isa/isa_device.h> 77#include <i386/isa/fdreg.h> 78#include <i386/isa/fdc.h> 79#include <i386/isa/rtc.h> 80#include <machine/stdarg.h> 81#if NFT > 0 82#include <sys/ftape.h> --- 86 unchanged lines hidden (view full) --- 169#define FD_ACTIVE 0x02 /* it's active */ 170#define FD_MOTOR 0x04 /* motor should be on */ 171#define FD_MOTOR_WAIT 0x08 /* motor coming up */ 172 int skip; 173 int hddrv; 174#define FD_NO_TRACK -2 175 int track; /* where we think the head is */ 176 int options; /* user configurable options, see ioctl_fd.h */ | 73#include <i386/isa/isa.h> 74#include <i386/isa/isa_device.h> 75#include <i386/isa/fdreg.h> 76#include <i386/isa/fdc.h> 77#include <i386/isa/rtc.h> 78#include <machine/stdarg.h> 79#if NFT > 0 80#include <sys/ftape.h> --- 86 unchanged lines hidden (view full) --- 167#define FD_ACTIVE 0x02 /* it's active */ 168#define FD_MOTOR 0x04 /* motor should be on */ 169#define FD_MOTOR_WAIT 0x08 /* motor coming up */ 170 int skip; 171 int hddrv; 172#define FD_NO_TRACK -2 173 int track; /* where we think the head is */ 174 int options; /* user configurable options, see ioctl_fd.h */ |
177#ifdef notyet 178 int dkunit; /* disk stats unit number */ 179#endif | |
180 struct callout_handle toffhandle; 181 struct callout_handle tohandle; | 175 struct callout_handle toffhandle; 176 struct callout_handle tohandle; |
177 struct devstat device_stats; |
|
182#ifdef DEVFS 183 void *bdevs[1 + NUMDENS + MAXPARTITIONS]; 184 void *cdevs[1 + NUMDENS + MAXPARTITIONS]; 185#endif 186} fd_data[NFD]; 187 188/***********************************************************************\ 189* Throughout this file the following conventions will be used: * --- 598 unchanged lines hidden (view full) --- 788 for (i = 0; i < MAXPARTITIONS; i++) { 789 fd->bdevs[1 + NUMDENS + i] = devfs_link(fd->bdevs[0], 790 "fd%d%c", fdu, 'a' + i); 791 fd->cdevs[1 + NUMDENS + i] = 792 devfs_link(fd->cdevs[0], 793 "rfd%d%c", fdu, 'a' + i); 794 } 795#endif /* DEVFS */ | 178#ifdef DEVFS 179 void *bdevs[1 + NUMDENS + MAXPARTITIONS]; 180 void *cdevs[1 + NUMDENS + MAXPARTITIONS]; 181#endif 182} fd_data[NFD]; 183 184/***********************************************************************\ 185* Throughout this file the following conventions will be used: * --- 598 unchanged lines hidden (view full) --- 784 for (i = 0; i < MAXPARTITIONS; i++) { 785 fd->bdevs[1 + NUMDENS + i] = devfs_link(fd->bdevs[0], 786 "fd%d%c", fdu, 'a' + i); 787 fd->cdevs[1 + NUMDENS + i] = 788 devfs_link(fd->cdevs[0], 789 "rfd%d%c", fdu, 'a' + i); 790 } 791#endif /* DEVFS */ |
796#ifdef notyet 797 if (dk_ndrive < DK_NDRIVE) { 798 sprintf(dk_names[dk_ndrive], "fd%d", fdu); 799 fd->dkunit = dk_ndrive++; 800 /* 801 * XXX assume rate is FDC_500KBPS. 802 */ 803 dk_wpms[dk_ndrive] = 500000 / 8 / 2; 804 } else { 805 fd->dkunit = -1; 806 } 807#endif | 792 /* 793 * Export the drive to the devstat interface. 794 */ 795 devstat_add_entry(&fd->device_stats, "fd", 796 fdu, 512, 797 DEVSTAT_NO_ORDERED_TAGS, 798 DEVSTAT_TYPE_FLOPPY | DEVSTAT_TYPE_IF_OTHER); 799 |
808 } 809 810 return (1); 811} 812 813 814 815/****************************************************************************/ --- 381 unchanged lines hidden (view full) --- 1197 bp->b_flags |= B_ERROR; 1198 goto bad; 1199 } 1200 } 1201 bp->b_pblkno = bp->b_blkno; 1202 s = splbio(); 1203 bufqdisksort(&fdc->head, bp); 1204 untimeout(fd_turnoff, (caddr_t)fdu, fd->toffhandle); /* a good idea */ | 800 } 801 802 return (1); 803} 804 805 806 807/****************************************************************************/ --- 381 unchanged lines hidden (view full) --- 1189 bp->b_flags |= B_ERROR; 1190 goto bad; 1191 } 1192 } 1193 bp->b_pblkno = bp->b_blkno; 1194 s = splbio(); 1195 bufqdisksort(&fdc->head, bp); 1196 untimeout(fd_turnoff, (caddr_t)fdu, fd->toffhandle); /* a good idea */ |
1197 1198 /* Tell devstat we are starting on the transaction */ 1199 devstat_start_transaction(&fd->device_stats); 1200 |
|
1205 fdstart(fdcu); 1206 splx(s); 1207 return; 1208 1209bad: 1210 biodone(bp); 1211} 1212 | 1201 fdstart(fdcu); 1202 splx(s); 1203 return; 1204 1205bad: 1206 biodone(bp); 1207} 1208 |
1213 | |
1214/***************************************************************\ 1215* fdstart * 1216* We have just queued something.. if the controller is not busy * 1217* then simulate the case where it has just finished a command * 1218* So that it (the interrupt routine) looks on the queue for more* 1219* work to do and picks up what we just added. * 1220* If the controller is already busy, we need do nothing, as it * 1221* will pick up our work when the present work completes * --- 400 unchanged lines hidden (view full) --- 1622 /* set up next transfer */ 1623 fdc->state = DOSEEK; 1624 } 1625 else 1626 { 1627 /* ALL DONE */ 1628 fd->skip = 0; 1629 bufq_remove(&fdc->head, bp); | 1209/***************************************************************\ 1210* fdstart * 1211* We have just queued something.. if the controller is not busy * 1212* then simulate the case where it has just finished a command * 1213* So that it (the interrupt routine) looks on the queue for more* 1214* work to do and picks up what we just added. * 1215* If the controller is already busy, we need do nothing, as it * 1216* will pick up our work when the present work completes * --- 400 unchanged lines hidden (view full) --- 1617 /* set up next transfer */ 1618 fdc->state = DOSEEK; 1619 } 1620 else 1621 { 1622 /* ALL DONE */ 1623 fd->skip = 0; 1624 bufq_remove(&fdc->head, bp); |
1625 /* Tell devstat we have finished with the transaction */ 1626 devstat_end_transaction(&fd->device_stats, 1627 bp->b_bcount - bp->b_resid, 1628 DEVSTAT_TAG_NONE, 1629 (bp->b_flags & B_READ) ? 1630 DEVSTAT_READ : DEVSTAT_WRITE); |
|
1630 biodone(bp); 1631 fdc->fd = (fd_p) 0; 1632 fdc->fdu = -1; 1633 fdc->state = FINDWORK; 1634 } 1635 return(1); 1636 case RESETCTLR: 1637 fdc_reset(fdc); --- 100 unchanged lines hidden (view full) --- 1738 1739static int 1740retrier(fdcu) 1741 fdcu_t fdcu; 1742{ 1743 struct subdev *sd; 1744 fdc_p fdc = fdc_data + fdcu; 1745 register struct buf *bp; | 1631 biodone(bp); 1632 fdc->fd = (fd_p) 0; 1633 fdc->fdu = -1; 1634 fdc->state = FINDWORK; 1635 } 1636 return(1); 1637 case RESETCTLR: 1638 fdc_reset(fdc); --- 100 unchanged lines hidden (view full) --- 1739 1740static int 1741retrier(fdcu) 1742 fdcu_t fdcu; 1743{ 1744 struct subdev *sd; 1745 fdc_p fdc = fdc_data + fdcu; 1746 register struct buf *bp; |
1747 struct fd_data *fd; 1748 int fdu; |
|
1746 1747 bp = bufq_first(&fdc->head); 1748 1749 if(fd_data[FDUNIT(minor(bp->b_dev))].options & FDOPT_NORETRY) 1750 goto fail; 1751 switch(fdc->retry) 1752 { 1753 case 0: case 1: case 2: --- 30 unchanged lines hidden (view full) --- 1784 } 1785 else 1786 printf(" (No status)\n"); 1787 } 1788 bp->b_flags |= B_ERROR; 1789 bp->b_error = EIO; 1790 bp->b_resid += bp->b_bcount - fdc->fd->skip; 1791 bufq_remove(&fdc->head, bp); | 1749 1750 bp = bufq_first(&fdc->head); 1751 1752 if(fd_data[FDUNIT(minor(bp->b_dev))].options & FDOPT_NORETRY) 1753 goto fail; 1754 switch(fdc->retry) 1755 { 1756 case 0: case 1: case 2: --- 30 unchanged lines hidden (view full) --- 1787 } 1788 else 1789 printf(" (No status)\n"); 1790 } 1791 bp->b_flags |= B_ERROR; 1792 bp->b_error = EIO; 1793 bp->b_resid += bp->b_bcount - fdc->fd->skip; 1794 bufq_remove(&fdc->head, bp); |
1795 1796 /* Tell devstat we have finished with the transaction */ 1797 devstat_end_transaction(&fd->device_stats, 1798 bp->b_bcount - bp->b_resid, 1799 DEVSTAT_TAG_NONE, 1800 (bp->b_flags & B_READ) ? DEVSTAT_READ : 1801 DEVSTAT_WRITE); |
|
1792 fdc->fd->skip = 0; 1793 biodone(bp); 1794 fdc->state = FINDWORK; 1795 fdc->flags |= FDC_NEEDS_RESET; 1796 fdc->fd = (fd_p) 0; 1797 fdc->fdu = -1; 1798 return(1); 1799 } --- 217 unchanged lines hidden --- | 1802 fdc->fd->skip = 0; 1803 biodone(bp); 1804 fdc->state = FINDWORK; 1805 fdc->flags |= FDC_NEEDS_RESET; 1806 fdc->fd = (fd_p) 0; 1807 fdc->fdu = -1; 1808 return(1); 1809 } --- 217 unchanged lines hidden --- |