how do i add a system call / utility in xv6

To add a system call that can be called in xv6’s shell,
you should so something with the five files

  • sysproc.c add the real implementation of your method here
  • syscall.h define the position of the system call vector that connect to your implementation
  • user.h define the function that can be called through the shell
  • syscall.c external define the function that connect the shell and the kernel, use the position defined in syscall.h to add the function to the system call vector
  • usys.S use the macro to define connect the call of user to the system call function

  • defs.h add a forward declaration for your new system call

  • sysfunc.h add the new system call handler into this file too like “int sys_newsystemcall(void)”

Leave a Comment