Example #1
0
bool devide_wait(uint8_t bits)
{
    uint8_t status;
    timer_t timeout;

    timeout = set_timer_sec(20);

    while(true){
        status = devide_readb(ide_reg_status);

        if((status & (IDE_STATUS_BUSY | IDE_STATUS_ERROR | bits)) == bits)
            return true;

        if(((status & (IDE_STATUS_BUSY | IDE_STATUS_ERROR)) == IDE_STATUS_ERROR) || /* error */
           (status == 0x00) || /* zeta-v2 PPIDE: status=0x00 - no drive */
           (status == 0xFF) || /* zeta-v2 PPIDE: status=0xFF - no drive */
           (status == 0xE0) || /* zeta-v2 PPIDE: status=0xE0 - no drive */
           (status == 0xF0) || /* zeta-v2 PPIDE: status=0xF0 - no drive */
           (status == 0x87)){  /* n8vem-mark4:   status=0x87 indicates neither master nor slave drive present */
            kprintf("ide error, status=%x\n", status);
            return false;
        }

        if(timer_expired(timeout)){
            kprintf("ide timeout, status=%x\n", status);
            return false;
        }
    }
}
Example #2
0
static void nudge_timer(void)
{
    di();
    spindown_timer = set_timer_sec(2);
    ei();
}