Previous 15994 Revisions Next

r13890 Thursday 5th January, 2012 at 22:48:36 UTC by Curt Coder
[scsibus.c] Sector size is now configurable in init_scsibus. [Curt Coder]
[scsihd.c] Get sector size from CHD metadata to support old 256 bytes/sector SASI drives, and allow hard disk image subdevices. [Curt Coder]
[src/emu/machine]scsihd.c
[src/mess/drivers]v1050.c
[src/mess/machine]d9060.c lux4105.c rmnimbus.c scsibus.c scsibus.h

src/emu/machine/scsihd.c
r13889r13890
1414{
1515   UINT32 lba;
1616   UINT32 blocks;
17   int sectorbytes;
1718   hard_disk_file *disk;
1819   bool is_file;
1920} SCSIHd;
r13889r13890
4546         logerror("SCSIHD: READ at LBA %x for %x blocks\n", our_this->lba, our_this->blocks);
4647
4748         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
48         return our_this->blocks * 512;
49         return our_this->blocks * our_this->sectorbytes;
4950
5051      case 0x0a: // WRITE(6)
5152         our_this->lba = (command[1]&0x1f)<<16 | command[2]<<8 | command[3];
r13889r13890
5455         logerror("SCSIHD: WRITE to LBA %x for %x blocks\n", our_this->lba, our_this->blocks);
5556
5657         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAOUT );
57         return our_this->blocks * 512;
58         return our_this->blocks * our_this->sectorbytes;
5859
5960      case 0x12: // INQUIRY
6061         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
r13889r13890
8081         logerror("SCSIHD: READ at LBA %x for %x blocks\n", our_this->lba, our_this->blocks);
8182
8283         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
83         return our_this->blocks * 512;
84         return our_this->blocks * our_this->sectorbytes;
8485
8586      case 0x2a: // WRITE (10)
8687         our_this->lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
r13889r13890
9091
9192         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAOUT );
9293
93         return our_this->blocks * 512;
94         return our_this->blocks * our_this->sectorbytes;
9495
9596      case 0xa8: // READ(12)
9697         our_this->lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
r13889r13890
99100         logerror("SCSIHD: READ at LBA %x for %x blocks\n", our_this->lba, our_this->blocks);
100101
101102         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
102         return our_this->blocks * 512;
103         return our_this->blocks * our_this->sectorbytes;
103104
104105      default:
105106         return SCSIBase( &SCSIClassHARDDISK, SCSIOP_EXEC_COMMAND, scsiInstance, 0, NULL );
r13889r13890
168169               }
169170               our_this->lba++;
170171               our_this->blocks--;
171               dataLength -= 512;
172               data += 512;
172               dataLength -= our_this->sectorbytes;
173               data += our_this->sectorbytes;
173174            }
174175         }
175176         break;
r13889r13890
231232               }
232233               our_this->lba++;
233234               our_this->blocks--;
234               dataLength -= 512;
235               data += 512;
235               dataLength -= our_this->sectorbytes;
236               data += our_this->sectorbytes;
236237            }
237238         }
238239         break;
r13889r13890
250251
251252   our_this->lba = 0;
252253   our_this->blocks = 0;
254   our_this->sectorbytes = 512;
253255
254256   state_save_register_item( machine, "scsihd", diskregion, 0, our_this->lba );
255257   state_save_register_item( machine, "scsihd", diskregion, 0, our_this->blocks );
r13889r13890
258260      our_this->is_file = TRUE;
259261      our_this->disk = machine.device<harddisk_image_device>(diskregion)->get_hard_disk_file();
260262   } else {
261      our_this->is_file = FALSE;
262      our_this->disk = hard_disk_open(get_disk_handle( machine, diskregion ));
263      for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
264      {
265         if (device->subdevice(diskregion)) {
266            our_this->is_file = TRUE;
267            our_this->disk = device->subdevice<harddisk_image_device>(diskregion)->get_hard_disk_file();
268         }
269      }
270     
271      if (!our_this->disk)
272      {
273         our_this->is_file = FALSE;
274         our_this->disk = hard_disk_open(get_disk_handle( machine, diskregion ));
275      }
263276   }
264277
265278   if (!our_this->disk)
266279   {
267280      logerror("SCSIHD: no HD found!\n");
268281   }
282   else
283   {
284      const hard_disk_info *hdinfo = hard_disk_get_info(our_this->disk);
285      our_this->sectorbytes = hdinfo->sectorbytes;
286   }
269287}
270288
271289static void scsihd_delete_instance( SCSIInstance *scsiInstance )
src/mess/machine/d9060.c
r13889r13890
77
88**********************************************************************/
99
10/*
11
12    TODO:
13
14    - scsihd.c wants the harddisk device to be at the driver level
15    - scsihd.c/scsibus.c have a fixed block size of 512
16
17*/
18
1910#include "d9060.h"
2011
2112
r13889r13890
476467   MCFG_VIA6522_ADD(M6522_TAG, XTAL_4MHz/4, via_intf)
477468
478469   MCFG_SCSIBUS_ADD(SASIBUS_TAG, sasi_intf)
479   //MCFG_HARDDISK_ADD("harddisk0") this needs to be in pet.c for now
470   MCFG_HARDDISK_ADD("harddisk0")
480471MACHINE_CONFIG_END
481472
482473
r13889r13890
574565
575566void base_d9060_device::device_reset()
576567{
577   init_scsibus(m_sasibus);
568   init_scsibus(m_sasibus, 256);
578569
579570   m_maincpu->set_input_line(M6502_SET_OVERFLOW, ASSERT_LINE);
580571   m_maincpu->set_input_line(M6502_SET_OVERFLOW, CLEAR_LINE);
src/mess/machine/scsibus.c
r13889r13890
5757   int         xfer_count;
5858   int         bytes_left;
5959   int         data_last;
60   int         sectorbytes;
6061
6162   emu_timer   *req_timer;
6263   emu_timer   *ack_timer;
r13889r13890
127128
128129static void scsibus_read_data(scsibus_t   *bus)
129130{
130    bus->data_last = (bus->bytes_left >= DATA_BLOCK_SIZE) ? DATA_BLOCK_SIZE : bus->bytes_left;
131    bus->data_last = (bus->bytes_left >= bus->sectorbytes) ? bus->sectorbytes : bus->bytes_left;
131132
132133    LOG(2,"SCSIBUS:scsibus_read_data bus->bytes_left=%04X, bus->data_last=%04X, bus->xfer_count=%04X\n",bus->bytes_left,bus->data_last,bus->xfer_count);
133134
r13889r13890
141142
142143static void scsibus_write_data(scsibus_t   *bus)
143144{
144    if(bus->bytes_left >= DATA_BLOCK_SIZE)
145    if(bus->bytes_left >= bus->sectorbytes)
145146    {
146        SCSIWriteData(bus->devices[bus->last_id], bus->data, DATA_BLOCK_SIZE);
147        SCSIWriteData(bus->devices[bus->last_id], bus->data, bus->sectorbytes);
147148
148        bus->bytes_left-=DATA_BLOCK_SIZE;
149        bus->bytes_left-=bus->sectorbytes;
149150        bus->data_idx=0;
150151    }
151152}
r13889r13890
164165
165166            // check to see if we have reached the end of the block buffer
166167            // and that there is more data to read from the scsi disk
167            if((bus->data_idx==DATA_BLOCK_SIZE) && (bus->bytes_left>0) && IS_READ_COMMAND())
168            if((bus->data_idx==bus->sectorbytes) && (bus->bytes_left>0) && IS_READ_COMMAND())
168169            {
169170                scsibus_read_data(bus);
170171            }
r13889r13890
237238         }
238239
239240            // If the data buffer is full, and we are writing blocks flush it to the SCSI disk
240            if((bus->data_idx == DATA_BLOCK_SIZE) && IS_WRITE_COMMAND())
241            if((bus->data_idx == bus->sectorbytes) && IS_WRITE_COMMAND())
241242                scsibus_write_data(bus);
242243            break;
243244    }
r13889r13890
938939   return 6;
939940}
940941
941void init_scsibus(device_t *device)
942void init_scsibus(device_t *device, int sectorbytes)
942943{
943944    scsibus_t               *bus = get_token(device);
944945    const SCSIConfigTable   *scsidevs = bus->interface->scsidevs;
r13889r13890
955956
956957        bus->initialised=1;
957958    }
959   
960   bus->sectorbytes = sectorbytes;
958961}
959962
960963static DEVICE_START( scsibus )
src/mess/machine/scsibus.h
r13889r13890
4949#define CMD_BUF_SIZE             32
5050#define ADAPTEC_BUF_SIZE         1024
5151
52#define DATA_BLOCK_SIZE            512
53
5452#define SCSI_CMD_TEST_READY         0x00
5553#define SCSI_CMD_RECALIBRATE      0x01
5654#define SCSI_CMD_REQUEST_SENSE      0x03
r13889r13890
216214int get_scsi_cmd_len(int cbyte);
217215
218216/* Initialisation at machine reset time */
219void init_scsibus(device_t *device);
217void init_scsibus(device_t *device, int sectorbytes);
220218
221219#endif
src/mess/machine/lux4105.c
r13889r13890
182182
183183void luxor_4105_device::device_reset()
184184{
185   init_scsibus(m_sasibus);
185   init_scsibus(m_sasibus, 512);
186186
187187   m_cs = 0;
188188   m_data = 0;
src/mess/machine/rmnimbus.c
r13889r13890
24272427   rmnimbus_state *state = machine.driver_data<rmnimbus_state>();
24282428    device_t *hdc = machine.device(SCSIBUS_TAG);
24292429
2430    init_scsibus(hdc);
2430    init_scsibus(hdc, 512);
24312431
24322432    state->m_nimbus_drives.reg410_in=0;
24332433    state->m_nimbus_drives.reg410_in |= (get_scsi_line(hdc,SCSI_LINE_REQ) ? HDC_REQ_MASK : 0);
src/mess/drivers/v1050.c
r13889r13890
102102
103103      chdman -createblankhd tm501.chd 306 2 32 256
104104        chdman -createblankhd cm5412.chd 306 4 17 512
105
106   - scsihd.c does not support 256 byte sectors
107105   
108106*/
109107
r13889r13890
10301028   address_space *program = m_maincpu->memory().space(AS_PROGRAM);
10311029
10321030   // initialize SASI bus
1033   init_scsibus(m_sasibus);
1031   init_scsibus(m_sasibus, 256);
10341032
10351033   // initialize I8214
10361034   m_pic->etlg_w(1);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team