1994-09-29 13:54:36 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1994 Wilko Bulte
|
2001-12-16 22:49:57 +00:00
|
|
|
.\" Copyright (c) 2001 Joerg Wunsch
|
1994-09-29 13:54:36 +00:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" 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. The name of the author may not be used to endorse or promote products
|
2001-08-23 21:36:18 +00:00
|
|
|
.\" derived from this software without specific prior written permission
|
1994-09-29 13:54:36 +00:00
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1994-09-29 13:54:36 +00:00
|
|
|
.\"
|
2001-12-16 22:49:57 +00:00
|
|
|
.Dd December 16, 2001
|
1999-11-15 23:14:32 +00:00
|
|
|
.Dt FDC 4
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1994-09-29 13:54:36 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm fdc
|
2002-01-10 16:51:28 +00:00
|
|
|
.Nd "PC architecture floppy disk controller driver"
|
1994-09-29 13:54:36 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-13 09:08:37 +00:00
|
|
|
.Cd device fdc
|
|
|
|
.Cd device fd
|
|
|
|
.Pp
|
|
|
|
In
|
|
|
|
.Pa /boot/device.hints :
|
|
|
|
.Cd hint.fdc.0.at="isa"
|
|
|
|
.Cd hint.fdc.0.port="0x3F0"
|
|
|
|
.Cd hint.fdc.0.irq="6"
|
|
|
|
.Cd hint.fdc.0.drq="2"
|
2001-12-16 22:49:57 +00:00
|
|
|
.Cd hint.fdc.0.flags="0x0"
|
2001-10-13 09:08:37 +00:00
|
|
|
.Cd hint.fd.0.at="fdc0"
|
|
|
|
.Cd hint.fd.0.drive="0"
|
2001-12-16 22:49:57 +00:00
|
|
|
.Cd hint.fd.0.flags="0x0"
|
2001-10-13 09:08:37 +00:00
|
|
|
.Cd hint.fd.1.at="fdc0"
|
|
|
|
.Cd hint.fd.1.drive="1"
|
2001-12-16 22:49:57 +00:00
|
|
|
.Cd hint.fd.1.flags="0x0"
|
1994-09-29 13:54:36 +00:00
|
|
|
.Sh DESCRIPTION
|
2001-12-16 22:49:57 +00:00
|
|
|
.Ss Device Usage
|
2002-01-10 16:51:28 +00:00
|
|
|
This driver provides access to floppy disk drives.
|
|
|
|
Floppy disks using
|
2001-12-16 22:49:57 +00:00
|
|
|
either FM (single-density) or MFM (double or high-density) recording
|
|
|
|
can be handled.
|
|
|
|
.Pp
|
2002-01-10 16:51:28 +00:00
|
|
|
Floppy disk controllers can connect up to four drives each.
|
|
|
|
The
|
2001-12-16 22:49:57 +00:00
|
|
|
.Nm
|
2002-01-10 16:51:28 +00:00
|
|
|
driver can currently handle up to two drives per controller.
|
|
|
|
Upon
|
2001-12-16 22:49:57 +00:00
|
|
|
driver initialization, an attempt is made to find out the type of the
|
2002-01-10 16:51:28 +00:00
|
|
|
floppy controller in use.
|
|
|
|
The known controller types are either the
|
2001-12-16 22:49:57 +00:00
|
|
|
original NE765 or i8272 chips, or alternatively
|
|
|
|
.Em enhanced
|
|
|
|
controllers that are compatible with the NE72065 or i82077 chips.
|
|
|
|
These enhanced controllers (among other enhancements) implement a FIFO
|
|
|
|
for floppy data transfers that will automatically be enabled once an
|
2002-01-10 16:51:28 +00:00
|
|
|
enhanced chip has been detected.
|
|
|
|
This FIFO activation can be disabled
|
2001-12-16 22:49:57 +00:00
|
|
|
using the per-controller flags value of
|
|
|
|
.Ar 0x1 .
|
|
|
|
.Pp
|
|
|
|
By default, this driver creates a single device node
|
|
|
|
.Pa /dev/fd Ns Ar N
|
|
|
|
for each attached drive with number
|
|
|
|
.Ar N .
|
|
|
|
For historical reasons, device nodes that use a trailing UFS-style
|
|
|
|
partition letter (ranging from
|
|
|
|
.Sq a
|
|
|
|
through
|
|
|
|
.Sq h )
|
|
|
|
can also be accessed, which will be implemented as symbolic links to
|
|
|
|
the main device node.
|
|
|
|
.Pp
|
|
|
|
Accessing the main device node will attempt to autodetect the density
|
2002-01-10 16:51:28 +00:00
|
|
|
of the available medium for multi-density devices.
|
|
|
|
Thus it is
|
2001-12-16 22:49:57 +00:00
|
|
|
possible to use either a 720 KB medium or a 1440 KB medium in a
|
2002-01-10 16:51:28 +00:00
|
|
|
high-density 3.5 inch standard floppy drive.
|
|
|
|
Normally, this
|
2001-12-16 22:49:57 +00:00
|
|
|
autodetection will only happen once at the first call to
|
|
|
|
.Xr open 2
|
2002-01-10 16:51:28 +00:00
|
|
|
for the device after inserting the medium.
|
|
|
|
This assumes the drive
|
2001-12-16 22:49:57 +00:00
|
|
|
offers proper changeline support so media changes can be detected by
|
2002-01-10 16:51:28 +00:00
|
|
|
the driver.
|
|
|
|
To indicate a drive that does not have the changeline support,
|
2001-12-16 22:49:57 +00:00
|
|
|
this can be overridden using the per-drive device flags value of
|
|
|
|
.Ar 0x10
|
|
|
|
(causing each call to
|
|
|
|
.Xr open 2
|
|
|
|
to perform the autodetection).
|
|
|
|
.Pp
|
|
|
|
When trying to use a floppy device with special-density media, other
|
|
|
|
device nodes can be created, of the form
|
|
|
|
.Pa /dev/fd Ns Ar N . Ns Ar MMMM ,
|
|
|
|
where
|
|
|
|
.Ar N
|
|
|
|
is the drive number, and
|
|
|
|
.Ar MMMM
|
|
|
|
is a number between one and four digits describing the device density.
|
2002-01-10 16:51:28 +00:00
|
|
|
Up to 15 additional subdevices per drive can be created that way.
|
|
|
|
The
|
2001-12-16 22:49:57 +00:00
|
|
|
administrator is free to decide on a policy how to assign these
|
2002-01-10 16:51:28 +00:00
|
|
|
numbers.
|
|
|
|
The two common policies are to either implement subdevices
|
2001-12-16 22:49:57 +00:00
|
|
|
numbered 1 through 15, or to use a number that describes the medium
|
2002-01-10 16:51:28 +00:00
|
|
|
density in kilobytes.
|
|
|
|
Initially, each of those devices will be
|
2001-12-16 22:49:57 +00:00
|
|
|
configured to the maximal density that is possible for the drive type
|
|
|
|
(like 1200 KB for 5.25 inch HD drives or 1440 KB for 3.5 inch HD
|
2002-01-10 16:51:28 +00:00
|
|
|
drives).
|
|
|
|
The desired density to be used on that subdevice needs to be
|
2001-12-16 22:49:57 +00:00
|
|
|
configured using
|
|
|
|
.Xr fdcontrol 8 .
|
|
|
|
.Pp
|
|
|
|
Drive types are configured using the lower four bits of the per-drive
|
2002-01-10 16:51:28 +00:00
|
|
|
device flags.
|
|
|
|
The following values can be specified:
|
|
|
|
.Bl -tag -width 2n -offset indent
|
2001-12-16 22:49:57 +00:00
|
|
|
.It Ar 1
|
|
|
|
5.25 inch double-density device with 40 cylinders (360 KB native
|
|
|
|
capacity)
|
|
|
|
.It Ar 2
|
|
|
|
5.25 inch high-density device with 80 cylinders (1200 KB native
|
|
|
|
capacity)
|
|
|
|
.It Ar 3
|
|
|
|
3.5 inch double-density device with 80 cylinders (720 KB native
|
|
|
|
capacity)
|
|
|
|
.It Ar 4
|
|
|
|
3.5 inch high-density device with 80 cylinders (1440 KB native
|
|
|
|
capacity)
|
|
|
|
.It Ar 5
|
|
|
|
3.5 inch extra-density device with 80 cylinders (2880 KB native
|
|
|
|
capacity, usage currently restricted to at most 1440 KB media)
|
|
|
|
.It Ar 6
|
|
|
|
Same as type 5, available for compatibility with some BIOSes
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
On IA32 architectures, the drive type can be specified as 0 for the
|
2002-01-10 16:51:28 +00:00
|
|
|
first two drives.
|
|
|
|
In that case, the CMOS configuration memory will be
|
2001-12-16 22:49:57 +00:00
|
|
|
consulted to obtain the value for that drive.
|
|
|
|
.Pp
|
|
|
|
Normally, each configured drive will be probed at initialization
|
2002-01-10 16:51:28 +00:00
|
|
|
time, using a short seek sequence.
|
|
|
|
This is intended to find out about
|
|
|
|
drives that have been configured but are actually missing or
|
|
|
|
otherwise not responding.
|
|
|
|
In some environments (like laptops with
|
2001-12-16 22:49:57 +00:00
|
|
|
detachable drives), it might be desirable to bypass this drive probe,
|
|
|
|
and pretend a drive to be there so the driver autoconfiguration will
|
2002-01-10 16:51:28 +00:00
|
|
|
work even if the drive is currently not present.
|
|
|
|
For that purpose, a
|
2001-12-16 22:49:57 +00:00
|
|
|
per-drive device flags value of
|
|
|
|
.Ar 0x20
|
|
|
|
needs to be specified.
|
|
|
|
.Pp
|
|
|
|
.Ss Programming Interface
|
|
|
|
In addition to the normal read and write functionality, the
|
|
|
|
.Nm
|
|
|
|
driver offers a number of configurable options using
|
|
|
|
.Xr ioctl 2 .
|
|
|
|
In order to access any of this functionality, programmers need to
|
|
|
|
include the header file
|
2003-09-08 19:57:22 +00:00
|
|
|
.In sys/fdcio.h
|
2002-01-10 16:51:28 +00:00
|
|
|
into their programs.
|
|
|
|
The call to
|
2001-12-16 22:49:57 +00:00
|
|
|
.Xr open 2
|
2002-01-10 16:51:28 +00:00
|
|
|
can be performed in two possible ways.
|
|
|
|
When opening the device
|
2001-12-16 22:49:57 +00:00
|
|
|
without the
|
2002-01-10 16:51:28 +00:00
|
|
|
.Dv O_NONBLOCK
|
2001-12-16 22:49:57 +00:00
|
|
|
flag set, the device is opened in a normal way, which would cause the
|
|
|
|
main device nodes to perform automatic media density selection, and which
|
2002-01-10 16:51:28 +00:00
|
|
|
will yield a file descriptor that is fully available for any I/O operation
|
2001-12-16 22:49:57 +00:00
|
|
|
or any of the following
|
|
|
|
.Xr ioctl 2
|
|
|
|
commands.
|
|
|
|
.Pp
|
2002-01-21 12:09:13 +00:00
|
|
|
When opening the device with
|
2002-01-10 16:51:28 +00:00
|
|
|
.Dv O_NONBLOCK
|
2001-12-16 22:49:57 +00:00
|
|
|
set, automatic media density selection will be bypassed, and the device
|
2002-01-10 16:51:28 +00:00
|
|
|
remains in a half-opened state.
|
|
|
|
No actual I/O operations are possible, but
|
2001-12-16 22:49:57 +00:00
|
|
|
many of the
|
|
|
|
.Xr ioctl 2
|
2002-01-10 16:51:28 +00:00
|
|
|
commands described below can be performed.
|
|
|
|
This mode is intended for
|
2001-12-16 22:49:57 +00:00
|
|
|
access to the device without the requirement to have an accessible
|
|
|
|
media present, like for status inquiries to the drive, or in order to
|
|
|
|
format a medium.
|
2002-01-10 16:51:28 +00:00
|
|
|
.Dv O_NONBLOCK
|
|
|
|
needs to be cleared before I/O operations are possible on the descriptor,
|
2001-12-16 22:49:57 +00:00
|
|
|
which requires a prior specification of the density using the
|
2002-01-10 16:51:28 +00:00
|
|
|
.Dv FD_STYPE
|
|
|
|
command (see below).
|
|
|
|
Operations that are not allowed on the half-opened
|
2001-12-16 22:49:57 +00:00
|
|
|
descriptor will cause an error value of
|
2002-01-10 16:51:28 +00:00
|
|
|
.Er EAGAIN .
|
2001-12-16 22:49:57 +00:00
|
|
|
.Pp
|
|
|
|
The following
|
|
|
|
.Xr ioctl 2
|
|
|
|
commands are currently available:
|
2002-01-10 16:51:28 +00:00
|
|
|
.Bl -tag -width ".Dv FD_READID"
|
|
|
|
.It Dv FD_FORM
|
|
|
|
Used to format a floppy disk medium.
|
|
|
|
Third argument is a pointer to a
|
|
|
|
.Vt "struct fd_formb"
|
2001-12-16 22:49:57 +00:00
|
|
|
specifying which track to format, and which parameters to fill into
|
|
|
|
the ID fields of the floppy disk medium.
|
2002-01-10 16:51:28 +00:00
|
|
|
.It Dv FD_GTYPE
|
2001-12-16 22:49:57 +00:00
|
|
|
Returns the current density definition record for the selected device.
|
|
|
|
Third argument is a pointer to
|
2002-01-10 16:51:28 +00:00
|
|
|
.Vt "struct fd_type" .
|
|
|
|
.It Dv FD_STYPE
|
|
|
|
Adjusts the density definition of the selected device.
|
|
|
|
Third argument
|
2001-12-16 22:49:57 +00:00
|
|
|
is a pointer to
|
2002-01-10 16:51:28 +00:00
|
|
|
.Vt "struct fd_type" .
|
2001-12-16 22:49:57 +00:00
|
|
|
For the fixed-density subdevices (1 through 15 per drive), this
|
2002-01-10 16:51:28 +00:00
|
|
|
operation is restricted to a process with superuser privileges.
|
|
|
|
For
|
2001-12-16 22:49:57 +00:00
|
|
|
the auto-selecting subdevice 0, the operation is temporarily allowed
|
|
|
|
to any process, but this setting will be lost again upon the next
|
2002-01-10 16:51:28 +00:00
|
|
|
autoselection.
|
|
|
|
This can be used when formatting a new medium (which
|
2001-12-16 22:49:57 +00:00
|
|
|
will require to open the device using
|
2002-01-10 16:51:28 +00:00
|
|
|
.Dv O_NONBLOCK ,
|
2001-12-16 22:49:57 +00:00
|
|
|
and thus to later adjust the density using
|
2002-01-10 16:51:28 +00:00
|
|
|
.Dv FD_STYPE ) .
|
|
|
|
.It Dv FD_GOPTS
|
|
|
|
Obtain the current drive options.
|
|
|
|
Third argument is a pointer to
|
|
|
|
.Vt int ,
|
2001-12-16 22:49:57 +00:00
|
|
|
containing a bitwise union of the following possible flag values:
|
2002-01-10 16:51:28 +00:00
|
|
|
.Bl -tag -width ".Dv FDOPT_NOERRLOG"
|
|
|
|
.It Dv FDOPT_NORETRY
|
2001-12-16 22:49:57 +00:00
|
|
|
Do not automatically retry operations upon failure.
|
2002-01-10 16:51:28 +00:00
|
|
|
.It Dv FDOPT_NOERRLOG
|
2001-12-16 22:49:57 +00:00
|
|
|
Do not cause
|
2002-01-10 16:51:28 +00:00
|
|
|
.Dq "hard error"
|
|
|
|
kernel logs for failed I/O operations.
|
|
|
|
.It Dv FDOPT_NOERROR
|
|
|
|
Do not indicate I/O errors when returning from
|
2001-12-16 22:49:57 +00:00
|
|
|
.Xr read 2
|
|
|
|
or
|
|
|
|
.Xr write 2
|
2002-01-10 16:51:28 +00:00
|
|
|
system calls.
|
|
|
|
The caller is assumed to use
|
|
|
|
.Dv FD_GSTAT
|
|
|
|
calls in order to inquire about the success of each operation.
|
|
|
|
This
|
2002-01-21 12:09:13 +00:00
|
|
|
is intended to allow even erroneous data from bad blocks to be
|
2002-01-10 16:51:28 +00:00
|
|
|
retrieved using normal I/O operations.
|
|
|
|
.It Dv FDOPT_AUTOSEL
|
|
|
|
Device performs automatic density selection.
|
|
|
|
Unlike the above flags,
|
2001-12-16 22:49:57 +00:00
|
|
|
this one is read-only.
|
|
|
|
.El
|
2002-01-10 16:51:28 +00:00
|
|
|
.It Dv FD_SOPTS
|
|
|
|
Set device options, see above for their meaning.
|
|
|
|
Third argument is a
|
2001-12-16 22:49:57 +00:00
|
|
|
pointer to
|
2002-01-10 16:51:28 +00:00
|
|
|
.Vt int .
|
2001-12-16 22:49:57 +00:00
|
|
|
Drive options will always be cleared when closing the descriptor.
|
2002-01-10 16:51:28 +00:00
|
|
|
.It Dv FD_DEBUG
|
|
|
|
Set the driver debug level.
|
|
|
|
Third argument is a pointer to
|
|
|
|
.Vt int ,
|
|
|
|
level 0 turns off all debugging.
|
|
|
|
Only applicable if the driver has
|
2001-12-16 22:49:57 +00:00
|
|
|
been configured with
|
2002-01-10 16:51:28 +00:00
|
|
|
.Cd "options FDC_DEBUG" .
|
|
|
|
.It Dv FD_CLRERR
|
|
|
|
Clear the internal low-level error counter.
|
|
|
|
Normally, controller-level
|
|
|
|
I/O errors are only logged up to
|
|
|
|
.Dv FDC_ERRMAX
|
|
|
|
errors (currently defined to 100).
|
|
|
|
This command resets the counter.
|
2001-12-16 22:49:57 +00:00
|
|
|
Requires superuser privileges.
|
2002-01-10 16:51:28 +00:00
|
|
|
.It Dv FD_READID
|
|
|
|
Read one sector ID field from the floppy disk medium.
|
|
|
|
Third argument is
|
2001-12-16 22:49:57 +00:00
|
|
|
a pointer to
|
2002-01-10 16:51:28 +00:00
|
|
|
.Vt "struct fdc_readid" ,
|
|
|
|
where the read data will be returned.
|
|
|
|
Can be used to analyze a floppy
|
2001-12-16 22:49:57 +00:00
|
|
|
disk medium.
|
2002-01-10 16:51:28 +00:00
|
|
|
.It Dv FD_GSTAT
|
|
|
|
Return the recent floppy disk controller status, if available.
|
|
|
|
Third
|
2001-12-16 22:49:57 +00:00
|
|
|
argument is a pointer to
|
2002-01-10 16:51:28 +00:00
|
|
|
.Vt "struct fdc_status" ,
|
2001-12-16 22:49:57 +00:00
|
|
|
where the status registers (ST0, ST1, ST2, C, H, R, and N) are being
|
|
|
|
returned.
|
2002-01-10 16:51:28 +00:00
|
|
|
.Er EINVAL
|
2001-12-16 22:49:57 +00:00
|
|
|
will be caused if no recent status is available.
|
2002-01-10 16:51:28 +00:00
|
|
|
.It Dv FD_GDTYPE
|
|
|
|
Returns the floppy disk drive type.
|
|
|
|
Third argument is a pointer to
|
|
|
|
.Vt "enum fd_drivetype" .
|
2001-12-16 22:49:57 +00:00
|
|
|
This type is the same as being used in the per-drive configuration
|
|
|
|
flags, or in the CMOS configuration data on IA32 systems.
|
|
|
|
.El
|
1994-09-29 13:54:36 +00:00
|
|
|
.Sh FILES
|
2002-01-10 16:51:28 +00:00
|
|
|
.Bl -tag -width ".Pa /dev/fd*" -compact
|
2001-02-01 16:38:02 +00:00
|
|
|
.It Pa /dev/fd*
|
1994-09-29 13:54:36 +00:00
|
|
|
floppy disk device nodes
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
1996-09-23 22:24:39 +00:00
|
|
|
.Xr fdformat 1 ,
|
2001-12-16 22:49:57 +00:00
|
|
|
.Xr fdread 1 ,
|
|
|
|
.Xr fdwrite 1 ,
|
|
|
|
.Xr ioctl 2 ,
|
|
|
|
.Xr open 2 ,
|
|
|
|
.Xr read 2 ,
|
2002-01-10 16:51:28 +00:00
|
|
|
.Xr write 2 ,
|
|
|
|
.Xr fdcontrol 8
|
2001-12-16 22:49:57 +00:00
|
|
|
.Sh AUTHORS
|
2002-01-10 16:51:28 +00:00
|
|
|
.An -nosplit
|
2001-12-16 22:49:57 +00:00
|
|
|
This man page was initially written by
|
|
|
|
.An Wilko Bulte ,
|
|
|
|
and later vastly rewritten by
|
|
|
|
.An J\(:org Wunsch .
|