Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
will be executed when it's already too late. (Besides the fact that it completely messes up your stack.)
You need assembly for those things.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
A detailed description of the problem would be required. That will require some debugging on your part.
Is your linker resolving references between the 2 files ?
You call some external functions, have you unit tested each of them ?
Have you printed out your IDT ? Was it correct ?
Does the int vector correctly ?
Does it make it to the assembler stub ?
Does it get to the C code ?
Does it ret ?
Does it iret ?
What is the last good instruction that runs ?
By the time you answer these questions you will likely have found and fixed the bug.
If a trainstation is where trains stop, what is a workstation ?
void int50(void)
{
unsigned char *vidmem = (unsigned char *) 0xB8E00;
vidmem[0] = 'U';
// Put a 'freeze' statement here and see if 'U' is actually printed out
// Besides, gerryg400 gave you some important tips
}
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
You could use attribute(naked) in gcc, but it's not available on all architectures.
Nor is it a proper fix for like, anything.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
berkus wrote:True, an interrupt stub in assembly is the best approach.
Edit: or should I say "thunk" instead. Or "trampoline"?
The stub should be present in the PIC/APIC module already, since it also needs to send EOI to the controller, and methods of doing that differs between PIC/APIC. When linking a new interrupt, it is best to supply an IRQ # and callback address to a registering function. When an interrupt happens, either in the PIC or APIC module, the assembly handler would save registers and call the previous callback function (which could be in C/C++). As the callback returns, registers should be restored and an EOI should be sent before doing an iret.