OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:55 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: can't detect IDE controller
PostPosted: Thu Dec 13, 2018 12:56 pm 
Offline

Joined: Sun Aug 09, 2015 11:54 am
Posts: 23
Hi,
I'm trying to detect ide drives, but in bochs and vmware they won't show up - I think there must be something wrong with my code but I don't know what. The first dword or 32 bits of information show some sensible deviceID, vendorID, so I suspect that I'm not reading the other dwords properly from the configuration space.
Code:
uint8_t j=0;
uint16_t bus;
uint8_t device;
for (bus=0;bus<256;bus++)
{
   for (device=0; device<32; device++)
   {
      address = (uint32_t) ( (1<<31) | (bus<<16) | (device<<11) | (0<<8) | 0x0  );
      outl(PCI_CONFIG_ADDRESS,address);
      tmp = inl(PCI_CONFIG_DATA);
      ptr=&tmp;
//      if ( tmp>>16 != 0xffff )
      if ( (tmp & 0xffff) != 0xffff )
      {
          print_byte(bus,25,0,4+j);
          print_byte(device,25,3,4+j);
         print_dword(ptr,25,6,4+j);   // vendor, device

      address = (uint32_t) ( (1<<31) | (bus<<16) | (device<<11) | (0<<8) | 0x8  );
      outl(PCI_CONFIG_ADDRESS,address);
      tmp = inl(PCI_CONFIG_DATA);
      ptr=&tmp;
      print_dword(ptr,25,15,4+j);   // class,subclass


      address = (uint32_t) ( (1<<31) | (bus<<16) | (device<<11) | (0<<8) | 0x10  );
      outl(PCI_CONFIG_ADDRESS,address);
      tmp = inl(PCI_CONFIG_DATA);
      ptr=&tmp;
      print_dword(ptr,25,24,4+j);     // bar0

    j++;
      }
   }

}


Attachments:
dddss.png
dddss.png [ 33.94 KiB | Viewed 1291 times ]
Top
 Profile  
 
 Post subject: Re: can't detect IDE controller
PostPosted: Thu Dec 13, 2018 2:01 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
You're not handling multi-function devices at all, so you won't see any devices with a non-zero function number.

Is your virtual machine configured to use an IDE controller at all? I see bus 00 device 10 is a SCSI controller (class 01 subclass 00) and claims to be one of several LSI Logic Ultra320 SCSI controllers (vendor 1000 device 0030).


Top
 Profile  
 
 Post subject: Re: can't detect IDE controller
PostPosted: Fri Dec 28, 2018 2:38 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Additionally, in the case of Bochs I would not be surprised if your configuration is set to behave as an ISA IDE controller - i.e. an older machine where it exists but does not yet show up as a PCI device.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


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: Bing [Bot], DotBot [Bot] and 61 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