void ATA_DEVICE::verify_sectors() { intrq = 1; // __debugbreak(); do { --reg.count; /* if(reg.devhead & 0x40) printf("lba=%d\n", *(unsigned*)(regs+3) & 0x0FFFFFFF); else printf("c/h/s=%d/%d/%d\n", reg.cyl, (reg.devhead & 0xF), reg.sec); */ if (!seek()) return; /* u8 Buf[512]; if (!ata_p.read_sector(Buf)) { reg.status = STATUS_DRDY | STATUS_DF | STATUS_CORR | STATUS_DSC | STATUS_ERR; reg.err = ERR_UNC | ERR_IDNF | ERR_ABRT | ERR_AMNF; state = S_IDLE; return; } */ if(reg.count) next_sector(); }while(reg.count); command_ok(); }
void ATA_DEVICE::write_sectors() { intrq = 1; //printf(" [write] "); if(!seek()) return; if (!ata_p.write_sector(transbf)) { reg.status = STATUS_DRDY | STATUS_DSC | STATUS_ERR; reg.err = ERR_UNC; state = S_IDLE; return; } if (!--reg.count) { command_ok(); return; } next_sector(); transptr = 0, transcount = 0x100; state = S_WRITE_SECTORS; reg.err = 0; reg.status = STATUS_DRQ | STATUS_DSC; }
unsigned ATA_DEVICE::read_data() { if (!loaded()) return 0xFFFFFFFF; if ((reg.devhead ^ device_id) & 0x10) return 0xFFFFFFFF; if (/* (reg.status & (STATUS_DRQ | STATUS_BSY)) != STATUS_DRQ ||*/ transptr >= transcount) return 0xFFFFFFFF; // DRQ=1, BSY=0, data present unsigned result = *(unsigned*)(transbf + transptr*2); transptr++; // printf(__FUNCTION__" data=0x%04X\n", result & 0xFFFF); if (transptr < transcount) return result; // look to state, prepare next block if (state == S_READ_ID || state == S_READ_ATAPI) command_ok(); if (state == S_READ_SECTORS) { // __debugbreak(); // printf("dev=%d, cnt=%d\n", device_id, reg.count); if(!--reg.count) command_ok(); else { next_sector(); read_sectors(); } } return result; }
static void read_sector_done(int which) { struct ide_state *ide = &idestate[which]; int lba = lba_address(ide), count = 0; /* now do the read */ if (ide->disk) count = hard_disk_read(ide->disk, lba, 1, ide->buffer); /* by default, mark the buffer ready and the seek complete */ if (!ide->verify_only) ide->status |= IDE_STATUS_BUFFER_READY; ide->status |= IDE_STATUS_SEEK_COMPLETE; /* and clear the busy and error flags */ ide->status &= ~IDE_STATUS_ERROR; ide->status &= ~IDE_STATUS_BUSY; /* if we succeeded, advance to the next sector and set the nice bits */ if (count == 1) { /* advance the pointers, unless this is the last sector */ /* Gauntlet: Dark Legacy checks to make sure we stop on the last sector */ if (ide->sector_count != 1) next_sector(ide); /* clear the error value */ ide->error = IDE_ERROR_NONE; /* signal an interrupt */ if (!ide->verify_only) ide->sectors_until_int--; if (ide->sectors_until_int == 0 || ide->sector_count == 1) { ide->sectors_until_int = ((ide->command == IDE_COMMAND_READ_MULTIPLE_BLOCK) ? ide->block_count : 1); signal_interrupt(ide); } /* handle DMA */ if (ide->dma_active) write_buffer_to_dma(ide); /* if we're just verifying or if we DMA'ed the data, we can read the next sector */ if (ide->verify_only || ide->dma_active) continue_read(ide); } /* if we got an error, we need to report it */ else { /* set the error flag and the error */ ide->status |= IDE_STATUS_ERROR; ide->error = IDE_ERROR_BAD_SECTOR; ide->bus_master_status |= IDE_BUSMASTER_STATUS_ERROR; ide->bus_master_status &= ~IDE_BUSMASTER_STATUS_ACTIVE; /* signal an interrupt */ signal_interrupt(ide); } }
void ide_controller_device::write_sector_done() { ide_device_interface *dev = slot[cur_drive]->dev(); int lba = dev->lba_address(), count = 0; /* now do the write */ count = dev->write_sector(lba, buffer); /* by default, mark the buffer ready and the seek complete */ status |= IDE_STATUS_BUFFER_READY; status |= IDE_STATUS_SEEK_COMPLETE; /* and clear the busy adn error flags */ status &= ~IDE_STATUS_ERROR; status &= ~IDE_STATUS_BUSY; /* if we succeeded, advance to the next sector and set the nice bits */ if (count == 1) { /* advance the pointers, unless this is the last sector */ /* Gauntlet: Dark Legacy checks to make sure we stop on the last sector */ if (sector_count != 1) next_sector(); /* clear the error value */ error = IDE_ERROR_NONE; /* signal an interrupt */ if (--sectors_until_int == 0 || sector_count == 1) { sectors_until_int = ((command == IDE_COMMAND_WRITE_MULTIPLE_BLOCK) ? block_count : 1); set_irq(ASSERT_LINE); } /* signal an interrupt if there's more data needed */ if (sector_count > 0) sector_count--; if (sector_count == 0) status &= ~IDE_STATUS_BUFFER_READY; /* keep going for DMA */ if (dma_active && sector_count != 0) { set_dmarq(1); } } /* if we got an error, we need to report it */ else { /* set the error flag and the error */ status |= IDE_STATUS_ERROR; error = IDE_ERROR_BAD_SECTOR; /* signal an interrupt */ set_irq(ASSERT_LINE); } }
static u8_t d64output(void) { if(hs->count == 0) { ds.track = 1; ds.sect = 0; /* c64_dio_init(8);*/ } if(uip_acked()) { ++hs->count; if(next_sector()) { return 1; } } read_sector(); uip_send(uip_appdata, 256); return 0; }
void ide_controller_device::read_sector_done() { ide_device_interface *dev = slot[cur_drive]->dev(); int lba = dev->lba_address(), count = 0; /* GNET readlock check */ if (gnetreadlock) { status &= ~IDE_STATUS_ERROR; status &= ~IDE_STATUS_BUSY; return; } /* now do the read */ count = dev->read_sector(lba, buffer); /* by default, mark the buffer ready and the seek complete */ if (!verify_only) status |= IDE_STATUS_BUFFER_READY; status |= IDE_STATUS_SEEK_COMPLETE; /* and clear the busy and error flags */ status &= ~IDE_STATUS_ERROR; status &= ~IDE_STATUS_BUSY; /* if we succeeded, advance to the next sector and set the nice bits */ if (count == 1) { /* advance the pointers, unless this is the last sector */ /* Gauntlet: Dark Legacy checks to make sure we stop on the last sector */ if (sector_count != 1) next_sector(); /* clear the error value */ error = IDE_ERROR_NONE; /* signal an interrupt */ if (!verify_only) sectors_until_int--; if (sectors_until_int == 0 || sector_count == 1) { sectors_until_int = ((command == IDE_COMMAND_READ_MULTIPLE_BLOCK) ? block_count : 1); set_irq(ASSERT_LINE); } /* handle DMA */ if (dma_active) set_dmarq(1); /* if we're just verifying we can read the next sector */ if (verify_only) read_buffer_empty(); } /* if we got an error, we need to report it */ else { /* set the error flag and the error */ status |= IDE_STATUS_ERROR; error = IDE_ERROR_BAD_SECTOR; /* signal an interrupt */ set_irq(ASSERT_LINE); } }