I copy-pasted the isr_wrapper code and put it in its own file.
To make it visible to C, I put the function signature in the source file where I use it. I'm attempting to fill in the IVT with the relative address of the assembly function. This is what the code looks like:
Code: Select all
extern void isr_wrapper(void);
u32 *ivt;
void ivt_init(){
ivt = (u32*)IVT_BASE;
u32 ptr = &isr_wrapper;
u32 segment = ptr/16;
u32 offset = ptr - (segment*16);
u32 reladd = (segment << 16) | offset;
ivt[9] = reladd; // keyboard
ivt[74] = reladd; // mouse
// Debugging output.
terminal_printf("Segment: %x\n", segment);
terminal_printf("Offset: %x\n", offset);
terminal_printf("IVT Base: %x\n", &ivt[0]);
terminal_printf("IVT Vector 9: %x\n", &ivt[9]);
terminal_printf("ISR Linear Address: %x\n", &isr_wrapper);
terminal_printf("ISR Relative Address: %x\n", reladd);
}
Code: Select all
Symbol table '.symtab' contains 79 entries:
Num: Value Size Type Bind Vis Ndx Name
...
70: 00080310 19 FUNC GLOBAL DEFAULT 1 msr_get
71: 00080e58 0 NOTYPE GLOBAL DEFAULT 1 isr_wrapper
72: 00080760 45 FUNC GLOBAL DEFAULT 1 cstr_hex_from_u32
...
Thank you.