Floppy driver tutorial
Floppy driver tutorial
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]
[mirrored] at bos.asmhackers.net
[sub]<pype>if broken, ask me for file md5#18d46e742babaf5e3ebf4f2627f3984d </pype>[/sub]
Re:Floppy driver tutorial
That's a pretty good tutorial. A few comments:
This isn't necessary at all for this structure, since it contains only chars. No compiler will put any padding between these fields.*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.
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.floppy_parameters floppy_disk; /*declare variable of floppy_parameters type*/
memcpy((unsigned char *)DISK_PARAMETER_ADDRESS,(unsigned char *)&floppy_disk,sizeof(floppy_parameters));
I don't think you mention what interrupt the controller uses (IRQ 6).3.wait for an interrupt from the controller
Re:Floppy driver tutorial
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)
then in the C code,
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
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
Code: Select all
unsigned short floppy_int_count=0;
void wait_floppy_interrupt()
{
while(floppy_int_count <= 0);
floppy_int_count--;
return;
}
Re:Floppy driver tutorial
can you send me the source code to your floppy drive please because i have been having trouble comming up with one that work
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Floppy driver tutorial
<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?
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?
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:Floppy driver tutorial
I, personally, like tutorials with source code with them. Not because im lazy...but because i learn from example better than long documents.
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Floppy driver tutorial
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.
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.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:Floppy driver tutorial
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
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.
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
Hello, where can I find that tutorial, because it says in the top, that admin has deleted it.
Thanks in advance.
Thanks in advance.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Floppy driver tutorial
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
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
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
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?
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?