Previous 15994 Revisions Next

r13246 Monday 14th November, 2011 at 13:03:48 UTC by Michael Zapf
ti99: Fixed chatty logerror, introduced verbose levels (no whatsnew)
[src/mess/machine]smc92x4.c

src/mess/machine/smc92x4.c
r13245r13246
239239#define TRKSIZE_DD      6144
240240#define TRKSIZE_SD      3172
241241
242#define VERBOSE 1
243#define LOG logerror
244
242245/***************************************************************************
243246    PROTOTYPES
244247***************************************************************************/
r13245r13246
319322{
320323   //assert(! (w->status & ST_DONE))
321324   smc92x4_state *w = get_safe_token(device);
322   //logerror("smc92x4 command %02x done, flags=%02x\n", w->command, flags);
325   if (VERBOSE>7) LOG("smc92x4 command %02x done, flags=%02x\n", w->command, flags);
323326
324327   w->register_r[INT_STATUS] |= ST_DONE;
325328   w->register_r[INT_STATUS] &= ~ST_TERMCOD; /* clear the previously set flags */
r13245r13246
337340{
338341   //assert(! (w->status & ST_DONE))
339342   smc92x4_state *w = get_safe_token(device);
340   //logerror("smc92x4 command %02x done\n", w->command);
343   if (VERBOSE>7) LOG("smc92x4 command %02x done\n", w->command);
341344
342345   w->register_r[INT_STATUS] |= ST_DONE;
343346
r13245r13246
396399   w->register_r[DRIVE_STATUS] = w->in_auxbus_func();
397400
398401   /* Raise interrupt if ready changes. TODO: Check this more closely. */
399//  logerror("disk status = %02x\n", reply);
400402   if (((w->register_r[DRIVE_STATUS] & DS_READY) != (prev & DS_READY))
401403      & (w->register_r[INT_STATUS] & ST_RDYCHNG))
402404   {
r13245r13246
520522
521523   if (!w->use_real_timing)
522524   {
523      logerror("smc92x4 info: Disk access without delays\n");
525      if (VERBOSE>5) LOG("smc92x4 info: Disk access without delays\n");
524526      time = 1;
525527   }
526528
r13245r13246
558560   int write_long = ((w->register_w[MODE]& MO_CRCECC)==0x40);
559561
560562   if (deldata)
561      logerror("smc92x4 warn: Write deleted data mark not supported. Writing normal mark.\n");
563      if (VERBOSE>0) LOG("smc92x4 warn: Write deleted data mark not supported. Writing normal mark.\n");
562564
563565   /* Now write the sector. */
564566   data_transfer_write(device, w->recent_id, deldata, redcur, precomp, write_long);
r13245r13246
593595      current_floppy = (*w->intf->current_floppy)(device);
594596      if (current_floppy==NULL)
595597      {
596         logerror("smc92x4 error: seek callback: no floppy\n");
598         if (VERBOSE>0) LOG("smc92x4 error: seek callback: no floppy\n");
597599         w->register_r[INT_STATUS] |= ST_TC_SEEKERR;
598600      }
599601      else
600602      {
601         logerror("smc92x4 step %s direction %d\n", current_floppy->tag(), w->step_direction);
603         if (VERBOSE>5) LOG("smc92x4 step %s direction %d\n", current_floppy->tag(), w->step_direction);
602604         floppy_drive_seek(current_floppy, w->step_direction);
603605      }
604606   }
605607   else
606608   {
607      // logerror("smc92x4 step harddisk direction %d\n", w->step_direction);
609      if (VERBOSE>6) LOG("smc92x4 step harddisk direction %d\n", w->step_direction);
608610      (*w->intf->mfmhd_seek)(device, w->step_direction);
609611   }
610612   sync_status_in(device);
r13245r13246
694696      device_t *disk_img = (*w->intf->current_floppy)(device);
695697      if (flopimg_get_image(disk_img) == NULL)
696698      {
697         logerror("smc92x4 warn: No disk in drive\n");
699         if (VERBOSE>2) LOG("smc92x4 warn: No disk in drive\n");
698700         w->register_r[CHIP_STATUS] |= CS_SYNCERR;
699701         return;
700702      }
r13245r13246
709711      }
710712      else
711713      {
712         logerror("smc92x4 warn: Controller and medium density do not match.\n");
714         if (VERBOSE>2) LOG("smc92x4 warn: Controller and medium density do not match.\n");
713715      }
714716      sync_status_in(device);
715717
716718      if (!found)
717719      {
718         logerror("smc92x4 error: read_id_field (floppy): sync error\n");
720         if (VERBOSE>1) LOG("smc92x4 error: read_id_field (floppy): sync error\n");
719721         w->register_r[CHIP_STATUS] |= CS_SYNCERR;
720722         return;
721723      }
r13245r13246
726728      sync_status_in(device);
727729      if (!(w->register_r[DRIVE_STATUS]& DS_READY))
728730      {
729         logerror("smc92x4 error: read_id_field (harddisk): sync error\n");
731         if (VERBOSE>1) LOG("smc92x4 error: read_id_field (harddisk): sync error\n");
730732         w->register_r[CHIP_STATUS] |= CS_SYNCERR;
731733         return;
732734      }
r13245r13246
767769      *direction = -1;
768770   }
769771
770   //logerror("smc92x4 seek required: %d steps\n", *steps);
772   if (VERBOSE>6) LOG("smc92x4 seek required: %d steps\n", *steps);
771773
772774   w->register_r[INT_STATUS] &= ~ST_TC_RDIDERR;
773775   return;
r13245r13246
802804         if (/* pass==1 && */!found)
803805         {
804806            w->register_r[CHIP_STATUS] |= CS_SYNCERR;
805            logerror("smc92x4 error: verify (floppy): sync error\n");
807            if (VERBOSE>1) LOG("smc92x4 error: verify (floppy): sync error\n");
806808            return ERROR;
807809         }
808810      }
r13245r13246
812814         sync_status_in(device);
813815         if (!(w->register_r[DRIVE_STATUS]& DS_READY))
814816         {
815            logerror("smc92x4 error: verify (harddisk): sync error\n");
817            if (VERBOSE>1) LOG("smc92x4 error: verify (harddisk): sync error\n");
816818            w->register_r[CHIP_STATUS] |= CS_SYNCERR;
817819            return ERROR;
818820         }
r13245r13246
830832      {
831833         des_cylinder = ((w->register_w[DESIRED_HEAD] & 0x70)<<4) | w->register_w[DESIRED_CYLINDER];
832834      }
833//     logerror("smc92x4 check id: current = (%d,%d,%d), required = (%d,%d,%d)\n", id->C, id->H, id->R, des_cylinder, w->register_w[DESIRED_HEAD] & 0x0f, w->register_w[DESIRED_SECTOR]);
835      if (VERBOSE>6) LOG("smc92x4 check id: current = (%d,%d,%d), required = (%d,%d,%d)\n", id->C, id->H, id->R, des_cylinder, w->register_w[DESIRED_HEAD] & 0x0f, w->register_w[DESIRED_SECTOR]);
834836      if ((des_cylinder == id->C)
835837         && ((w->register_w[DESIRED_HEAD] & 0x0f) == id->H))
836838      {
r13245r13246
841843   if (!foundsect)
842844   {
843845      w->register_r[CHIP_STATUS] |= CS_COMPERR;
844      logerror("smc92x4 error: verify: sector not found, seek error (desired cyl=%d/sec=%d, current cyl=%d/sec=%d)\n", des_cylinder, w->register_w[DESIRED_SECTOR], id->C, id->R);
846      if (VERBOSE>1) LOG("smc92x4 error: verify: sector not found, seek error (desired cyl=%d/sec=%d, current cyl=%d/sec=%d)\n", des_cylinder, w->register_w[DESIRED_SECTOR], id->C, id->R);
845847      return ERROR;
846848   }
847849
r13245r13246
991993
992994   if (write_long)
993995   {
994      logerror("smc92x4 warn: write sector: Write_long not supported. Performing a normal write.\n");
996      if (VERBOSE>1) LOG("smc92x4 warn: write sector: Write_long not supported. Performing a normal write.\n");
995997   }
996998
997999   if (w->selected_drive_type & TYPE_FLOPPY)
r13245r13246
11011103   /* Needed for the two ways of re-entry: during the seek process, and during sector read */
11021104   if (!w->after_seek)
11031105   {
1104      // logerror("smc92x4 continue with sector read\n");
1106      if (VERBOSE>7) LOG("smc92x4 continue with sector read\n");
11051107      w->seek_count--;
11061108      if (w->seek_count > 0)
11071109      {
r13245r13246
11161118      w->to_be_continued = FALSE;
11171119      if (w->register_r[INT_STATUS] & ST_TERMCOD)
11181120      {
1119         logerror("smc92x4 error: data error during sector read: INTSTATUS=%02x\n", w->register_r[INT_STATUS]);
1121         if (VERBOSE>1) LOG("smc92x4 error: data error during sector read: INTSTATUS=%02x\n", w->register_r[INT_STATUS]);
11201122         set_command_done(device, ST_TC_DATAERR);
11211123         return;
11221124      }
r13245r13246
11331135      if (state==ERROR)
11341136      {
11351137         // TODO: set command done?
1136         logerror("smc92x4 error: verify error during sector read\n");
1138         if (VERBOSE>0) LOG("smc92x4 error: verify error during sector read\n");
11371139         return;
11381140      }
11391141
r13245r13246
11431145
11441146      if (w->recent_id.flags & BAD_SECTOR)
11451147      {
1146         logerror("smc92x4 error: Bad sector, seek error\n");
1148         if (VERBOSE>0) LOG("smc92x4 error: Bad sector, seek error\n");
11471149         set_command_done(device, ST_TC_SEEKERR);
11481150      }
11491151      else
r13245r13246
11541156   else
11551157   {
11561158      set_command_done(device, ST_TC_SUCCESS);
1157      //logerror("smc92x4 read sector command done\n");
1159      if (VERBOSE>7) LOG("smc92x4 read sector command done\n");
11581160   }
11591161}
11601162
r13245r13246
11831185      w->to_be_continued = FALSE;
11841186      if (w->register_r[INT_STATUS] & ST_TERMCOD)
11851187      {
1186         logerror("smc92x4 error: data error during sector write\n");
1188         if (VERBOSE>0) LOG("smc92x4 error: data error during sector write\n");
11871189         set_command_done(device, ST_TC_DATAERR);
11881190         return;
11891191      }
r13245r13246
11921194   w->to_be_continued = FALSE;
11931195
11941196   if ((w->register_w[RETRY_COUNT] & 0xf0)!= 0xf0)
1195      logerror("smc92x4 warn: RETRY_COUNT in write sector should be set to 0. Ignored.\n");
1197      if (VERBOSE>1) LOG("smc92x4 warn: RETRY_COUNT in write sector should be set to 0. Ignored.\n");
11961198
11971199   /* Wait for SEEK_COMPLETE. We assume the signal has appeared. */
11981200   if (w->register_w[SECTOR_COUNT] > 0)
r13245r13246
12011203      state = verify(device, &w->recent_id, check_sector);
12021204      if (state==ERROR)
12031205      {
1204         logerror("smc92x4 error: verify error during sector write\n");
1206         if (VERBOSE>0) LOG("smc92x4 error: verify error during sector write\n");
12051207         return;
12061208      }
12071209
r13245r13246
12211223   else
12221224   {
12231225      set_command_done(device, ST_TC_SUCCESS);
1224      // logerror("smc92x4 write sector command done\n");
1226      if (VERBOSE>7) LOG("smc92x4 write sector command done\n");
12251227   }
12261228}
12271229
r13245r13246
12411243
12421244   if (w->seek_count>=4096 || !(w->register_r[DRIVE_STATUS] & DS_READY))
12431245   {
1244      logerror("smc92x4 error: seek error in restore\n");
1246      if (VERBOSE>0) LOG("smc92x4 error: seek error in restore\n");
12451247      w->register_r[INT_STATUS] |= ST_TC_SEEKERR;
12461248      return;
12471249   }
r13245r13246
12861288   w->buffered = buffered;
12871289
12881290   smc92x4_timed_seek_request(device);
1289   //logerror("smc92x4 waiting for drive step\n");
1291   if (VERBOSE>6) LOG("smc92x4 waiting for drive step\n");
12901292}
12911293
12921294static void step_continue(device_t *device)
12931295{
12941296   smc92x4_state *w = get_safe_token(device);
1295   //logerror("smc92x4 step continue\n");
1297   if (VERBOSE>7) LOG("smc92x4 step continue\n");
12961298   w->to_be_continued = FALSE;
12971299   set_command_done(device,  ST_TC_SUCCESS);
12981300}
r13245r13246
13811383      else
13821384      {
13831385         if (wait)
1384            logerror("smc92x4 warn: seed_read_id: Waiting for seek_complete not implemented.\n");
1386            if (VERBOSE>1) LOG("smc92x4 warn: seed_read_id: Waiting for seek_complete not implemented.\n");
13851387
13861388         if (verify_id)
13871389         {
r13245r13246
15531555   exp_size = gap0 + inam + gap1 + count*(sync1 + mark + gap2 + sync2 + size*128 + gap3) + gap4;
15541556
15551557   if (exp_size != data_count)
1556      logerror("smc92x4 warn: The current track length in the image (%d) does not match the new track length (%d). Keeping the old length. This will break the image (sorry).\n", data_count, exp_size);
1558      if (VERBOSE>0) LOG("smc92x4 warn: The current track length in the image (%d) does not match the new track length (%d). Keeping the old length. This will break the image (sorry).\n", data_count, exp_size);
15571559
15581560   /* use the backup registers set up during drive_select */
15591561   set_dma_address(device, CURRENT_IDENT, CURRENT_CYLINDER, CURRENT_HEAD);
r13245r13246
16031605      buffer[index++] = curr_sect;
16041606      buffer[index++] = curr_size;
16051607
1606      // if (j==0) logerror("current_floppy=%s, format track %d, head %d\n",  current_floppy->tag(), curr_cyl, curr_head);
1608      if (j==0)
1609         if (VERBOSE>6) LOG("current_floppy=%s, format track %d, head %d\n",  current_floppy->tag(), curr_cyl, curr_head);
16071610
16081611      /* Calculate CRC16 (5 bytes for ID) */
16091612      crc = ccitt_crc16(0xffff, &buffer[index-5], 5);
r13245r13246
18011804
18021805   if (transfer_only_ids)
18031806   {
1804      logerror("smc92x4 warn: read track: Ignoring transfer-only-ids. Reading complete track.\n");
1807      if (VERBOSE>1) LOG("smc92x4 warn: read track: Ignoring transfer-only-ids. Reading complete track.\n");
18051808   }
18061809
18071810   smc92x4_set_dip(device, TRUE);
r13245r13246
18311834
18321835   if (!(w->register_r[DRIVE_STATUS] & DS_READY))
18331836   {
1834      logerror("smc92x4 error: read harddisk track failed.\n");
1837      if (VERBOSE>0) LOG("smc92x4 error: read harddisk track failed.\n");
18351838      /* no buffer was allocated */
18361839   }
18371840
r13245r13246
18411844
18421845   if (transfer_only_ids)
18431846   {
1844      logerror("smc92x4 warn: read track: Ignoring transfer-only-ids. Reading complete track.\n");
1847      if (VERBOSE>1) LOG("smc92x4 warn: read track: Ignoring transfer-only-ids. Reading complete track.\n");
18451848   }
18461849
18471850   smc92x4_set_dip(device, TRUE);
r13245r13246
19361939   }
19371940   else
19381941   {
1939      logerror("smc92x4 warn: Invalid command %x or command changed while waiting for callback\n", opcode);
1942      if (VERBOSE>1) LOG("smc92x4 warn: Invalid command %x or command changed while waiting for callback\n", opcode);
19401943   }
19411944}
19421945
r13245r13246
19471950{
19481951   smc92x4_state *w = get_safe_token(device);
19491952
1950   //logerror("smc92x4 process command %02x\n", opcode);
1953   if (VERBOSE>6) LOG("smc92x4 process command %02x\n", opcode);
19511954   if (w->to_be_continued)
19521955   {
1953      logerror("smc92x4 warn: previous command %02x not complete\n", w->command);
1956      if (VERBOSE>1) LOG("smc92x4 warn: previous command %02x not complete\n", w->command);
19541957   }
19551958
19561959   /* Reset DONE and BAD_SECTOR. */
r13245r13246
19691972   {
19701973      /* RESET */
19711974      /* same effect as the RST* pin being active */
1972      logerror("smc92x4 info: reset command\n");
1975      if (VERBOSE>0) LOG("smc92x4 info: reset command\n");
19731976      smc92x4_reset(device);
19741977   }
19751978   else if (opcode == 0x01)
19761979   {
19771980      /* DESELECT DRIVE */
19781981      /* done when no drive is in use */
1979      logerror("smc92x4 info: drdeselect command\n");
1982      if (VERBOSE>2) LOG("smc92x4 info: drdeselect command\n");
19801983      w->output1 &= ~(OUT1_DRVSEL3|OUT1_DRVSEL2|OUT1_DRVSEL1|OUT1_DRVSEL0);
19811984      w->output2 |= OUT2_DRVSEL3_;
19821985      /* sync the latches on the PCB */
r13245r13246
19881991      /* RESTORE DRIVE */
19891992      // bit 0: 0 -> command ends after last seek pulse, 1 -> command
19901993      // ends when the drive asserts the seek complete pin
1991      logerror("smc92x4 info: restore command %X\n", opcode);
1994      if (VERBOSE>2) LOG("smc92x4 info: restore command %X\n", opcode);
19921995      restore_drive(device);
19931996   }
19941997   else if (opcode >= 0x04 && opcode <= 0x07)
19951998   {
19961999      /* STEP IN/OUT ONE CYLINDER */
1997      logerror("smc92x4 info: step in/out command %X\n", opcode);
2000      if (VERBOSE>2) LOG("smc92x4 info: step in/out command %X\n", opcode);
19982001      step_in_out(device);
19992002   }
20002003   else if (opcode >= 0x08 && opcode <= 0x0f)
20012004   {
20022005      /* TAPE BACKUP (08-0f)*/
2003      logerror("smc92x4 warn: tape backup command %X not implemented\n", opcode);
2006      if (VERBOSE>0) LOG("smc92x4 error: tape backup command %X not implemented\n", opcode);
20042007   }
20052008   else if (opcode >= 0x10 && opcode <= 0x1f)
20062009   {
20072010      /* POLLDRIVE */
2008      logerror("smc92x4 info: polldrive command %X\n", opcode);
2011      if (VERBOSE>2) LOG("smc92x4 info: polldrive command %X\n", opcode);
20092012      poll_drives(device);
20102013   }
20112014   else if (opcode >= 0x20 && opcode <= 0x3f)
20122015   {
20132016      /* DRIVE SELECT */
2014      logerror("smc92x4 info: drselect command %X\n", opcode);
2017      if (VERBOSE>2) LOG("smc92x4 info: drselect command %X\n", opcode);
20152018      drive_select(device, opcode&0x1f);
20162019   }
20172020   else if (opcode >= 0x40 && opcode <= 0x4f)
20182021   {
20192022      /* SETREGPTR */
2020      logerror("smc92x4 info: setregptr command %X\n", opcode);
2023      if (VERBOSE>2) LOG("smc92x4 info: setregptr command %X\n", opcode);
20212024      w->register_pointer = opcode & 0xf;
20222025      // Spec does not say anything about the effect of setting an
20232026      // invalid value (only "care should be taken")
20242027      if (w->register_pointer > 10)
20252028      {
2026         logerror("smc92x4 error: set register pointer: Invalid register number: %d. Setting to 10.\n", w->register_pointer);
2029         if (VERBOSE>1) LOG("smc92x4 error: set register pointer: Invalid register number: %d. Setting to 10.\n", w->register_pointer);
20272030         w->register_pointer = 10;
20282031      }
20292032   }
20302033   else if (opcode >= 0x50 && opcode <= 0x57)
20312034   {
20322035      /* SEEK/READ ID */
2033      logerror("smc92x4 seekreadid command %X\n", opcode);
2036      if (VERBOSE>2) LOG("smc92x4 seekreadid command %X\n", opcode);
20342037      seek_read_id(device);
20352038   }
20362039   else if ((opcode >= 0x58 && opcode <= 0x59)
r13245r13246
20382041      || (opcode >= 0x80))
20392042   {
20402043      /* READ/WRITE SECTORS PHYSICAL/LOGICAL */
2041      logerror("smc92x4 info: read/write sector command %X\n", opcode);
2044      if (VERBOSE>2) LOG("smc92x4 info: read/write sector command %X\n", opcode);
20422045      read_write_sectors(device);
20432046   }
20442047   else if (opcode >= 0x5A && opcode <= 0x5b)
20452048   {
20462049      /* READ TRACK */
2047      logerror("smc92x4 info: read track command %X\n", opcode);
2050      if (VERBOSE>2) LOG("smc92x4 info: read track command %X\n", opcode);
20482051      read_track(device);
20492052   }
20502053   else if (opcode >= 0x60 && opcode <= 0x7f)
20512054   {
20522055      /* FORMAT TRACK */
2053      logerror("smc92x4 info: format track command %X\n", opcode);
2056      if (VERBOSE>2) LOG("smc92x4 info: format track command %X\n", opcode);
20542057      format_track(device);
20552058   }
20562059   else
20572060   {
2058      logerror("smc92x4 warn: Invalid command %x, ignored\n", opcode);
2061      if (VERBOSE>0) LOG("smc92x4 error: Invalid command %x, ignored\n", opcode);
20592062   }
20602063
20612064   if (!w->to_be_continued)
r13245r13246
20792082   {
20802083      /* data register */
20812084      reply = w->register_r[w->register_pointer];
2082      // logerror("smc92x4 register_r[%d] -> %02x\n", w->register_pointer, reply);
2085      if (VERBOSE>6) LOG("smc92x4 register_r[%d] -> %02x\n", w->register_pointer, reply);
20832086      /* Autoincrement until DATA is reached. */
20842087      if (w->register_pointer < DATA)
20852088         w->register_pointer++;
r13245r13246
20902093      reply = w->register_r[INT_STATUS];
20912094      // Spec (p.3) : The interrupt pin is reset to its inactive state
20922095      // when the UDC interrupt status register is read.
2093      // logerror("smc92x4 interrupt status read = %02x\n", reply);
2096      if (VERBOSE>6) LOG("smc92x4 interrupt status read = %02x\n", reply);
20942097      smc92x4_clear_interrupt(device);
20952098      /* Clear the bits due to int status register read. */
20962099      w->register_r[INT_STATUS] &= ~(ST_INTPEND | ST_RDYCHNG);
r13245r13246
21102113   if ((offset & 1) == 0)
21112114   {
21122115      /* data register */
2113      // logerror("smc92x4 register_w[%d] <- %X\n", w->register_pointer, data);
2116      if (VERBOSE>6) LOG("smc92x4 register_w[%d] <- %X\n", w->register_pointer, data);
21142117      w->register_w[w->register_pointer] = data;
21152118
21162119      // The DMA registers and the sector register for read and
r13245r13246
21752178{
21762179   smc92x4_state *w = get_safe_token(device);
21772180   w->use_real_timing = realistic;
2178   logerror("smc92x4: use realistic timing: %02x\n", realistic);
2181   if (VERBOSE>0) LOG("smc92x4: use realistic timing: %02x\n", realistic);
21792182}
21802183
21812184/***************************************************************************

Previous 15994 Revisions Next


© 1998-2018 The MESS Team