请问如何在xv6-public的启动信息中打印自己自定义的内容?

soaking12138
  • 1
新手上路,请多包涵

在虚拟机上安装好xv6-public后,输入make qemu-nox进入当前终端后会打印出启动信息,像这样:

qemu-system-i386 -nographic -drive file=fs.img,index=1,media=disk,format=raw -drive file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512 
xv6...
cpu1: starting 1
cpu0: starting 0
sb: size 1000 nblocks 941 ninodes 200 nlog 30 logstart 2 inodestart 32 bmap start 58
init: starting sh
$ 

问题是我改如何在init:starting sh后直接打印出我自己想要的信息?像网上有的是说添加一个.c文件,但是这样等于又要输入一次指令而不是直接打印信息。比如我想尝试添加一些人物介绍,如:

qemu-system-i386 -nographic -drive file=fs.img,index=1,media=disk,format=raw -drive file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512 
xv6...
cpu1: starting 1
cpu0: starting 0
sb: size 1000 nblocks 941 ninodes 200 nlog 30 logstart 2 inodestart 32 bmap start 58
init: starting sh
Name: Jack Ma
Company: Alibaba
Address: Hangzhou, China
$ 

该怎么实现呢?我自己尝试过修改main.c中的cprintf,如:

// Common CPU setup code.
static void
mpmain(void)
{
  cprintf("cpu%d: starting %d\n", cpuid(), cpuid());
  cprintf("Name: Jack Ma %d\nCompany: Alibaba %d\nAddress: Hangzhou, China");
  idtinit();
      // load idt register
  xchg(&(mycpu()->started), 1);
// tell startothers() we're up
  scheduler(); 
      // start running processes
}

却只能得到这样的内容:

qemu-system-i386 -nographic -drive file=fs.img,index=1,media=disk,format=raw -drive file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512 
xv6...
cpu1: starting 1
Name: Jack Ma 1
Company: Alibaba 1
Address: Hangzhou, Chinacpu0: starting 0
Name: Jack Ma 0
Company: Alibaba 0
Address: Hangzhou, Chinasb: size 1000 nblocks 941 ninodes 200 nlog 30 logstart 2 inodestart 32 bmap start 58
init: starting sh
$ 

希望可以得到大家的指导谢谢

评论
阅读 362
撰写回答

登录后参与交流、获取后续更新提醒

宣传栏