Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i add a system call / utility in xv6

Can any one tell me/ point me any references to how to add a system call / utility in XV6

exhaustive search on google was futile and hacking the hard way also was not productive so far .

the reference book also did not have any hello world example to start with any help greatly appreciated

like image 704
sashank Avatar asked Nov 05 '11 17:11

sashank


People also ask

How do you implement system call in xv6?

Next, you need to add pointer to system call in syscall. c file. This file contains an array of function pointers which uses above-defined numbers (indexes) as pointers to system calls which are defined in different location. In order to add your custom system call, add following line to this file.

In which file system calls are declared?

syscall is declared in unistd. h .

What are system calls in Linux?

A system call is a procedure that provides the interface between a process and the operating system. It is the way by which a computer program requests a service from the kernel of the operating system. Different operating systems execute different system calls.


1 Answers

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)"
like image 194
Yang Avatar answered Oct 20 '22 15:10

Yang