我正在尝试在 Minix 3.3 中创建一个新的系统调用。起初我只想创建简单的 printmsg() 调用,它将在屏幕上写下“Hello World”。
我在互联网上查看了各种教程,但仍然找不到解决方案。
我像这样在callnr.h 中定义了我的 sys call number#define PM_PRINTMSG (PM BASE + 48)并且我增加了 sys call 的数量#define NR_PM_CALLS 49。
在table.c 中,我添加了CALL(PM_PRINTMSG) = doprintmsg.
在proto.h 中,我描述了函数原型 `int do_printmsg(void);
函数实现是用misc.c编写的。我添加#include <stdio.h>并制作了 Hello World 功能int do printmsg(){ printf("I am a system call"); return 0; }
当我在用户程序中测试我的系统调用时,_syscall(PM_PROC_NR, PM_PRINTMSG, &m);我没有收到任何错误,但没有显示 printf。
那么,是否可以从系统调用<stdio.h>中打印消息,因为我必须将自己添加到misc.c 中或者我错过了一些步骤。我忘了提到我进入 /usr/src/releasetoolsmake services …