Who saves the hardware and software context before the system call routine? Is it the processor itself or the software handler?
Thanks.
Advertisement
Answer
Each system call has a wrapper function as already mentioned, each wrapper function triggers interrupt 128, int 0x80, which automatically saves on kernel stack the registers eip, esp, cs, ss, eflags. In the handling function a SAVE_ALL macro is invoked and it will push the rest of the registers on stack, when the system call is served, the values are poped to restore previous state. A iret command is invoked and the CPU pops the 5 registers it saved previously.