Previous 15994 Revisions Next

r8585 Thursday 22nd July, 2010 at 13:17:59 UTC by Dirk Best
[WD17XX] Changed to update the data register via a timer instead of everytime the data register has been read. This allows us to properly detect data lost conditions and improves overall timing. Needed for smc777 to start booting. Driver authors: Please test for regressions.
[src/mess/machine]wd17xx.c

src/mess/machine/wd17xx.c
r8584r8585
377377static void wd17xx_complete_command(running_device *device, int delay);
378378static void wd17xx_timed_data_request(running_device *device);
379379static void wd17xx_index_pulse_callback(running_device *controller, running_device *img, int state);
380static int wd17xx_locate_sector(running_device *device);
381static void wd17xx_timed_read_sector_request(running_device *device);
380382
381383
382384/*****************************************************************************
r8584r8585
472474   }
473475}
474476
475/* set drq after delay */
477/* write next byte to data register and set drq */
476478static TIMER_CALLBACK( wd17xx_data_callback )
477479{
478480   running_device *device = (running_device *)ptr;
479   wd17xx_set_drq(device);
481   wd1770_state *w = get_safe_token(device);
482
483   /* any bytes remaining? */
484   if (w->data_count >= 1)
485   {
486      /* yes */
487      w->data = w->buffer[w->data_offset++];
488
489      if (VERBOSE_DATA)
490         logerror("wd17xx_data_callback: $%02X (data_count %d)\n", w->data, w->data_count);
491
492      wd17xx_set_drq(device);
493
494      /* any bytes remaining? */
495      if (--w->data_count < 1)
496      {
497         /* no */
498         w->data_offset = 0;
499
500         /* clear ddam type */
501         w->status &=~STA_2_REC_TYPE;
502
503         /* read a sector with ddam set? */
504         if (w->command_type == TYPE_II && w->ddam != 0)
505         {
506            /* set it */
507            w->status |= STA_2_REC_TYPE;
508         }
509
510         /* check if we should handle the next sector for a multi record read */
511         if (w->command_type == TYPE_II && w->command == FDC_READ_SEC && (w->read_cmd & 0x10))
512         {
513            if (VERBOSE)
514               logerror("wd17xx_data_callback: multi sector read\n")
515
516            if (w->sector == 0xff)
517               w->sector = 0x01;
518            else
519               w->sector++;
520
521            wd17xx_timed_read_sector_request(device);
522         }
523         else
524         {
525            /* Delay the INTRQ 3 byte times because we need to read two CRC bytes and
526               compare them with a calculated CRC */
527            wd17xx_complete_command(device, DELAY_DATADONE);
528
529            if (VERBOSE)
530               logerror("wd17xx_data_callback: data read completed\n");
531         }
532      }
533      else
534      {
535         /* requeue us for more data */
536         timer_adjust_oneshot(w->timer_data, ATTOTIME_IN_USEC(wd17xx_dden(device) ? 128 : 32), 0);
537      }
538   }
539   else
540   {
541      logerror("wd17xx_data_callback: (no new data) $%02X (data_count %d)\n", w->data, w->data_count);
542   }
480543}
481544
482545
r8584r8585
793856      wd17xx_set_busy(device, ATTOTIME_IN_USEC(400));
794857      w->busy_count = 0;
795858
796      wd17xx_set_drq(device);
797
798859      if (VERBOSE)
799860         logerror("read id succeeded.\n");
861
862      wd17xx_timed_data_request(device);
800863   }
801864   else
802865   {
r8584r8585
10501113
10511114
10521115/* callback to initiate write sector */
1053static TIMER_CALLBACK(wd17xx_write_sector_callback)
1116static TIMER_CALLBACK( wd17xx_write_sector_callback )
10541117{
10551118   running_device *device = (running_device *)ptr;
10561119   wd1770_state *w = get_safe_token(device);
r8584r8585
13601423{
13611424   wd1770_state *w = get_safe_token(device);
13621425
1363   if (w->data_count >= 1)
1364   {
1365      /* clear data request */
1366      wd17xx_clear_drq(device);
1426   if (VERBOSE_DATA)
1427      logerror("wd17xx_data_r: %02x\n", w->data);
13671428
1368      /* yes */
1369      w->data = w->buffer[w->data_offset++];
1429   /* clear data request */
1430   wd17xx_clear_drq(device);
13701431
1371      if (VERBOSE_DATA)
1372         logerror("wd17xx_data_r: $%02X (data_count %d)\n", w->data, w->data_count);
1373
1374      /* any bytes remaining? */
1375      if (--w->data_count < 1)
1376      {
1377         /* no */
1378         w->data_offset = 0;
1379
1380         /* clear ddam type */
1381         w->status &=~STA_2_REC_TYPE;
1382         /* read a sector with ddam set? */
1383         if (w->command_type == TYPE_II && w->ddam != 0)
1384         {
1385            /* set it */
1386            w->status |= STA_2_REC_TYPE;
1387         }
1388
1389         /* Check we should handle the next sector for a multi record read */
1390         if ( w->command_type == TYPE_II && w->command == FDC_READ_SEC && ( w->read_cmd & 0x10 ) ) {
1391            w->sector++;
1392            if (wd17xx_locate_sector(device))
1393            {
1394               w->data_count = w->sector_length;
1395
1396               /* read data */
1397               floppy_drive_read_sector_data(w->drive, w->hd, w->sector_data_id, (char *)w->buffer, w->sector_length);
1398
1399               wd17xx_timed_data_request(device);
1400
1401               w->status |= STA_2_BUSY;
1402               w->busy_count = 0;
1403            }
1404            else
1405            {
1406               wd17xx_complete_command(device, DELAY_DATADONE);
1407
1408               if (VERBOSE)
1409                  logerror("wd17xx_data_r(): multi data read completed\n");
1410            }
1411         }
1412         else
1413         {
1414            /* Delay the INTRQ 3 byte times because we need to read two CRC bytes and
1415                   compare them with a calculated CRC */
1416            wd17xx_complete_command(device, DELAY_DATADONE);
1417
1418            if (VERBOSE)
1419               logerror("wd17xx_data_r(): data read completed\n");
1420         }
1421      }
1422      else
1423      {
1424         /* issue a timed data request */
1425         wd17xx_timed_data_request(device);
1426      }
1427   }
1428   else
1429   {
1430      logerror("wd17xx_data_r: (no new data) $%02X (data_count %d)\n", w->data, w->data_count);
1431   }
1432
14331432   return w->data;
14341433}
14351434
r8584r8585
19751974   w->intf = (const wd17xx_interface*)device->baseconfig().static_config();
19761975
19771976   w->status = STA_1_TRACK0;
1978   w->pause_time = 40;
1977   w->pause_time = 1000;
19791978    w->complete_command_delay = 12;
19801979
19811980   /* allocate timers */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team