|
Syscall problems
Hi,
I'm very new to linux kernel development, but I have a few years of programming experience (not much C though).
I'm trying to get a syscall to work in user mode linux (version 2.6.29.1). I found a couple of tutorials on how to do it, but the file- and catalogue-structures doesn't really match, so I've tried to add code as best I could to make it work in my linux version.
The following additions have been made by me:
* In arch/x86/kernel/syscall_table_32.S
long sys_mycall
* In arch/x86/include/asm/unistd_32.h
#define __NR_mycall 333
* In arch/x86/include/asm/syscalls.h
asmlinkage long sys_mycall();
* In kernel\sys_ni.c
cond_syscall(sys_mycall);
(don't know why I would need this line, but it doesn't compile without it)
* In arch/x86/kernel/Makefile
obj-y += mycall.o
* In arch/x86/kernel/mycall.c
#include <asm/linkage.h>
asmlinkage long sys_mycall()
{
kprint("Hello world!\n");
return 1234;
}
I then run the kernel in user mode and try to call my syscall:
* testmycall.c
#include<stdio.h>
#include "testmycall.h"
int main(void)
{
printf("Output: %d \n", syscall(333));
}
I get the output -1 and it doesn't print my hello world message :,(
Now I'm stuck and don't really know how to proceed or what could be wrong with my syscall code.
Help would be much appreciated!
Thanks in advance!
/Magnus
|