FD(4) — UNIX Programmer’s Manual
NAME
fd − NEWS floppy disk interface
SYNOPSIS
controller fc0 at iop0 priority 7 (NWS-800/900/1800/1900)
controller fc0 at hb0 csr 0x2000 priority 20 (NWS-1700/PWS- 1500)
disk fd0 at fc0 drive 0
disk fd1 at fc0 drive 1 (only for NWS-1700/PWS-1500)
disk fd2 at fc0 drive 2 (only for NWS-1700/PWS-1500)
disk fd3 at fc0 drive 3 (only for NWS-1700/PWS-1500)
DESCRIPTION
The fd interface provides accesses to a internal 3.5" microfloppy disk. This disk unit has the capability of both accessing a 2DD type (double-tracked, double-sided and double-density) and 2HD type (double-tracked, double-sided and a High-density) soft-sectored floppy disk. A minor device number controls floppy disk format.
In addition to the internal disk unit, the NWS-1700/PWS-1500 series models provide an interface for the external floppy disk unit of the NEC PC-9800 series personal computers. For this purpose, the device driver functions were extended.
The provided device driver enables the user to select a desired disk format from multiple formats. That is, each unit is assigned 8 minor device numbers, which allows the user to select a desired disk format from eight formats by changing device names. In addition, the user can use the ioctl to change various parameters for the format control. The disk initialization, read/write operation and ID read operation can be carried out in accordance with the format selected in the above manner.
You can use the ioctl to read the ID portion of each disk sector or check (or view) the current parameters of the specified device file format.
The hardware function of the NEWS internal 3.5" micro floppy disk unit fully supports the read operation to a 2D floppy disk. However, it does not support the write access to that type of floppy disk. If the 2HD format has been selected, the spindle motor rotation speed of the internal 3.5" floppy disk unit will be 300rpm. Note that it cannot maintain the read/write compatibility with a 360rpm disk unit (for example, NEC 3.5" disk drive unit).
Restrictions on read/write start positioning
The lseek(2) can be used to specify the read/write start point. Note that each machine has some restrictions on the positionings as below.
<NWS-800/900/1800/1900 series model>
If you want to start the I/O operation to a "raw" device, data is read/written from/to the device in sector unit (512 bytes). Therefore, the start point for read/write should be positioned on each sector boundary. If you want to start the I/O operation to a "block" device, there are no restrictions.
<NWS-1700/PWS-1500 series models>
Condition: Sector size < 512 bytes
If the I/O operations to a raw device are carried out, the start point for the read/write access should be positioned at 512bytes boundary. Therefore, the read/write start point should not be positioned at odd-numbered sector boundaries if the sector size has been set to 256 bytes. If the I/O operations to a block device, no restrictions should be considered.
Condition: Sector size > 512 bytes
If you used an I/O request to a raw device, the start point for the read/write access should be positioned according to a selected sector size. That is, it should be placed at the disk sector boundaries divided by a sector size. The I/O request to a block device may result in illegal transfer.
NOTES
The device driver supports both block I/O and raw I/O interfaces. For selecting a block I/O operation for FD, set the major number to ’1’. Set the number to ’5’ to start the raw I/O operation.
fd device driver for the NWS-800/900/1800/1900
The two format types, 2DD and 2HD, can be selected as follows:
Type bytes s# h# c# format capacity record
2DD 512 9 2 80 E/I 720KB MFM
2DD 512 9 2 80 E/I 720KB MFM
(bytes=sector size, s#=number of sectors, h#=number of heads(sides), c#=number of cylinders, E/I=ECMA/ISO)
<minor number-file name-format type>
minor# file name type
0 rfh0a/fh0 2HD(double-tracked, double-sided and High-density)
8 rfd0a/fd0 2DD (double-tracked, double-sided and Double-density)
fd device driver for the NWS-1700/PWS-1500
<format types pre-defined>
A desired disk format can be selected from thirteen format types pre-defined in the device driver. The thirteen format types are as follows:
type# type bytes s# h# c# format capacity record dr SW
0 FD2DD 512 9 2 80 E/I 720KB MFM S/N 640KB
1 FD2HD 512 18 2 80 E/I 1440KB MFM SONY
2 FD2HD1024 1024 8 2 77 IBM 1232KB MFM NEC 1MB
3 FD2DDMS9 512 9 2 80 IBM 720KB MFM S/N 640KB
4 FD2DDMS8 512 8 2 80 IBM 640KB MFM S/N 640KB
5 FD2DMS9 512 9 2 40 IBM 360KB MFM S/N 640KB
6 FD2DMS8 512 8 2 40 IBM 320KB MFM S/N 64KB
7 FD2HDPS 512 18 2 80 IBM 1440KB MFM SONY
8 FD2HCAT 512 15 2 80 IBM 1200KB MFM NEC 1MB
9 FD2DDOA 1024 5 2 77 IBM 770KB MFM S/N 640KB
10 FD2DDOA0 256 16 2 77 IBM 616KB MFM S/N 640KB
11 FD1S128 128 26 1 77 IBM 250KB FM NEC 1MB
12 FD2D256 256 26 2 77 IBM 1001KB MFM NEC 1MB
(dr=recommended disk drive unit, S/N=SONY/NEC)
In the above table, some disk drive units are recommended for use. The recommendation is based on the spindle motor rotation speed as previously mentioned. If you are to employ an NEC disk drive unit, set the density selection switch on the back panel to the proper position in accordance with each SW data. In addition, set the drive unit selection SW to 3/4.
<minor number-file name-format type>
The use of the minor number and specification of a device file name are discussed next.
∗ Minor number
bit (b7 − b0)
UUFFFPPP
UU=unit#, FFF=format slot#, PPP=partition# Bits 3 to 5 (FFF) are used to for format identification.
You can specify one format for each slot. Therefore you can use 8 kinds of format only by changing device file name.
∗ device file name(raw/block)
rfdxya/fdxya
x=unit#, y=format slot#, a=partition a
Device files are created by using the MAKEDEV command. The correspondence between minor numbers, special file names and initial format types is shown in the table below.
minor# file name type type# Remarks
0 rfd00a/fd00a FD2HD 1 same as rfh0a/fh0
8 rfd01a/fd01a FD2DD 0 same as rfd0a/rd0
16 rfd02a/fd02a FD2DDMS9 3
24 rfd03a/fd03a FD2DDMS8 4
32 rfd04a/fd04a FD2DMS9 5
40 rfd05a/fd05a FD2DMS8 6
48 rfd06a/fd06a FD2HDPS 7
56 rfd07a/fd07a FD2HCAT 8
128 rfd20a/fd20a FD2HD1024 2
136 rfd21a/fd21a FD2DDOA 9
144 rfd22a/fd22a FD2DDMS9 3
152 rfd23a/fd23a FD2DDMS8 4
160 rfd24a/fd24a FD2DMS9 5
168 rfd25a/fd25a FD2DMS8 6
176 rfd26a/fd26a FD1S128 11
184 rfd27a/fd27a FD2D256 12
192 rfd30a/fd30a FD2HD1024 2
200 rfd31a/fd31a FD2DDOA 9
208 rfd32a/fd32a FD2DDMS9 3
216 rfd33a/fd33a FD2DDMS8 4
224 rfd34a/fd34a FD2DMS9 5
232 rfd35a/fd35a FD2DMS8 6
240 rfd36a/fd36a FD1S128 11
248 rfd37a/fd37a FD2D256 12
Disk with special formats
The lseek operation should be carefully handled if disk format varies depending on each track.
First, set parameters for the FDC in accordance with format of a disk block to be accessed. The lseek operation can be then started on the assumption that the format of that disk block can apply to the whole disk space. During the lseek operation, the skipped blocks (to be accessed) are not actually accessed.
Note that a read error will be detected if dd command is executed. If dd command is used, the contents of the disk blocks specified by the skip value are actually accessed. In this case, a read error will be detected if the format of a block to be read is different from that the FDC parameter setting, thereby disabling a read access to the target block.
IOCTL
In this section, the ioctl command is detailed. The following header files should be included in the application program:
#inlude <news800iop/fdreg.h>.....NWS-800/900 series
#include <news1800iop/fdreg.h>.....NWS-1800/1900 series
#include <newshbdev/fdc.h>.....NWS-1700/PWS-1500 series
IOCTL(common to NWS-800/1800/1900/1700/PWS-1500 series)
FDIOCFORMAT
The FDIOCFORMAT is used to format a specified track of the floppy disk to be accessed. It is only the function used on the NWS-800/900/1800/1900 series models. usage:
int track;
ioctl(fd, FDIOCFORMAT,&track);
IOCTL(available only on the NWS-1700/PWS-1500 series models)
The following functions can be used only on the NWS-1700/PWS- 1500 series models.
FDIOCSET
This function is used to set FDC parameters (manual setting).
The sx2 flag is used to perform the seeking on every other cylinder. If you are to make an access to a 2D type floppy disk (5/3.5"), set this flag to ’1’. Note that the cylinder-to-cylinder space of a 2D type floppy disk is twice that of a 2DD/2HD type floppy disk.
If the seek operation is carried out to cylinder 17 with the sx2 flag set to ’1’, cylinder 34 on a 2DD/2HD floppy disk will be reached.
Generally if a 2D type floppy disk is driven by a 2DD/2HD floppy disk drive unit (called a high-density drive), the read operation between them will be guaranteed. That is, the data written into the 2D type floppy disk by the 2D floppy disk drive unit can be read by the 2DD/2HD drive unit. However, the data written into the 2DD/2HD type floppy disk by the high-density drive may not be read by the 2D disk drive.
Note 1: If the NEWS internal floppy disk drive unit (unit 0) is accessed, the EXT_VFO mode cannot be specified.
Note 2: If the 8" floppy disk drive unit is to be used, the cylinder number exceeding 77 should not be specified.
usage:
FDCparam fdcp;
ioctl(fd,FDIOCSET,&fdcp);
typedef struct FDCpram{
int nsect; /∗ # sectors/track ∗/
int ntrak; /∗ # tracks/cylinder ∗/
int ncyl; /∗ # cylinders ∗/
int nbytes; /∗ # byts/sector/(fd_length) ∗/
int n; /∗ sector length code(fd_n) ∗/
int gsl; /∗ GSL ∗/
int gpl; /∗ GPL ∗/
int mf; /∗ mfm mode(1=MFM,0=FM) ∗/
int ninterl; /∗ interleave(fd_interleave) ∗/
int trspd; /∗ tarnsfer speed ∗/
int fomt; /∗ format(ECMA_ISO,IBM) ∗/
int vfomode; /∗ VFO mode(ext=1/int=0) ∗/
int srt; /∗ SRT ∗/
int hut; /∗ HUT ∗/
int hlt; /∗ HLT ∗/
int sx2; /∗ seek doublly flag ∗/
int widd; /∗ write-id data ∗/
}FDCparam;
#define MFM 1
#define FM 0
#define IBM 0
#define ECMA_ISO 1
#define EXT_VFO 1
#define INT_VFO 0
FDIOCSELECT
The FDIOCSELECT is used to specify a floppy disk format type.
The selected format type parameter will be set in FDC.
usage;
int type;
icotl(fd,FDIOCSELECT,&type);
You can specify a desired format type in the type field. A desired format type can be selected from the format types listed in <format types pre-defined> table.
FDIOCREADID
The FDIOCREADID is almost the same as the READID command of FDC. FDIOCREADID seeks a specified cylinder first and then starts the READID command. Note that the seek operation to that cylider is carried out normally (as in case of a 2DD/2HD floppy disk). Note that this seek operation is performed, irrespective of the sx2 flag specification.
The c, h, r, and n values of the first sector of an accessed cylinder are returned. The return value will be ’0’ if the read operation has terminated successfully. Otherwise, the value will be nagative.
As the seek operation is carried out in the above manner, you can use the return values from cylinders with odd numbers except for ’0’ to determine whether the floppy disk now being accessed is a 2DD or 2D type one. The relationship between a specified cylinder and return value res_c is as follows:
2DD cylinder == res_c
2D cylinder == res_c ∗ 2
usege:
FDCid fdcid;
ioctl(fd,FDIOCREADID,&fdcid);
typedef struct FDCid{
int cylinder; /∗ physical cylinder # ∗/
int head; /∗ head ∗/
int res_c; /∗ result: cylinder ∗/
int res_h; /∗ result: head ∗/
int res_r; /∗ result: sector ∗/
int res_n; /∗ result: rec length code ∗/
}FDCid;
FDIOCRESTORETYPE
The FDIOCRESTORETYPE is used to re-initialize the format control parameters for a specified device file.
usage:
ioctl(fd, FDIOCRESTORETYPE,0);
FDIOCGET
The FDIOCGET is used to view the parameters of the specified device file.
usage:
FDCparam fdcp;
ioctl(fd, FDIOCGET, &fdcp);
ERRORS
If a system call ends with an error, the following values are set in the errno (groval varialble). Therefore, the user can identify what has caused the error by viewing the content of that area.
#include <sys/errno.h>
extern int errno;
ENXIO
The illegal ’open’ system call has been issued. The system call with an incorrect unit number may be used. For example, the unit number is ’1’.
EIO The floppy disk drive is not active yet, although the "open" system call, FDIOCFORMAT or FDIOCREADID was used by program. It is ’Drive not ready.’ This error is detected if the floppy disk media has not been mounted on the drive unit at the open system call.
EACCES
User has made a write operation to the write-protected disk.
EINVAL
The format parameters have not been specified. Incorrect arguments were used in an ioctl.
EFAULT
The seek operation started by the FDIOCFORMAT or FDIOCREADID terminated unsuccessfully. Or IDs could not be read normally. Note that related error messages will be displayed on the console if the EFAULT, EACCES and EIO are set in the errno area at read/write/format operation.
FILES
/dev/fh0 /dev/rfh0a
/dev/fd0 /dev/rfd0a
/dev/fd[0-3][0-7]a /dev/rfd[0-3][0-7]a
SEE ALSO
format(8), newfs(8), mkfs(8), tar(1)
BUGS
When you remove a mount(8)ed floppy disk from a drive unit, you have to execute the umount(8) command in advance.
NEWS-OSRelease 3.3