After quite a lot of reading, now I can successfully run the github version xinu in QEMU. This is how I did it:
- The github version xinu has little to change to be run in QEMU. Adding the multiboot header as described in my question is required.
After making, run with xinu with:
qemu-system-i386 -kernel xinu.elf
- When QEMU runs, it will stop at a screen showing "Booting from ROM...". Then press
CTRL-ALT-3
, there will you find it!
Booting with QEMU, you skip grub, together with any issues grub causes.
QEMU also makes it convenient for debugging. If you run xinu with:
qemu-system-i386 -s -S -kernel xinu.elf
QEMU will start and pause before any instruction is run (check the QEMU manual for more details about the parameters). Then, you can start gdb and attach to it by:
gdb xinu.elf
And after gdb starts, issue:
target remote localhost:1234
You will attach gdb onto the QEMU process running xinu. You can do whatever you normally do with gdb, such as setting breakpoints, displaying registers, or disassembling, etc. When all is done, issue c
(continue
) to kick off.
You may find that you cannot display the CRx
registers with gdb. You can do that with QEMU directly. Press CTRL-ALT-2
in the QEMU window, you will be put into a console, where you can issue:
info registers
And you will get all registers including the CRx
ones. There are more commands can be issued in that console. help
will give you more info about them.