Timer won't work ?!?
Timer won't work ?!?
Can someone look at my code here http://unnamed-0s.googlecode.com/files/ ... -0.0.0.rar and tell me why the f**k the timer wont' work ? I'm stucking with it dor nearly two weeks now
"Programmers are tools for converting caffeine into code."
-
- Member
- Posts: 391
- Joined: Wed Jul 25, 2007 8:45 am
- Libera.chat IRC: aejsmith
- Location: London, UK
- Contact:
Re: Timer won't work ?!?
Try putting
after the init_timer call to enable interrupts.
Code: Select all
__asm__ volatile("sti");
Re: Timer won't work ?!?
well thank you very very very much. But I'm wondering why it keep says "recieved interupt: 6". Why "6" here ?
EDIT: one more silly question: variable 'tick' start at 0. After the first time IRQ0 fired, 'tick' is 1 ( that's fine). But after the second time, it goes to 2097671. WTF is wrong with it ?
EDIT: one more silly question: variable 'tick' start at 0. After the first time IRQ0 fired, 'tick' is 1 ( that's fine). But after the second time, it goes to 2097671. WTF is wrong with it ?
Last edited by quanganht on Wed Dec 31, 2008 8:30 am, edited 1 time in total.
"Programmers are tools for converting caffeine into code."
Re: Timer won't work ?!?
I was looking at your source and Im wondering, why does your code in console.c write to video memory, but it seems like you are setting up protected mode? Does this work?
Re: Timer won't work ?!?
What do you mean? Can you quote the code that make you think so?yemista wrote:I was looking at your source and Im wondering, why does your code in console.c write to video memory, but it seems like you are setting up protected mode? Does this work?
It's can't be. 'Cause GRUB had set up Pmode for me even before my kernel start. All I have to do is load my own GDT, IDT.
"Programmers are tools for converting caffeine into code."
Re: Timer won't work ?!?
Ok I am still learning alot about these things myself, but I thought that you can only access the VGA by writing directly to video memory while in real mode, and if you try to same code in protected mode, not only will the address be interpretted differently, but you wont have the video interrupt like you did in real mode. Would you be able to take a copy of the video interrupt while in real mode, setup pmode, and then set an IDT entry with that code?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Timer won't work ?!?
The VGA interrupt expects that it is being run from real mode. Because of the addressing changes you can't call that code anymore from protected mode.
You can still access the VGA from the standard methods: video memory and I/O ports.
<shameless plug>VGA Hardware</shameless plug>
You can still access the VGA from the standard methods: video memory and I/O ports.
<shameless plug>VGA Hardware</shameless plug>
Re: Timer won't work ?!?
Ok, so now I keep receiving interupt 6, which means 'Undefined OPCode instruction'. Err ?
And if I turn optimization OFF, the machine seems to be triple faulted every time tick reach 1.
And if I turn optimization OFF, the machine seems to be triple faulted every time tick reach 1.
"Programmers are tools for converting caffeine into code."
Re: Timer won't work ?!?
just a guess but try making the tick variable volatile since the timer updates it.
Re: Timer won't work ?!?
I found it out now. It the 'sti' instruction make VMware reset over and over again. But when I compile with -O1 option, triple-fault is replaced by firing interupt 6 'Undefined OPCode instruction'. F**K them.
EDIT: to AlexExtreme: asm volatile ("sti") is stupid, as I read on BrokenThorn:
EDIT: to AlexExtreme: asm volatile ("sti") is stupid, as I read on BrokenThorn:
So there must be somthing *REALLY* wrong with my timer or isr codeAs you know, if we enter protected mode all interrupts must be disabled. If we have not done this, our system will triple fault immediately on the next clock tick.
"Programmers are tools for converting caffeine into code."
-
- Member
- Posts: 391
- Joined: Wed Jul 25, 2007 8:45 am
- Libera.chat IRC: aejsmith
- Location: London, UK
- Contact:
Re: Timer won't work ?!?
No, it's not stupid. It's what you need to do to get interrupts to fire. The fact that its faulting means that your IDT is probably set up incorrectly.quanganht wrote:EDIT: to AlexExtreme: asm volatile ("sti") is stupid, as I read on BrokenThorn:So there must be somthing *REALLY* wrong with my timer or isr codeAs you know, if we enter protected mode all interrupts must be disabled. If we have not done this, our system will triple fault immediately on the next clock tick.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Timer won't work ?!?
Have you tried running the code in bochs and see what it does there (if it breaks it usually does that with more verbose info)?
Re: Timer won't work ?!?
There is no clue of what went wrong. It just ... keep triple-faulting my @ss
"Programmers are tools for converting caffeine into code."
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Timer won't work ?!?
your bochs dump?