I'm currently writing a kernel, and I need help on understanding how system call are handled, because I can't find any documents that explained how they are defined and handled.
Asked
Active
Viewed 88 times
0
-
2Did you read _CHAPTER 6 INTERRUPT AND EXCEPTION HANDLING_ in the _Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 3: System Programming Guide_? Did you read the pages about `syscall`/`sysenter` in the instruction set reference? Did you read the [System calls page on osdev](https://wiki.osdev.org/System_Calls)? Have you looked at open source OS code? What exactly do you have a problem with? Be specific. – Jester May 16 '20 at 10:49
-
What I need is how to DEFINE a interrupt(like int 0x80) – Clement Poon May 16 '20 at 11:21
-
Does this answer your question? [How syscall knows where to jump?](https://stackoverflow.com/questions/56854297/how-syscall-knows-where-to-jump) – 0x777C May 16 '20 at 11:49
-
@ClementPoon Put an appropriate entry into the [IDT](https://wiki.osdev.org/Interrupt_Descriptor_Table). – fuz May 16 '20 at 11:59
-
My answer on [What happens if you use the 32-bit int 0x80 Linux ABI in 64-bit code?](https://stackoverflow.com/q/46087730) shows some of the kernel side of dispatching system calls via the table of function pointers, indexed by the call number in RAX. For the x86 IDT part, [What does "int 0x80" mean in assembly code?](https://stackoverflow.com/q/1817577) – Peter Cordes May 16 '20 at 13:16
-
My kernel uses the real mode instead of protected mode. – Clement Poon May 16 '20 at 15:08
-
1Then it's much simpler: simply put the address of the interrupt handler into an appropriate spot in the IVT. – fuz May 16 '20 at 18:04
-
I'm literally asking for how to PUT the address of the interrupt handler code into IVT. – Clement Poon May 17 '20 at 04:11