i try to write a system call. I followed these steps:
linux/arch/x86/kernel/syscall_table_32.S ----> . long sys mycall
linux/include/linux/syscalls.h --------> asmlinkage int sys mycall (int i , int j );
linux/arch/x86/include/asm/unistd_32.h ----> #define NR mycall 333
I changed linux/Makefile to core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ mycall/
I created a directory, called mycall. ---->linux/mycall
Inside of that file, I placed mycall.c :
#include <linux/kernel.h>
asmlinkageintsysmcall(int i,int j )
{
return i + j ;
}
6)i create Makefile. ---> linux/mycall/Makefile.
obj−y := mycall.o
Then whrn i try this system call, it returns always -1. These lines are my test code in Desktop. testmycall.c
#include <stdio.h>
#include <sys/syscall.h>
#define __NR_mycall 333
int main(void)
{
int x1=10, x2=20, y ;
y = syscall (__NR_mycall, x1, x2 );
printf (”%d\n”,y );
return 0 ;
}
Then i recompile the kernel. If i compile the code, there is nothing wrong. when i run this program then it doesn't sum two values. It just returns always -1. What is wrong with my system call? (when i recompile the kernel, system didn't waste time more than 3 seconds. I think here, there could be a problem)