Previous 15994 Revisions Next

r2420 Saturday 19th April, 2008 at 23:45:27 UTC by R. Belmont
[MACPLUS] SCSI HDDs work again (bug #1580)
[src/mess/drivers]mac.c
[src/mess/includes]mac.h
[src/mess/machine]mac.c ncr5380.c ncr5380.h

src/mess/includes/mac.h
r2419r2420
2121
2222/*----------- defined in machine/mac.c -----------*/
2323
24MACHINE_START( macscsi );
2425MACHINE_RESET( mac );
2526
2627DRIVER_INIT(mac128k512k);
src/mess/machine/mac.c
r2419r2420
13871387
13881388static const SCSIConfigTable dev_table =
13891389{
1390   2,                                      /* 2 SCSI devices */
1391   { { SCSI_ID_5, 1, SCSI_DEVICE_HARDDISK },  /* SCSI ID 5, using CHD 1, and it's a harddisk */
1392    { SCSI_ID_6, 0, SCSI_DEVICE_HARDDISK } } /* SCSI ID 6, using CHD 0, and it's a harddisk */
1390   1,                                      /* 2 SCSI devices */
1391   {
1392    { SCSI_ID_5, 0, SCSI_DEVICE_HARDDISK },  /* SCSI ID 5, using CHD 1, and it's a harddisk */
1393    { SCSI_ID_6, 1, SCSI_DEVICE_HARDDISK }   /* SCSI ID 6, using CHD 0, and it's a harddisk */
1394   }
13931395};
13941396
13951397static const struct NCR5380interface macplus_5380intf =
r2419r2420
13981400   NULL      // IRQ (unconnected on the Mac Plus)
13991401};
14001402
1403MACHINE_START( macscsi )
1404{
1405   ncr5380_init(&macplus_5380intf);
1406}
1407
14011408DRIVER_INIT(macplus)
14021409{
14031410   mac_driver_init(MODEL_MAC_PLUS);
1404
1405   ncr5380_init(&macplus_5380intf);
14061411}
14071412
14081413DRIVER_INIT(macse)
14091414{
14101415   mac_driver_init(MODEL_MAC_SE);
1411
1412   ncr5380_init(&macplus_5380intf);
14131416}
14141417
14151418DRIVER_INIT(macclassic)
14161419{
14171420   mac_driver_init(MODEL_MAC_CLASSIC);
1418
1419   ncr5380_init(&macplus_5380intf);
14201421}
14211422
14221423static void mac_vblank_irq(running_machine *machine)
src/mess/machine/ncr5380.c
r2419r2420
4949   "DMA initiator rec"
5050};
5151
52typedef struct
53{
54   void *data;      // device's "this" pointer
55   pSCSIDispatch handler;   // device's handler routine
56} SCSIDev;
57
58static SCSIDev devices[8];   // SCSI IDs 0-7
52static SCSIInstance *devices[8];   // SCSI IDs 0-7
5953static const struct NCR5380interface *intf;
6054
6155static UINT8 n5380_Registers[8];
r2419r2420
6458static INT32 cmd_ptr, d_ptr, d_limit;
6559static UINT8 n5380_Data[512];
6660
61#if NCR5380_DEVICE_CONVERSION
62typedef struct _ncr5380_t ncr5380_t;   
63struct _ncr5380_t
64{
65   SCSIInstance *devices[8];
66   struct NCR5380interface *intf;
67
68   UINT8 n5380_Registers[8];
69   UINT8 last_id;
70   UINT8 n5380_Command[32];
71   INT32 cmd_ptr, d_ptr, d_limit;
72   UINT8 n5380_Data[512];
73};
74#endif
75
6776// get the length of a SCSI command based on it's command byte type
6877static int get_cmd_len(int cbyte)
6978{
r2419r2420
172181               if (get_cmd_len(n5380_Command[0]) == cmd_ptr)
173182               {
174183                  if (VERBOSE)
175                     logerror("Command (to ID %d): %x %x %x %x %x %x\n", last_id, n5380_Command[0], n5380_Command[1], n5380_Command[2], n5380_Command[3], n5380_Command[4], n5380_Command[5]);
184                     logerror("NCR5380: Command (to ID %d): %x %x %x %x %x %x\n", last_id, n5380_Command[0], n5380_Command[1], n5380_Command[2], n5380_Command[3], n5380_Command[4], n5380_Command[5]);
176185
177                  d_limit = devices[last_id].handler(SCSIOP_EXEC_COMMAND, devices[last_id].data, 0, &n5380_Command[0]);
186                  SCSISetCommand(devices[last_id], &n5380_Command[0], 16);
187                  SCSIExecCommand(devices[last_id], &d_limit);
178188
189                  if (VERBOSE)
190                     logerror("NCR5380: Command returned %d bytes\n",  d_limit);
191
179192                  d_ptr = 0;
180193
181194                  // is data available?
r2419r2420
203216            // if the device exists, make the bus busy.
204217            // otherwise don't.
205218
206            if (devices[last_id].handler)
219            if (devices[last_id])
207220            {
221               if (VERBOSE)
222                  logerror("NCR5380: Giving the bus for ID %d\n", last_id);
208223               n5380_Registers[R5380_BUSSTATUS] |= 0x40;
209224            }
210225            else
211226            {
227               if (VERBOSE)
228                  logerror("NCR5380: Rejecting the bus for ID %d\n", last_id);
212229               n5380_Registers[R5380_BUSSTATUS] &= ~0x40;
213230            }
214231         }
r2419r2420
333350   return rv;
334351}
335352
336extern void ncr5380_init( const struct NCR5380interface *interface )
353void ncr5380_init( const struct NCR5380interface *interface )
337354{
338355   int i;
339356
r2419r2420
346363   // try to open the devices
347364   for (i = 0; i < interface->scsidevs->devs_present; i++)
348365   {
349      /* compilation error */
350      /* devices[interface->scsidevs->devices[i].scsiID].handler = interface->scsidevs->devices[i].handler; */
351      /* interface->scsidevs->devices[i].handler(SCSIOP_ALLOC_INSTANCE, &devices[interface->scsidevs->devices[i].scsiID].data, interface->scsidevs->devices[i].diskID, (UINT8 *)NULL); */
366      SCSIAllocInstance( interface->scsidevs->devices[i].scsiClass, &devices[interface->scsidevs->devices[i].scsiID], interface->scsidevs->devices[i].diskID );
352367   }
353368
354369   state_save_register_item_array("ncr5380", 0, n5380_Registers);
r2419r2420
360375   state_save_register_item("ncr5380", 0, d_limit);
361376}
362377
378void ncr5380_exit( const struct NCR5380interface *interface )
379{
380   int i;
381
382   // clean up the devices
383   for (i = 0; i < interface->scsidevs->devs_present; i++)
384   {
385      SCSIDeleteInstance( devices[interface->scsidevs->devices[i].scsiID] );
386   }
387}
388
363389void ncr5380_read_data(int bytes, UINT8 *pData)
364390{
365   if (devices[last_id].handler)
391   if (devices[last_id])
366392   {
367      devices[last_id].handler(SCSIOP_READ_DATA, devices[last_id].data, bytes, pData);
393      if (VERBOSE)
394         logerror("NCR5380: issuing read for %d bytes\n", bytes);
395      SCSIReadData(devices[last_id], pData, bytes);
368396   }
369397   else
370398   {
r2419r2420
374402
375403void ncr5380_write_data(int bytes, UINT8 *pData)
376404{
377   if (devices[last_id].handler)
405   if (devices[last_id])
378406   {
379      devices[last_id].handler(SCSIOP_WRITE_DATA, devices[last_id].data, bytes, pData);
407      SCSIWriteData(devices[last_id], pData, bytes);
380408   }
381409   else
382410   {
r2419r2420
388416{
389417   void *ret;
390418
391   if (devices[id].handler)
419   if (devices[id])
392420   {
393421      logerror("ncr5380: fetching dev pointer for SCSI ID %d\n", id);
394      devices[id].handler(SCSIOP_GET_DEVICE, devices[id].data, 0, (UINT8 *)&ret);
422      SCSIGetDevice(devices[id], &ret);
395423
396424      return ret;
397425   }
398426
399427   return NULL;
400428}
429
430/* device interface */
431#if NCR5380_DEVICE_CONVERSION
432static DEVICE_START( ncr5380 )
433{
434}
435
436
437static DEVICE_RESET( ncr5380 )
438{
439}
440
441
442static DEVICE_SET_INFO( ncr5380 )
443{
444   switch ( state )
445   {
446      /* no parameters to set */
447   }
448}
449
450
451DEVICE_GET_INFO( ncr5380 ) {
452   switch ( state ) {
453      /* --- the following bits of info are returned as 64-bit signed integers --- */
454      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(ncr5380_t);            break;
455      case DEVINFO_INT_INLINE_CONFIG_BYTES:      info->i = 0;                        break;
456      case DEVINFO_INT_CLASS:            info->i = DEVICE_CLASS_PERIPHERAL;         break;
457
458      /* --- the following bits of info are returned as pointers to data or functions --- */
459      case DEVINFO_FCT_SET_INFO:         info->set_info = DEVICE_SET_INFO_NAME(ncr5380);   break;
460      case DEVINFO_FCT_START:            info->start = DEVICE_START_NAME(ncr5380);   break;
461      case DEVINFO_FCT_STOP:            /* nothing */                break;
462      case DEVINFO_FCT_RESET:            info->reset = DEVICE_RESET_NAME(ncr5380);   break;
463
464      /* --- the following bits of info are returned as NULL-terminated strings --- */
465      case DEVINFO_STR_NAME:            info->s = "NCR 5380";               break;
466      case DEVINFO_STR_FAMILY:         info->s = "NCR53xx";               break;
467      case DEVINFO_STR_VERSION:         info->s = "1.1";               break;
468      case DEVINFO_STR_SOURCE_FILE:         info->s = __FILE__;               break;
469      case DEVINFO_STR_CREDITS:         info->s = "Copyright the MAME and MESS Teams"; break;
470   }
471}
472#endif
src/mess/machine/ncr5380.h
r2419r2420
11/*
2 * ncr5380.h
2 * ncr5380.h SCSI controller
33 *
44 */
55
r2419r2420
88
99#include "machine/scsidev.h"
1010
11#define NCR5380_DEVICE_CONVERSION (0)
12
1113struct NCR5380interface
1214{
1315   const SCSIConfigTable *scsidevs;      /* SCSI devices */
r2419r2420
3739#define R5380_CURDATA_DTACK   (R5380_CURDATA | 0x10)
3840
3941extern void ncr5380_init( const struct NCR5380interface *interface );
42extern void ncr5380_exit( const struct NCR5380interface *interface );
4043extern void ncr5380_read_data(int bytes, UINT8 *pData);
4144extern void ncr5380_write_data(int bytes, UINT8 *pData);
4245extern void *ncr5380_get_device(int id);
4346extern READ8_HANDLER(ncr5380_r);
4447extern WRITE8_HANDLER(ncr5380_w);
4548
49// device stuff
50
51#if NCR5380_DEVICE_CONVERSION
52#define NCR5380   DEVICE_GET_INFO_NAME(ncr5380)
53
54DEVICE_GET_INFO(scsi5380);
4655#endif
56
57#endif
src/mess/drivers/mac.c
r2419r2420
3838#include "driver.h"
3939#include "includes/mac.h"
4040#include "machine/6522via.h"
41#include "machine/ncr5380.h"
4142#include "devices/sonydriv.h"
4243#include "devices/harddriv.h"
4344
r2419r2420
9798   MDRV_NVRAM_HANDLER(mac)
9899MACHINE_DRIVER_END
99100
100
101
102101static MACHINE_DRIVER_START( macplus )
103102   MDRV_IMPORT_FROM( mac512ke )
104103   MDRV_CPU_MODIFY( "main" )
105104   MDRV_CPU_PROGRAM_MAP(macplus_map, 0)
105
106   MDRV_MACHINE_START(macscsi)
106107MACHINE_DRIVER_END
107108
108109

Previous 15994 Revisions Next


© 1998-2018 The MESS Team