This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
developersguide:newkernelcall [2015/09/20 11:44] sahutd |
developersguide:newkernelcall [2025/02/14 19:31] (current) johnnoble |
||
---|---|---|---|
Line 5: | Line 5: | ||
This tutorial helps you to add a new kernel call in MINIX. Let's say your new kernel call is called //sample//. | This tutorial helps you to add a new kernel call in MINIX. Let's say your new kernel call is called //sample//. | ||
- | - Add the prototype of your kernel function do_sample() in the file: ///usr/src/minix/kernel/system.h// | + | * Add the prototype of your kernel function do_sample() in the file: ///usr/src/minix/kernel/system.h// |
<code> | <code> | ||
... | ... | ||
Line 12: | Line 12: | ||
#endif /* SYSTEM_H */ | #endif /* SYSTEM_H */ | ||
</code> | </code> | ||
- | - Write the implementation of do_sample() in its own source file: ///usr/src/minix/kernel/system/do_sample.c// | + | * Write the implementation of do_sample() in its own source file: ///usr/src/minix/kernel/system/do_sample.c// |
<code> | <code> | ||
#include "kernel/system.h" | #include "kernel/system.h" | ||
#include <minix/endpoint.h> | #include <minix/endpoint.h> | ||
- | /*===========================================================================* | + | /*===========================================================================* |
* do_sample * | * do_sample * | ||
*===========================================================================*/ | *===========================================================================*/ | ||
Line 25: | Line 25: | ||
} | } | ||
</code> | </code> | ||
- | - Add do_sample.c to the Makefile for compilation: ///usr/src/minix/kernel/system/Makefile.inc// | + | * Add do_sample.c to the Makefile for compilation: ///usr/src/minix/kernel/system/Makefile.inc// |
<code> | <code> | ||
# Makefile for system library implementation | # Makefile for system library implementation | ||
Line 39: | Line 39: | ||
do_sample.c | do_sample.c | ||
</code> | </code> | ||
- | - Map SYS_SAMPLE to do_sample() in the system call table: ///usr/src/minix/kernel/system.c// | + | * Map SYS_SAMPLE to do_sample() in the system call table: ///usr/src/minix/kernel/system.c// |
<code> | <code> | ||
... | ... | ||
Line 46: | Line 46: | ||
... | ... | ||
</code> | </code> | ||
- | - Add a prototype for the sys_sample function in the file: ///usr/src/minix/include/minix/syslib.h// | + | * Add a prototype for the sys_sample function in the file: ///usr/src/minix/include/minix/syslib.h// |
<code> | <code> | ||
... | ... | ||
Line 52: | Line 52: | ||
... | ... | ||
</code> | </code> | ||
- | - Add the call number for sys_sample to the call vector and increment its dimension: ///usr/src/minix/include/minix/com.h// | + | * Add the call number for sys_sample to the call vector and increment its dimension: ///usr/src/minix/include/minix/com.h// |
<code> | <code> | ||
... | ... | ||
Line 63: | Line 63: | ||
... | ... | ||
</code> | </code> | ||
- | - Add the SAMPLE service to the system tab: ///usr/src/minix/commands/service/parse.c//; build the updated system tab and install it with //make; make install// from ///usr/src/commands/service/// | + | * Add the SAMPLE service to the system tab: ///usr/src/minix/commands/service/parse.c//; build the updated system tab and install it with //make; make install// from ///usr/src/minix/commands/service/// |
<code> | <code> | ||
... | ... | ||
Line 79: | Line 79: | ||
... | ... | ||
</code> | </code> | ||
- | - Write your implementation of the function sys_sample in a new file: ///usr/src/minix/lib/libsys/sys_sample.c// | + | * Write your implementation of the function sys_sample in a new file: ///usr/src/minix/lib/libsys/sys_sample.c// |
<code> | <code> | ||
#include "syslib.h" | #include "syslib.h" | ||
Line 90: | Line 90: | ||
} | } | ||
</code> | </code> | ||
- | - Add sys_sample.c to the ///usr/src/minix/lib/libsys/Makefile//, and install it in ///usr/lib/${MACHINE_ARCH}// with //make install//. | + | * Add sys_sample.c to the ///usr/src/minix/lib/libsys/Makefile//, and install it in ///usr/lib/${MACHINE_ARCH}// with //make install//. |
<code> | <code> | ||
# Makefile for libsys | # Makefile for libsys | ||
Line 96: | Line 96: | ||
LIB= sys | LIB= sys | ||
- | SRCS= \ | + | SRCS+= \ |
... | ... | ||
sys_sample.c \ | sys_sample.c \ |