如何添加Linux内核系统调用

来源:互联网 发布:办公室软件2003下载 编辑:程序博客网 时间:2024/05/22 10:38

首先介绍系统调用相关文件:

• arch/x86/kernel/entry_32.S
– Implementation of the system call entry
• arch/x86/kernel/traps_32.c
– Interrupt service routines
• arch/x86/kernel/syscall_table_32.S
– State the system call entry
• arch/x86/include/asm/unistd_32.h
– Define the system call number
• kernel/sys.c
– Implementation of the system call

然后,如何增加系统调用呢?

• Add new system call entry in syscall_table
– arch/x86/kernel/syscall_table_32.S
– e.g., add .long sys_hello
• Define a system call number
– arch/x86/include/asm/unistd.h
• Code for the implementation
– kernel/sys.c


下面举一个简单的例子:

asmlinkage long sys_hello(void){    printk(“Hello, kernel!\n”);    return 0;}





原创粉丝点击