summaryrefslogtreecommitdiffstats
path: root/usr.sbin/fdcontrol
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-08-20 15:14:25 +0000
committerphk <phk@FreeBSD.org>2004-08-20 15:14:25 +0000
commit91de1b896dea3928223e2531589b4c7c0d422ada (patch)
treeb948c22d12f559b0c58f576fc7da5d69acc1c8ef /usr.sbin/fdcontrol
parentca124b900b50e6642bad1e763cd2750ba4776602 (diff)
downloadFreeBSD-src-91de1b896dea3928223e2531589b4c7c0d422ada.zip
FreeBSD-src-91de1b896dea3928223e2531589b4c7c0d422ada.tar.gz
Rewrite of the floppy driver to make it MPsafe & GEOM friendly:
Centralize the fdctl_wr() function by adding the offset in the resource to the softc structure. Bugfix: Read the drive-change signal from the correct place: same place as the ctl register. Remove the cdevsw{} related code and implement a GEOM class. Ditch the state-engine and park a thread on each controller to service the queue. Make the interrupt FAST & MPSAFE since it is just a simple wakeup(9) call. Rely on a per controller mutex to protect the bioqueues. Grab GEOMs topology lock when we have to and Giant when ISADMA needs it. Since all access to the hardware is isolated in the per controller thread, the rest of the driver is lock & Giant free. Create a per-drive queue where requests are parked while the motor spins up. When the motor is running the requests are purged to the per controller queue. This allows requests to other drives to be serviced during spin-up. Only setup the motor-off timeout when we finish the last request on the queue and cancel it when a new request arrives. This fixes the bug in the old code where the motor turned off while we were still retrying a request. Make the "drive-change" work reliably. Probe the drive on first opens. Probe with a recal and a seek to cyl=1 to reset the drive change line and check again to see if we have a media. When we see the media disappear we destroy the geom provider, create a new one, and flag that autodetection should happen next time we see a media (unless a specific format is configured). Add sysctl tunables for a lot of drive related parameters. If you spend a lot of time waiting for floppies you can grab the i82078 pdf from Intels web-page and try tuning these. Add sysctl debug.fdc.debugflags which will enable various kinds of debugging printfs. Add central definitions of our well known floppy formats. Simplify datastructures for autoselection of format and call the code at the right times. Bugfix: Remove at least one piece of code which would have made 2.88M floppies not work. Use implied seeks on enhanced controllers. Use multisector transfers on all controllers. Increase ISADMA bounce buffers accordingly. Fall back to single sector when retrying. Reset retry count on every successful transaction. Sort functions in a more sensible order and generally tidy up a fair bit here and there. Assorted related fixes and adjustments in userland utilities. WORKAROUNDS: Do allow r/w opens of r/o media but refuse actual write operations. This is necessary until the p4::phk_bufwork branch gets integrated (This problem relates to remounting not reopening devices, see sys/*/*/${fs}_vfsops.c for details). Keep PC98's private copy of the old floppy driver compiling and presumably working (see below). TODO (planned) Move probing of drives until after interrupts/timeouts work (like for ATA/SCSI drives). TODO (unplanned) This driver should be made to work on PC98 as well. Test on YE-DATA PCMCIA floppy drive. Fix 2.88M media. This is a MT5 candidate (depends on the bioq_takefirst() addition).
Diffstat (limited to 'usr.sbin/fdcontrol')
-rw-r--r--usr.sbin/fdcontrol/fdcontrol.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/usr.sbin/fdcontrol/fdcontrol.c b/usr.sbin/fdcontrol/fdcontrol.c
index 5ef5057..ff0f90b 100644
--- a/usr.sbin/fdcontrol/fdcontrol.c
+++ b/usr.sbin/fdcontrol/fdcontrol.c
@@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
#include "fdutil.h"
-static int debug = -1, format, verbose, show = 1, showfmt;
+static int format, verbose, show = 1, showfmt;
static char *fmtstring;
static void showdev(enum fd_drivetype, const char *);
@@ -72,20 +72,14 @@ main(int argc, char **argv)
enum fd_drivetype type;
struct fd_type ft, newft, *fdtp;
const char *name, *descr;
- int fd, i, mode;
+ int fd, i, mode, autofmt;
- while((i = getopt(argc, argv, "d:Ff:s:v")) != -1)
+ autofmt = 0;
+ while((i = getopt(argc, argv, "aFf:s:v")) != -1)
switch(i) {
- case 'd':
- if (strcmp(optarg, "0") == 0)
- debug = 0;
- else if (strcmp(optarg, "1") == 0)
- debug = 1;
- else
- usage();
- show = 0;
- break;
+ case 'a':
+ autofmt = 1;
case 'F':
showfmt = 1;
show = 0;
@@ -141,6 +135,11 @@ mode = O_RDONLY | O_NONBLOCK;
return (0);
}
+ if (autofmt) {
+ memset(&newft, 0, sizeof newft);
+ ft = newft;
+ }
+
if (format) {
getname(type, &name, &descr);
fdtp = get_fmt(format, type);
@@ -195,6 +194,10 @@ mode = O_RDONLY | O_NONBLOCK;
printf("%sPERPENDICULAR", s);
s = ",";
}
+ if (ft.flags & FL_AUTO) {
+ printf("%sAUTO", s);
+ s = ",";
+ }
printf(">\n");
} else {
print_fmt(ft);
@@ -208,11 +211,5 @@ mode = O_RDONLY | O_NONBLOCK;
return (0);
}
- if (debug != -1) {
- if (ioctl(fd, FD_DEBUG, &debug) == -1)
- err(EX_OSERR, "ioctl(FD_DEBUG)");
- return (0);
- }
-
return 0;
}
OpenPOWER on IntegriCloud