Home |
The ISO 9660 File System Structure The exFAT File System Structure RTFiles-32 in Embedded Applications Floppy Disk Driver |
Floppy Disk DriverThe floppy disk driver requires a NEC uPD765A compatible diskette controller used in PC compatible systems at port address 03F0h - 03F7h connected to IRQ 6 and a 8237 compatible DMA controller, whose channel 2 is used for the floppy controller. If the driver should automatically detect the installed drives and drive types, a BIOS CMOS RAM with valid diskette configuration data is also required. DMA BufferThe floppy driver uses DMA to transfer data between the computer's memory and the diskette controller. Some important restrictions apply to such a buffer on PC compatible systems:
The floppy driver will call a system driver function to allocate a DMA buffer. With RTTarget-32's and RTKernel-32's system drivers, the DMA buffer must be located explicitly in the application's RTTarget-32 configuration file with an entry such as: Locate Nothing FloppyDMA Region 18k 32k ReadWrite The name of this Nothing section must be "FloppyDMA". Region must be replaced with a physical (not virtual) RAM region located below 16M. The section must have a size of at least 512 bytes; however, for best performance, a larger buffer (such as 18k for a complete cylinder on a 1.44M diskette in the above example) is recommended. The buffer may not span a 64k boundary, which is achieved by specifying an alignment of at least the size of the buffer or 64k. The DMA hardware bypasses any CPU memory protection, but ReadWrite access is required to enable the driver to access the buffer. If you only need read-only access to floppies, you can also set it to ReadOnly. The DMA buffer is used for all read and write operations. A large buffer allows more sectors to be transferred in a single operation, possibly improving performance. At most, a complete cylinder (2 tracks) of data can be transferred. Thus, it does not make sense to allocate a DMA buffer larger than 2 times the maximum number of sectors per track. For example, if you will be using 1.44M diskettes with 18 sectors per track, the maximum usable DMA buffer size would be 18*2*512 = 18k. For 2.88M diskettes, it would be 36k. The DMA buffer is also used for read-ahead operations. When only a single sector is read, the floppy driver will automatically round up the number of sectors to 4. If and how many sectors are read ahead can be controlled with device flags (see below). When sectors are read which are already present in the DMA buffer, disk access can be avoided. However, whether a read-ahead buffer improves performance depends on the application's characteristics. If the driver does not find the "FloppyDMA" section at run time, any diskette access will return error RTF_DEVICE_RESOURCE_ERROR. RTFDevice.DeviceTypeRTFDevice.DeviceType must be set to RTF_DEVICE_FLOPPY for this driver. RTFDevice.DeviceNumberThis field supports values 0, 1, 2, and 3, for drives A, B, etc. Please note that most PC compatible systems will only support 0 and 1 for drives A and B. RTFDevice.DeviceFlagsApart from device independent device flags documented in section Device List, the following flags can be specified for RTFDevice.DeviceFlags: RTF_CUSTOM_TIMERThis flag instructs the driver not to call the system driver to install a timer callback. The timer callback is required to turn the diskette motor(s) off after a timeout. The use of this flag is recommended when you already have a timer interrupt running or you have a low-priority cyclic task in a multitasking system. In this case, the application can periodically call function RTFFLPYTurnMotorOff. This function should typically be called once per second. It requires very little CPU time and it never blocks. When RTF_CUSTOM_TIMER is not set, the system driver will supply the callback. Under RTTarget-32, the timer interrupt is used for this purpose; for example, an Idle Handler called by RTWait would be a better solution (if supported by the application). The RTKernel-32 system driver will create a task with priority 2 for this purpose. The RTKernel-32 task handle is the public symbol RTFTimerTaskHandle. A dedicated task for this purpose is wasteful. If you already have a low priority cyclic task, use that instead. RTF_MOTOR_TIMEOUT_1This flag instructs the driver to turn the diskette motor(s) off after one second of no access. The default value is two seconds. Large values can improve performance, because turning the motor on requires an extra delay in the driver. On the other hand, head wear can be higher with long timeouts. RTF_MOTOR_TIMEOUT_5This flag instructs the driver to turn the diskette motors off after five seconds of no access. RTF_MOTOR_TIMEOUT_10This flag instructs the driver to turn the diskette motors off after 10 seconds of no access. RTF_READ_AHEAD_0Do not use the DMA buffer to read ahead sectors. By default, a read-ahead value of 4 is used i.e., when the application reads only one sector, four contiguous sectors will be read instead). RTF_READ_AHEAD_2Use a read-ahead value of 2 sectors. RTF_READ_AHEAD_8Use a read-ahead value of 8 sectors. RTF_READ_AHEAD_16Use a read-ahead value of 16 sectors. The floppy driver is not reentrant (this cannot be supported by the diskette controller) and therefore does not support device flag RTF_DEVICE_NEW_LOCK. RTFDevice.DriverThis field must point to RTFDrvFloppy. RTFDevice.DriverDataThe floppy disk driver requires a pointer to a structure of type RTFDrvFLPYData for RTFDevice.DriverData with the following layout: typedef struct { UINT DeviceType; RTF_FPLY_BIOS_Disk_Parameter * DPT; UINT DiskTimeout; UINT ControllerTimeout; UINT Retries; ... } RTFDrvFLPYData; RTFDrvFLPYData.DeviceType specifies the drive type. It can be initialized to 0 or any of the following values:
If set to 0, the driver will enquire the drive type from the BIOS CMOS RAM. Please note that this is only supported if the computer has a CMOS RAM and the drive has been correctly defined in the BIOS setup. You must not specify 0 for device numbers 2 and 3, since the BIOS only has information about diskette drives 0 and 1 (A and B). RTFDrvFLPYData.DPT may be NULL or must point to a valid BIOS Parameter Block for the device. The floppy driver will supply a default BIOS Parameter Block which will work for most drives. If you know that your drives require special values here, please supply an alternate BIOS Parameter Block. RTFDrvFLPYData.DiskTimeout, RTFDrvFLPYData.ControllerTimeout, and RTFDrvFLPYData.Retries default to 2000, 500, and 3 if set to 0. You can override the defaults by supplying non-zero values. The other fields of RTFDrvFLPYData are for the driver's internal use and should be left uninitialized or initialized to 0.
|