OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 10:48 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Unable to boot from an AHCI hhd in qemu
PostPosted: Thu Oct 17, 2019 10:33 am 
Offline

Joined: Thu Oct 17, 2019 10:06 am
Posts: 2
I recently started developing my own bootloader and kernel for educational purposes.

I started out booting from a floppy disk using
Code:
qemu-system-i386 -fda image.bin
, and then from a hard drive using
Code:
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 https://stackoverflow.com/questions/48351096/how-to-emulate-a-sata-disk-drive-in-qemu)

Code:
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-

Code:
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
Code:
-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
Code:
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 AHCI the bios should initialize so for now I assume it's the same issue.
Am I doing something wrong here?

(I also posted this question to stack overflow if you happen to encounter it)


Top
 Profile  
 
 Post subject: Re: Unable to boot from an AHCI hhd in qemu
PostPosted: Thu Oct 17, 2019 3:55 pm 
Offline

Joined: Thu Oct 17, 2019 10:06 am
Posts: 2
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
Code:
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 115 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group