Page 1 of 1
IRQ Handler doesn't get called all the time
Posted: Fri Oct 17, 2014 12:44 pm
by gpuJake
Hi, So i'm very much of a beginner in OSDeving. I've been working on a small kernel and following a few different tutorials (BareBones, etc.). Anyway I've come across a problem where when a function gets called from my kernel (Like to test a new feature that I've implemented.) the handlers for my keyboard and PIT stop getting called for some reason. But when that function returns, I get them back. For instance, I noticed that when I was testing my wait() function. It just waits for a certain number of "ticks" (milliseconds) to elapse then it returns but upon investigation, the timer_ticks don't get incremented. And thus, my wait function hangs and never returns.
Any pointers and help would be appreciated. My code can be found here:
https://github.com/JRWynneIII/jForth_Kernel timer code is in timer.c
Thanks!
Re: IRQ Handler doesn't get called all the time
Posted: Fri Oct 17, 2014 4:22 pm
by eryjus
gpuJake wrote:Any pointers and help would be appreciated.
I poked around a little bit. I do not see where you enable interrupts.
Re: IRQ Handler doesn't get called all the time
Posted: Fri Oct 17, 2014 4:47 pm
by gpuJake
Thanks for the reply
In irq.c, at the end of install_irq() I call
then in kernel.c:kernel_main() I call install_irq() before i start my timer.
If i'm not mistaken, that starts interrupts, right?
Re: IRQ Handler doesn't get called all the time
Posted: Sat Oct 18, 2014 8:00 am
by Combuster
You're only properly handling IRQ0 and IRQ1, any other interrupt doesn't get an EOI and break your kernel.
I'm also not exactly sure if I trust your description. How did you test that calling wait() prevents interrups, and returning(?) enables them again?
Re: IRQ Handler doesn't get called all the time
Posted: Sat Oct 18, 2014 12:33 pm
by sortie
Some side notes unrelated to your question:
Code: Select all
#if defined(__linux__)
#error "You are not using a cross-compiler. Exiting."
#endif
You have that in a bunch of files. I added that to the Bare Bones tutorial to catch lazy users not using a cross-compiler. Obviously you are not lazy, there is no need to have it in any of your files. If you really insist, you can just put it in a single file, but most likely your OS won't even build without one (and if it does, that might change in the future). Note how most of those ifdefs in Bare Bones are simply meant to be removed appropriately by the reader. :-)
Your Makefile is not very-Makefile-like. Perhaps study the Makefile I use in my
Meaty Skeleton example.
Code: Select all
movl %esp,%eax # Push us the stack
pushl %eax
You can actually push esp. No need to be complicated here.
Beware. Your malloc doesn't properly align its return values so it can be used for any storage. This might trigger
undefined behavior (scary!). You also don't seem to verify the memory actually exists, but that's not too important when starting out assuming there's a good little chunk of memory at 1 MiB.
You must provide a memset, memcmp, memcpy and memmove. I see you have some of them, but the gcc documentation says you should always have those four as the code generation and optimization may generate calls to them.
You have a single, big system.h header. I recommend breaking that into multipel headers soon. I've seen hobby kernels accumulate huge scary system.h headers. Stuff like memcpy and strlen can fittingly be moved to <string.h>.
(I gave your code a quick, cursory look for common mistakes and I didn't find many, just the above)
Re: IRQ Handler doesn't get called all the time
Posted: Sat Oct 18, 2014 10:11 pm
by gpuJake
I'm only handling IRQ0 and 1 because those are the only ones I currently have implemented. I'm just not done yet haha. Im not good with explanations so I apologize if it was weird. Basically whats happening is in my wait function, it will count the number of milliseconds (ticks of the PIT from IRQ0) until the designated number of milliseconds have elapsed. But for some reason when the wait function gets called, my interrupt handler for both IRQ1 and 0 never gets called so the elapsed millisecond count never gets incrememnted so it never reaches the proper number to exit the wait function.
Thanks for all the pointers, sortie! I'm going back through and fixing those things gradually. I know my makefile isn't the best, i generally wait until my project is complete before i fix my makefile to be more make-ish. Not to mention i'm terrible at make syntax. I've actually been meaning to go back through and break up my "system.h" stuff and break my source into a better fashion like in your Meaty Skeleton tutorial (by the way, thank you for linking it, I've not run across it before and it has good material in it!).
Re: IRQ Handler doesn't get called all the time
Posted: Wed Oct 22, 2014 11:14 am
by gpuJake
Anybody have any idea what my problem is? I still can't figure it out
Re: IRQ Handler doesn't get called all the time
Posted: Wed Oct 22, 2014 3:00 pm
by xenos
It would certainly be helpful to run your code in Bochs and examine the log file.