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!
IRQ Handler doesn't get called all the time
- eryjus
- Member
- Posts: 286
- Joined: Fri Oct 21, 2011 9:47 pm
- Libera.chat IRC: eryjus
- Location: Tustin, CA USA
Re: IRQ Handler doesn't get called all the time
I poked around a little bit. I do not see where you enable interrupts.gpuJake wrote:Any pointers and help would be appreciated.
Adam
The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal
"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber
The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal
"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber
Re: IRQ Handler doesn't get called all the time
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?
In irq.c, at the end of install_irq() I call
Code: Select all
__asm__ __volatile__("sti");
If i'm not mistaken, that starts interrupts, right?
- 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: IRQ Handler doesn't get called all the time
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?
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
Some side notes unrelated to your question:
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.
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)
Code: Select all
#if defined(__linux__)
#error "You are not using a cross-compiler. Exiting."
#endif
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
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
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!).
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
Anybody have any idea what my problem is? I still can't figure it out
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: IRQ Handler doesn't get called all the time
It would certainly be helpful to run your code in Bochs and examine the log file.