I am trying to compile the android source after writing my own system
call, __NR_helloworld , the compilation goes smoothly and new kernel
image is created arch/arm/boot/zImage. I am able to boot from new
kernel image as well .. using "emulator -avd NameOfYourAVD -kernel
arch/arm/boot/zImage -ramdisk ~/android-sdk/platforms/android/images/
ramdisk.img -show-kernel".

How can I compile a small program, that uses __NR_helloworld, using
cross compiler against the new kernel image that i created ?
arm-none-linux-gnueabi-gcc -static -o hello hello.c is giving
compilation error :(

Steps followed to write new system call :

1. edit include/asm-generic/unistd.h - ADDED

#define __NR_helloworld 242
__SYSCALL(__NR_helloworld, sys_helloworld)

incremented __NR_syscalls to 243

2. edit arch/arm/kernel/calls.S - Added

CALL(sys_helloworld) in the end after perf_event_open call.

3. created mycalls/helloworld.c

#include <linux/kernel.h>
#include <linux/linkage.h>
asmlinkage int sys_helloworld(){
    printk(KERN_DEBUG "Hello World!");
    return(1);
}

4. created mycalls/Makefile
obj-y := helloworld.o

5. edited the kernel make file to include mycalls folder.

core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ mycalls/

6. Compile the source - make -j2 ARCH=arm CROSS_COMPILE=arm-none-linux-
gnueabi-

7. arch/arm/boot/zImage - new kernel image is created !


Testing new helloworld system call.

1. write hello.c

#include <linux/errno.h>
#include <sys/syscall.h>
#include <linux/unistd.h>

/* For testing your syscall */

int helloworld()
{
        return syscall(__NR_helloworld);
}

int main()
{
        helloworld();
        return 0;
}

2. compile it - arm-none-linux-gnueabi-gcc -static -o hello hello.c

3. step 2 is erroring out with - error: '__NR_helloworld' undeclared,
I suspect it is not getting the new kernel image location ?

Thanx
Adam

-- 
unsubscribe: [email protected]
website: http://groups.google.com/group/android-kernel

Reply via email to