首先在arch/mips模块里添加新系统调用getposition的实现:
arch/mips/kernel/scall32-o32.S
sys sys_ni_syscall 0
sys sys_ni_syscall 0
sys sys_ni_syscall 0
sys sys_ioprio_set 3
sys sys_ioprio_get 2 /* 4315 */
+ sys sys_getposition 0 /* 4316 */
.endm
arch/mips/kernel/syscall.c
+ asmlinkage int sys_getposition()
+ {
+ return 0;
+ }
然后在头文件里给系统调用分配调用号:
include/asm-mips/unistd.h
#define __NR_ioprio_set (__NR_Linux + 314)
#define __NR_ioprio_get (__NR_Linux + 315)
+ #define __NR_getposition (__NR_Linux + 316)
/*
* Offset of the last Linux o32 flavoured syscall
*/
- #define __NR_Linux_syscalls 315
+ #define __NR_Linux_syscalls 316
#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
#define __NR_O32_Linux 4000
- #define __NR_O32_Linux_syscalls 315
+ #define __NR_O32_Linux_syscalls 316
编译内核。。。。
完成后,测试新的系统调用:
test.c
#include <linux/unistd.h>
_syscall0(int, getposition)
int main()
{
int i = getposition();
...
return 0;
}
完成!