From f2589c6cd89ee00ca9c9c98ef5adb51063922199 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 2 Jan 2014 21:30:09 +0100 Subject: [PATCH] syscall.9: Add a rough explanation of how a syscall ends up in the kernel. --- share/man/man9/syscall.9 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/share/man/man9/syscall.9 b/share/man/man9/syscall.9 index 11e86ab153..39f602b966 100644 --- a/share/man/man9/syscall.9 +++ b/share/man/man9/syscall.9 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd May 25, 2009 +.Dd January 2, 2014 .Dt SYSCALL 9 .Os .Sh NAME @@ -127,6 +127,26 @@ Last, in order to return a value to userland, the .Fa uap->sysmsg_result variable and friends of it are used, as defined in .Pa sys/sys/sysmsg.h . +.Sh IMPLEMENTATION NOTES +In the kernel, a syscall is implemented by a +.Fn sys_syscallname +function. +In userspace, the function that executes a syscall is automatically generated +using the description in +.Pa syscalls.master . +The symbols in the +.Lb libc +are assembly wrappers generated in +.Pa lib/libc/{i386,x86_64} , +again using the description in +.Pa syscalls.master . +These wrappers use macros provided by the platform-dependent +.In SYS.h +header file which take care of putting the syscall arguments into registers +(per the ABI specification) and either invoking int 0x80 (on i386) or +inserting a +.Li syscall +instruction (on x86_64). .Sh FILES .Bl -tag -width sys/kern/syscalls.master -compact .It Pa sys/kern/makesyscalls.sh -- 2.41.0