2017-05-30 86 views
0

我想加载一个简单的内核使用qemu模拟器,但是,qemu卡在“从硬盘启动”。在目录obj/kern/kernel.imghttps://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-828-operating-system-engineering-fall-2012/,在实验室1分配: A screenshot of the problemQemu卡在从硬盘启动

为内核的源代码可以在下面的链接中找到。 Pdf of lab1tar.gz of lab1pointers1.c。现在的任务是:

The first part concentrates on getting familiarized with x86 assembly language, the QEMU x86 emulator, and the PC's power-on bootstrap procedure. The second part examines the boot loader for our 6.828 kernel, which resides in the boot directory of the lab tree ...

% cd lab 
% make 
... 
+ mk obj/kern/kernel.img 

.. Now you're ready to run QEMU, supplying the file obj/kern/kernel.img, created above, as the contents of the emulated PC's "virtual hard disk." This hard disk image contains both our boot loader (obj/boot/boot) and our kernel (obj/kernel).

% make qemu 
+1

添加更多关于启动参数的信息。这张照片无助于找出你面临的问题吗? – LethalProgrammer

+0

@LethalProgrammer感谢您的回应!我正在使用以下命令:sudo qemu-system-x86_64 -drive format = raw,file = obj/kern/kernel.img – eng140

+0

什么是'obj/kern/kernel.img',它是否可启动?什么说'file -k obj/kern/kernel.img'? – osgx

回答

0

eng140,如在使用过程中的PDF MIT6_828F12_lab1.pdf解释 - https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-828-operating-system-engineering-fall-2012/labs/MIT6_828F12_lab1.pdf,你应该从makefile文件开始QEMU与make qemu

This executes QEMU with the options required to set the hard disk and direct serial port output to the terminal. Some text should appear in the QEMU window: ...

你不应该手动程序启动像你一样(qemu-system-x86_64 ..)。这个目标在实验室GNUmakefile实现

qemu: $(IMAGES) pre-qemu 
    $(QEMU) $(QEMUOPTS) 

和QEMU var为qemu在大多数平台上,并在Mac OS I386-softmmu。要尝试使用32位系统版本的qemu或标准qemu命令。从生成文件的选项是这样的:

QEMUOPTS = -hda $(OBJDIR)/kern/kernel.img -serial mon:stdio -gdb tcp::$(GDBPORT) 
QEMUOPTS += $(shell if $(QEMU) -nographic -help | grep -q '^-D '; then echo '-D qemu.log'; fi) 
IMAGES = $(OBJDIR)/kern/kernel.img 
QEMUOPTS += $(QEMUEXTRA) 

实验室选项有-serial mon:stdio这是... http://download.qemu.org/qemu-doc.html

-serial dev -- Redirect the virtual serial port to host character device dev. .. This option can be used several times to simulate up to 4 serial ports. ...

mon:dev_string 

This is a special option to allow the monitor to be multiplexed onto another serial port. The monitor is accessed with key sequence of Control-a and then pressing c. dev_string should be any one of the serial devices specified above. An example to multiplex the monitor onto a telnet server listening on port 4444 would be:

也许你的形象是开机使用串行端口,不显示打印的东西。尝试添加到您的命令,如:

qemu-system-i386 -drive format=raw,file=obj/kern/kernel.img -serial mon:stdio 

qemu-system-i386 -hda obj/kern/kernel.img -serial mon:stdio 
+0

感谢您的回应!我试着将上面的代码行添加到GNUmake文件中,但它不起作用。 – eng140

+0

eng140,'qemu-system-i386 -hda obj/kern/kernel。img -serial mon:stdio'行工作?它的文本输出是什么? – osgx

+0

它显示:无法打开qemu-system-i386,没有这样的文件或目录。 – eng140

0

eng140,您可以使用32位Linux。我有同样的问题。使用32位Linux后,此问题已解决。在以下网页https://pdos.csail.mit.edu/6.828/2017/tools.html 的“使用虚拟机”一节中,他们建议我们应该使用32位Linux。