(Working Draft)
This tutorial helps you to add a new kernel call in MINIX. Let's say your new kernel call is called sample.
... int do_sample(struct proc *caller, message *m_ptr); #endif /* SYSTEM_H */
#include "kernel/system.h" #include <minix/endpoint.h> /*===========================================================================* * do_sample * *===========================================================================*/ int do_sample(struct proc *caller_ptr, message *m_ptr) { return(OK); }
# Makefile for system library implementation .include <bsd.own.mk> .PATH: ${.CURDIR}/system SRCS+= \ do_fork.c \ do_exec.c \ ... do_statectl.c \ do_sample.c
... map(SYS_STATECTL, do_statectl); /* let a process control its state */ map(SYS_SAMPLE, do_sample); /* your kernel call */ ...
... int sys_sample(unsigned flags, endpoint_t proc_ep); ...
... # define SYS_SAFEMEMSET (KERNEL_CALL + 56) /* sys_statectl() */ # define SYS_SAMPLE (KERNEL_CALL + 57) /* sys_sample() */ /* Total */ #define NR_SYS_CALLS 58 /* number of kernel calls */ ...
... struct { char *label; int call_nr; } system_tab[]= { ... { "MEMSET", SYS_MEMSET }, { NULL, 0 } }; ...
#include "syslib.h" int sys_sample(unsigned flags, endpoint_t proc_ep) { message m; return(_kernel_call(SYS_SAMPLE, &m)); }
# Makefile for libsys LIB= sys SRCS= \ ... sys_sample.c \ ...