This system works simply:
- Program calls call_driver() method.
- This causes interrupt 0x10 (I don't know why I'm using it)
- Then, from kernel side, interrupt handler is executed and it processes command (EAX - code of driver, EBX - function, ECX - data (may be ptr))
- Handler should return result in EDX
Driver call code (program-side):
Code: Select all
unsigned int call_driver(unsigned int drv, unsigned int func,
unsigned int data0) {
int res=0;
__asm__ ("int $0x10"
:"=d"(res)
:"a"(drv), "b"(func), "c"(data0)
:
);
return res;
}
Code: Select all
void isr_handler(registers_t regs)
{
if (interrupt_handlers[regs.int_no] != 0)
{
isr_t handler = interrupt_handlers[regs.int_no];
handler(regs);
}
else
{
puts("Unhandled interrupt: 0x");
puts_h(regs.int_no);
puts("\n");
}
// Just write test value to EDX
__asm__ ("movl $12, %edx");
return;
}
Thanks in advance.