Floppy Disk Controller: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Added title text and list of fdc chips
Combuster (talk | contribs)
m linkfixing, typofixing
Line 1: Line 1:
The Floppy Disk Controller (FDC) is a (legacy) device that controls hardware for access to 3.5/5.25 inch floppy disks. There are a range of chips that have been produced for this function and include: 8272A, 82078, 82077SL & 82077AA.
The Floppy Disk Controller (FDC) is a (legacy) device that controls hardware for access to 3.5/5.25 inch floppy disks. There are a range of chips that have been produced for this function and include: 8272A, 82078, 82077SL & 82077AA.


==A quick look at Floppy hardware==
==A quick look at floppy hardware==


Floppy controller is programmed through 8 registers accessed from 0x3F0 through 0x3F7 I/O ports. As usual on PC architecture, some of those registers have different meaning depending on whether you read or write them. For extra info, refer to the datasheet (see link below). Note that snippets and datasheets name those registers from their trigrams (e.g. SRA, MSR, DIR, CCR, etc)
Floppy controller is programmed through 8 registers accessed from 0x3F0 through 0x3F7 I/O ports. As usual on PC architecture, some of those registers have different meaning depending on whether you read or write them. For extra info, refer to the datasheet (see link below). Note that snippets and datasheets name those registers from their trigrams (e.g. SRA, MSR, DIR, CCR, etc)
Line 49: Line 49:
*head positions: Before you can read/write to a track, you need to issue a "seek/recalibrate" command to reach that track.
*head positions: Before you can read/write to a track, you need to issue a "seek/recalibrate" command to reach that track.


==How do i read/write to the floppy in [[ProtectedMode]]?==
==How do I read/write to the floppy in [[Protected Mode|protected mode]]?==


You need to re-implement the driver yourself (or find a suitable existing implementation in someone else's work). A complete workflow diagram is available on page 44 of the 82077AA datasheet (see below). Note that most of the time, you may skip some of those steps if you know the former state (e.g. is your motor still spinning ? are you still on the correct track, etc).
You need to re-implement the driver yourself (or find a suitable existing implementation in someone else's work). A complete workflow diagram is available on page 44 of the 82077AA datasheet (see below). Note that most of the time, you may skip some of those steps if you know the former state (e.g. is your motor still spinning ? are you still on the correct track, etc).


====Can i program the floppy without using DMA ?====
====Can I program the floppy without using DMA ?====


Yes. In this case, you will get an interrupt for every byte transferred. You then have to get the byte on the controller and write it in memory. This method can improve the time it takes to transfer the data (up to 10% faster for a rough/inaccurate guess), but the large number of interrupts can cripple CPU performance when other work is being done at the same time (especially for slower computers - AFAIK Windows 95 did this and could cause a 166 MHz Pentium to become entirely unusable during floppy transfers). By using DMA the floppy drive can be working hard without any noticable difference to CPU performance. See the DMA page elsewhere in the OS FAQ [DMA Programming|http://www.mega-tokyo.com/osfaq2/index.php/DMA].
Yes. In this case, you will get an interrupt for every byte transferred. You then have to get the byte on the controller and write it in memory. This method can improve the time it takes to transfer the data (up to 10% faster for a rough/inaccurate guess), but the large number of interrupts can cripple CPU performance when other work is being done at the same time (especially for slower computers - AFAIK Windows 95 did this and could cause a 166 MHz Pentium to become entirely unusable during floppy transfers). By using [[DMA]] the floppy drive can be working hard without any noticable difference to CPU performance.


====What's that "Sense Interrupt" thing ?====
====What's that "Sense Interrupt" thing ?====
Line 61: Line 61:
It mainly allows you to check if an operation has completed or failed. It's also the way you tell the floppy controller that you received the interrupt.
It mainly allows you to check if an operation has completed or failed. It's also the way you tell the floppy controller that you received the interrupt.


====When should i recalibrate/seek ?====
====When should I recalibrate/seek ?====


Unless you set the "implied seek" control bit (EIS using the "configure" command, but this is not supported everywhere), you have to issue a 'seek' command everytime you read/write to another track. Failing to do so might lead to silently reading the wrong track. Recalibration is required only when an error has been encountered while reading/writing (e.g. as part of the 'reset' sequence)
Unless you set the "implied seek" control bit (EIS using the "configure" command, but this is not supported everywhere), you have to issue a 'seek' command everytime you read/write to another track. Failing to do so might lead to silently reading the wrong track. Recalibration is required only when an error has been encountered while reading/writing (e.g. as part of the 'reset' sequence)