Hello. I?d like to know with a simple example how to implement a simple syscall in assembly.
Thanks.
Syscall
Re:Syscall
I take it you mean for x86.
In kernel mode, set up the IDT with a syscall interrupt (say index 0x80) which can be triggered from user mode. The handler for this interrupt has a syscall table and takes a parameter (in eax) which is the syscall number. It looks up the number in the table and dispatches the request (typically the table is an array of function pointers).
The user program raises a software interrupt ("int 0x80" in this example), with eax set to the syscall number it wants.
Parameter passing is left as an excersize to the reader.
In kernel mode, set up the IDT with a syscall interrupt (say index 0x80) which can be triggered from user mode. The handler for this interrupt has a syscall table and takes a parameter (in eax) which is the syscall number. It looks up the number in the table and dispatches the request (typically the table is an array of function pointers).
The user program raises a software interrupt ("int 0x80" in this example), with eax set to the syscall number it wants.
Parameter passing is left as an excersize to the reader.
Re:Syscall
sysenter/sysleave and syscall/sysret don't work on all x86 processors if I remember rightly. I'd suggest starting with interrupts and adding those pairs as options depending on what processor you're targeting.
Thats what I'm intending to do with my OS anyways .
Thats what I'm intending to do with my OS anyways .
Re:Syscall
Yea you 're right. To implement syscalls via interrupts may be the best choice.paulbarker wrote: sysenter/sysleave and syscall/sysret don't work on all x86 processors if I remember rightly. I'd suggest starting with interrupts and adding those pairs as options depending on what processor you're targeting.
Thats what I'm intending to do with my OS anyways .
Re:Syscall
Does anyone have a simple implementation example for syscall/sysenter based uhm.. syscall?
Re:Syscall
Yes, I own the Holy Books of Intel, but what I'm looking for would be an actual implementation example, so I could actually see how it fits into an existing system.Solar wrote: Erm... the Intel Manuals perhaps?
I couldn't find a clean example by google, so I thought I might as well ask.
(Actually the Manuals are under my motherboard right now, the board is not in a case and the coolant pipes were too short. Luckily there are the PDF versions
I think I'll try to get my simple sysenter test working and upload it somewhere. Maybe someone else will someday need it. I'm nowhere near implementing them in the core project at this time, I want to handle several bigger performance issues before that. :S