title: Writing a System Calls for linux
body: <p>i try to write a system call. I followed these steps:</p>
  
  <p>linux/arch/x86/kernel/syscall_table_32.S ---->    . long sys mycall</p>
  
  <p>linux/include/linux/syscalls.h  -------->     asmlinkage int sys mycall (int i , int j );</p>
  
  <p>linux/arch/x86/include/asm/unistd_32.h   ---->    #define NR mycall 333</p>
  
  <p>I changed linux/Makefile to core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ mycall/</p>
  
  <p>I created a directory, called mycall. ---->linux/mycall</p>
  
  <p>Inside of that file, I placed mycall.c :</p>
  
  <pre><code>#include &lt;linux/kernel.h&gt;
  asmlinkageintsysmcall(int i,int j )
  {
  return i + j ;
  }
  </code></pre>
  
  <p>6)i create Makefile. ---> linux/mycall/Makefile.</p>
  
  <pre><code>obj−y := mycall.o
  </code></pre>
  
  <p>Then whrn i try this system call, it returns always -1. These lines are my test code in Desktop.
  testmycall.c</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/syscall.h&gt;
  #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 ;
  }
  </code></pre>
  
  <p>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)</p>