trunk/src/emu/machine/idectrl.c
| r23668 | r23669 | |
| 83 | 83 | #define IDE_COMMAND_TAITO_GNET_UNLOCK_2 0xfc |
| 84 | 84 | #define IDE_COMMAND_TAITO_GNET_UNLOCK_3 0x0f |
| 85 | 85 | |
| 86 | | #define IDE_ERROR_NONE 0x00 |
| 87 | | #define IDE_ERROR_DEFAULT 0x01 |
| 88 | | #define IDE_ERROR_TRACK0_NOT_FOUND 0x02 |
| 89 | | #define IDE_ERROR_UNKNOWN_COMMAND 0x04 |
| 90 | | #define IDE_ERROR_BAD_LOCATION 0x10 |
| 91 | | #define IDE_ERROR_BAD_SECTOR 0x80 |
| 92 | 86 | |
| 93 | | |
| 94 | 87 | void ide_controller_device::set_irq(int state) |
| 95 | 88 | { |
| 96 | 89 | ide_device_interface *dev = slot[cur_drive]->dev(); |
| r23668 | r23669 | |
| 283 | 276 | /* clear the buffer ready and busy flag */ |
| 284 | 277 | status &= ~IDE_STATUS_BUFFER_READY; |
| 285 | 278 | status &= ~IDE_STATUS_BUSY; |
| 286 | | error = IDE_ERROR_DEFAULT; |
| 279 | dev->error = IDE_ERROR_DEFAULT; |
| 287 | 280 | set_dmarq(0); |
| 288 | 281 | |
| 289 | 282 | if (dev->master_password_enable || dev->user_password_enable) |
| r23668 | r23669 | |
| 336 | 329 | next_sector(); |
| 337 | 330 | |
| 338 | 331 | /* clear the error value */ |
| 339 | | error = IDE_ERROR_NONE; |
| 332 | dev->error = IDE_ERROR_NONE; |
| 340 | 333 | |
| 341 | 334 | /* signal an interrupt */ |
| 342 | 335 | if (!dev->verify_only) |
| r23668 | r23669 | |
| 361 | 354 | { |
| 362 | 355 | /* set the error flag and the error */ |
| 363 | 356 | status |= IDE_STATUS_ERROR; |
| 364 | | error = IDE_ERROR_BAD_SECTOR; |
| 357 | dev->error = IDE_ERROR_BAD_SECTOR; |
| 365 | 358 | |
| 366 | 359 | /* signal an interrupt */ |
| 367 | 360 | set_irq(ASSERT_LINE); |
| r23668 | r23669 | |
| 547 | 540 | next_sector(); |
| 548 | 541 | |
| 549 | 542 | /* clear the error value */ |
| 550 | | error = IDE_ERROR_NONE; |
| 543 | dev->error = IDE_ERROR_NONE; |
| 551 | 544 | |
| 552 | 545 | /* signal an interrupt */ |
| 553 | 546 | if (--dev->sectors_until_int == 0 || dev->sector_count == 1) |
| r23668 | r23669 | |
| 574 | 567 | { |
| 575 | 568 | /* set the error flag and the error */ |
| 576 | 569 | status |= IDE_STATUS_ERROR; |
| 577 | | error = IDE_ERROR_BAD_SECTOR; |
| 570 | dev->error = IDE_ERROR_BAD_SECTOR; |
| 578 | 571 | |
| 579 | 572 | /* signal an interrupt */ |
| 580 | 573 | set_irq(ASSERT_LINE); |
| r23668 | r23669 | |
| 731 | 724 | status &= ~IDE_STATUS_BUSY; |
| 732 | 725 | |
| 733 | 726 | /* clear the error too */ |
| 734 | | error = IDE_ERROR_NONE; |
| 727 | dev->error = IDE_ERROR_NONE; |
| 735 | 728 | |
| 736 | 729 | /* signal an interrupt */ |
| 737 | 730 | signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 1); |
| 738 | 731 | break; |
| 739 | 732 | |
| 740 | 733 | case IDE_COMMAND_DIAGNOSTIC: |
| 741 | | error = IDE_ERROR_DEFAULT; |
| 734 | dev->error = IDE_ERROR_DEFAULT; |
| 742 | 735 | |
| 743 | 736 | /* signal an interrupt */ |
| 744 | 737 | signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0); |
| r23668 | r23669 | |
| 746 | 739 | |
| 747 | 740 | case IDE_COMMAND_RECALIBRATE: |
| 748 | 741 | /* clear the error too */ |
| 749 | | error = IDE_ERROR_NONE; |
| 742 | dev->error = IDE_ERROR_NONE; |
| 750 | 743 | /* signal an interrupt */ |
| 751 | 744 | signal_delayed_interrupt(MINIMUM_COMMAND_TIME, 0); |
| 752 | 745 | break; |
| 753 | 746 | |
| 754 | 747 | case IDE_COMMAND_IDLE: |
| 755 | 748 | /* clear the error too */ |
| 756 | | error = IDE_ERROR_NONE; |
| 749 | dev->error = IDE_ERROR_NONE; |
| 757 | 750 | |
| 758 | 751 | /* for timeout disabled value is 0 */ |
| 759 | 752 | dev->sector_count = 0; |
| r23668 | r23669 | |
| 764 | 757 | case IDE_COMMAND_SET_CONFIG: |
| 765 | 758 | LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", dev->cur_head + 1, dev->sector_count)); |
| 766 | 759 | status &= ~IDE_STATUS_ERROR; |
| 767 | | error = IDE_ERROR_NONE; |
| 760 | dev->error = IDE_ERROR_NONE; |
| 768 | 761 | dev->set_geometry(dev->sector_count,dev->cur_head + 1); |
| 769 | 762 | |
| 770 | 763 | /* signal an interrupt */ |
| r23668 | r23669 | |
| 842 | 835 | so that implements actual seek |
| 843 | 836 | */ |
| 844 | 837 | /* clear the error too */ |
| 845 | | error = IDE_ERROR_NONE; |
| 838 | dev->error = IDE_ERROR_NONE; |
| 846 | 839 | |
| 847 | 840 | /* for timeout disabled value is 0 */ |
| 848 | 841 | dev->sector_count = 0; |
| r23668 | r23669 | |
| 854 | 847 | default: |
| 855 | 848 | LOGPRINT(("IDE unknown command (%02X)\n", command)); |
| 856 | 849 | status |= IDE_STATUS_ERROR; |
| 857 | | error = IDE_ERROR_UNKNOWN_COMMAND; |
| 850 | dev->error = IDE_ERROR_UNKNOWN_COMMAND; |
| 858 | 851 | set_irq(ASSERT_LINE); |
| 859 | 852 | //debugger_break(device->machine()); |
| 860 | 853 | break; |
| r23668 | r23669 | |
| 983 | 976 | |
| 984 | 977 | /* return the current error */ |
| 985 | 978 | case IDE_BANK0_ERROR: |
| 986 | | result = error; |
| 979 | result = dev->error; |
| 987 | 980 | break; |
| 988 | 981 | |
| 989 | 982 | /* return the current sector count */ |
| r23668 | r23669 | |
| 1145 | 1138 | { |
| 1146 | 1139 | ide_device_interface *dev = slot[cur_drive]->dev(); |
| 1147 | 1140 | |
| 1141 | if (dev == NULL) |
| 1142 | return; |
| 1143 | |
| 1148 | 1144 | dev->buffer[dev->buffer_offset++] = data; |
| 1149 | 1145 | dev->buffer[dev->buffer_offset++] = data >> 8; |
| 1150 | 1146 | |
| r23668 | r23669 | |
| 1168 | 1164 | } |
| 1169 | 1165 | |
| 1170 | 1166 | ide_device_interface *dev = slot[cur_drive]->dev(); |
| 1167 | |
| 1171 | 1168 | if (dev == NULL) |
| 1172 | 1169 | return; |
| 1173 | 1170 | |
| r23668 | r23669 | |
| 1284 | 1281 | ide_controller_device::ide_controller_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) : |
| 1285 | 1282 | device_t(mconfig, type, name, tag, owner, clock), |
| 1286 | 1283 | status(0), |
| 1287 | | error(0), |
| 1288 | 1284 | command(0), |
| 1289 | 1285 | config_unknown(0), |
| 1290 | 1286 | config_register_num(0), |
| r23668 | r23669 | |
| 1298 | 1294 | |
| 1299 | 1295 | ide_controller_device::ide_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 1300 | 1296 | device_t(mconfig, IDE_CONTROLLER, "IDE Controller", tag, owner, clock), |
| 1301 | | error(0), |
| 1302 | 1297 | command(0), |
| 1303 | 1298 | config_unknown(0), |
| 1304 | 1299 | config_register_num(0), |
| r23668 | r23669 | |
| 1325 | 1320 | |
| 1326 | 1321 | /* register ide states */ |
| 1327 | 1322 | save_item(NAME(status)); |
| 1328 | | save_item(NAME(error)); |
| 1329 | 1323 | save_item(NAME(command)); |
| 1330 | 1324 | |
| 1331 | 1325 | save_item(NAME(config_unknown)); |
| r23668 | r23669 | |
| 1343 | 1337 | /* reset the drive state */ |
| 1344 | 1338 | cur_drive = 0; |
| 1345 | 1339 | status = IDE_STATUS_DRIVE_READY | IDE_STATUS_SEEK_COMPLETE; |
| 1346 | | error = IDE_ERROR_DEFAULT; |
| 1347 | 1340 | set_irq(CLEAR_LINE); |
| 1348 | 1341 | set_dmarq(0); |
| 1349 | 1342 | } |