FDC(4)

NAME
fd - micro diskette drive.

DESCRIPTION
Files in the directory /dev whose names are of the form: fd{f,v}{256,512,1024} or rfd{f,v}{256,512,1024} are block and character devices respectively which refer to the built-in micro diskette drive using various sector sizes and layouts. There are 6 block devices and 6 character (raw) devices. There may also be names of the form: fd{f,v}{256,512,1024}{a,b} or rfd{f,v}{256,512,1024}{a,b} which allow use of a second micro diskette drive, if fitted; those ending in "a" are equivalent to those without such a suffix in referring to drive zero, while those ending in "b" refer to the second drive, drive one, with parameters identical to those of the corresponding drive zero. In the discussion below, mention of any device pertains equally to that device name suffixed with "a" or "b".

The device [r]fdf256 uses 2560 256-byte sectors physically laid out on the disk surfaces in a manner similar to the "ADFS" format used on the British Broadcasting Corporation Master Compact Microcomputer 3.5 inch disk. The device [r]fdf512 uses 1440 512-byte sectors physically laid out in a manner similar to MS-DOS 720Kbyte floppy format. The device [r]fdf1024 uses 800 1024-byte sectors physically laid out in a manner similar to the "ADFS" format used by Acorn Archimedes computers' native operating system. This is the recommended format.

The devices [r]fdv256, [r]fdv512 and [r]fdv1024 are devices which may have sector sizes, interleave etc arbitrarily varied, but which are initialised at system boot time to the same parameters as [r]fdf256, [r]fdf512 and [r]fdf1024 respectively.

Note that in all cases the formats referred to above are followed in respect of the physical addressing and size of data sectors on the disc, but the logical structure of data stored in the sectors is not in the driver's control, i.e. ADFS or MSDOS directories, free-space maps etc are not created or maintained by the device driver, it is just the order of access of tracks, sector size and interleave parameters which are determined by the device. Thus it is entirely up to the code using the driver how the data stored in the sectors is interpreted or constructed.

Only one type of device may be opened at once.

Ioctl(2) commands are available on the raw devices (whose names begin with `r') to format diskettes according to the ISO specification, to enquire about the sector size and interleave parameters, and to download sector size and interleave information onto the devices which permit user definition.

The following ioctl(2) commands are available. The constants and structure definitions are all given in the header file <fdioctl.h>. In all the descriptions fd represents a file descriptor open to the raw device.

ioctl(fd, XIOCFORMAT, &result) formats the diskette according to the current sector size, number of tracks and sectors. If the format operation is successful, the int value result is set to zero. Otherwise result is set to a bit pattern consisting of the value

    0xF1000000	if an error occurred seeking to a track or
    0xF2000000 	if an error occurred writing a track
    + 0x100		if the error occurred on the second side
    + track number

The first error encountered causes the format operation to be aborted.

ioctl(fd, XIOCGPARM, &layout) reports the sector size and interleave parameters for the device. Layout is a structure of the following format:

    struct	xiocparm	{
    	unsigned  char	fd_bytes;	/*  Bytes/sector / 256  */
    	unsigned  char	fd_sects;	/*  Sectors/track  */
    	unsigned  char	fd_tracks;	/*  Tracks per side  */
    	unsigned  char	fd_interleave;	/*  Interleave factor  */
    	unsigned  char	fd_skew;	/*  Intertrack skew  */
    	unsigned  char	fd_inittrack;	/*  Track to start at  */
    	unsigned	fd_snstart : 1;	/*  Sector nos start at 0 or 1  */
    	unsigned	fd_cylmode : 1;	/*  0 surface by surface 1 cyl  */
    	unsigned	fd_backside : 1;	/* 2nd side goes backwards */
    	unsigned	fd_hardskew : 1;	/* skew applied at format time */
    };

Interleave values of 0 and 1 are synonymous.

The field fd_inittrack is provided as some diskette formats commence at other than the first track on the diskette, run to the end and then start at the beginning again.

The field fd_backside is only defined if surface mode is selected; this means that the second side is accessed moving outwards from the centre of the diskette.

The field fd_hardskew determines whether the skew and interleave parameters are applied when the diskette is formatted (1) or as a remapping when the diskette is read or written (0).

ioctl(fd, XIOCSPARM, &layout) may only be applied to the variable devices rfdv256, rfdv512 and rfdv1024. A pointer to an instance of the above structure is passed, and the parameters are installed for the device. Once they have been installed, they remain unchanged, even if the device is closed, until reset or the system is rebooted. It is the responsibility of the user to ensure that the parameters are sensible. Note that setting a variable device's parameters can only be done via the raw interface to the device (/dev/rfdvnnn), but the changes are immediately reflected in the behaviour of the corresponding block interface (/dev/fdvnnn).

The standard parameters for the fixed-format devices, and the initial values of the variable-format devices are as follows:

    Device	Sector size	Sectors/	Surface/	Sector	Skew
    Number	bytes	Track	Cylinder	Numbering
    256	256	16	Surface	0	0
    512	512	9	Cylinder	1	0
    1024	1024	5	Cylinder	0	0

In all cases the skew type is "hard" and there is no interleave.

The command ioctl(fd, XIOCSSTD, arg) resets one of the variable devices rfdv256, rfdv512 or rfdv1024 to a standard format, given by the integer value arg, which may be XST0, XST1 or XST2 to set to the same formats as rfdf1024, rfdf256 and rfdf512 respectively.

FILES
/dev/fdf*    - fixed format block devices
/dev/fdv*    - variable format block devices
/dev/rfdf*    - fixed format raw devices
/dev/rfdv*    - variable format raw devices

SEE ALSO
ffd(8), adfsls(1), adfscat(1), adfscp(1), adfsrm(1), wradfs(1), msdosls(1), msdoscat(1), msdoscp(1), msdosrm(1), wrmsdos(1).

DIAGNOSTICS
Various error conditions are noted, and appropriate messages are output on the console.

LIMITATIONS
The raw devices are restrictive in the disc position and size of data transfer requests made using read/write calls. All requests must be aligned with respect to the start of the disc in units of 512 bytes or the disc sector size, whichever is larger; the length of a request must similarly be an integral multiple of this number. Failure to comply with these requirements will cause an error to be returned.

It is a limitation of the current block device interface (for all block devices, not just the floppy disc devices) that attempts to write beyond the end of a disc or disc partition will fail silently, with no error reported or returned to the user. Such an attempt made on the raw interface will return the error ENXIO.

Inappropriate sector sizes etc (e.g. sector size 768), given when size and interleave parameters are installed on a variable device, will not be detected until later, when the sectors prove to be of some random different length.