Subject: Re: How do I create a include-file to match my new syscall?
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-kern
Date: 03/07/2000 16:58:59
In article <4366uyhq0t.fsf@bifrost.unik.no>,
Espen Jorde; IFI; H97 <espenjo@unik.no> wrote:
>Hi!
>
>Part of the work for my master thesis involves adding some system
>calls to the kernel.
>
>After some time I have figured out how to add my own system call. I
>have done this successfully with a 1.4.1 kernel.
>
>Now my problem is how to access syscalls from user-space. I can call
>them by using "syscall(<syscallnumber>, arguments)". But i would love
>to be able to do something like this:
>
>#include <foo.h>
>
>foo(i, j, k);
>
>Can anybody give me a hint on where I should look? Which directory
>should I put my .h file for it to compile correctly and end up in
>/usr/include. How should my .h file look. Any good examples?
>
>Any help is appreciated!

Look in /usr/src/lib/libc/sys/Makefile.inc:

ASM, PASM, SASM are the normal syscall targets [p = profile, s = shared]
NOERR, PNOERR, SNOERR are for syscalls that don't return an error.

/usr/src/lib/libc/arch/${MACHINE_ARCH}/SYS.h contains the necessary
macros to build the assembly for the syscall.

Something like the following should be close enough for the ASM case.

printf '#include "SYS.h"\nRSYSCALL(<your_syscall_number>)\n' | \
            /usr/bin/cpp \
	    -I/usr/src/lib/libc/sys/arch/${MACHINE_ARCH} | \
	    as -o <your_syscall_name>.o.o \
	    ld -x -r <your_syscall_name>.o.o -o <your_syscall_name>.o