There is little documentation about how to add a system call to Linux kernel on x86_64. This is how I do it.
Of course adding new system call is hardly a good idea. But my teacher simply gives us the homework ;-)
Things are different now in these aspects:
1. Entry.S no longer contains the syscall table; those tutorial mentioning entry.S don't apply to 2.6.
2. Now the i386 and x86_64 arch are merged into one: x86. (See arch and include directories.) However, some files, like syscall_table_32.S, don't have corresponding ones under x86_64.
For i386, here's a list of files to be edited, (see this tldp page):
1. arch/i386/kernel/syscall_table.S,
(now arch/x86/kernel/syscall_table_32.S)
2. include/asm-i386/unistd.h,
(now include/asm-x86/unistd_32.h)
3. include/linux/syscalls.h
For x86_64 arch, no corresponding syscall_table_64.S exists. To add new system calls to x86_64 kernel, edit these files:
1. include/asm-x86/unistd_64.h,
Add lines like:
#define __NR_my_call 288
__SYSCALL(__NR_my_call, sys_my_call)
2. include/linux/syscalls.h
Add a declaration here:
asmlinkage long sys_my_call(int n);
Of course, you can write the implementation in kernel/sys.c or another new foo.c file and then write Makefiles.
Thanks to this thread.
Monday, December 29, 2008
Subscribe to:
Post Comments (Atom)

1 comments:
I am a kernel newbie and this is of great help. Thanks for sharing it with us.
Post a Comment