xref: /freebsd/usr.sbin/fdcontrol/fdcontrol.8 (revision fed1ca4b719c56c930f2259d80663cd34be812bb)
1.\" Copyright (C) 1994, 2001 by Joerg Wunsch, Dresden
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY
14.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
19.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
20.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23.\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
24.\" DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd December 25, 2001
29.Dt FDCONTROL 8
30.Os
31.Sh NAME
32.Nm fdcontrol
33.Nd display and modify floppy disk parameters
34.Sh SYNOPSIS
35.Nm
36.Op Fl F
37.Op Fl d Ar dbg
38.Op Fl f Ar fmt
39.Op Fl s Ar fmtstr
40.Op Fl v
41.Ar device
42.Sh DESCRIPTION
43The
44.Nm
45utility allows the modification of the run-time behavior of the
46.Xr fdc 4
47driver for the device specified by
48.Ar device .
49.Pp
50Commands are implemented to query the current device density settings
51as well as the underlying device hardware as registered with the
52driver, to manipulate debugging levels, and to adjust the device
53density settings.
54All the operations that manipulate the kernel
55settings are restricted to the superuser (by the device driver), while
56all inquiry requests only require read access to
57.Ar device .
58.Pp
59The
60.Ar device
61argument should always be given as a full path name, e.g.\&
62.Pa /dev/fd0 .
63.Ss Inquiry Commands
64Running the
65.Nm
66utility without any of the optional flags will report the drive type
67that is registered with the device driver.
68In the shortest form, a single string describing the drive type will
69be returned.
70Possible values are:
71.Dq Li 360K ,
72.Dq Li 1.2M ,
73.Dq Li 720K ,
74.Dq Li 1.44M ,
75.Dq Li 2.88M ,
76or
77.Dq Li unknown .
78This information is primarily intended to be easily parsable by
79scripts.
80.Pp
81In order to add some descriptive text that makes the output better
82human readable, the flag
83.Fl v
84can be added.
85.Pp
86Specifying flag
87.Fl F
88will report the device's density settings in a form that is suitable
89as input to the
90.Fl s Ar fmtstr
91option (see below).
92Again, together with
93.Fl v ,
94some more text will be returned, including the total capacity of the
95density settings in kilobytes.
96.Ss Debug Control
97If the
98.Xr fdc 4
99driver was configured with the
100.Dv FDC_DEBUG
101option, by default, device debugging information is still disabled
102since it could produce huge amounts of kernel messages.
103It needs to
104be turned on using
105.Nm
106together with
107.Dq Fl d Li 1 ,
108usually immediately before starting an operation on the respective
109device the debug information is wanted for, and later turned off again
110using
111.Dq Fl d Li 0 .
112Note that debugging levels are a driver's global option that will
113affect any drives and controllers using the
114.Xr fdc 4
115driver, regardless which
116.Ar device
117was specified on the
118.Nm
119command line.
120.Ss Density Control
121The
122.Xr fdc 4
123control utilities support two different options how to specify device
124density settings.
125The first form uses
126.Fl f Ar fmt
127to specify the format of the medium in kilobytes.
128Depending on the
129underlying drive type, the value is compared against a table of known
130commonly used device density settings for that drive, and if a match
131is found, those settings will be used.
132Currently, the following
133values for the respective drive types are acceptable:
134.Bl -item
135.It
1362.88M and 1.44M drives:
137.Bd -ragged -offset indent -compact
138.TS
139lB lB lB lB lB lB lB
140r l l l l l l.
141KB	sectrac	secsize	ncyls	speed	heads	flags
1421721	21	2 (512)	82	500	2	MFM
1431476	18	2 (512)	82	500	2	MFM
1441440	18	2 (512)	80	500	2	MFM
1451200	15	2 (512)	80	500	2	MFM
146820	10	2 (512)	82	250	2	MFM
147800	10	2 (512)	80	250	2	MFM
148720	9	2 (512)	80	250	2	MFM
149.TE
150.Ed
151.It
1521.2M drives:
153.Bd -ragged -offset indent -compact
154.TS
155lB lB lB lB lB lB lB
156r l l l l l l.
157KB	sectrac	secsize	ncyls	speed	heads	flags
1581200	15	2 (512)	80	500	2	MFM
1591232	8	3 (1024)	77	500	2	MFM
1601476	18	2 (512)	82	500	2	MFM
1611440	18	2 (512)	80	500	2	MFM
1621200	15	2 (512)	80	500	2	MFM
163820	10	2 (512)	82	300	2	MFM
164800	10	2 (512)	80	300	2	MFM
165720	9	2 (512)	80	300	2	MFM
166360	9	2 (512)	40	300	2	MFM,2STEP
167640	8	2 (512)	80	300	2	MFM
168.TE
169.Ed
170.It
171720K drives:
172.Bd -ragged -offset indent -compact
173.TS
174lB lB lB lB lB lB lB
175r l l l l l l.
176KB	sectrac	secsize	ncyls	speed	heads	flags
177720	9	2 (512)	80	250	2	MFM
178.TE
179.Ed
180.It
181360K drives:
182.Bd -ragged -offset indent -compact
183.TS
184lB lB lB lB lB lB lB
185r l l l l l l.
186KB	sectrac	secsize	ncyls	speed	heads	flags
187360	9	2 (512)	40	250	2	MFM
188.TE
189.Ed
190.El
191.Pp
192The second form to specify a device density uses
193.Fl s Ar fmtstr
194to explicitly specify each parameter in detail.
195The argument
196.Ar fmtstr
197is a comma-separated list of values of the form:
198.Pp
199.Sm off
200.Ar sectrac , secsize , datalen , gap , ncyls , speed ,
201.Ar heads , f_gap , f_inter , offs2 , flags
202.Sm on
203.Pp
204The meaning of the parameters is:
205.Bl -tag -width ".Ar secsize"
206.It Ar sectrac
207The number of sectors per track.
208.It Ar secsize
209The sector size code, 0 = 128 bytes (or less), 1 = 256 bytes, 2 = 512
210bytes, 3 = 1024 bytes.
211.It Ar datalen
212The actual sector size if the size code is 0, or the (ignored) value
2130xFF for larger size codes.
214.It Ar gap
215The length of the gap 3 parameter for read/write operations.
216.It Ar ncyls
217The number of cylinders.
218.It Ar speed
219The transfer speed in kilobytes per second.
220Can be 250, 300, 500, or
2211000, but each drive type only supports a subset of these values.
222.It Ar heads
223The number of heads.
224.It Ar f_gap
225The length of the gap 3 when formatting media.
226.It Ar f_inter
227The sector interleave to be applied when formatting.
2280 means no
229interleave, 1 means 1:1 etc.
230.It Ar offs2
231The offset of the sector numbers on side 2 (i.e., head number 1).
232Normally, sector numbering on both sides starts with 1.
233.It Ar flags
234A list from one of the following flag values:
235.Pp
236.Bl -tag -width ".Cm +perpend" -compact
237.It Cm +mfm
238Use MFM encoding.
239.It Cm -mfm
240Use FM (single-density) encoding.
241.It Cm +2step
242Use 2 steps per each cylinder (for accessing 40-cylinder media in
24380-cylinder drives).
244.It Cm -2step
245Do not use 2 steps per cylinder, i.e., access each physical cylinder
246of the drive.
247.It Cm +perpend
248Use perpendicular recording (for 2.88 MB media, currently not
249supported).
250.It Cm -perpend
251Use longitudinal recording.
252.El
253.El
254.Pp
255For any missing parameter, the current value will be used, so only
256actual changes need to be specified.
257Thus to turn off a flag bit
258(like
259.Cm +mfm
260which is the default for all drive types), the form with a leading
261minus sign must explicitly be used.
262.Sh EXAMPLES
263A simple inquiry about the drive type:
264.Bd -literal -offset indent
265$ fdcontrol /dev/fd0
2661.44M
267.Ed
268.Pp
269Same as above, but with verbose output.
270Note that the result is about
271the
272.Em "drive type" ,
273as opposed to a
274.Em "device density" ,
275so it is independent from the actual subdevice being used for
276.Ar device .
277.Bd -literal -offset indent
278$ fdcontrol -v /dev/fd0
279/dev/fd0: 1.44M drive (3.5" high-density)
280.Ed
281.Pp
282Inquiry about the density settings:
283.Bd -literal -offset indent
284$ fdcontrol -F /dev/fd0
28518,512,0xff,0x1b,80,500,2,0x6c,1,0,+mfm
286.Ed
287.Pp
288The verbose flag makes this human readable:
289.Bd -literal -offset indent
290/dev/fd0: 1440 KB media type
291        Format:         18,512,0xff,0x1b,80,500,2,0x6c,1,0,+mfm
292        Sector size:    512
293        Sectors/track:  18
294        Heads/cylinder: 2
295        Cylinders/disk: 80
296        Transfer rate:  500 kbps
297        Sector gap:     27
298        Format gap:     108
299        Interleave:     1
300        Side offset:    0
301        Flags           <MFM>
302.Ed
303.Pp
304As indicated, trailing commas in the parameter list may be omitted.
305.Pp
306In order to access archaic 160 KB single-density (FM encoded) 5.25
307media in a modern 1.2M drive, something like the following definition
308would be needed.
309(Note that not all controller hardware is actually
310capable of handling FM encoding at all.)
311.Bd -literal
312# fdcontrol -s 16,128,0x80,0x2,40,300,,0x10,,,-mfm,+2step /dev/fd1.1
313.Ed
314.Pp
315It is still possible to hook up 8" drives to most modern floppy
316controllers, given the right cable magic.
317(On PC hardware, tell the BIOS that it is a 5.25" drive.)
318The classical 128/26/2/77 format can be read with this entry
319.Bd -literal -offset indent
320fdcontrol -s  26,128,0x80,0x2,77,500,2,0x10,,,-mfm /dev/fd0
321.Ed
322.Sh SEE ALSO
323.Xr fdc 4
324.Sh HISTORY
325The
326.Nm
327utility appeared in
328.Fx 2.0 ,
329and was vastly overhauled in
330.Fx 5.0 .
331.Sh AUTHORS
332The program and this man page was contributed by
333.An J\(:org Wunsch ,
334Dresden.
335