summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/alpha/include/ioctl_fd.h20
-rw-r--r--sys/dev/fdc/fdc.c63
-rw-r--r--sys/i386/include/ioctl_fd.h20
-rw-r--r--sys/isa/fd.c63
-rw-r--r--sys/sys/fdcio.h20
5 files changed, 134 insertions, 52 deletions
diff --git a/sys/alpha/include/ioctl_fd.h b/sys/alpha/include/ioctl_fd.h
index dd6e9d0..95a6680 100644
--- a/sys/alpha/include/ioctl_fd.h
+++ b/sys/alpha/include/ioctl_fd.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden
+ * Copyright (C) 1992-1994,2001 by Joerg Wunsch, Dresden
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -98,6 +98,10 @@ struct fd_type {
int f_inter; /* format interleave factor */
};
+struct fdc_status {
+ u_int status[7];
+};
+
#define FD_FORM _IOW('F', 61, struct fd_formb) /* format a track */
#define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */
#define FD_STYPE _IOW('F', 63, struct fd_type) /* set drive type */
@@ -107,7 +111,19 @@ struct fd_type {
#define FD_DEBUG _IOW('F', 66, int)
-#define FDOPT_NORETRY 0x0001 /* no retries on failure (cleared on close) */
+#define FD_CLRERR _IO('F', 67) /* clear error counter */
+
+/*
+ * Obtain NE765 status registers. Only successful if there is
+ * a valid status stored in fdc->status[].
+ */
+#define FD_GSTAT _IOR('F', 68, struct fdc_status)
+
+/* Options for FD_GOPTS/FD_SOPTS, cleared on device close */
+#define FDOPT_NORETRY 0x0001 /* no retries on failure */
+#define FDOPT_NOERRLOG 0x002 /* no "hard error" kernel log messages */
+#define FDOPT_NOERROR 0x0004 /* do not indicate errors, caller will use
+ FD_GSTAT in order to obtain status */
/*
* The following definitions duplicate those in sys/i386/isa/fdreg.h
diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c
index 29939cc..d086261 100644
--- a/sys/dev/fdc/fdc.c
+++ b/sys/dev/fdc/fdc.c
@@ -18,6 +18,9 @@
* joerg_wunsch@uriah.sax.de (Joerg Wunsch)
* dufault@hda.com (Peter Dufault)
*
+ * Copyright (c) 2001 Joerg Wunsch,
+ * joerg_wunsch@uriah.sax.de (Joerg Wunsch)
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -26,13 +29,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -1494,7 +1490,7 @@ fdclose(dev_t dev, int flags, int mode, struct proc *p)
fd = devclass_get_softc(fd_devclass, fdu);
fd->flags &= ~FD_OPEN;
- fd->options &= ~FDOPT_NORETRY;
+ fd->options &= ~(FDOPT_NORETRY | FDOPT_NOERRLOG | FDOPT_NOERROR);
return (0);
}
@@ -2220,28 +2216,35 @@ retrier(struct fdc_data *fdc)
fail:
{
dev_t sav_bio_dev = bp->bio_dev;
+ int printerror = (fd->options & FDOPT_NOERRLOG) == 0;
+
/* Trick diskerr */
bp->bio_dev = makedev(major(bp->bio_dev),
(FDUNIT(minor(bp->bio_dev))<<3)|RAW_PART);
- diskerr(bp, "hard error", fdc->fd->skip / DEV_BSIZE,
- (struct disklabel *)NULL);
+ if (printerror)
+ diskerr(bp, "hard error", fdc->fd->skip / DEV_BSIZE,
+ (struct disklabel *)NULL);
bp->bio_dev = sav_bio_dev;
- if (fdc->flags & FDC_STAT_VALID)
- {
- printf(
+ if (printerror) {
+ if (fdc->flags & FDC_STAT_VALID)
+ {
+ printf(
" (ST0 %b ST1 %b ST2 %b cyl %u hd %u sec %u)\n",
- fdc->status[0], NE7_ST0BITS,
- fdc->status[1], NE7_ST1BITS,
- fdc->status[2], NE7_ST2BITS,
- fdc->status[3], fdc->status[4],
- fdc->status[5]);
- }
+ fdc->status[0], NE7_ST0BITS,
+ fdc->status[1], NE7_ST1BITS,
+ fdc->status[2], NE7_ST2BITS,
+ fdc->status[3], fdc->status[4],
+ fdc->status[5]);
+ }
else
- printf(" (No status)\n");
+ printf(" (No status)\n");
+ }
+ }
+ if ((fd->options & FDOPT_NOERROR) == 0) {
+ bp->bio_flags |= BIO_ERROR;
+ bp->bio_error = EIO;
+ bp->bio_resid += bp->bio_bcount - fdc->fd->skip;
}
- bp->bio_flags |= BIO_ERROR;
- bp->bio_error = EIO;
- bp->bio_resid += bp->bio_bcount - fdc->fd->skip;
fdc->bp = NULL;
fdc->fd->skip = 0;
device_unbusy(fd->dev);
@@ -2347,6 +2350,7 @@ fdioctl(dev, cmd, addr, flag, p)
struct fd_type *fdt;
struct disklabel *dl;
+ struct fdc_status *fsp;
char buffer[DEV_BSIZE];
int error = 0;
@@ -2423,6 +2427,19 @@ fdioctl(dev, cmd, addr, flag, p)
fd->options = *(int *)addr;
break;
+ case FD_CLRERR:
+ if (suser(p) != 0)
+ return EPERM;
+ fd->fdc->fdc_errs = 0;
+ break;
+
+ case FD_GSTAT:
+ fsp = (struct fdc_status *)addr;
+ if ((fd->fdc->flags & FDC_STAT_VALID) == 0)
+ return EINVAL;
+ memcpy(fsp->status, fd->fdc->status, 7 * sizeof(u_int));
+ break;
+
default:
error = ENOTTY;
break;
diff --git a/sys/i386/include/ioctl_fd.h b/sys/i386/include/ioctl_fd.h
index 92724df..0a9990b0 100644
--- a/sys/i386/include/ioctl_fd.h
+++ b/sys/i386/include/ioctl_fd.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden
+ * Copyright (C) 1992-1994,2001 by Joerg Wunsch, Dresden
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -97,6 +97,10 @@ struct fd_type {
int f_inter; /* format interleave factor */
};
+struct fdc_status {
+ u_int status[7];
+};
+
#define FD_FORM _IOW('F', 61, struct fd_formb) /* format a track */
#define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */
#define FD_STYPE _IOW('F', 63, struct fd_type) /* set drive type */
@@ -106,7 +110,19 @@ struct fd_type {
#define FD_DEBUG _IOW('F', 66, int)
-#define FDOPT_NORETRY 0x0001 /* no retries on failure (cleared on close) */
+#define FD_CLRERR _IO('F', 67) /* clear error counter */
+
+/*
+ * Obtain NE765 status registers. Only successful if there is
+ * a valid status stored in fdc->status[].
+ */
+#define FD_GSTAT _IOR('F', 68, struct fdc_status)
+
+/* Options for FD_GOPTS/FD_SOPTS, cleared on device close */
+#define FDOPT_NORETRY 0x0001 /* no retries on failure */
+#define FDOPT_NOERRLOG 0x002 /* no "hard error" kernel log messages */
+#define FDOPT_NOERROR 0x0004 /* do not indicate errors, caller will use
+ FD_GSTAT in order to obtain status */
/*
* The following definitions duplicate those in sys/i386/isa/fdreg.h
diff --git a/sys/isa/fd.c b/sys/isa/fd.c
index 29939cc..d086261 100644
--- a/sys/isa/fd.c
+++ b/sys/isa/fd.c
@@ -18,6 +18,9 @@
* joerg_wunsch@uriah.sax.de (Joerg Wunsch)
* dufault@hda.com (Peter Dufault)
*
+ * Copyright (c) 2001 Joerg Wunsch,
+ * joerg_wunsch@uriah.sax.de (Joerg Wunsch)
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -26,13 +29,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -1494,7 +1490,7 @@ fdclose(dev_t dev, int flags, int mode, struct proc *p)
fd = devclass_get_softc(fd_devclass, fdu);
fd->flags &= ~FD_OPEN;
- fd->options &= ~FDOPT_NORETRY;
+ fd->options &= ~(FDOPT_NORETRY | FDOPT_NOERRLOG | FDOPT_NOERROR);
return (0);
}
@@ -2220,28 +2216,35 @@ retrier(struct fdc_data *fdc)
fail:
{
dev_t sav_bio_dev = bp->bio_dev;
+ int printerror = (fd->options & FDOPT_NOERRLOG) == 0;
+
/* Trick diskerr */
bp->bio_dev = makedev(major(bp->bio_dev),
(FDUNIT(minor(bp->bio_dev))<<3)|RAW_PART);
- diskerr(bp, "hard error", fdc->fd->skip / DEV_BSIZE,
- (struct disklabel *)NULL);
+ if (printerror)
+ diskerr(bp, "hard error", fdc->fd->skip / DEV_BSIZE,
+ (struct disklabel *)NULL);
bp->bio_dev = sav_bio_dev;
- if (fdc->flags & FDC_STAT_VALID)
- {
- printf(
+ if (printerror) {
+ if (fdc->flags & FDC_STAT_VALID)
+ {
+ printf(
" (ST0 %b ST1 %b ST2 %b cyl %u hd %u sec %u)\n",
- fdc->status[0], NE7_ST0BITS,
- fdc->status[1], NE7_ST1BITS,
- fdc->status[2], NE7_ST2BITS,
- fdc->status[3], fdc->status[4],
- fdc->status[5]);
- }
+ fdc->status[0], NE7_ST0BITS,
+ fdc->status[1], NE7_ST1BITS,
+ fdc->status[2], NE7_ST2BITS,
+ fdc->status[3], fdc->status[4],
+ fdc->status[5]);
+ }
else
- printf(" (No status)\n");
+ printf(" (No status)\n");
+ }
+ }
+ if ((fd->options & FDOPT_NOERROR) == 0) {
+ bp->bio_flags |= BIO_ERROR;
+ bp->bio_error = EIO;
+ bp->bio_resid += bp->bio_bcount - fdc->fd->skip;
}
- bp->bio_flags |= BIO_ERROR;
- bp->bio_error = EIO;
- bp->bio_resid += bp->bio_bcount - fdc->fd->skip;
fdc->bp = NULL;
fdc->fd->skip = 0;
device_unbusy(fd->dev);
@@ -2347,6 +2350,7 @@ fdioctl(dev, cmd, addr, flag, p)
struct fd_type *fdt;
struct disklabel *dl;
+ struct fdc_status *fsp;
char buffer[DEV_BSIZE];
int error = 0;
@@ -2423,6 +2427,19 @@ fdioctl(dev, cmd, addr, flag, p)
fd->options = *(int *)addr;
break;
+ case FD_CLRERR:
+ if (suser(p) != 0)
+ return EPERM;
+ fd->fdc->fdc_errs = 0;
+ break;
+
+ case FD_GSTAT:
+ fsp = (struct fdc_status *)addr;
+ if ((fd->fdc->flags & FDC_STAT_VALID) == 0)
+ return EINVAL;
+ memcpy(fsp->status, fd->fdc->status, 7 * sizeof(u_int));
+ break;
+
default:
error = ENOTTY;
break;
diff --git a/sys/sys/fdcio.h b/sys/sys/fdcio.h
index 92724df..0a9990b0 100644
--- a/sys/sys/fdcio.h
+++ b/sys/sys/fdcio.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden
+ * Copyright (C) 1992-1994,2001 by Joerg Wunsch, Dresden
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -97,6 +97,10 @@ struct fd_type {
int f_inter; /* format interleave factor */
};
+struct fdc_status {
+ u_int status[7];
+};
+
#define FD_FORM _IOW('F', 61, struct fd_formb) /* format a track */
#define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */
#define FD_STYPE _IOW('F', 63, struct fd_type) /* set drive type */
@@ -106,7 +110,19 @@ struct fd_type {
#define FD_DEBUG _IOW('F', 66, int)
-#define FDOPT_NORETRY 0x0001 /* no retries on failure (cleared on close) */
+#define FD_CLRERR _IO('F', 67) /* clear error counter */
+
+/*
+ * Obtain NE765 status registers. Only successful if there is
+ * a valid status stored in fdc->status[].
+ */
+#define FD_GSTAT _IOR('F', 68, struct fdc_status)
+
+/* Options for FD_GOPTS/FD_SOPTS, cleared on device close */
+#define FDOPT_NORETRY 0x0001 /* no retries on failure */
+#define FDOPT_NOERRLOG 0x002 /* no "hard error" kernel log messages */
+#define FDOPT_NOERROR 0x0004 /* do not indicate errors, caller will use
+ FD_GSTAT in order to obtain status */
/*
* The following definitions duplicate those in sys/i386/isa/fdreg.h
OpenPOWER on IntegriCloud