2017-05-30 125 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。