Previous 199869 Revisions Next

r18132 Tuesday 25th September, 2012 at 05:23:18 UTC by smf
(MESS) fixed v1050 hard drive, drive can be formatted, installed & booted from. [smf]
[src/emu/machine]scsibus.c scsibus.h

trunk/src/emu/machine/scsibus.c
r18131r18132
6464{
6565   data_last = (bytes_left >= sectorbytes) ? sectorbytes : bytes_left;
6666
67   LOG(2,"SCSIBUS:scsibus_read_data bytes_left=%04X, data_last=%04X, xfer_count=%04X\n",bytes_left,data_last,xfer_count);
67   LOG(2,"SCSIBUS:scsibus_read_data bytes_left=%04X, data_last=%04X\n",bytes_left,data_last);
6868
6969   if (data_last > 0)
7070   {
7171      devices[last_id]->ReadData(buffer, data_last);
7272      bytes_left-=data_last;
73      data_idx=0;
7473   }
74
75   data_idx=0;
7576}
7677
7778void scsibus_device::scsibus_write_data()
7879{
79   if(bytes_left >= sectorbytes)
80   if (data_last > 0)
8081   {
81      devices[last_id]->WriteData(buffer, sectorbytes);
82
83      bytes_left-=sectorbytes;
84      data_idx=0;
82      devices[last_id]->WriteData(buffer, data_last);
83      bytes_left-=data_last;
8584   }
85
86   data_idx=0;
8687}
8788
8889/* SCSI Bus read/write */
r18131r18132
9495   switch (phase)
9596   {
9697      case SCSI_PHASE_DATAIN:
97         result=buffer[data_idx++];
98
99         // check to see if we have reached the end of the block buffer
100         // and that there is more data to read from the scsi disk
101         if((data_idx==sectorbytes) && (bytes_left>0) && IS_READ_COMMAND())
102         {
103            scsibus_read_data();
104         }
98         result=buffer[data_idx];
10599         break;
106100
107101      case SCSI_PHASE_STATUS:
r18131r18132
134128         break;
135129
136130      case SCSI_PHASE_COMMAND:
137         command[cmd_idx++]=data;
131         command[cmd_idx]=data;
138132         break;
139133
140134      case SCSI_PHASE_DATAOUT:
141135
142         //LOG(1,"SCSIBUS:xfer_count=%02X, bytes_left=%02X data_idx=%02X\n",xfer_count,bytes_left,data_idx);
136         //LOG(1,"SCSIBUS:bytes_left=%02X data_idx=%02X\n",bytes_left,data_idx);
143137
144138         if(IS_COMMAND(SCSI_CMD_FORMAT_UNIT))
145139         {
146140            // Only store the first 4 bytes of the bad block list (the header)
147141            //if(data_idx<4)
148               buffer[data_idx++]=data;
142               buffer[data_idx]=data;
149143               dump_data_bytes(4);
150144            //else
151145            //   data_idx++;
152146
153147            // If we have the first byte, then cancel the dataout timout
154            if(data_idx==1)
148            if(data_idx==0)
155149               dataout_timer->adjust(attotime::never);
156150
157151            // When we have the first 3 bytes, calculate how many more are in the
158152            // bad block list.
159            if(data_idx==3)
153            if(data_idx==2)
160154            {
161               xfer_count+=((buffer[2]<<8)+buffer[3]);
162               data_last=xfer_count;
163               LOG(1,"format_unit reading an extra %d bytes\n",xfer_count-4);
155               bytes_left+=((buffer[2]<<8)+buffer[3]);
156               LOG(1,"format_unit reading an extra %d bytes\n",bytes_left-4);
164157               dump_data_bytes(4);
165158            }
166159         }
167160         else
168161         {
169            buffer[data_idx++]=data;
162            buffer[data_idx]=data;
170163         }
171
172         // If the data buffer is full, and we are writing blocks flush it to the SCSI disk
173         if((data_idx == sectorbytes) && IS_WRITE_COMMAND())
174            scsibus_write_data();
175164         break;
176165   }
177166}
r18131r18132
277266         else
278267            devices[last_id]->SetPhase(SCSI_PHASE_STATUS);
279268
280         xfer_count=4;
281         data_last=xfer_count;
282         bytes_left=0;
269         bytes_left=4;
283270         dataout_timer->adjust(attotime::from_seconds(FORMAT_UNIT_TIMEOUT));
284271         break;
285272
286273      case SCSI_CMD_SEARCH_DATA_EQUAL:
287274         LOG(1,"SCSIBUS: Search_data_equaln");
288275         command_local=1;
289         xfer_count=0;
290         data_last=xfer_count;
291276         bytes_left=0;
292277         devices[last_id]->SetPhase(SCSI_PHASE_STATUS);
293278         break;
r18131r18132
301286         buffer[3] = 0x00; // defect list len msb
302287         buffer[4] = 0x00; // defect list len lsb
303288
304         xfer_count=4;
305         data_last=xfer_count;
306         bytes_left=0;
289         bytes_left=4;
307290         devices[last_id]->SetPhase(SCSI_PHASE_DATAIN);
308291         break;
309292
r18131r18132
311294      case SCSI_CMD_BUFFER_WRITE:
312295         LOG(1,"SCSIBUS: write_buffer\n");
313296         command_local=1;
314         xfer_count=(command[7]<<8)+command[8];
315         data_last=xfer_count;
316         bytes_left=0;
297         bytes_left=(command[7]<<8)+command[8];
317298         devices[last_id]->SetPhase(SCSI_PHASE_DATAOUT);
318299         break;
319300
r18131r18132
321302      case SCSI_CMD_BUFFER_READ:
322303         LOG(1,"SCSIBUS: read_buffer\n");
323304         command_local=1;
324         xfer_count=(command[7]<<8)+command[8];
325         data_last=xfer_count;
326         bytes_left=0;
305         bytes_left=(command[7]<<8)+command[8];
327306         devices[last_id]->SetPhase(SCSI_PHASE_DATAIN);
328307         break;
329308   }
r18131r18132
334313   if(!command_local)
335314   {
336315      devices[last_id]->SetCommand(command, cmd_idx);
337      devices[last_id]->ExecCommand(&xfer_count);
338      bytes_left=xfer_count;
339      data_last=xfer_count;
316      devices[last_id]->ExecCommand(&bytes_left);
340317      data_idx=0;
341318   }
342319
r18131r18132
344321
345322   scsi_change_phase(newphase);
346323
347   LOG(1,"SCSIBUS:xfer_count=%02X, bytes_left=%02X data_idx=%02X\n",xfer_count,bytes_left,data_idx);
324   LOG(1,"SCSIBUS:bytes_left=%02X data_idx=%02X\n",bytes_left,data_idx);
348325
349326   // This is correct as we need to read from disk for commands other than just read data
350327   if ((phase == SCSI_PHASE_DATAIN) && (!command_local))
351328      scsibus_read_data();
352329}
353330
354int scsibus_device::datain_done()
355{
356   int result=0;
357
358   // Read data commands
359   if(IS_READ_COMMAND() && (data_idx == data_last) && (bytes_left == 0))
360      result=1;
361   else if (data_idx==data_last)
362      result=1;
363
364   return result;
365}
366
367int scsibus_device::dataout_done()
368{
369   int result=0;
370
371   // Write data commands
372   if(IS_WRITE_COMMAND() && (data_idx == 0) && (bytes_left == 0))
373      result=1;
374   else if (data_idx==data_last)
375      result=1;
376
377   return result;
378}
379
380331void scsibus_device::check_process_dataout()
381332{
382333   int capacity=0;
r18131r18132
438389         {
439390            if(state)
440391            {
392               cmd_idx++;
393
441394               // If the command is ready go and execute it
442395               if(cmd_idx==get_scsi_cmd_len(command[0]))
443396               {
r18131r18132
456409         {
457410            if(state)
458411            {
459               if(datain_done())
412               data_idx++;
413
414               // check to see if we have reached the end of the block buffer
415               // and that there is more data to read from the scsi disk
416               if(data_idx==sectorbytes)
417               {
418                  scsibus_read_data();
419               }
420
421               if(data_idx == data_last && bytes_left == 0)
460422                  scsi_change_phase(SCSI_PHASE_STATUS);
461423               else
462424                  scsi_out_line_change(SCSI_LINE_REQ,0);
r18131r18132
471433         {
472434            if(state)
473435            {
474               if(dataout_done())
436               data_idx++;
437               
438               // If the data buffer is full flush it to the SCSI disk
439
440               data_last = (bytes_left >= sectorbytes) ? sectorbytes : bytes_left;
441
442               if(data_idx == data_last)
443                  scsibus_write_data();
444
445               if(data_idx == 0 && bytes_left == 0)
475446               {
476447                  check_process_dataout();
477448                  scsi_change_phase(SCSI_PHASE_STATUS);
trunk/src/emu/machine/scsibus.h
r18131r18132
135135   void scsi_out_line_req(UINT8 state);
136136   void scsibus_read_data();
137137   void scsibus_write_data();
138   int datain_done();
139   int dataout_done();
140138   void scsibus_exec_command();
141139   void check_process_dataout();
142140   void dump_command_bytes();
r18131r18132
156154
157155   UINT8       buffer[ADAPTEC_BUF_SIZE];
158156   UINT16      data_idx;
159   int         xfer_count;
160157   int         bytes_left;
161158   int         data_last;
162159   int         sectorbytes;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team