Bochs isnt fire interrupt for writing[solved]
Posted: Thu Feb 21, 2019 1:14 pm
Good day!
I found problem with my ata pio driver. If I in Bochs write, interrupt isnt fire. This is my code:
Please where is bug?
I found problem with my ata pio driver. If I in Bochs write, interrupt isnt fire. This is my code:
Code: Select all
int ata_pio28(uint16_t base, uint8_t type, uint64_t addr, uint8_t drive) {
int cycle=0;
if(drive==IDE_MASTER) {
outb(base+ATA_PORT_DRV, 0xE0);
}
else { // IDE_SLAVE
outb(base+ATA_PORT_DRV, 0xF0);
}
if ((inb(base+ATA_PORT_STATUS) & 0x01)) {
system_ata_pio_error();
return 0;
}
ide_primary_interrupt=0; //prepare value for next interrupt
//PIO28
outb(base+ATA_PORT_FEATURES, 0x00);
outb(base+ATA_PORT_SCT_COUNT, 0x01);
outb(base+ATA_PORT_SCT_NUMBER, (unsigned char)addr);
outb(base+ATA_PORT_CYL_LOW, (unsigned char)(addr >> 8));
outb(base+ATA_PORT_CYL_HIGH, (unsigned char)(addr >> 16));
//type
if(type==ATA_READ) {
outb(base+ATA_PORT_COMMAND, 0x20); // Send command
}
else {
outb(base+ATA_PORT_COMMAND, 0x30);
}
//wait for irq
cycle=0;
for(int i=0; i<10000; i++) {
inb(base+7); //wait
if( ide_primary_interrupt==1 ) { //irq is fire
cycle=1;
break;
}
}
if(cycle==0) { //Something is wrong
return 0;
}
for (int idx = 0; idx < 256; idx++)
{
if(type==ATA_READ) {
ata_buffer[idx] = inw(base + ATA_PORT_DATA);
}
else {
outw(base + ATA_PORT_DATA, ata_buffer[idx]);
}
}
return 1;
}