How to implement the SYSCALL instruction
Posted: Fri Feb 19, 2021 12:18 pm
I didn't name this "How to implement syscalls", because that could refer to an interrupt interface, or sysenter.
I recently got context switching working in my OS. As in, 10 minutes ago. And boy, it felt amazing. I broke a chair. My arms went chockful of adrenaline. IT was bliss.
So, I now know that my keyboard handler works, thus implying interrupts work. And it returns to ring 3 properly.
So now I feel the next step towards writing user code is syscalls. Then I can interface with the screen/keyboard.
I know that the syscall handler needs to be existent, and the address to it should be in the LSTAR MSR.
A) How do I read/write from the LSTAR MSR?
B) What other flags in various other registers do I need to set?
C) What structures may I need to set up?
D) Do I need to alter existing structures?
E) Are there specific things I need to do inside the syscall handler to run/return properly without faults?
I recently got context switching working in my OS. As in, 10 minutes ago. And boy, it felt amazing. I broke a chair. My arms went chockful of adrenaline. IT was bliss.
So, I now know that my keyboard handler works, thus implying interrupts work. And it returns to ring 3 properly.
So now I feel the next step towards writing user code is syscalls. Then I can interface with the screen/keyboard.
I know that the syscall handler needs to be existent, and the address to it should be in the LSTAR MSR.
A) How do I read/write from the LSTAR MSR?
B) What other flags in various other registers do I need to set?
C) What structures may I need to set up?
D) Do I need to alter existing structures?
E) Are there specific things I need to do inside the syscall handler to run/return properly without faults?