Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use QEMU properly with multi boot headers

I am learning the basic of OS making. I have made a multi boot header compliant .asm file and a .c file. The code in the .asm file calls the main function of .c file.

The problem is that QEMU is unable to boot from the file produced after the compilation and linking of the .asm and the .c file .

It simply says that it can't find a bootable device.

Although, I am able to boot from a simple .asm file like :-

  mov ax, 0x0e
  mov al, 'H' 
  int 10h 
  times 510 - ($ - $$) db 0 
  jmp $ 
  dw 0xaa55 

Is there something more which I have to do?

like image 844
Pratik Singhal Avatar asked Jan 10 '23 23:01

Pratik Singhal


1 Answers

QEMU 2.0.0 does support multiboot

man qemu says:

-kernel bzImage

Use bzImage as kernel image. The kernel can be either a Linux kernel or in multiboot format.

I have uploaded a minimal hello world example at: https://github.com/cirosantilli/x86-bare-metal-examples/tree/dbbed23e4753320aff59bed7d252fb98ef57832f/multiboot

It generates a GAS + C multiboot file, and uses QEMU to run it.

grub-mkrescue can also convert a multiboot binary to a bootable .iso image which is another good approach.

Barry mentions that multiboot2 is not supported. How to generate a multiboot2 image in case you want to test it: How to compile the simple kernel in multiboot2 Spec corrently?