trunk/src/emu/machine/idectrl.c
| r23653 | r23654 | |
| 57 | 57 | #define IDE_BANK2_CONFIG_REGISTER 8 |
| 58 | 58 | #define IDE_BANK2_CONFIG_DATA 0xc |
| 59 | 59 | |
| 60 | | #define IDE_COMMAND_READ_MULTIPLE 0x20 |
| 61 | | #define IDE_COMMAND_READ_MULTIPLE_NORETRY 0x21 |
| 62 | | #define IDE_COMMAND_WRITE_MULTIPLE 0x30 |
| 63 | | #define IDE_COMMAND_WRITE_MULTIPLE_NORETRY 0x31 |
| 60 | #define IDE_COMMAND_READ_SECTORS 0x20 |
| 61 | #define IDE_COMMAND_READ_SECTORS_NORETRY 0x21 |
| 62 | #define IDE_COMMAND_WRITE_SECTORS 0x30 |
| 63 | #define IDE_COMMAND_WRITE_SECTORS_NORETRY 0x31 |
| 64 | 64 | #define IDE_COMMAND_DIAGNOSTIC 0x90 |
| 65 | 65 | #define IDE_COMMAND_SET_CONFIG 0x91 |
| 66 | | #define IDE_COMMAND_READ_MULTIPLE_BLOCK 0xc4 |
| 67 | | #define IDE_COMMAND_WRITE_MULTIPLE_BLOCK 0xc5 |
| 66 | #define IDE_COMMAND_READ_MULTIPLE 0xc4 |
| 67 | #define IDE_COMMAND_WRITE_MULTIPLE 0xc5 |
| 68 | 68 | #define IDE_COMMAND_SET_BLOCK_COUNT 0xc6 |
| 69 | 69 | #define IDE_COMMAND_READ_DMA 0xc8 |
| 70 | 70 | #define IDE_COMMAND_WRITE_DMA 0xca |
| r23653 | r23654 | |
| 72 | 72 | #define IDE_COMMAND_SET_FEATURES 0xef |
| 73 | 73 | #define IDE_COMMAND_SECURITY_UNLOCK 0xf2 |
| 74 | 74 | #define IDE_COMMAND_UNKNOWN_F9 0xf9 |
| 75 | | #define IDE_COMMAND_VERIFY_MULTIPLE 0x40 |
| 76 | | #define IDE_COMMAND_VERIFY_NORETRY 0x41 |
| 75 | #define IDE_COMMAND_VERIFY_SECTORS 0x40 |
| 76 | #define IDE_COMMAND_VERIFY_SECTORS_NORETRY 0x41 |
| 77 | 77 | #define IDE_COMMAND_ATAPI_IDENTIFY 0xa1 |
| 78 | 78 | #define IDE_COMMAND_RECALIBRATE 0x10 |
| 79 | 79 | #define IDE_COMMAND_SEEK 0x70 |
| r23653 | r23654 | |
| 336 | 336 | sectors_until_int--; |
| 337 | 337 | if (sectors_until_int == 0 || dev->sector_count == 1) |
| 338 | 338 | { |
| 339 | | sectors_until_int = ((command == IDE_COMMAND_READ_MULTIPLE_BLOCK) ? block_count : 1); |
| 339 | sectors_until_int = ((command == IDE_COMMAND_READ_MULTIPLE) ? dev->block_count : 1); |
| 340 | 340 | set_irq(ASSERT_LINE); |
| 341 | 341 | } |
| 342 | 342 | |
| r23653 | r23654 | |
| 369 | 369 | status |= IDE_STATUS_BUSY; |
| 370 | 370 | |
| 371 | 371 | /* just set a timer */ |
| 372 | | if (command == IDE_COMMAND_READ_MULTIPLE_BLOCK) |
| 372 | if (command == IDE_COMMAND_READ_MULTIPLE) |
| 373 | 373 | { |
| 374 | 374 | int new_lba = dev->lba_address(); |
| 375 | 375 | attotime seek_time; |
| r23653 | r23654 | |
| 392 | 392 | /* mark ourselves busy */ |
| 393 | 393 | status |= IDE_STATUS_BUSY; |
| 394 | 394 | |
| 395 | | if (command == IDE_COMMAND_READ_MULTIPLE_BLOCK) |
| 395 | if (command == IDE_COMMAND_READ_MULTIPLE) |
| 396 | 396 | { |
| 397 | 397 | if (sectors_until_int != 1) |
| 398 | 398 | /* make ready now */ |
| r23653 | r23654 | |
| 425 | 425 | status &= ~IDE_STATUS_BUFFER_READY; |
| 426 | 426 | status |= IDE_STATUS_BUSY; |
| 427 | 427 | |
| 428 | | if (command == IDE_COMMAND_WRITE_MULTIPLE_BLOCK) |
| 428 | if (command == IDE_COMMAND_WRITE_MULTIPLE) |
| 429 | 429 | { |
| 430 | 430 | if (sectors_until_int != 1) |
| 431 | 431 | { |
| r23653 | r23654 | |
| 543 | 543 | /* signal an interrupt */ |
| 544 | 544 | if (--sectors_until_int == 0 || dev->sector_count == 1) |
| 545 | 545 | { |
| 546 | | sectors_until_int = ((command == IDE_COMMAND_WRITE_MULTIPLE_BLOCK) ? block_count : 1); |
| 546 | sectors_until_int = ((command == IDE_COMMAND_WRITE_MULTIPLE) ? dev->block_count : 1); |
| 547 | 547 | set_irq(ASSERT_LINE); |
| 548 | 548 | } |
| 549 | 549 | |
| r23653 | r23654 | |
| 591 | 591 | command = _command; |
| 592 | 592 | switch (command) |
| 593 | 593 | { |
| 594 | | case IDE_COMMAND_READ_MULTIPLE: |
| 595 | | case IDE_COMMAND_READ_MULTIPLE_NORETRY: |
| 594 | case IDE_COMMAND_READ_SECTORS: |
| 595 | case IDE_COMMAND_READ_SECTORS_NORETRY: |
| 596 | 596 | LOGPRINT(("IDE Read multiple: C=%d H=%d S=%d LBA=%d count=%d\n", |
| 597 | 597 | dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count)); |
| 598 | 598 | |
| r23653 | r23654 | |
| 606 | 606 | read_first_sector(); |
| 607 | 607 | break; |
| 608 | 608 | |
| 609 | | case IDE_COMMAND_READ_MULTIPLE_BLOCK: |
| 609 | case IDE_COMMAND_READ_MULTIPLE: |
| 610 | 610 | LOGPRINT(("IDE Read multiple block: C=%d H=%d S=%d LBA=%d count=%d\n", |
| 611 | 611 | dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count)); |
| 612 | 612 | |
| 613 | 613 | /* reset the buffer */ |
| 614 | 614 | dev->buffer_offset = 0; |
| 615 | | sectors_until_int = 1; |
| 615 | sectors_until_int = dev->block_count; |
| 616 | 616 | dma_active = 0; |
| 617 | 617 | verify_only = 0; |
| 618 | 618 | |
| r23653 | r23654 | |
| 620 | 620 | read_first_sector(); |
| 621 | 621 | break; |
| 622 | 622 | |
| 623 | | case IDE_COMMAND_VERIFY_MULTIPLE: |
| 624 | | case IDE_COMMAND_VERIFY_NORETRY: |
| 623 | case IDE_COMMAND_VERIFY_SECTORS: |
| 624 | case IDE_COMMAND_VERIFY_SECTORS_NORETRY: |
| 625 | 625 | LOGPRINT(("IDE Read verify multiple with/without retries: C=%d H=%d S=%d LBA=%d count=%d\n", |
| 626 | 626 | dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count)); |
| 627 | 627 | |
| r23653 | r23654 | |
| 649 | 649 | read_first_sector(); |
| 650 | 650 | break; |
| 651 | 651 | |
| 652 | | case IDE_COMMAND_WRITE_MULTIPLE: |
| 653 | | case IDE_COMMAND_WRITE_MULTIPLE_NORETRY: |
| 652 | case IDE_COMMAND_WRITE_SECTORS: |
| 653 | case IDE_COMMAND_WRITE_SECTORS_NORETRY: |
| 654 | 654 | LOGPRINT(("IDE Write multiple: C=%d H=%d S=%d LBA=%d count=%d\n", |
| 655 | 655 | dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count)); |
| 656 | 656 | |
| r23653 | r23654 | |
| 663 | 663 | status |= IDE_STATUS_BUFFER_READY; |
| 664 | 664 | break; |
| 665 | 665 | |
| 666 | | case IDE_COMMAND_WRITE_MULTIPLE_BLOCK: |
| 666 | case IDE_COMMAND_WRITE_MULTIPLE: |
| 667 | 667 | LOGPRINT(("IDE Write multiple block: C=%d H=%d S=%d LBA=%d count=%d\n", |
| 668 | 668 | dev->cur_cylinder, dev->cur_head, dev->cur_sector, dev->lba_address(), dev->sector_count)); |
| 669 | 669 | |
| 670 | 670 | /* reset the buffer */ |
| 671 | 671 | dev->buffer_offset = 0; |
| 672 | | sectors_until_int = 1; |
| 672 | sectors_until_int = dev->block_count; |
| 673 | 673 | dma_active = 0; |
| 674 | 674 | |
| 675 | 675 | /* mark the buffer ready */ |
| r23653 | r23654 | |
| 780 | 780 | case IDE_COMMAND_SET_BLOCK_COUNT: |
| 781 | 781 | LOGPRINT(("IDE Set block count (%02X)\n", dev->sector_count)); |
| 782 | 782 | |
| 783 | | block_count = dev->sector_count; |
| 783 | dev->block_count = dev->sector_count; |
| 784 | 784 | // judge dredd wants 'drive ready' on this command |
| 785 | 785 | status |= IDE_STATUS_DRIVE_READY; |
| 786 | 786 | |
| r23653 | r23654 | |
| 1274 | 1274 | error(0), |
| 1275 | 1275 | command(0), |
| 1276 | 1276 | interrupt_pending(0), |
| 1277 | | block_count(0), |
| 1278 | 1277 | sectors_until_int(0), |
| 1279 | 1278 | verify_only(0), |
| 1280 | 1279 | config_unknown(0), |
| r23653 | r23654 | |
| 1292 | 1291 | error(0), |
| 1293 | 1292 | command(0), |
| 1294 | 1293 | interrupt_pending(0), |
| 1295 | | block_count(0), |
| 1296 | 1294 | sectors_until_int(0), |
| 1297 | 1295 | verify_only(0), |
| 1298 | 1296 | config_unknown(0), |
| r23653 | r23654 | |
| 1324 | 1322 | save_item(NAME(command)); |
| 1325 | 1323 | save_item(NAME(interrupt_pending)); |
| 1326 | 1324 | |
| 1327 | | save_item(NAME(block_count)); |
| 1328 | 1325 | save_item(NAME(sectors_until_int)); |
| 1329 | 1326 | |
| 1330 | 1327 | save_item(NAME(dma_active)); |