Deleted Added
sdiff udiff text old ( 175230 ) new ( 184976 )
full compact
1/*-
2 * Copyright (c) 2004 Poul-Henning Kamp
3 * Copyright (c) 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Don Ahn.
8 *

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

46 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 *
49 * from: @(#)fd.c 7.4 (Berkeley) 5/25/91
50 *
51 */
52
53#include <sys/cdefs.h>
54__FBSDID("$FreeBSD: head/sys/dev/fdc/fdc.c 175230 2008-01-11 16:50:52Z kib $");
55
56#include "opt_fdc.h"
57
58#include <sys/param.h>
59#include <sys/bio.h>
60#include <sys/bus.h>
61#include <sys/devicestat.h>
62#include <sys/disk.h>

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

92 * Runtime configuration hints/flags
93 */
94
95/* configuration flags for fd */
96#define FD_TYPEMASK 0x0f /* drive type, matches enum
97 * fd_drivetype; on i386 machines, if
98 * given as 0, use RTC type for fd0
99 * and fd1 */
100#define FD_NO_PROBE 0x20 /* don't probe drive (seek test), just
101 * assume it is there */
102
103/*
104 * Things that could conceiveably considered parameters or tweakables
105 */
106
107/*

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

258 struct bio_queue_head fd_bq;
259};
260
261#define FD_NOT_VALID -2
262
263static driver_intr_t fdc_intr;
264static driver_filter_t fdc_intr_fast;
265static void fdc_reset(struct fdc_data *);
266
267SYSCTL_NODE(_debug, OID_AUTO, fdc, CTLFLAG_RW, 0, "fdc driver");
268
269static int fifo_threshold = 8;
270SYSCTL_INT(_debug_fdc, OID_AUTO, fifo, CTLFLAG_RW, &fifo_threshold, 0,
271 "FIFO threshold setting");
272
273static int debugflags = 0;

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

763
764 /* Have we exhausted our retries ? */
765 bp = fdc->bp;
766 fd = fdc->fd;
767 if (bp != NULL &&
768 (fdc->retry >= retries || (fd->options & FDOPT_NORETRY))) {
769 if ((debugflags & 4))
770 printf("Too many retries (EIO)\n");
771 mtx_lock(&fdc->fdc_mtx);
772 fd->flags |= FD_EMPTY;
773 mtx_unlock(&fdc->fdc_mtx);
774 return (fdc_biodone(fdc, EIO));
775 }
776
777 /* Disable ISADMA if we bailed while it was active */
778 if (fd != NULL && (fd->flags & FD_ISADMA)) {
779 mtx_lock(&Giant);
780 isa_dmadone(
781 bp->bio_cmd & BIO_READ ? ISADMA_READ : ISADMA_WRITE,

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

831 /* Select drive, setup params */
832 fd_select(fd);
833 if (fdc->fdct == FDC_ENHANCED)
834 fddsr_wr(fdc, fd->ft->trans);
835 else
836 fdctl_wr(fdc, fd->ft->trans);
837
838 if (bp->bio_cmd & BIO_PROBE) {
839
840 if (!(fdin_rd(fdc) & FDI_DCHG) && !(fd->flags & FD_EMPTY))
841 return (fdc_biodone(fdc, 0));
842
843 /*
844 * Try to find out if we have a disk in the drive
845 *
846 * First recal, then seek to cyl#1, this clears the
847 * old condition on the disk change line so we can
848 * examine it for current status
849 */
850 if (debugflags & 0x40)
851 printf("New disk in probe\n");
852 mtx_lock(&fdc->fdc_mtx);
853 fd->flags |= FD_NEWDISK;
854 mtx_unlock(&fdc->fdc_mtx);
855 retry_line = __LINE__;
856 if (fdc_cmd(fdc, 2, NE7CMD_RECAL, fd->fdsu, 0))
857 return (1);
858 tsleep(fdc, PRIBIO, "fdrecal", hz);
859 retry_line = __LINE__;
860 if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
861 return (1); /* XXX */
862 retry_line = __LINE__;
863 if ((st0 & 0xc0) || cyl != 0)
864 return (1);
865
866 /* Seek to track 1 */
867 retry_line = __LINE__;
868 if (fdc_cmd(fdc, 3, NE7CMD_SEEK, fd->fdsu, 1, 0))
869 return (1);
870 tsleep(fdc, PRIBIO, "fdseek", hz);
871 retry_line = __LINE__;
872 if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
873 return (1); /* XXX */
874 need_recal |= (1 << fd->fdsu);
875 if (fdin_rd(fdc) & FDI_DCHG) {
876 if (debugflags & 0x40)
877 printf("Empty in probe\n");
878 mtx_lock(&fdc->fdc_mtx);
879 fd->flags |= FD_EMPTY;
880 mtx_unlock(&fdc->fdc_mtx);
881 } else {
882 if (debugflags & 0x40)
883 printf("Got disk in probe\n");
884 mtx_lock(&fdc->fdc_mtx);
885 fd->flags &= ~FD_EMPTY;
886 mtx_unlock(&fdc->fdc_mtx);
887 retry_line = __LINE__;
888 if(fdc_sense_drive(fdc, &st3) != 0)
889 return (1);
890 mtx_lock(&fdc->fdc_mtx);
891 if(st3 & NE7_ST3_WP)
892 fd->flags |= FD_WP;
893 else
894 fd->flags &= ~FD_WP;
895 mtx_unlock(&fdc->fdc_mtx);
896 }
897 return (fdc_biodone(fdc, 0));
898 }
899
900 /*
901 * If we are dead just flush the requests
902 */
903 if (fd->flags & FD_EMPTY)
904 return (fdc_biodone(fdc, ENXIO));
905

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

1233 /* Queue it on the drive until the motor has started */
1234 bioq_insert_tail(&fd->fd_bq, bp);
1235 if (!(fd->flags & FD_MOTORWAIT))
1236 fd_motor(fd, 1);
1237 }
1238 mtx_unlock(&fdc->fdc_mtx);
1239}
1240
1241static int
1242fdmisccmd(struct fd_data *fd, u_int cmd, void *data)
1243{
1244 struct bio *bp;
1245 struct fd_formb *finfo;
1246 struct fdc_readid *idfield;
1247 int error;
1248
1249 bp = malloc(sizeof(struct bio), M_TEMP, M_WAITOK | M_ZERO);

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

1345 break;
1346 }
1347
1348 fd->options = oopts;
1349 if (fdtp->heads == 0) {
1350 if (debugflags & 0x40)
1351 device_printf(fd->dev, "autoselection failed\n");
1352 fdsettype(fd, fd_native_types[fd->type]);
1353 return (0);
1354 } else {
1355 if (debugflags & 0x40) {
1356 device_printf(fd->dev,
1357 "autoselected %d KB medium\n", fd->ft->size / 2);
1358 fdprinttype(fd->ft);
1359 }
1360 return (0);
1361 }

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

1406
1407 busy = 0;
1408 if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) {
1409 if (fdmisccmd(fd, BIO_PROBE, NULL))
1410 return (ENXIO);
1411 if (fd->flags & FD_EMPTY)
1412 return (ENXIO);
1413 if (fd->flags & FD_NEWDISK) {
1414 fdautoselect(fd);
1415 mtx_lock(&fdc->fdc_mtx);
1416 fd->flags &= ~FD_NEWDISK;
1417 mtx_unlock(&fdc->fdc_mtx);
1418 }
1419 device_busy(fd->dev);
1420 busy = 1;
1421 }
1422

--- 634 unchanged lines hidden ---