Subject: Re: How to add a system call in NetBSD
From: Jason Thorpe <>
List: tech-kern
Date: 02/20/1997 15:29:39
On Thu, 20 Feb 1997 18:22:22 +0530 

 > 	Can anyone tell me how to add a system call in NetBSD. 


edit src/sys/kern/syscalls.master... pick a system call number... there
are a few free ones at 172-174 and 177-180... Define your system
call and arguments here:

172	STD		{ int sys_mysyscall(int fd, struct foobar *foo); }

Save that file, and run "make init_sysent.c" ... that will regenerate
the .c and .h files that depend on syscalls.master.

That's the glue for the system call switch.  Your system call will
be automatically prototyped in the appropriate headers.

Note that the function that implements your system call should
be declared:

 * My system call.
sys_mysyscall(p, v, retval)
	struct proc *p;
	void *v;
	register_t *retval;
	struct sys_mysyscall_args /* {
		syscallarg(int) fd;
		syscallarg(struct foobar *) foo;
	} */ *uap = v;

	[ . . . ]

	return (0);

Next, you need to add glue for the C library.  Edit
src/lib/libc/sys/ and add "mysyscall.o" to the "ASM=" list.
That will cause your system call stub to be generated when the C library
is built.

Jason R. Thorpe                             
NASA Ames Research Center                               Home: 408.866.1912
NAS: M/S 258-6                                          Work: 415.604.0935
Moffett Field, CA 94035                                Pager: 415.428.6939