"真正的"入口点
// kern/init/init.c
#include <stdio.h>
#include <string.h>
//这里include的头文件, 并不是C语言的标准库,而是我们自己编写的!
//noreturn 告诉编译器这个函数不会返回
int kern_init(void) __attribute__((noreturn));
int kern_init(void) {
extern char edata[], end[];
//这里声明的两个符号,实际上由链接器ld在链接过程中定义, 所以加了extern关键字
memset(edata, 0, end - edata);
//内核运行的时候并没有c标准库可以使用,memset函数是我们自己在string.h定义的
const char *message = "(THU.CST) os is loading ...\n";
cprintf("%s\n\n", message); //cprintf是我们自己定义的格式化输出函数
while (1)
;
}最后更新于