I tried with both QEMU and bochs but no hdd is never found. Can someone tell me which option do i have to use to add an hdd to the IDE bus?
To be sure i also add all the devices and the addresses of the channels:
Code: Select all
Device: 0
Vendor ID: 8086
Device ID: 1237
Class ID: 6
SubClass ID: 0
Prog if: 0
Device: 1
Vendor ID: 8086
Device ID: 7000
Class ID: 6
SubClass ID: 1
Prog if: 0
Device: 2
Vendor ID: 8086
Device ID: 7010
Class ID: 1
SubClass ID: 1
Prog if: 80
Device: 3
Vendor ID: 8086
Device ID: 7020
Class ID: c
SubClass ID: 3
Prog if: 0
Device: 4
Vendor ID: 8086
Device ID: 7113
Class ID: 6
SubClass ID: 80
Prog if: 0
PRIMARY_ATA:
BASE: f0
CONTROL: f6
SECONDARY_ATA:
BASE: 70
CONTROL: 76
This is how i get the addresses:
Code: Select all
void getChannelData(struct PCIDevice dev){
channels[ATA_PRIMARY ].base = (dev.BAR[0] & 0xFFFFFFFC) + 0x1F0 * !(dev.BAR[0]);
channels[ATA_PRIMARY ].control = (dev.BAR[1] & 0xFFFFFFFC) + 0x3F6 * !(dev.BAR[1]);
channels[ATA_SECONDARY].base = (dev.BAR[2] & 0xFFFFFFFC) + 0x170 * !(dev.BAR[2]);
channels[ATA_SECONDARY].control = (dev.BAR[3] & 0xFFFFFFFC) + 0x376 * !(dev.BAR[3]);
channels[ATA_PRIMARY ].busmaster = (dev.BAR[4] & 0xFFFFFFFC) + 0; // Bus Master IDE
channels[ATA_SECONDARY].busmaster = (dev.BAR[4] & 0xFFFFFFFC) + 8; // Bus Master IDE
}
Code: Select all
uint8_t read(unsigned char channel, unsigned char reg) {
unsigned char result;
if (reg > 0x07 && reg < 0x0C)
write(channel, ATA_REG_CONTROL, 0x80 | channels[channel].nInt);
if (reg < 0x08)
result = inb(channels[channel].base + reg - 0x00);
else if (reg < 0x0C)
result = inb(channels[channel].base + reg - 0x06);
else if (reg < 0x0E)
result = inb(channels[channel].control + reg - 0x0A);
else if (reg < 0x16)
result = inb(channels[channel].busmaster + reg - 0x0E);
if (reg > 0x07 && reg < 0x0C)
write(channel, ATA_REG_CONTROL, channels[channel].nInt);
return result;
}
Most of this code is from the tutorial on the wiki, if there is something wrong please tell me.
Thanks to everyone and sorry for my english.