OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 20, 2024 3:08 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Bochs isnt fire interrupt for writing[solved]
PostPosted: Thu Feb 21, 2019 1:14 pm 
Offline
Member
Member

Joined: Sat Mar 10, 2018 10:16 am
Posts: 296
Good day!

I found problem with my ata pio driver. If I in Bochs write, interrupt isnt fire. This is my code:

Code:
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;
}


Please where is bug?

_________________
https://github.com/VendelinSlezak/BleskOS


Last edited by Klakap on Sat Feb 23, 2019 12:12 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Bochs isnt fire interrupt for writing
PostPosted: Fri Feb 22, 2019 4:43 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
I don't know if this is related to the issues you're having in Bochs, but I see you're reading the status register outside of your interrupt handler. Reading the status register acknowledges the interrupt. You should use the alternate status register instead.


Top
 Profile  
 
 Post subject: Re: Bochs isnt fire interrupt for writing
PostPosted: Sat Feb 23, 2019 12:12 pm 
Offline
Member
Member

Joined: Sat Mar 10, 2018 10:16 am
Posts: 296
Thank you! With reading from alternate status register and pooling is all good. I think than my waiting cycle was little time for irq.

_________________
https://github.com/VendelinSlezak/BleskOS


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: belliash and 15 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