trunk/src/emu/machine/idehd.c
| r26321 | r26322 | |
| 14 | 14 | |
| 15 | 15 | #define TIME_PER_SECTOR (attotime::from_usec(100)) |
| 16 | 16 | #define TIME_PER_ROTATION (attotime::from_hz(5400/60)) |
| 17 | | #define TIME_MULTIPLE_SECTORS (attotime::from_nsec(400)) |
| 17 | #define TIME_BETWEEN_SECTORS (attotime::from_nsec(400)) |
| 18 | 18 | |
| 19 | | #define TIME_SEEK_MULTISECTOR (attotime::from_usec(13000)) |
| 20 | | #define TIME_NO_SEEK_MULTISECTOR (attotime::from_usec(1300)) |
| 19 | #define TIME_FULL_STROKE_SEEK (attotime::from_usec(13000)) |
| 20 | #define TIME_AVERAGE_ROTATIONAL_LATENCY (attotime::from_usec(1300)) |
| 21 | 21 | |
| 22 | 22 | ata_mass_storage_device::ata_mass_storage_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock,const char *shortname, const char *source) |
| 23 | 23 | : ata_hle_device(mconfig, type, name, tag, owner, clock, shortname, source), |
| r26321 | r26322 | |
| 187 | 187 | { |
| 188 | 188 | ata_hle_device::soft_reset(); |
| 189 | 189 | |
| 190 | m_cur_lba = 0; |
| 190 | 191 | m_status |= IDE_STATUS_DSC; |
| 191 | 192 | |
| 192 | 193 | m_master_password_enable = (m_master_password != NULL); |
| r26321 | r26322 | |
| 338 | 339 | * |
| 339 | 340 | *************************************/ |
| 340 | 341 | |
| 342 | attotime ata_mass_storage_device::seek_time() |
| 343 | { |
| 344 | /* just set a timer */ |
| 345 | int new_lba = lba_address(); |
| 346 | |
| 347 | int old_cylinder = m_cur_lba / (m_num_heads * m_num_sectors); |
| 348 | int new_cylinder = new_lba / (m_num_heads * m_num_sectors); |
| 349 | int diff = abs(old_cylinder - new_cylinder); |
| 350 | |
| 351 | m_cur_lba = new_lba; |
| 352 | |
| 353 | if (diff == 0) |
| 354 | return TIME_BETWEEN_SECTORS; |
| 355 | |
| 356 | attotime seek_time = (TIME_FULL_STROKE_SEEK * diff) / m_num_cylinders; |
| 357 | |
| 358 | return seek_time + TIME_AVERAGE_ROTATIONAL_LATENCY; |
| 359 | } |
| 360 | |
| 341 | 361 | void ata_mass_storage_device::fill_buffer() |
| 342 | 362 | { |
| 343 | 363 | switch (m_command) |
| r26321 | r26322 | |
| 354 | 374 | { |
| 355 | 375 | set_dasp(ASSERT_LINE); |
| 356 | 376 | |
| 357 | | start_busy(TIME_MULTIPLE_SECTORS, PARAM_COMMAND); |
| 377 | start_busy(TIME_BETWEEN_SECTORS, PARAM_COMMAND); |
| 358 | 378 | } |
| 359 | 379 | break; |
| 360 | 380 | } |
| r26321 | r26322 | |
| 423 | 443 | { |
| 424 | 444 | set_dasp(ASSERT_LINE); |
| 425 | 445 | |
| 426 | | /* just set a timer */ |
| 427 | | int new_lba = lba_address(); |
| 428 | | int diff = abs(m_cur_lba - new_lba); |
| 429 | | int total_sectors = m_num_cylinders * m_num_heads * m_num_sectors; |
| 430 | | attotime seek_time = TIME_NO_SEEK_MULTISECTOR + ((TIME_SEEK_MULTISECTOR * diff) / total_sectors); |
| 431 | | |
| 432 | | start_busy(seek_time, PARAM_COMMAND); |
| 433 | | |
| 434 | | m_cur_lba = new_lba; |
| 446 | start_busy(seek_time(), PARAM_COMMAND); |
| 435 | 447 | } |
| 436 | 448 | } |
| 437 | 449 | |