OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 23, 2017 12:25 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 37 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Floppy driver tutorial
PostPosted: Thu Jul 03, 2003 3:30 am 
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]


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jul 03, 2003 12:42 pm 
That's a pretty good tutorial. A few comments:
Quote:
*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.
Quote:
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.
Quote:
3.wait for an interrupt from the controller

I don't think you mention what interrupt the controller uses (IRQ 6).


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jul 04, 2003 11:55 am 
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:
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:
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


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jun 30, 2005 1:54 pm 
can you send me the source code to your floppy drive please because i have been having trouble comming up with one that work


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jul 01, 2005 12:16 am 
Offline
Member
Member

Joined: Wed Oct 18, 2006 11:59 am
Posts: 1600
Location: Vienna/Austria
<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?

_________________
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image


Top
 Profile  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jul 01, 2005 12:40 am 
I, personally, like tutorials with source code with them. Not because im lazy...but because i learn from example better than long documents.


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jul 01, 2005 12:49 am 
Offline
Member
Member

Joined: Wed Oct 18, 2006 11:59 am
Posts: 1600
Location: Vienna/Austria
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.

_________________
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image


Top
 Profile  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jul 01, 2005 3:51 am 
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.


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jul 01, 2005 4:09 am 
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.


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 7:24 am 
Hello, where can I find that tutorial, because it says in the top, that admin has deleted it.

Thanks in advance.


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 7:47 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5959
Location: In a galaxy, far, far away
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 ...

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 7:52 am 
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


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 9:39 am 
Thanks alot:)


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 12:21 pm 
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?


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 12:54 pm 
@Vladaz, Have you got your IDT set up in your OS ?.


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group