在Minix中添加新的系统调用 [英] Adding new System Call in Minix
问题描述
我正在尝试在Minix 3.3中创建一个新的系统调用.首先,我只是想创建一个简单的printmsg()调用,该调用将在屏幕上显示"Hello World".
我在互联网上浏览了各种教程,但仍然找不到解决方案.
I am trying to create a new system call in Minix 3.3. At first i just want to create simple printmsg() call that will write "Hello World" on screen.
I looked various tutorials on internet and still couldn't find out solution.
-
我像这样
#define PM_PRINTMSG (PM BASE + 48)
在 callnr.h 中定义了系统调用号码,并且增加了#define NR_PM_CALLS 49
的系统调用次数.
I defined my sys call number in callnr.h like this
#define PM_PRINTMSG (PM BASE + 48)
and i increased number of sys calls#define NR_PM_CALLS 49
.
在 table.c 中,我添加了CALL(PM_PRINTMSG) = doprintmsg
.
在 proto.h 中,我描述了函数原型`int do_printmsg(void);
In proto.h I described function prototype `int do_printmsg(void);
函数实现是用 misc.c 编写的.我添加了#include <stdio.h>
并设置了Hello World函数int do printmsg(){ printf("I am a system call"); return 0; }
Function implementation is written in misc.c. I added #include <stdio.h>
and made Hello World function int do printmsg(){ printf("I am a system call"); return 0; }
当我在用户程序_syscall(PM_PROC_NR, PM_PRINTMSG, &m);
中测试系统调用时,我没有收到任何错误,但没有显示printf.
When I test my system call in user program _syscall(PM_PROC_NR, PM_PRINTMSG, &m);
I don't get any errors but no printf is displayed.
因此,是否可以从系统调用中打印消息,因为我必须在 misc.c 中自己添加<stdio.h>
,或者我错过了一些步骤.我忘了提到我进入/usr/src/releasetools并分别键入make services
和make install
来重新编译内核.
So, is it possible to printf messages from system calls since i had to add <stdio.h>
myself in misc.c or i missed some steps. I forgot to mention that i go in /usr/src/releasetools and type make services
and make install
respectively to recompile kernel.
推荐答案
我想出了问题所在,因此如果将来有人需要它,我将发布答案.在此示例中,我做得很好,但是无法编译内核.
正确的位置是usr/src/releasetools,但是所需的命令是make hdboot
.另外,我发现我的PC无法与此虚拟机一起正常工作,即使我没有进行任何更改,我在编译时也遇到了许多错误.当我切换到笔记本电脑时,一切正常.
我的结论是,有时您的计算机上出现问题,因此您应该尝试在不同的计算机上测试问题
I figured out what was the problem, so i will post answer if someone needs this in future. I did everything well in this example but i failed to compile kernel.
The location was correct which is usr/src/releasetools, but command needed is make hdboot
. Also i figured out my PC somehow wasnt working well with this virtual machines and i had many errors while compiling even though i didn't change anything. When i switched to laptop everything worked fine.
My conclusion is sometimes there is just something wrong on your machine so you should try and test problems on different ones
这篇关于在Minix中添加新的系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!