How can I call my custom system call through symbol name?

hk7

New Member


Messages: 16

#1
I have implemented a trivial system call and now I can call the system call through `syscall`. My question is how can I call the custom system call like normal system call, e.g.`write`.? What files do I need to modify?

The steps I take to add a custom system call:
1. add custom syscall to kern/syscalls.master
2. make sysent
3. add implementation dot c file to sys/conf/files
4. compile and install the kernel
5. test the system using `syscall`
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 6,409
Messages: 27,707

#2
My question is how can I call the custom system call like normal system call, e.g.`write`.?
Really not sure what you mean by that but:
Code:
     The syscall() function performs the system call whose assembly language
     interface has the specified number with the specified arguments.  [b]Sym-
     bolic constants for system calls can be found in the header file
     <sys/syscall.h>[/b].
From syscall(2).
 
OP
OP
H

hk7

New Member


Messages: 16

#3
@SirDice Thanks for your reply.
Sorry for my unclear expression.
My question is how can I call the custom system call through its symbol name. for example I can call the `write` system call by including the `unistd.h` file and then`write(args...)` to call the `write` system call.
 
OP
OP
H

hk7

New Member


Messages: 16

#4
I did it.
in case people may want to get the same effects. Below are some notes.
First of all the official wiki: https://wiki.freebsd.org/AddingSyscalls.
Other things I did:
1. edit /usr/src/include/unistd.h to include the custom system call signature
2. make all install in /usr/src/include/
3. add custom system call files in /usr/src/lib/libc/sys, just like other system call files.
4. edit /usr/src/lib/libc/sys/Makefile.inc to include the custom system call files
5. make all install in /usr/src/lib/libc
 
Top