Extern "C" and inline assembly - A solution for ISRs on GCC?
Posted: Wed Aug 20, 2014 6:04 pm
I noticed the wiki explains that GCC doesn't have a way to make "naked" functions (without the normal function bounding instructions, enter, leave, and ret) for ISRs on x86. I wonder if I've discovered something novel in that case, though I hardly expect so.
Declare an extern "C" method,
then, in an assembly block,
Obviously, the method actual_handler will also have to be declared extern "C", and defined elsewhere in the kernel. One could further parameterize actual_handler according to their ABI.
Is this what people already use, and I just thought I devised it myself? Do people normally split the implementation into its own assembly source file? That would make sense for a more realistic ISR, probably -- one that takes note of its environment before calling into the kernel.
Declare an extern "C" method,
Code: Select all
extern "C" void interrupt_handler();
Code: Select all
asm("interrupt_handler:\n
call actual_handler\n
iret");
Is this what people already use, and I just thought I devised it myself? Do people normally split the implementation into its own assembly source file? That would make sense for a more realistic ISR, probably -- one that takes note of its environment before calling into the kernel.