内核版本2.6.32.2
1 修改 arch/arm/include/asm/unistd.h
....
#define __NR_preadv (__NR_SYSCALL_BASE+361)
#define __NR_pwritev (__NR_SYSCALL_BASE+362)
#define __NR_rt_tgsigqueueinfo (__NR_SYSCALL_BASE+363)
#define __NR_perf_event_open (__NR_SYSCALL_BASE+364)
在后面添加自己写的调用
#define __NR_kernel_add (__NR_SYSCALL_BASE+365)
2 修改 arch/arm/kernel/sys_arm.c
在文件最后添加函数的实现
asmlinkage int sys_kernel_add(int a, int b)
{
return a+b;
}
3 修改 arck/arm/kernel/calls.S
....
/* 360 */ CALL(sys_inotify_init1)
CALL(sys_preadv)
CALL(sys_pwritev)
CALL(sys_rt_tgsigqueueinfo)
CALL(sys_perf_event_open)
CALL(sys_kernel_add) /*添加这一行*/
4 编译内核,编译测试文件,下载测试程序到开发板运行
----test.c----
#define _GNU_SOURCE /* or _BSD_SOURCE or _SVID_SOURCE */
#include
#include /* For SYS_xxx definitions */
#include
#define __NR_kernel_add (__NR_SYSCALL_BASE+365)
int add(int a,int b)
{
return syscall(__NR_kernel_add,a,b);
}
int main ()
{
int c;
c=add(5,6);
printf("%d\n",c);
return 0;
}
阅读(471) | 评论(0) | 转发(0) |