Page 1 of 3
Floppy driver tutorial
Posted: Thu Jul 03, 2003 3:30 am
by Slasher
I've attached my first version of the Floppy driver tutorial. Let me know what you think and what could be improved. The mouse driver tutorial is coming soon.
[mirrored] at bos.asmhackers.net
[sub]<pype>if broken, ask me for file md5#18d46e742babaf5e3ebf4f2627f3984d </pype>[/sub]
Re:Floppy driver tutorial
Posted: Thu Jul 03, 2003 12:42 pm
by Tim
That's a pretty good tutorial. A few comments:
*NOTE: __attribute__ ((packed)) is used in djgpp gcc to instruct the compiler not to place extra bytes in the structure in an attempt to align it. ie it should leave the structure as it is. if you are not using djgpp gcc, you can remove it.
This isn't necessary at all for this structure, since it contains only chars. No compiler will put any padding between these fields.
floppy_parameters floppy_disk; /*declare variable of floppy_parameters type*/
memcpy((unsigned char *)DISK_PARAMETER_ADDRESS,(unsigned char *)&floppy_disk,sizeof(floppy_parameters));
Are you sure you want to copy zeroes into the BIOS disk parameter structure? You probably want the first two parameters the other way round. Also, the second (unsigned char*) is unnecessary.
3.wait for an interrupt from the controller
I don't think you mention what interrupt the controller uses (IRQ 6).
Re:Floppy driver tutorial
Posted: Fri Jul 04, 2003 11:55 am
by Slasher
Thanks Tim, I must have gotten my memcpy backwards.
Believe it or not, the one I posted is not the complete one. :'(
Well, this is what is missing:
The floppy uses interrupt line 6 (IRQ 6) for its interrupts. If you have reprogrammed the PIC say to handle the master interrupts from 0x20 and the slave interrupts from 0x28, the the floppy's interrupts should be installed at interrupt service routine 0x26.
An example floppy ISR could be
(NASM format)
Code: Select all
extern _floppy_int_count
_floppy_int:
inc word [_floppy_int_count]
mov al,0x20 ;acknowledge interrupt to PIC
out 0x20,al
iret
then in the C code,
Code: Select all
unsigned short floppy_int_count=0;
void wait_floppy_interrupt()
{
while(floppy_int_count <= 0);
floppy_int_count--;
return;
}
This is one method. Another is to use interprocess communication code such as send and receive to send messages to a floppy server that will handle the interrupts. this is the method i used, as it saves cpu cycles due to the suspension of the server until an interrupt occurs. during that time, another task is allocated the cpu ie running
Re:Floppy driver tutorial
Posted: Thu Jun 30, 2005 1:54 pm
by gmoney
can you send me the source code to your floppy drive please because i have been having trouble comming up with one that work
Re:Floppy driver tutorial
Posted: Fri Jul 01, 2005 12:16 am
by distantvoices
<moody>
Damn, this ain't no source code repository for each and every lazy lad who doesn't want to turn his grey matter around one more time to get a problem solved.
No Source Code Requests! we aren't here to *solve* your problems without you doing your homework -- excessively!
</moody>
I for one have managed to get a decent fdc driver up and running - with the aid of code slashers text. So I don't see why you souhlna be able to do so either.
Just tell: what are you doing? where does your code fail? what steps have you done to narrow the error down? what do you think, why it is failing? whay do you suppose to do for geting it fixed?
Then we might get in to a fairly neat talk, ok?
Re:Floppy driver tutorial
Posted: Fri Jul 01, 2005 12:40 am
by Tora OS
I, personally, like tutorials with source code with them. Not because im lazy...but because i learn from example better than long documents.
Re:Floppy driver tutorial
Posted: Fri Jul 01, 2005 12:49 am
by distantvoices
that tutorial has already some source code in it so you can see what is at least needed to be done - these are the examples.
What pisses me off is this "gimme source gimme source" attitude which is not appropriate at all. Homework is to be done by one himself.
Re:Floppy driver tutorial
Posted: Fri Jul 01, 2005 3:51 am
by Kemp
Quick suggestion, there is a chance the table may be in a different place at startup so it's usually best to get the location from the interrupt table (I think it's in there at least, should check, I forget the exact position) rather than using a fixed address. Good work though, should be quite useful.
Re:Floppy driver tutorial
Posted: Fri Jul 01, 2005 4:09 am
by Dex4u
I agree with beyond infinity, 99% of people just want to rip code, code should only be used for debugging eg: if after reading tut and doc and you have done some code, but it still does not do what you want, than use code to compear the code flow and see if you have miss some thing.
The Intel floppy controller pdf is a great doc compeared to other devices doc.
In short people start OS coding before they know how to program, some people can get away with it and are quick learns, most can not and end up rip bits of code from here and there and wonder why thing do not work, in most case it is easier to write code from the start then try and make some one else's code work in your OS.
You should have at least one major coding project under your belt, before trying to make a OS.
Re:Floppy driver tutorial
Posted: Thu Jan 12, 2006 7:24 am
by Vladaz`
Hello, where can I find that tutorial, because it says in the top, that admin has deleted it.
Thanks in advance.
Re:Floppy driver tutorial
Posted: Thu Jan 12, 2006 7:47 am
by Pype.Clicker
this thread is over 2 years old. YabbSE deletes the attachments after less than this, you know... you're better to contact the guy who posted it and ask him where the tutorial might be now ...
Re:Floppy driver tutorial
Posted: Thu Jan 12, 2006 7:52 am
by Slasher
Hi, I don't have a live website, so some members have mirrored it at this link -
http://bos.asmhackers.net/docs/floppy/d ... torial.txt
Once, I have my own site, I'll rewrite it and add more tutorials
Re:Floppy driver tutorial
Posted: Thu Jan 12, 2006 9:39 am
by Vladaz
Thanks alot:)
Re:Floppy driver tutorial
Posted: Thu Jan 12, 2006 12:21 pm
by Vladaz
I've read that tutorial, but I found some things. Some of the functions weren't covered. Functions like:
kreceive_message();
start_dma();
For now I only need those functions? Can someone help me?
kreceive_message(); suppose to wait until interrupt arrives from the controller. How could I do that?
Re:Floppy driver tutorial
Posted: Thu Jan 12, 2006 12:54 pm
by Dex4u
@Vladaz, Have you got your IDT set up in your OS ?.