Floppy driver tutorial

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Vladaz

Re:Floppy driver tutorial

Post by Vladaz »

Maybe to make a pause:) usleep() is suppose to be in the unistd.h but I can't get that. I think(I'm not sure), that usleep()(or sleep()) uses PIT.
Phugoid

Re:Floppy driver tutorial

Post by Phugoid »

What makes you think it uses the PIT? What if it's implemented on a computer with no PIT - i.e. not a PC? What if the computer it is implemented on doesn't even have a device like the PIT (some embedded system maybe)?

Ask yourself such questions, they will help you design these things on your own.

And "maybe to make a pause" is hardly a specification. Try along the lines of "sleep() causes the scheduler to place the calling thread at the end of the run queue/other scheduling thingy" or "sleep(x) causes the operating system to suspend execution of the thread until at least x seconds have passed." Think about what the manual page for your version of sleep or usleep would say.
dushara

Re:Floppy driver tutorial

Post by dushara »

Code Slasher wrote: If you want, you can declare it as volatile. Doesn't make much difference, as only used in 2 places.

Note: That code is used to show a principle. In my os, the driver actually does to sleep instead of polling.
Sorry don't mean to be knit picking (spelling). But according to my understanding, one of the places you're modifying the variable is at an interrupt handler. Therefore when you're using it in the main body of code, the compiler is unaware that the contents of the variable may change and can optimize it out.

In the line:
while(floppy_int_count <= 0);
floppy_int_count maybe loaded to a register once and and changes to the variable will go unnoticed resulting in an infinite loop.
Vladaz

Re:Floppy driver tutorial

Post by Vladaz »

There is another function:

motor_control()

I couldn't find the implementation of this function as well? Any ideas?
Dex4u

Re:Floppy driver tutorial

Post by Dex4u »

May be turns the motor on or off ?.
I think you are making a lot of work for your self. It's so simple, follow the pedo code in the intel pdf and code each bit untill you have a working driver.
johniak
Posts: 3
Joined: Wed Apr 17, 2013 4:47 pm

Re: Floppy driver tutorial

Post by johniak »

Sorry that I'm writing in this dead topic, but my question probably fits this topic.

I read this tutorial and I think it's very good, but I found function

Code: Select all

wait_floppy_ready(base);
so I thought that it should be probably something like waitFloppyData

Code: Select all

static void waitFloppyReady(){
	while(((inb(FLOPPY_PRIMARY_BASE+MAIN_STATUS_REG))&0xd0)!=IDLE);
}
I don't know that my idea is good. I found somewhere (I don't remember where) that IDLE is equals 0x80, but I don't know that it's true. I'm looking for some datasheet saying about this constants.

I have one more problem, with function:

Code: Select all

seek_track(head,cylinder,drive);
I know that I must send command SEEK, but what after that?

I found something like this but it don't using head,cylinder,drive parameters:

Code: Select all

   writeFloppyCommand(SEEK_TRACK);
   writeFloppyCommand(0);
   writeFloppyCommand(track);
Thanks in advance
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: Floppy driver tutorial

Post by bubach »

have you had a look at my other documents ands snippets on the same server as the tutorial?
full folder listing at http://bos.asmhackers.net/docs/floppy/
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
Post Reply