Support for 'plug and play' of floppy drives, to be used soon by the
ACPI fdc attachment. Reviewed by fvdl.
This commit is contained in:
parent
4a7a63dba9
commit
5df8dc3180
108
sys/dev/isa/fd.c
108
sys/dev/isa/fd.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fd.c,v 1.32 2003/01/01 00:20:33 thorpej Exp $ */
|
||||
/* $NetBSD: fd.c,v 1.33 2003/01/08 23:51:11 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -92,7 +92,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.32 2003/01/01 00:20:33 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.33 2003/01/08 23:51:11 jmcneill Exp $");
|
||||
|
||||
#include "rnd.h"
|
||||
#include "opt_ddb.h"
|
||||
@ -167,6 +167,8 @@ __KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.32 2003/01/01 00:20:33 thorpej Exp $");
|
||||
|
||||
#endif /* i386 */
|
||||
|
||||
#include <dev/isa/fdvar.h>
|
||||
|
||||
#define FDUNIT(dev) (minor(dev) / 8)
|
||||
#define FDTYPE(dev) (minor(dev) % 8)
|
||||
|
||||
@ -176,28 +178,6 @@ __KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.32 2003/01/01 00:20:33 thorpej Exp $");
|
||||
/* controller driver configuration */
|
||||
int fdprint __P((void *, const char *));
|
||||
|
||||
/*
|
||||
* Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how
|
||||
* we tell them apart.
|
||||
*/
|
||||
struct fd_type {
|
||||
int sectrac; /* sectors per track */
|
||||
int heads; /* number of heads */
|
||||
int seccyl; /* sectors per cylinder */
|
||||
int secsize; /* size code for sectors */
|
||||
int datalen; /* data len when secsize = 0 */
|
||||
int steprate; /* step rate and head unload time */
|
||||
int gap1; /* gap len between sectors */
|
||||
int gap2; /* formatting gap */
|
||||
int cyls; /* total num of cylinders */
|
||||
int size; /* size of disk in sectors */
|
||||
int step; /* steps per cylinder */
|
||||
int rate; /* transfer speed code */
|
||||
u_char fillbyte; /* format fill byte */
|
||||
u_char interleave; /* interleave factor (formatting) */
|
||||
const char *name;
|
||||
};
|
||||
|
||||
#if NMCA > 0
|
||||
/* MCA - specific entries */
|
||||
const struct fd_type mca_fd_types[] = {
|
||||
@ -226,44 +206,6 @@ const struct fd_type fd_types[] = {
|
||||
};
|
||||
#endif /* defined(atari) */
|
||||
|
||||
/* software state, per disk (with up to 4 disks per ctlr) */
|
||||
struct fd_softc {
|
||||
struct device sc_dev;
|
||||
struct disk sc_dk;
|
||||
|
||||
const struct fd_type *sc_deftype; /* default type descriptor */
|
||||
struct fd_type *sc_type; /* current type descriptor */
|
||||
struct fd_type sc_type_copy; /* copy for fiddling when formatting */
|
||||
|
||||
struct callout sc_motoron_ch;
|
||||
struct callout sc_motoroff_ch;
|
||||
|
||||
daddr_t sc_blkno; /* starting block number */
|
||||
int sc_bcount; /* byte count left */
|
||||
int sc_opts; /* user-set options */
|
||||
int sc_skip; /* bytes already transferred */
|
||||
int sc_nblks; /* number of blocks currently transferring */
|
||||
int sc_nbytes; /* number of bytes currently transferring */
|
||||
|
||||
int sc_drive; /* physical unit number */
|
||||
int sc_flags;
|
||||
#define FD_OPEN 0x01 /* it's open */
|
||||
#define FD_MOTOR 0x02 /* motor should be on */
|
||||
#define FD_MOTOR_WAIT 0x04 /* motor coming up */
|
||||
int sc_cylin; /* where we think the head is */
|
||||
|
||||
void *sc_sdhook; /* saved shutdown hook for drive. */
|
||||
|
||||
TAILQ_ENTRY(fd_softc) sc_drivechain;
|
||||
int sc_ops; /* I/O ops since last switch */
|
||||
struct bufq_state sc_q; /* pending I/O requests */
|
||||
int sc_active; /* number of active I/O operations */
|
||||
|
||||
#if NRND > 0
|
||||
rndsource_element_t rnd_source;
|
||||
#endif
|
||||
};
|
||||
|
||||
int fdprobe __P((struct device *, struct cfdata *, void *));
|
||||
void fdattach __P((struct device *, struct device *, void *));
|
||||
|
||||
@ -398,25 +340,33 @@ fdcattach(fdc)
|
||||
|
||||
/* physical limit: four drives per controller. */
|
||||
for (fa.fa_drive = 0; fa.fa_drive < 4; fa.fa_drive++) {
|
||||
if (fdc->sc_known) {
|
||||
if (fdc->sc_present & (1 << fa.fa_drive)) {
|
||||
fa.fa_deftype = fdc->sc_knownfds[fa.fa_drive];
|
||||
config_found(&fdc->sc_dev, (void *)&fa,
|
||||
fdprint);
|
||||
}
|
||||
} else {
|
||||
#if defined(i386)
|
||||
if (type >= 0 && fa.fa_drive < 2)
|
||||
fa.fa_deftype = fd_nvtotype(fdc->sc_dev.dv_xname,
|
||||
type, fa.fa_drive);
|
||||
else
|
||||
fa.fa_deftype = NULL; /* unknown */
|
||||
if (type >= 0 && fa.fa_drive < 2)
|
||||
fa.fa_deftype = fd_nvtotype(fdc->sc_dev.dv_xname,
|
||||
type, fa.fa_drive);
|
||||
else
|
||||
fa.fa_deftype = NULL; /* unknown */
|
||||
#elif defined(atari)
|
||||
/*
|
||||
* Atari has a different ordening, defaults to 1.44
|
||||
*/
|
||||
fa.fa_deftype = &fd_types[2];
|
||||
/*
|
||||
* Atari has a different ordening, defaults to 1.44
|
||||
*/
|
||||
fa.fa_deftype = &fd_types[2];
|
||||
#else
|
||||
/*
|
||||
* Default to 1.44MB on Alpha and BeBox. How do we tell
|
||||
* on these platforms?
|
||||
*/
|
||||
fa.fa_deftype = &fd_types[0];
|
||||
/*
|
||||
* Default to 1.44MB on Alpha and BeBox. How do we tell
|
||||
* on these platforms?
|
||||
*/
|
||||
fa.fa_deftype = &fd_types[0];
|
||||
#endif /* i386 */
|
||||
(void)config_found(&fdc->sc_dev, (void *)&fa, fdprint);
|
||||
(void)config_found(&fdc->sc_dev, (void *)&fa, fdprint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -445,6 +395,10 @@ fdprobe(parent, match, aux)
|
||||
if (cf->cf_loc[FDCCF_DRIVE] == FDCCF_DRIVE_DEFAULT && drive >= 2)
|
||||
return 0;
|
||||
|
||||
/* Use PNP information if available */
|
||||
if (fdc->sc_known)
|
||||
return 1;
|
||||
|
||||
/* select drive and turn on motor */
|
||||
bus_space_write_1(iot, ioh, fdout, drive | FDO_FRST | FDO_MOEN(drive));
|
||||
/* wait for motor to spin up */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fdcvar.h,v 1.1 2000/04/23 16:47:45 thorpej Exp $ */
|
||||
/* $NetBSD: fdcvar.h,v 1.2 2003/01/08 23:51:11 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -139,6 +139,10 @@ struct fdc_softc {
|
||||
enum fdc_state sc_state;
|
||||
int sc_errors; /* number of retries so far */
|
||||
u_char sc_status[7]; /* copy of registers */
|
||||
|
||||
int sc_known; /* direct configuration if non-zero */
|
||||
int sc_present; /* bitmap of available fds */
|
||||
const struct fd_type *sc_knownfds[4]; /* drive info known fds */
|
||||
};
|
||||
|
||||
int out_fdc __P((bus_space_tag_t iot, bus_space_handle_t ioh, u_char x));
|
||||
|
103
sys/dev/isa/fdvar.h
Normal file
103
sys/dev/isa/fdvar.h
Normal file
@ -0,0 +1,103 @@
|
||||
/* $NetBSD: fdvar.h,v 1.1 2003/01/08 23:51:11 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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 NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "rnd.h"
|
||||
|
||||
#if NRND > 0
|
||||
#include <sys/rnd.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how
|
||||
* we tell them apart.
|
||||
*/
|
||||
struct fd_type {
|
||||
int sectrac; /* sectors per track */
|
||||
int heads; /* number of heads */
|
||||
int seccyl; /* sectors per cylinder */
|
||||
int secsize; /* size code for sectors */
|
||||
int datalen; /* data len when secsize = 0 */
|
||||
int steprate; /* step rate and head unload time */
|
||||
int gap1; /* gap len between sectors */
|
||||
int gap2; /* formatting gap */
|
||||
int cyls; /* total num of cylinders */
|
||||
int size; /* size of disk in sectors */
|
||||
int step; /* steps per cylinder */
|
||||
int rate; /* transfer speed code */
|
||||
u_char fillbyte; /* format fill byte */
|
||||
u_char interleave; /* interleave factor (formatting) */
|
||||
const char *name;
|
||||
};
|
||||
|
||||
/* software state, per disk (with up to 4 disks per ctlr) */
|
||||
struct fd_softc {
|
||||
struct device sc_dev;
|
||||
struct disk sc_dk;
|
||||
|
||||
const struct fd_type *sc_deftype; /* default type descriptor */
|
||||
struct fd_type *sc_type; /* current type descriptor */
|
||||
struct fd_type sc_type_copy; /* copy for fiddling when formatting */
|
||||
|
||||
struct callout sc_motoron_ch;
|
||||
struct callout sc_motoroff_ch;
|
||||
|
||||
daddr_t sc_blkno; /* starting block number */
|
||||
int sc_bcount; /* byte count left */
|
||||
int sc_opts; /* user-set options */
|
||||
int sc_skip; /* bytes already transferred */
|
||||
int sc_nblks; /* number of blocks currently transferring */
|
||||
int sc_nbytes; /* number of bytes currently transferring */
|
||||
|
||||
int sc_drive; /* physical unit number */
|
||||
int sc_flags;
|
||||
#define FD_OPEN 0x01 /* it's open */
|
||||
#define FD_MOTOR 0x02 /* motor should be on */
|
||||
#define FD_MOTOR_WAIT 0x04 /* motor coming up */
|
||||
int sc_cylin; /* where we think the head is */
|
||||
|
||||
void *sc_sdhook; /* saved shutdown hook for drive. */
|
||||
|
||||
TAILQ_ENTRY(fd_softc) sc_drivechain;
|
||||
int sc_ops; /* I/O ops since last switch */
|
||||
struct bufq_state sc_q; /* pending I/O requests */
|
||||
int sc_active; /* number of active I/O operations */
|
||||
|
||||
#if NRND > 0
|
||||
rndsource_element_t rnd_source;
|
||||
#endif
|
||||
};
|
Loading…
Reference in New Issue
Block a user