Previous 199869 Revisions Next

r26322 Thursday 21st November, 2013 at 01:12:08 UTC by smf
Calculate seek time using tracks rather than sectors, assuming that reading any sector on the current track will already be in the drives cache. Zeros m_cur_lba when the drive is reset for consistency (running kinst in a debug build took 30 seconds to start) (nw)
[src/emu/machine]idehd.c idehd.h

trunk/src/emu/machine/idehd.c
r26321r26322
1414
1515#define TIME_PER_SECTOR                     (attotime::from_usec(100))
1616#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))
1818
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))
2121
2222ata_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)
2323   : ata_hle_device(mconfig, type, name, tag, owner, clock, shortname, source),
r26321r26322
187187{
188188   ata_hle_device::soft_reset();
189189
190   m_cur_lba = 0;
190191   m_status |= IDE_STATUS_DSC;
191192
192193   m_master_password_enable = (m_master_password != NULL);
r26321r26322
338339 *
339340 *************************************/
340341
342attotime 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
341361void ata_mass_storage_device::fill_buffer()
342362{
343363   switch (m_command)
r26321r26322
354374      {
355375         set_dasp(ASSERT_LINE);
356376
357         start_busy(TIME_MULTIPLE_SECTORS, PARAM_COMMAND);
377         start_busy(TIME_BETWEEN_SECTORS, PARAM_COMMAND);
358378      }
359379      break;
360380   }
r26321r26322
423443   {
424444      set_dasp(ASSERT_LINE);
425445
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);
435447   }
436448}
437449
trunk/src/emu/machine/idehd.h
r26321r26322
7272   void security_error();
7373   void read_first_sector();
7474   void soft_reset();
75   attotime seek_time();
7576
7677   UINT32          m_cur_lba;
7778   UINT16          m_block_count;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team