Yay, new year! I got some decent-looking ideas about interrupt system. If we make some bunch of already-existing dummy interrupt handlers that calls actual interrupt handler and register the handlers in advance, we can effectively minimize the hardware part when registering interrupt. Say, we declare these dummy functions and register to interrupt beforehand :
void interrupt_handler0(void);
void interrupt_handler1(void);
void interrupt_handler2(void);
void interrupt_handler3(void);
void interrupt_handler4(void);
void interrupt_handler5(void);
void interrupt_handler6(void);
...
And make them to call the function that is stored to some kind of manager. (Something like "interrupt function manager") That way the manager acts like some kind of "buffer" that works between hardware and kernel.
// this is pseudo code!
void interrupt_handler0(void) {
// array that contains all the "real" interrupt functions ptr
interrupt_function *functions_array = manager.get_functions_array();
// call the real handler
functions_array[0]();
}
void interrupt_handler1(void) {
interrupt_function *functions_array = manager.get_functions_array();
functions_array[1]();
}
void interrupt_handler2(void) {
interrupt_function *functions_array = manager.get_functions_array();
functions_array[2]();
}
...
.. Now to make everything work, we just register these to IDT(or other..) in advance.
...
register_interrupt_idt(0 , interrupt_handler0 , ...);
register_interrupt_idt(1 , interrupt_handler1 , ...);
register_interrupt_idt(2 , interrupt_handler2 , ...);
register_interrupt_idt(3 , interrupt_handler3 , ...);
...
Not sure if I explained this correctly...
This system is particularly useful when you have interrupts that has no "interrupt vector number" and only requires handler to be registered. (Like LAPIC_TIMER_INTERRUPT) But when you use this in "general interrupt"(interrupt that has interrupt vector via an interrupt descriptor table,) it's very inefficient and not quite effective.