Page 2 of 3
Re:What all do I need to achieve this?
Posted: Wed Aug 20, 2003 5:38 pm
by TheChuckster
Tim, if you could pin point me to some code that would do delays, I would be very grateful. Right now I'm using the keyboard (press any key to continue). Good temporary solution!
Re:What all do I need to achieve this?
Posted: Wed Aug 20, 2003 5:48 pm
by Tim
You'll need to start handling the timer interrupt (IRQ 0). If you do this, and increment a clock value on each interrupt, measuring time will be easy.
Re:What all do I need to achieve this?
Posted: Wed Aug 20, 2003 6:04 pm
by TheChuckster
Should I just init the PICS so that IRQ0 starts at 0x20?
Then just inportb 0x20 to find out when the timer goes off?
Re:What all do I need to achieve this?
Posted: Wed Aug 20, 2003 6:23 pm
by Slasher
do you have your idt setup? if you do,you need to write,as Tim just said, an isr for the timer on IRQ0.
A little side info, the x86 in pmode uses the first 32 ints(0 - 31) for its exceptions and faults (read the intel doc,that part is clear
) The PIC has to then be reprogrammed to use int values starting from 32(0x20) upwards(you can choose which ones) to use for interrupts like keyboard,timer etc. Most people use continuous numbers ie for the master pic, ints 0x20 - 0x27 (32 to 39) and the slave pic 0x28 - 0x2f (40 - 47) the way the pic is programed, you only have to supply the starting values for ints on master and slave pics after certain command setting have be issued. the docs on programming the pic are clear and easy to implement.
so your isr for timer on irq0, would have to so something like this (at least until you get signalling implemented in your kernel either though passing messages or a shared semaphore between the timer isr and timer driver/task)
In the asm file,(NASM syntax)
Global _timer_counter,_timer_int
_timer_counter dd 0
_timer_int:
inc dword [timer_counter]
mov al,0x20 ;this is the value to ack ints to PIC
out 0x20,al ;send the value to the PIC
iret
Now, if you programmed the PIC to use 0x20+ for the master then the timer int has to be serviced by the code pointed to by the 0x20th entry in your IDT,keyboard int by entry 0x21,floppy ints by entry 0x26,ps/2 mouse ints by entry 0x2c etc
so you point
idt_table[0x20].function address = address of timer_int
idt_table[0x21].function address = address of keyboard_int
idt_table[0x26].function address = address of floppy_int
....
once you've done this,
all you have to do is poll the global variable timer_counter
until it gets to the value desired
eg
void delay(int milliseconds)
{
while(timer_counter < milliseconds) ; // wait for timer to fire
timer_counter=0; //timer has fired so reset variable after each use!
return;
}
hope this helps and not confuses you ;D
Re:What all do I need to achieve this?
Posted: Wed Aug 20, 2003 6:42 pm
by TheChuckster
Very helpful! I do not have an IDT set up, at least not manually (I'm using GRUB).
By the way, you said you learned this from the Intel docs? Where can I get those?
Re:What all do I need to achieve this?
Posted: Wed Aug 20, 2003 6:54 pm
by Slasher
Try these other Os dev sites
plenty os docs here
http://kos.enix.org/docs.php?lang=en - has the intel Vol 1 to 3 docs
www.osdev.org
Re:What all do I need to achieve this?
Posted: Wed Aug 20, 2003 11:55 pm
by Solar
Re:What all do I need to achieve this?
Posted: Thu Aug 21, 2003 12:09 am
by beyond infinity lazy
oy, solar ... Wouldn't a hint be sufficient instead of wagging the Finger Of Judgement?
Re:What all do I need to achieve this?
Posted: Thu Aug 21, 2003 3:17 am
by Solar
Sorry, you are right. Hint remains, Finger of Judgement edited away.
I've got a "weak spot" there when it comes to seeing people hurling themselves at some large-scope development efforts without having covered the basics. That's not limited to OS development; SourceForge is full of such "projects"... I'm a bit testy when it comes to this, and the reduced signal / noise ratio resulting from it.
Again, my apologies.
Re:What all do I need to achieve this?
Posted: Thu Aug 21, 2003 4:05 am
by beyond infinity lazy
that's, why i for my part prefer to develop silently, working in the background prior to avising a huuuge project aiming at building a egg-laying wool-milk-swine (shall be: eierlegende wollmilchsau - canna translate it properly to english cuz it's kinda "telling nonsense" *rofl*). Since I have the knowledge and know the nitty gritty... ]:->. being an apprentice of the Dark Arts Of OS helps, even in job life *dg*.
Re:What all do I need to achieve this?
Posted: Thu Aug 21, 2003 6:18 am
by Solar
beyond infinity lazy wrote:
...egg-laying wool-milk-swine (shall be: eierlegende wollmilchsau - canna translate it properly to english cuz it's kinda "telling nonsense" *rofl*).
Kind of "Jack of all Trades", or "Swiss Army Knife", with stressing the impossibility (you can't get eggs, wool, milk, and meat from the same animal).
Ich glaube allerdings, Wollmilchsau schreibt man hier gro?...
Re:What all do I need to achieve this?
Posted: Thu Aug 21, 2003 6:49 am
by beyond infinity lazy
hehe ];->
the "jack of all trades" is known as "der Schnittlauch in allen Suppen" here in vienna, altough "Hansdampf in allen Gassen" will be recognized too. as far as I know, the "eierlegende Wollmilchsau" is mostly applied to so called high sophisticated programs that claim to deliver the all of best solution to every problem.
*gg* sorry for omitting that "Gross/klein - schreibung" sometimes. When one is delving deep beneath the crust of OS Secrets, he might forget about such rules ;p.
Re:What all do I need to achieve this?
Posted: Thu Aug 21, 2003 7:22 am
by Eero Ränik
I "delve deep beneath the crust of OS secrets" too, but that doesn't mean I forget about spelling rules of human languages... ::) Maybe because I don't drink milk... ;D
Re:What all do I need to achieve this?
Posted: Thu Aug 21, 2003 7:59 am
by beyond infinity lazy
@eero r?nik:
Oh thou who are wise amongst the wisest, honor is due to thee for thou sharest thy vast knowladge about languages with us ]:->. Wilt thou forgive my faults?
--- snip ---
Well, I 've forgotten to put emphasis on that MIGHT in this very special sentence you have cited. Oh, and I am of cource on too much coffee.
Re:What all do I need to achieve this?
Posted: Thu Aug 21, 2003 8:09 am
by Eero Ränik
I shall... um... think about it... You drink coffee a lot? Like me! I have forgiven! ;D
And we better stop kidding around, unless we don't want to get this thread locked.
That is, if we do want to play like kids, you really should send me a PM...