Hi
i am new to the world of osdev. read some tutorials and now following JamesM tutorial to get started with the initial learning phase. problem is that i cannot fire the timer interrupt.when i compile timer.c i am getting the following warning
timer.c: In function ‘init_timer’:
timer.c:16: warning: passing argument 2 of ‘register_interrupt_handler’ from incompatible pointer type
i ran the linked file using bochs and the output i am getting is :
unhandled interrupt: 0x6
i have cross checked the code with the source provided along with the tutorial but cannot find out what i am doing wrong.have attached my source files and also i am using gcc 4.2.4 and nasm to compile.
Any help guys.
Thanks
Mayank
cannot fire timer interrupt
cannot fire timer interrupt
- Attachments
-
- source.rar
- (11.41 KiB) Downloaded 52 times
Re: cannot fire timer interrupt
Interrupt 6 is the invalid opcode exception. Most likely, you are hitting some random address, which'll contain invalid code. Try debugging your code in Bochs.mayankgrover wrote:unhandled interrupt: 0x6
JAL
Re: cannot fire timer interrupt
Ok. i am not aware of how to use bochs debugger or gdb. have googled it and started reading some tutorial related to bochs debugging. meanwhile if anyone knows some nice tutorials or links from where i can learn about them do post.
Thanks
Mayank
Thanks
Mayank
Re: cannot fire timer interrupt
Hi,
If you are using the timer interrupt (based on the original post, you are), it looks to me like your stack is getting corrupted somewhere in your IRQ handler. Check the assembly stub - do you have the same number of PUSHes and POPs (or do you add anything to ESP)?
The compilation warning looks very much like a simple type-casting issue. Check that you are passing the function the correct data type, and then apply the appropriate cast. Also check that you are at the right reference level (no extraneous '*' or '&' operator).
Cheers,
Adam
If you are using the timer interrupt (based on the original post, you are), it looks to me like your stack is getting corrupted somewhere in your IRQ handler. Check the assembly stub - do you have the same number of PUSHes and POPs (or do you add anything to ESP)?
The compilation warning looks very much like a simple type-casting issue. Check that you are passing the function the correct data type, and then apply the appropriate cast. Also check that you are at the right reference level (no extraneous '*' or '&' operator).
Cheers,
Adam
Re: cannot fire timer interrupt
i have checked the number of push and pops and seems there is no prob there. But i am not sure about the way IRQ's have been implemented in JamesMolloy tutorial. I think there are a few type errors because of which the program is going nuts. i would like if someone can conform whether there is some error specially with this:AJ wrote:Check the assembly stub - do you have the same number of PUSHes and POPs (or do you add anything to ESP)?
Code: Select all
//isr.h
typedef void (*isr_t)(registers_t);
void register_interrupt_handler(u8int n, isr_t handler);
i am not sure of the data type becuase of the mentioned piece of code.not able to figure out what the typedef statement means. Any help.AJ wrote:Check that you are passing the function the correct data type, and then apply the appropriate cast.
Thanks
Mayank
Re: cannot fire timer interrupt
Hi
Problem solved. I was not sure about the way IRQ were being set up in James Molloy tutorial.So i refered to Bran's tutorial and used the method used for setting up the IRQ's. The only difference being in the way address of the timer handler function is passed to the interrupt_handler_register function. And it worked. Now i am convinced there is some type errors as i mentioned before.Changed my function defination to this
and it worked..
Thanks
Mayank
Problem solved. I was not sure about the way IRQ were being set up in James Molloy tutorial.So i refered to Bran's tutorial and used the method used for setting up the IRQ's. The only difference being in the way address of the timer handler function is passed to the interrupt_handler_register function. And it worked. Now i am convinced there is some type errors as i mentioned before.Changed my function defination to this
Code: Select all
void register_interrupt_handler(u8int n, void (*handler)(registers_t r));
Thanks
Mayank
Re: cannot fire timer interrupt
Hi,
Glad you got it sorted out but I am a little concerned about the following:
Defines a type of function pointer - the the function that has the prototype:
I would assume (without looking at your code or the tutorial) that registers_t is a type of pointer to a structure containing your general purpose and segment registers.
Cheers,
Adam
Glad you got it sorted out but I am a little concerned about the following:
As you continue with OS dev, you will use lots of this kind of thing (function pointers, unusual use of casts and so on...). I would really suggest that you find a good language guide (either online or a book) so that you can familiarise yourself with those parts of the language you may not have used too much in the past. For this specific example:mayankgrover wrote:i am not sure of the data type becuase of the mentioned piece of code.not able to figure out what the typedef statement means.
Code: Select all
typedef void (*isr_t)(registers_t);Code: Select all
void functionName(registers_t)Cheers,
Adam
Re: cannot fire timer interrupt
Hi
Thanks alot AJ for the explanation and advice. I am sure i must have studied it in some textbook but these things do not click until you practice. I will certainly look it up on the net and rest assured i can add one more thing that i learned today.
Thanks once again.......
Mayank
Thanks alot AJ for the explanation and advice. I am sure i must have studied it in some textbook but these things do not click until you practice. I will certainly look it up on the net and rest assured i can add one more thing that i learned today.
Thanks once again.......
Mayank

