Floppy driver tutorial
Re:Floppy driver tutorial
This is the wait for floppy int in my driver
It is called like this:
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.
Thats how it works, if your using C, you will need to convert it.
Code: Select all
;----------------------------------------------------;
; 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
Code: Select all
mov [done],0 ; we need to wait
call WaitDone ; for floppy int.
jc FddReadError ; jump to error exit,if timeout.
Also Note this code go in your ISR, so when it firers, it sets [done] to 1.
Code: Select all
or [done],1
Re:Floppy driver tutorial
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?
Re:Floppy driver tutorial
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.
Re:Floppy driver tutorial
@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.
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.
Re:Floppy driver tutorial
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?:)
And I have another question about the another function:
start_dma();
Any ideas?:)
Re:Floppy driver tutorial
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.
Re:Floppy driver tutorial
What's the point of interrupt-driven programming if you're going to convert it into a polling loop?Dex4u wrote: This is the wait for floppy int in my driver
Re:Floppy driver tutorial
It's single tasking.
- 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
http://www.osdev.org/osfaq2/index.php/DMA ?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?:)
Re:Floppy driver tutorial
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?
@ 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?
Re:Floppy driver tutorial
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.
Note: That code is used to show a principle. In my os, the driver actually does to sleep instead of polling.
Re:Floppy driver tutorial
Yes i was waiting for someone to point this out ;D .Candy wrote:What's the point of interrupt-driven programming if you're going to convert it into a polling loop?
As bubach said it single tasking. but maybe if we add multi-threading support, we may rethink this.
Re:Floppy driver tutorial
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:)
Re:Floppy driver tutorial
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.
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.