我需要为Raspbian Linux内核添加一个自己的系统调用.现在我在搜索了大约2天后找到了解决方案.
要添加系统调用,我基本上遵循以下git repo中的内核源代码的大纲(http://elinux.org/RPi_Kernel_Compilation):
混帐://github.com/raspberrypi/tools.git
我使用crosstool-ng安装了交叉编译环境(http://www.kitware.com/blog/home/post/426).
以上所有这些都有效.我能够编译和部署新内核.我还能够为Raspbian交叉编译.
我正在尝试添加一个'hello world'系统调用.该函数驻留在自己的实现文件(kernel/helloworld.?)中,并实现为:
helloworld.c:
#include <linux/linkage.h>
#include <linux/kernel.h>
#include <linux/random.h>
#include "helloworld.h"
asmlinkage long sys_helloworld(){
printk (KERN_EMERG "hello world!");
return get_random_int()*4;
}
Run Code Online (Sandbox Code Playgroud)
helloworld.h:
#ifndef HELLO_WORLD_H
#define HELLO_WORLD_H
asmlinkage long sys_helloworld(void);
#endif
Run Code Online (Sandbox Code Playgroud)
Makefile相应地扩展.
我现在卡在错误消息中
AS arch/arm/kernel/entry-common.o
arch/arm/kernel/entry-common.S: Assembler messages:
arch/arm/kernel/entry-common.S:104: Error: __NR_syscalls is not equal to the size of the syscall table
make[1]: *** [arch/arm/kernel/entry-common.o] Error 1
Run Code Online (Sandbox Code Playgroud)
按照编写新系统调用的建议,我添加了以下内容:
弓/ ARM /内核/ calls.S
CALL(sys_helloworld)
Run Code Online (Sandbox Code Playgroud)拱/臂/包括/ uapi/ASM/unistd.h中
#define __NR_helloworld (__NR_SYSCALL_BASE+380)
Run Code Online (Sandbox Code Playgroud)包括/ …