can't detect IDE controller
Posted: Thu Dec 13, 2018 12:56 pm
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.
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: Select all
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++;
}
}
}