按实验说明的有:
1. 在 kernel/sysproc.c 中,添加:
// kernel/sysproc.c
uint64
sys_hello(void) {
printf("Hello syscall from xv6!\n");
return 0;
}
2. 修改 Makefile,增加一个命令: $U/_hello\
// Makefile
$U/_hello\
3. 在 user 目录下,增加一个源文件hello.c:
// user
// hello.c
#include "kernel/types.h"
#include "kernel/stat.h"
#include "user.h"
int main() { hello(); exit(); }
额外的 4 个添加项(注意末尾的符号):
1. user/user.h 中,添加: int hello(void);
2. user/usys.pl 中,添加: entry("hello");
3. kernel/syscall.h 中,添加: #define SYS_hello 26
4. kernel/syscall.c 中,添加: extern uint64 sys_hello(void); 和 [SYS_hello] sys_hello,
153




被折叠的 条评论
为什么被折叠?



