OSDev.org

The Place to Start for Operating System Developers
It is currently Sun Oct 17, 2021 1:31 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: QEMU - Add an IDE drive.
PostPosted: Wed Jul 21, 2021 1:05 pm 
Offline

Joined: Sat Oct 24, 2020 11:24 am
Posts: 8
Hi

I want to develop an IDE driver (using https://wiki.osdev.org/PCI_IDE_Controller). In that article, it says that an IDE should be listed in the PCI with class 0x1 and subclass 0x1. This is my code of finding PCI devices: (Please ignore the mess... It just for testing. I will rewrite it later..)

Code:
void PCI::check_device(uint8_t bus, uint8_t device)
{
    uint16_t vendor_id = get_vendor_id(bus, device, 0);
    if (vendor_id == PCI_VENDOR_ID_DEVICE_DOES_NOT_EXIST)
        return;
    uint8_t header_type = get_header_type(bus, device, 0);
    if (header_type & PCI_HAS_MULTIPLE_FUNCTIONS_MASK)
    {
        for (int function = 0; function < PCI_NUMBER_OF_DEVICES_PER_BUS; function++)
        {
            uint8_t class_code = get_class_code(bus, device, function);
            uint8_t sub_class_code = get_sub_class_code(bus, device, function);

            kprintf("Class Code: %x, Sub Class Code: %x", (int) class_code, (int) (sub_class_code));
        }
    }
    else
    {
        uint8_t class_code = get_class_code(bus, device, 0);
        uint8_t sub_class_code = get_sub_class_code(bus, device, 0);

        kprintf("Class Code: %x, Sub Class Code: %x", (int) class_code, (int) (sub_class_code));
    }
}


When I run this code, I don't get any IDE device (I do get another devices).
So I went to Google, to check how to add an IDE disk to my emulator (QEMU). I didn't find how to do that.

Can someone please help me?

Thank's!


Top
 Profile  
 
 Post subject: Re: QEMU - Add an IDE drive.
PostPosted: Wed Jul 21, 2021 5:22 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 3395
What's your QEMU command line? You have to be using a configuration with a PCI IDE controller to see a PCI IDE controller.

Shouldn't that be PCI_NUMBER_OF_FUNCTIONS_PER_DEVICE?

Which devices are you able to find? (Vendor and device IDs can be more useful than class codes for figuring this out.)


Top
 Profile  
 
 Post subject: Re: QEMU - Add an IDE drive.
PostPosted: Thu Jul 22, 2021 12:11 am 
Offline

Joined: Sat Oct 24, 2020 11:24 am
Posts: 8
Hi

Thank you for your reply

Finally I did managed to find a way to add an IDE controller, now I can see it in the list:
Code:
qemu -device piix3-ide,id=ide -drive id=disk,file=image.img,format=raw,if=none -device ide-hd,drive=disk,bus=ide.0

But thanks anyway.

Octocontrabass wrote:
Shouldn't that be PCI_NUMBER_OF_FUNCTIONS_PER_DEVICE?

Oh, right. Did not notice. Thank you.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 17 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