Hi,
viral wrote:
My kernel is now able to run different tasks at a time. All my tasks are void functions() which are running simultaneously. I need a floppy driver to load programs from floppy.
I have a floppy driver which i coded before i started multitasking. So now its not that useful.
Can anyone tell me how to design (I repeat design as i know the code) a floppy driver for a multitask environment.
I'm not too sure if this is useful for you (you may have already done it), but instead of designing the floppy driver I'd suggest designing some form of generic storage device driver interface.
This interface would include low-level facilities for reading/writing raw sectors, handling "media changed" notification, formatting the device, etc.
The same thing applies to file systems - design a common interface and make all file system code comply with it. If this is done correctly, any normal code (applications, etc) should be able to use any file system without caring what it actually is, and any file system code should be able to use any storage device driver (without caring what it actually is).
For most OSs, the "storage device driver specification" and the "file I/O specification" are very closely related, and sometimes they are the same thing (e.g. combined into some sort of "Virtual File System Interface"). This is (IMHO) a better way to do things - it allows you to treat devices and files the same way. For e.g. mounting a file, or copying raw disk images to/from devices.
In the end, writing a device driver means following the interface specification on the OSs side, and following the manufacturers specification on the hardware side. This shouldn't leave much to "design"...
viral wrote:
A floppy read_or_write() function must wait for interrupt from fdc, so when we wait for that interrupt the Timer can preempt the current process. So how to deal with this?
First, I'd ask why it matters if the floppy driver is pre-empted (it'd get control back when the IRQ arrives).
Cheers,
Brendan