Subject: Re: adding a syscall -- howto?
To: Joe Reed <jnr@po.cwru.edu>
From: =?iso-8859-1?Q?P=E5l_Halvorsen?= <paalh@ifi.uio.no>
List: tech-kern
Date: 08/13/2002 15:20:56
Hi.

Adding a system call can be done like this:

* add an entry to the file /sys/kern/syscalls.master, add at bottom
and use #ifdef, e.g.:

#ifdef ADDCALL
          298     STD      { ssize_t sys_read (int fd, void *buf, \
                                 size_t bufsize); }
#else
          298     UNIMPL
#endif     =20
     =20
* execute make init_sysent.c in /usr/src/sys/kern.

* copy the new files /usr/src/sys/sys/syscall.h and
/usr/src/sys/sys/syscallargs.h to /usr/include/sys

* add the syscall stub to /usr/src/lib/libc/sys/Makefile.inc (under
ASM=3D)

* add your syscall code to the "appropriate" file in /usr/src/sys/kern
(would it go anywhere else?)

* include these files for compilation by adding the file names in the
file /usr/src/sys/conf/files under "kernel sources".

* build and install a new kernel, see intrtuctions under
http://www.netbsd.org/Documentation/kernel/#building_a_kernel

* reboot single user:
      - Stop boot by pressing "space"
      - Execute boot netbsd -s
      (can use multiuser boot if you are the only user)

* build and install a new libc set by executing make ; make install
under /usr/src/lib/libc

* reboot multi-user


-ph



--------- Paal Halvorsen ----- www.ifi.uio.no/~paalh ---------