OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 11:23 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 3:08 pm 
Yes, I have:)


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 4:19 pm 
This is the wait for floppy int in my driver
Code:
;----------------------------------------------------;
; Wait Done                 ;waits for a floppy int. ;
;----------------------------------------------------;

WaitDone:
mov   [Timer],30  ; 20 = about 1 second,we use (1.5 seconds).
mov   [TimerOn],1  ; start couting.
WaitDoneLoop:
mov   al,[TimerOn]  ; we test if
or    al,al                ; timeout is up yet?.
jz    WaitDoneError  ; if it is we exit,with error.
mov   ax,[done]       ; if not we check for floppt int.
or    ax,ax
jz    WaitDoneLoop ; if not do another loop.
clc                         ; we end here if we have a int:-)
ret

WaitDoneError:      ;we end up here if we run out of time:-(.
stc
ret

It is called like this:
Code:
mov   [done],0  ; we need to wait
call  WaitDone  ; for floppy int.
jc    FddReadError  ; jump to error exit,if timeout.

And here is what appans whan a floppy int comes
Also Note this code go in your ISR, so when it firers, it sets [done] to 1.
Code:
or    [done],1


Thats how it works, if your using C, you will need to convert it.


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 5:17 pm 
So that's just makes a thing "where to go if something happens". But how to check that floppy interrupt, when it comes and else? I mean, maybe there you have to check some port or anything else or is it enough?


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 5:29 pm 
Uh. You have to write an interrupt handler that will set the byte at "done" to use that code, as Dex4u just pointed out. You don't directly "check" for when an interrupt comes. It just comes and interrupts you. It causes the processor to drop what it's doing and execute the code in the appropriate interrupt handler. When the interrupt handler is finished, the processor resumes executing the code that was interrupted. You can think of it as subroutine that can be called by devices.


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 5:34 pm 
@Vladaz.
You miss understand the code, first the var [done] is set to 0 , when the floppy irq fires, it sets the [done] var to 1 .
We test the var [done] if its 0, we loop, if its 1 we exit with no error, if it has not fired by 1.5 seconds we exit with a timeout error.

The "or [done],1 " code goes in your floppy ISR.


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 5:38 pm 
Oh. Now I get it:) But how Floppy Interrupt can know when to fire?:)

And I have another question about the another function:
start_dma();
Any ideas?:)


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 6:17 pm 
I can not see how you have got your IDT working, but do not know about hardware int's and software int's and things like Dma, i think you should read up on these before going on with your floppy driver.


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Thu Jan 12, 2006 11:43 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3882
Location: Eindhoven
Dex4u wrote:
This is the wait for floppy int in my driver


What's the point of interrupt-driven programming if you're going to convert it into a polling loop?


Top
 Profile  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jan 13, 2006 4:17 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 1223
Location: Sweden
It's single tasking.

_________________
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub


Top
 Profile  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jan 13, 2006 4:26 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
Vladaz wrote:
Oh. Now I get it:) But how Floppy Interrupt can know when to fire?:)

And I have another question about the another function:
start_dma();
Any ideas?:)


http://www.osdev.org/osfaq2/index.php/DMA ?

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jan 13, 2006 6:07 am 
Hi I don't know how to reply to an individual message so I'm writing here:

@ Code Slasher,

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;
}


shouldn't floppy_int_count be declared volatile?


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jan 13, 2006 7:45 am 
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.


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jan 13, 2006 10:53 am 
Candy wrote:
What's the point of interrupt-driven programming if you're going to convert it into a polling loop?

Yes i was waiting for someone to point this out ;D .
As bubach said it single tasking. but maybe if we add multi-threading support, we may rethink this.


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jan 13, 2006 2:00 pm 
And actually, I'm now searching for the information about making the functions usleep() or sleep(). I will appreciate any good ideas. Or maybe even source code:)


Top
  
 
 Post subject: Re:Floppy driver tutorial
PostPosted: Fri Jan 13, 2006 2:43 pm 
Hi,

I've got two good ideas:
1. Tell us what sleep and usleep are supposed to do.
2. Come up with the solution completely on your own without asking for source code, and learn from it.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot], Majestic-12 [Bot], MichaelPetch and 107 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