FD(4) — NEWS-OS Programmer’s Manual
NAME
fd − NEWS floppy disk interface
SYNOPSIS
controller fc0 at iop0 priority 7
controller fc0 at hb0 priority 20
disk fd0 at fc0 drive 0
disk fd1 at fc0 drive 1
disk fd2 at fc0 drive 2
disk fd3 at fc0 drive 3
controller fc0 at ap0 priority 34
controller fc1 at ap0 priority 34
disk fd0 at fc0 drive 0
disk fd1 at fc1 drive 1
disk fd2 at fc1 drive 2
disk fd3 at fc1 drive 3
DESCRIPTION
The fd interface provides accesses to an internal 3.5" microfloppy disk unit and/or an external floppy disk unit (available only for provided workstations). Internal disk unit has the capability of both accessing a 2DD type (double-tracked, double-sided, double-density) and 2HD type (double-tracked, double-sided, high-density) soft-sectored floppy disk. NWS-3100/5000 Series models supports a 2ED type (double-tracked, double-sided, extra high density) floppy disk, as well. Device whose filename starting with "r" indicates a raw device (major number 5), and others are block device (major number 1).
Multiple Format Function
NWS-1200/1400/1700/3100/3200/3400/3700/5000, PWS-1500/1600 Series models supports multiple format functions which allow to access different formats of the media. Each disk unit has eight device names with different minor numbers. 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. This function is not supported in NWS-800/900/1800/1900/3800 Series models.
External Floppy Disk Unit
In addition to the internal disk unit, the NWS-1400/1700/3400/3700/5000, PWS-1500/1600 series models provide an interface for the external 3.5"/ 5.25"/ 8" floppy disk unit of the NEC PC-9800 series personal computers.
Auto Eject Function
NWS-1200/3100/3200/3400/3700/3800/5000 Series models controls an eject operation of the media with software to avoid removing the media out from the disk drive unit while the device is open (the internal disk unit only). Use ioctl to eject the media when the last open process closes the device. This function is called as eject on close.
Auto Media Capacity Distinction Function
NWS-3100/5000 Series model can automatically distinguish the capacity of the media, set in a floppy disk drive unit, and access the device in the appropriate format type (the internal disk unit only). FD2ED, format type number 13, has another name, FDAUTO, whose name is used in this feature. The special files, which FDAUTO is specified, are accessed in one of FD2DD, FD2HD, or FD2ED format, according to the media set in the drive unit.
Multiple Format non-supported Workstations
By changing special device minor numbers, the following two different formats are available for the NEWS workstations which do not support multiple format functions
devicesminor#typebytess#h#c#formatcapacityrecord
rfh0a,fh00FD2HD51218280E/I1440KBMFM
rfd0a,fd08FD2DD5129280E/I720KBMFM
bytes: sector size, s#: number of sectors, h#: number of heads(sides)
c#: number of cylinders, E/I: ECMA/ISO
Multiple Format Provided Workstations
The provided device driver enables the user to select a desired disk format from the defined multiple format types. In addition, the user can use the ioctl to change various FDC parameters for the format control. That is, each unit is assigned 8 minor device numbers. These 8 devices with different minor numbers are set as one of the following format types as defaults.
Format Type
In the system, 13 format types are defined on NWS-1200/1400/1700/3200/3400/3700, PWS-1500/1600 Series models, and 14 format types are defined on NWS-3100/5000 Series models.
type#typebytess#h#c#formatcapacityrecordrpmSW
0FD2DD5129280E/I720KBMFM - 640KB
1FD2HD51218280E/I1440KBMFM300
2FD2HD102410248277IBM1232KBMFM3601MB
3FD2DDMS95129280IBM720KBMFM - 640KB
4FD2DDMS85128280IBM640KBMFM - 640KB
5FD2DMS95129240IBM360KBMFM - 640KB
6FD2DMS85128240IBM320KBMFM - 640KB
7FD2HDPS51218280IBM1440KBMFM300
8FD2HCAT51215280IBM1200KBMFM3601MB
9FD2DDOA10245277IBM770KBMFM - 640KB
10FD2DDOA025616277IBM616KBMFM - 640KB
11FD1S12812826177IBM250KBFM3601MB
12FD2D25625626277IBM1001KBMFM3601MB
∗13FD2ED(FDAUTO)51236280E/I2880KBMFM
rpm: Spindle motor rotation speed of 3.5inch drive using 2HD media
SW: Position of density selection switch on the back panel
NOTES
A 3.5" disk drive for 2 HD media supports the two types of rotational speeds: 300 rpm (revolutions per minutes) and 360 rpm. An internal disk drive unit uses 300 rpm and an external NEC disk drive unit uses 360 rpm. You cannot use 360 rpm format disk on 300 rpm type disk drive, and vice versa. The user need to select a suitable format type from the disk format types shown above.
If you are to employ an NEC disk drive unit, set the drive unit selection SW to 3/4 on NWS-1200/1400/1700/3200/3400/3700, PWS-1500/1600 Series models. If you are to employ an NEC disk drive unit, set the drive unit selection SW according to the system configuration on NWS-5000 Series models.
The hardware function of the internal 3.5" microfloppy disk unit supports the read operation to a 2D floppy disk. However, it does not support the write access to that type of floppy disk.
A request on a block device unit does not succeed if the sector size is set to bigger than 512 bytes. The user need to request the sector boundary at lseek time for raw devices. When the size of the sector is less than 512 bytes, the user need to request lseek at 512 byte boundary.
type# 13 is defined only on NWS-3100/5000 Series models.
Special Devices and its initial format type
The following format types are set as defaults for each device.
special devicesminor#typetype#Remarks
[inner drive]
(NWS-1200/1400/1700/3200/3400/3700, PWS-1500/1600 Series)
rfd00a/fd00a0FD2HD1same as rfh0a/fh0
(NWS-3100/5000 Series)
rfd00a/fd00a0FDAUTO13auto media capacity distinguish function
rfd01a/fd01a8FD2DD0same as rfd0a/fd0
rfd02a/fd02a16FD2DDMS93
rfd03a/fd03a24FD2DDMS84
rfd04a/fd04a32FD2DMS95
rfd05a/fd05a40FD2DMS86
rfd06a/fd06a48FD2HDPS7
rfd07a/fd07a56FD2DDOA9
[external drive] (NWS-5000 Series only)
rfd10a/fd10a64FD2HD10242
rfd11a/fd11a72FD2DDOA9
rfd12a/fd12a80FD2DDMS93
rfd13a/fd13a88FD2DDMS84
rfd14a/fd14a96FD2DMS95
rfd15a/fd15a104FD2DMS86
rfd16a/fd16a112FD1S12811
rfd17a/fd17a120FD2D25612
[external drive]
rfd20a/fd20a128FD2HD10242
rfd21a/fd21a136FD2DDOA9
rfd22a/fd22a144FD2DDMS93
rfd23a/fd23a152FD2DDMS84
rfd24a/fd24a160FD2DMS95
rfd25a/fd25a168FD2DMS86
rfd26a/fd26a176FD1S12811
rfd27a/fd27a184FD2D25612
rfd30a/fd30a192FD2HD10242
rfd31a/fd31a200FD2DDOA9
rfd32a/fd32a208FD2DDMS93
rfd33a/fd33a216FD2DDMS84
rfd34a/fd34a224FD2DMS95
rfd35a/fd35a232FD2DMS86
rfd36a/fd36a240FD1S12811
rfd37a/fd37a248FD2D25612
Disk with Special Formats
Specify the disk drive unit as a raw device when using different format types for each track. Unexpected errors may happen when a user specifies this as a block device because accesses between buffer cache in a block device do not act in the same way as the system call request.
First, set parameters for the FDC in accordance with the 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.
Here is an example of how to access 8" disk drive unit with IBM format.
cyl#track#sec#typeAccess
001-26FD1S128lseek(0byte),read(128 ∗ 26 bytes)
011-26FD2D256lseek(256 ∗ 26 byte),read(256 ∗ 26 bytes)
Write Protect Check of Media
User can’t write-open write-protected media, because device-driver checks media’s write-protect notch while opening the device.
IOCTL
In this section, the ioctl command is detailed. The following header files should be included in the application program:
#include <newsiop/fdreg.h>NWS-800/900/1800/1900/3800 series
#include <newshbdev/fdc.h>NWS-1200/1400/1700/3200/3400/3700,
PWS-1500/1600 series
#include <newsapbus/fdc.h>NWS-3100/5000
IOCTL common to all NEWS
The following ioctl can be used for all NEWS workstations.
FDIOCFORMAT
The FDIOCFORMAT is used to format a specified track of the floppy disk to be accessed.
int track;
ioctl(fd, FDIOCFORMAT, &track);
IOCTL for supporting multiple format function
The following ioctl can be used only for those NEWS workstations which support multiple format functions.
FDIOCSET
FDIOCGET
These functions are used to set and view FDC parameters of the specified device file. 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/2ED 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/2ED 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.
FDCparam fdcp;
ioctl(fd, FDIOCSET, &fdcp);
ioctl(fd, FDIOCGET, &fdcp);
typedef struct FDCpram{
int nsect; /∗ # sectors/track ∗/
int ntrak; /∗ # tracks/cylinder ∗/
int ncyl; /∗ # cylinders ∗/
int nbytes; /∗ # bytes/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; /∗ transfer 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 doubly 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 from the format types listed above. The selected format type parameter will be set in FDC.
int type;
ioctl(fd, FDIOCSELECT, &type);
FDIOCRESTORETYPE
The FDIOCRESTORETYPE is used to re-initialize the format control parameters for a specified device file.
ioctl(fd, FDIOCRESTORETYPE, 0);
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 cylinder 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 negative. 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:
2DDcylinder == res_c
2Dcylinder == res_c ∗ 2
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;
IOCTL in order to support Auto Eject Function
MTIOCTOP
Set the internal disk drive unit to eject on close.
#include <sys/mtio.h>
struct mtop mt;
mt.mt_op = MTOFFL;
ioctl(fd, MTIOCTOP, &mt);
IOCTL in order to support Auto Media Capacity Distinction Function
Used to get the ID number of the media set in the drive on NWS-3100/5000 Series models. ID number of medias are as follows:
MediaID Number
2ED 0
2HD 1
2DD 2
FDIOCGETMID
Get the ID number of the media set in the drive unit.
int mid;
ioctl(fd, FDIOCGETMID, &mid);
ERRORS
If a system call ends with an error, it returns −1 and the following values are set in the errno (global variable). 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.
[EIO]
The floppy disk drive is not active.
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 / write open
to the write-protected disk.
[EINVAL]
The format parameters have not been specified.
Incorrect arguments were used in an ioctl.
[EFAULT]
The seek operation terminated unsuccessfully.
Or IDs could not be read normally.
Note that related error messages will be logged in the system log 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
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 4.2.1R