How to implement the SYSCALL instruction

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

How to implement the SYSCALL instruction

Post by austanss »

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?
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How to implement the SYSCALL instruction

Post by iansjack »

If only Intel would publish some sort of Programmer's Manual that detailed this sort of thing.
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: How to implement the SYSCALL instruction

Post by austanss »

iansjack wrote:If only Intel would publish some sort of Programmer's Manual that detailed this sort of thing.
I always forget about those...
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: How to implement the SYSCALL instruction

Post by PeterX »

Post Reply