[Midnightbsd-cvs] src: dev/fdc: Sync with freebsd 7
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Nov 30 11:26:20 EST 2008
Log Message:
-----------
Sync with freebsd 7
Modified Files:
--------------
src/sys/dev/fdc:
fdc.c (r1.2 -> r1.3)
fdc_acpi.c (r1.1.1.1 -> r1.2)
-------------- next part --------------
Index: fdc_acpi.c
===================================================================
RCS file: /home/cvs/src/sys/dev/fdc/fdc_acpi.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L sys/dev/fdc/fdc_acpi.c -L sys/dev/fdc/fdc_acpi.c -u -r1.1.1.1 -r1.2
--- sys/dev/fdc/fdc_acpi.c
+++ sys/dev/fdc/fdc_acpi.c
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc_acpi.c,v 1.10.2.1 2005/11/07 09:53:24 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc_acpi.c,v 1.12 2006/02/21 03:19:24 njl Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -98,7 +98,6 @@
device_t bus;
int error, fde_count, i;
ACPI_OBJECT *obj, *pkg;
- ACPI_HANDLE h;
uint32_t fde[ACPI_FDC_MAXDEVS];
/* Get our softc and use the same accessor as ISA. */
@@ -107,7 +106,6 @@
/* Initialize variables and get a temporary buffer for _FDE. */
error = ENXIO;
- h = acpi_get_handle(dev);
buf.Length = ACPI_FDC_BUFLEN;
buf.Pointer = malloc(buf.Length, M_TEMP, M_NOWAIT | M_ZERO);
if (buf.Pointer == NULL)
Index: fdc.c
===================================================================
RCS file: /home/cvs/src/sys/dev/fdc/fdc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -L sys/dev/fdc/fdc.c -L sys/dev/fdc/fdc.c -u -r1.2 -r1.3
--- sys/dev/fdc/fdc.c
+++ sys/dev/fdc/fdc.c
@@ -51,7 +51,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc.c,v 1.307.2.2 2006/03/07 15:50:25 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc.c,v 1.317 2007/02/27 17:16:52 jhb Exp $");
#include "opt_fdc.h"
@@ -69,6 +69,7 @@
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
+#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/rman.h>
#include <sys/sysctl.h>
@@ -191,6 +192,7 @@
#define FDO_MOEN3 0x80 /* motor enable drive 3 */
#define FDSTS 4 /* NEC 765 Main Status Register (R) */
+#define FDDSR 4 /* Data Rate Select Register (W) */
#define FDDATA 5 /* NEC 765 Data Register (R/W) */
#define FDCTL 7 /* Control Register (W) */
@@ -259,6 +261,7 @@
#define FD_NOT_VALID -2
static driver_intr_t fdc_intr;
+static driver_filter_t fdc_intr_fast;
static void fdc_reset(struct fdc_data *);
SYSCTL_NODE(_debug, OID_AUTO, fdc, CTLFLAG_RW, 0, "fdc driver");
@@ -344,6 +347,13 @@
}
static void
+fddsr_wr(struct fdc_data *fdc, u_int8_t v)
+{
+
+ fdregwr(fdc, FDDSR, v);
+}
+
+static void
fddata_wr(struct fdc_data *fdc, u_int8_t v)
{
@@ -494,11 +504,16 @@
{
int i, r[10];
- /* Try a reset, keep motor on */
- fdout_wr(fdc, fdc->fdout & ~(FDO_FRST|FDO_FDMAEN));
- DELAY(100);
- /* enable FDC, but defer interrupts a moment */
- fdout_wr(fdc, fdc->fdout & ~FDO_FDMAEN);
+ if (fdc->fdct == FDC_ENHANCED) {
+ /* Try a software reset, default precomp, and 500 kb/s */
+ fddsr_wr(fdc, I8207X_DSR_SR);
+ } else {
+ /* Try a hardware reset, keep motor on */
+ fdout_wr(fdc, fdc->fdout & ~(FDO_FRST|FDO_FDMAEN));
+ DELAY(100);
+ /* enable FDC, but defer interrupts a moment */
+ fdout_wr(fdc, fdc->fdout & ~FDO_FDMAEN);
+ }
DELAY(100);
fdout_wr(fdc, fdc->fdout);
@@ -508,7 +523,7 @@
if (fdc->fdct == FDC_ENHANCED) {
if (fdc_cmd(fdc, 4,
- I8207X_CONFIGURE,
+ I8207X_CONFIG,
0,
0x40 | /* Enable Implied Seek */
0x10 | /* Polling disabled */
@@ -519,7 +534,7 @@
" CONFIGURE failed in reset\n");
if (debugflags & 1) {
if (fdc_cmd(fdc, 1,
- 0x0e, /* DUMPREG */
+ I8207X_DUMPREG,
10, &r[0], &r[1], &r[2], &r[3], &r[4],
&r[5], &r[6], &r[7], &r[8], &r[9]))
device_printf(fdc->fdc_dev,
@@ -672,6 +687,14 @@
wakeup(arg);
}
+static int
+fdc_intr_fast(void *arg)
+{
+
+ wakeup(arg);
+ return(FILTER_HANDLED);
+}
+
/*
* fdc_pio(): perform programmed IO read/write for YE PCMCIA floppy.
*/
@@ -745,6 +768,9 @@
(fdc->retry >= retries || (fd->options & FDOPT_NORETRY))) {
if ((debugflags & 4))
printf("Too many retries (EIO)\n");
+ mtx_lock(&fdc->fdc_mtx);
+ fd->flags |= FD_EMPTY;
+ mtx_unlock(&fdc->fdc_mtx);
return (fdc_biodone(fdc, EIO));
}
@@ -764,7 +790,7 @@
if (fdc->flags & FDC_NEEDS_RESET) {
fdc->flags &= ~FDC_NEEDS_RESET;
fdc_reset(fdc);
- msleep(fdc, NULL, PRIBIO, "fdcrst", hz);
+ tsleep(fdc, PRIBIO, "fdcrst", hz);
/* Discard results */
for (i = 0; i < 4; i++)
fdc_sense_int(fdc, &st0, &cyl);
@@ -804,7 +830,10 @@
/* Select drive, setup params */
fd_select(fd);
- fdctl_wr(fdc, fd->ft->trans);
+ if (fdc->fdct == FDC_ENHANCED)
+ fddsr_wr(fdc, fd->ft->trans);
+ else
+ fdctl_wr(fdc, fd->ft->trans);
if (bp->bio_cmd & BIO_PROBE) {
@@ -826,7 +855,7 @@
retry_line = __LINE__;
if (fdc_cmd(fdc, 2, NE7CMD_RECAL, fd->fdsu, 0))
return (1);
- msleep(fdc, NULL, PRIBIO, "fdrecal", hz);
+ tsleep(fdc, PRIBIO, "fdrecal", hz);
retry_line = __LINE__;
if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
return (1); /* XXX */
@@ -838,7 +867,7 @@
retry_line = __LINE__;
if (fdc_cmd(fdc, 3, NE7CMD_SEEK, fd->fdsu, 1, 0))
return (1);
- msleep(fdc, NULL, PRIBIO, "fdseek", hz);
+ tsleep(fdc, PRIBIO, "fdseek", hz);
retry_line = __LINE__;
if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
return (1); /* XXX */
@@ -927,7 +956,7 @@
retry_line = __LINE__;
if (fdc_cmd(fdc, 2, NE7CMD_RECAL, fd->fdsu, 0))
return (1);
- msleep(fdc, NULL, PRIBIO, "fdrecal", hz);
+ tsleep(fdc, PRIBIO, "fdrecal", hz);
retry_line = __LINE__;
if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
return (1); /* XXX */
@@ -938,7 +967,7 @@
fd->track = 0;
/* let the heads settle */
if (settle)
- msleep(fdc->fd, NULL, PRIBIO, "fdhdstl", settle);
+ tsleep(fdc->fd, PRIBIO, "fdhdstl", settle);
}
/*
@@ -954,7 +983,7 @@
retry_line = __LINE__;
if (fdc_cmd(fdc, 3, NE7CMD_SEEK, fd->fdsu, descyl, 0))
return (1);
- msleep(fdc, NULL, PRIBIO, "fdseek", hz);
+ tsleep(fdc, PRIBIO, "fdseek", hz);
retry_line = __LINE__;
if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
return (1); /* XXX */
@@ -965,7 +994,7 @@
}
/* let the heads settle */
if (settle)
- msleep(fdc->fd, NULL, PRIBIO, "fdhdstl", settle);
+ tsleep(fdc->fd, PRIBIO, "fdhdstl", settle);
}
fd->track = cylinder;
@@ -1051,7 +1080,7 @@
}
/* Wait for interrupt */
- i = msleep(fdc, NULL, PRIBIO, "fddata", hz);
+ i = tsleep(fdc, PRIBIO, "fddata", hz);
/* PIO if the read looks good */
if (i == 0 && (fdc->flags & FDC_NODMA) && (bp->bio_cmd & BIO_READ))
@@ -1176,7 +1205,6 @@
mtx_lock(&fdc->fdc_mtx);
}
fdc->flags &= ~(FDC_KTHREAD_EXIT | FDC_KTHREAD_ALIVE);
- wakeup(&fdc->fdc_thread);
mtx_unlock(&fdc->fdc_mtx);
kthread_exit(0);
@@ -1250,7 +1278,7 @@
fd_enqueue(fd, bp);
do {
- msleep(bp, NULL, PRIBIO, "fdwait", hz);
+ tsleep(bp, PRIBIO, "fdwait", hz);
} while (!(bp->bio_flags & BIO_DONE));
error = bp->bio_error;
@@ -1470,8 +1498,9 @@
return (0);
case FD_CLRERR:
- if (suser(td) != 0)
- return (EPERM);
+ error = priv_check(td, PRIV_DRIVER);
+ if (error)
+ return (error);
fd->fdc->fdc_errs = 0;
return (0);
@@ -1681,8 +1710,8 @@
return (error);
/* kill worker thread */
- fdc->flags |= FDC_KTHREAD_EXIT;
mtx_lock(&fdc->fdc_mtx);
+ fdc->flags |= FDC_KTHREAD_EXIT;
wakeup(&fdc->head);
while ((fdc->flags & FDC_KTHREAD_ALIVE) != 0)
msleep(&fdc->fdc_thread, &fdc->fdc_mtx, PRIBIO, "fdcdet", 0);
@@ -1737,9 +1766,11 @@
return (error);
}
error = bus_setup_intr(dev, fdc->res_irq,
- INTR_TYPE_BIO | INTR_ENTROPY | INTR_MPSAFE |
- ((fdc->flags & FDC_NOFAST) ? 0 : INTR_FAST),
- fdc_intr, fdc, &fdc->fdc_intr);
+ INTR_TYPE_BIO | INTR_ENTROPY |
+ ((fdc->flags & FDC_NOFAST) ? INTR_MPSAFE : 0),
+ ((fdc->flags & FDC_NOFAST) ? NULL : fdc_intr_fast),
+ ((fdc->flags & FDC_NOFAST) ? fdc_intr : NULL),
+ fdc, &fdc->fdc_intr);
if (error) {
device_printf(dev, "cannot setup interrupt\n");
return (error);
More information about the Midnightbsd-cvs
mailing list