Subject: Re: Adding a New System Call
To: None <tech-kern@netbsd.org,santanum@delhi.tcs.co.in>
From: Ben Harris <bjh21@netbsd.org>
List: tech-kern
Date: 12/19/2000 17:26:28
In article <01C069ED.E6ACBDE0@NOKIA_26M> you write:
>I am trying to add two new system calls (getMacAddrList, setMacAddrList) =
>in NetBSD 1.4.1. I have carried out the following steps:
>
>Step1. Added the following entry in the file =
>/usr/src/sys/kern/syscalls.master
>
>151	STD	{int sys_getMacAddrList(void);}
>
>152	STD	{int sys_setMacAddrList(int myAddr);}
>
>Step2. Executed  make /usr/src/sys/kern/ init_sysent.c
>
>Step3. Copied the new syscall.h and syscallargs.h headers from =
>/usr/src/sys/sys to /usr/include/sys.

This should happen if you run "make includes" in /usr/src/sys.

>
>Step4. I believe I have to add the syscall stub for this two methods to =
>/usr/src/lib/libc/sys/Makefile.inc. However there are no such =
>directories  as /usr/src/lib/libc. Where should I add the stub code ?

You need to get the source code for libc (from src.tgz, probably), and add
it to that.

>Step5. Where should I add the headers and the C files for the above two =
>calls. Will the implementation file (.C file) names remain the same as =
>the function name or they are prefixed by anything ?

The function in the kernel will be called sys_getMacAddrList().

>Can you provide an example how the source (getMacAddrList.c)

Look at the various sys_* functions in (say) sys/kern/sys_generic.c.

>  and header =
>(getMacAddrList.h) will look like ?

Much like any other header file.  It needs to contain:

__BEGIN_DECLS
extern int getMacAddrList(void);
extern int setMacAddrList(int);
__END_DECLS

>After this I believe that I need to rebuilt the kernel and reboot.

You also need to re-build and install libc.

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/arm26               <URL:http://www.netbsd.org/Ports/arm26/>