interrupt service routine for syscall with return value
Posted: Wed Jul 11, 2012 9:00 pm
In JamesM's kernel tutorials, he used the same assembly stub for interrupt service routines and syscalls. However, I guess the popa instruction will overwrite %eax, which holds the return value if a syscall has one (eg. pid_t fork()). As a result, the current implementation will return the system call number back, as it was stored in %eax, which seems useless. So I explicitly pushed and popped every general purpose register except for %eax when it comes to syscalls. Does that sound reasonable? At least now fork() works for me..
Code: Select all
pusha ; Pushes eax,ecx,edx,ebx,esp,ebp,esi,edi, in order
...
call isr_handler ; Call into our C code.
...
popa ; Pops edi,esi,ebp...