Subject: Re: proposal for MI floppy formatting
To: None <ignatios@cs.uni-bonn.de>
From: John Kohl <jtk@kolvir.arlington.ma.us>
List: tech-kern
Date: 11/17/1996 12:57:43
>>>>> "Ignatios" == Ignatios Souvatzis <ignatios@cs.uni-bonn.de> writes:

Ignatios>    MI floppy formatting proposal:
Ignatios>    $Id: proposal,v 1.2 1996/11/16 17:02:32 jtk Exp $

Ignatios> What is sector_shift supposed to be? The thing otherwise known as
Ignatios> interleave? Else it is missing.

Sector shift was actually not needed (it was related to sector size on
the i386 hardware), and interleave was indeed missing.  Sector size is
there, as "nbps".

Here's an updated version (I have an i386 version working :)

MI floppy formatting proposal:
$Id: proposal,v 1.3 1996/11/16 21:51:19 jtk Exp $

Gordon Ross and Ignatios Souvatzis commented last month on my call for
suggestions on floppy formatting.

Gordon suggested a generic formatting interface with get/set and format
commands, and suggested that we verify any interface is sufficiently
flexible for SCSI floppy formatting.

Ignatios explained how the amiga drivers work (essentially, all software
magic); I think the interface below should work OK for an Amiga; it's
more complicated than the simple "dd" that they can use for formatting
but should be easily implementable for those drivers.

So, here's my first draft proposal for floppy drivers, mostly pulled up
from the existing i386 floppy formatting code.  I haven't a SCSI-2 spec
to verify this with--can someone take a look and see if there are any
additional parameters that could/should be passed in the fdformat_parms?

Floppy diskette drivers provide the following IOCTLs:

FDIOCSETFORMAT(struct fdformat_parms):
	set formatting parameters, using 'struct fdformat_parms'
	the driver saves this state and it persists while the device is open.

FDIOCGETFORMAT(struct fdformat_parms):
	fetch current formatting parameters into 'struct fdformat_parms'

FDIOCFORMAT_TRACK(struct fdformat_cmd):
	format a track on the medium, returning format results
	[I chose a per-track format, since feedback during formatting a
	disk is nice.  An alternative would be a list or range of
	heads/cylinders to format, and an array of success/failure values for
	each one.  Comments welcome]

FDIOCSETOPTS(int):	(useful for avoiding console blurt when hitting
			 media errors)
	set options:
	 FDOPT_NORETRY	/* no retries on failure (cleared on close) */
	 FDOPT_SILENT	/* no error messages (cleared on close) */
FDIOCGETOPTS(int):
	get options

enum fdformat_result {
	FDFORMAT_SUCCESS,
	FDFORMAT_MEDIA_ERROR,		/* hardware reported a formatting
					   error */
	FDFORMAT_CONFIG_ERROR		/* something bogus in parameters */
};

#define FDFORMAT_VERSION 19961117

struct fdformat_cmd {
	u_int formatcmd_version;	/* FDFORMAT_VERSION */
	int head;		/* IN */
	int cylinder;		/* IN */
	enum fdformat_result result;	/* OUT */
};

struct fdformat_parms {
/* list of items taken from i386 formatting glop (NEC 765);
   should be made the union of support needed for other devices. */
    u_int fdformat_version;	/* rev this when needed; write drivers to
				   allow forward compatibility, please,
				   and add elements to the end of the
				   structure */
    u_int nbps;				/* number of bytes per sector */
    u_int ncyl;				/* number of cylinders */
    u_int nspt;				/* sectors per track */
    u_int ntrk;				/* number of heads/tracks per cyl */
    u_int stepspercyl;			/* steps per cylinder */
    u_int gaplen;				/* formatting gap length */
    u_int fillbyte;			/* formatting fill byte */
    u_int xfer_rate;			/* in bits per second; driver
					   must convert */
    u_int interleave;			/* interleave factor */
};