2

I recently started developing my own bootloader and kernel for educational purposes.

I started out booting from a floppy disk using qemu-system-i386 -fda image.bin, and then from a hard drive using qemu-system-i386 -hda image.bin

I then started working on an ahci driver for reading / writing from sata hhds.

The problem is when starting qemu using these args (taken from this question)

qemu-system-i386 \
 -drive id=disk,file=image.bin,if=none \
 -device ahci,id=ahci \
 -device ide-drive,drive=disk,bus=ahci.0

the bios doesn't seem to find the hard drive, it outputs-

SeaBIOS (version rel-1.12.-0-ga5cab58e9a3f-prebuilt.qemu.org)

iPXE (http://ipxe.org) 00:03.0 C980 PCI2.10 PnP PMM+07F914C0+07EF14C0 C980

Booting from Hard Disk...
Boot failed: could not read the boot disk

Booting from Floppy...
Boot failed: could not read the boot disk

Booting from ROM...
...

starting qemu with -boot menu=on does show the ahci drive, but when I select it it just prints the same output from above.

I tried using qemu 4.1.50 on both linux and windows and 2.8.1 on linux, exact same result in all versions.

A workaround I found (for working on the driver) was using

qemu-system-i386 \
 -hda image.bin
 -drive id=disk,file=other.bin,if=none \
 -device ahci,id=ahci \
 -device ide-drive,drive=disk,bus=ahci.0

to boot the kernel. (But I do want to boot from the same hard drive that I interact with) I then enumerate the pci bus and find the ahci controller (as part of the driver initialization). But then reading the active ports' sata status results in an ipm of 0 and det of 1 (the device is present but the connection hasn't been initalized) , which according to this osdev page the bios should initialize so for now I assume it's the same issue.

Am I doing something wrong here?

Yanay Goor
  • 51
  • 9

1 Answers1

1

After comparing my bootloader to a different os with ahci hhd support and some more research I figured out I was missing a valid partition table from my mbr, so the BIOS didn't consider it bootable.

I don't exactly know why it worked with qemu-system-i386 -hda image.bin since it should still be a hard drive with partitions, I'll edit this answer if I figure that out.

Yanay Goor
  • 51
  • 9