I am attempting to create a system call that will increment a number that was added to the cpu struct. However I believe that a sys call has to be void so how can I pass in a va
Xv6 has its own functions for passing arguments from user space to kernel space (system call). You can use argint() to retrieve integer arguments in your system call and argstr() to retrieve string arguments.
Passing arguments can be done the traditional way but for retrieving the arguments, you must use these methods. In your case:
In syscall.c :
extern int incrementNum(int);
static int (*syscalls[])(void) = {
...
[SYS_incrementNum] sys_incrementNum,
};
In syscall.h
#define SYS_incrementNum 22
In user.h
int incrementNum(int);
In Usys.S
SYSCALL(incrementNum);
In sysproc.c (where you want to retrieve the argument)
int
sys_incrementNum(int num)
{
argint(0,&num); //retrieving first argument
cprintf("%d - Inside system call!",num);
}
Calling the system call can now be done via:
incrementNum(3);