Previous 15994 Revisions Next

r9036 Saturday 4th September, 2010 at 21:53:29 UTC by R. Belmont
[MAC] Work around HDD breakage, preliminary proper memory mapping for LC-style machines, start converting NCR5380 to a modern device class.
[src/mess/drivers]mac.c
[src/mess/machine]mac.c ncr5380.c ncr5380.h

src/mess/machine/ncr5380.c
r9035r9036
5858static INT32 cmd_ptr, d_ptr, d_limit, next_req_flag;
5959static UINT8 n5380_Data[512];
6060
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
7661// get the length of a SCSI command based on it's command byte type
7762static int get_cmd_len(int cbyte)
7863{
r9035r9036
380365
381366void ncr5380_init( running_machine *machine, const struct NCR5380interface *interface )
382367{
383   int i;
384
385368   // save interface pointer for later
386369   intf = interface;
387370
388371   memset(n5380_Registers, 0, sizeof(n5380_Registers));
372   memset(n5380_Data, 0, sizeof(n5380_Data));
389373   memset(devices, 0, sizeof(devices));
390374
391375   next_req_flag = 0;
392
393   // try to open the devices
394   for (i = 0; i < interface->scsidevs->devs_present; i++)
395   {
396      SCSIAllocInstance( machine, interface->scsidevs->devices[i].scsiClass, &devices[interface->scsidevs->devices[i].scsiID], interface->scsidevs->devices[i].diskregion );
397   }
398
399376   state_save_register_item_array(machine, "ncr5380", NULL, 0, n5380_Registers);
400377   state_save_register_item_array(machine, "ncr5380", NULL, 0, n5380_Command);
401378   state_save_register_item_array(machine, "ncr5380", NULL, 0, n5380_Data);
r9035r9036
406383   state_save_register_item(machine, "ncr5380", NULL, 0, next_req_flag);
407384}
408385
386void ncr5380_scan_devices( running_machine *machine )
387{
388   int i;
389
390   // try to open the devices
391   for (i = 0; i < intf->scsidevs->devs_present; i++)
392   {
393      // if a device wasn't already allocated
394      if (!devices[intf->scsidevs->devices[i].scsiID])
395      {
396         SCSIAllocInstance( machine,
397               intf->scsidevs->devices[i].scsiClass,
398               &devices[intf->scsidevs->devices[i].scsiID],
399               intf->scsidevs->devices[i].diskregion );
400      }
401   }
402}
403
409404void ncr5380_exit( const struct NCR5380interface *interface )
410405{
411406   int i;
r9035r9036
458453   return NULL;
459454}
460455
461/* device interface */
462#if NCR5380_DEVICE_CONVERSION
463static DEVICE_START( ncr5380 )
456#if USE_5380_DEVICE
457//**************************************************************************
458//  DEVICE CONFIGURATION
459//**************************************************************************
460
461ncr5380_device_config::ncr5380_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
462    : device_config(mconfig, static_alloc_device_config, "5380 SCSI", tag, owner, clock)
464463{
465464}
466465
466device_config *ncr5380_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
467{
468   return global_alloc(ncr5380_device_config(mconfig, tag, owner, clock));
469}
467470
468static DEVICE_RESET( ncr5380 )
471device_t *ncr5380_device_config::alloc_device(running_machine &machine) const
469472{
473   return auto_alloc(&machine, ncr5380_device(machine, *this));
470474}
471475
476//-------------------------------------------------
477//  device_config_complete - perform any
478//  operations now that the configuration is
479//  complete
480//-------------------------------------------------
472481
473DEVICE_GET_INFO( ncr5380 ) {
474   switch ( state ) {
475      /* --- the following bits of info are returned as 64-bit signed integers --- */
476      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(ncr5380_t);            break;
477      case DEVINFO_INT_INLINE_CONFIG_BYTES:      info->i = 0;                      break;
482void ncr5380_device_config::device_config_complete()
483{
484   // inherit a copy of the static data
485   const NCR5380interface *intf = reinterpret_cast<const NCR5380interface *>(static_config());
486   if (intf != NULL)
487      *static_cast<NCR5380interface *>(this) = *intf;
478488
479      /* --- the following bits of info are returned as pointers to data or functions --- */
480      case DEVINFO_FCT_START:            info->start = DEVICE_START_NAME(ncr5380);   break;
481      case DEVINFO_FCT_STOP:            /* nothing */               break;
482      case DEVINFO_FCT_RESET:            info->reset = DEVICE_RESET_NAME(ncr5380);   break;
489   // or initialize to defaults if none provided
490   else
491   {
492      scsidevs = NULL;
493      irq_callback = NULL;
494   }
495}
483496
484      /* --- the following bits of info are returned as NULL-terminated strings --- */
485      case DEVINFO_STR_NAME:            strcpy(info->s, "NCR 5380");            break;
486      case DEVINFO_STR_FAMILY:         strcpy(info->s, "NCR53xx");            break;
487      case DEVINFO_STR_VERSION:         strcpy(info->s, "1.1");            break;
488      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);            break;
489      case DEVINFO_STR_CREDITS:         strcpy(info->s, "Copyright the MAME and MESS Teams"); break;
497//**************************************************************************
498//  LIVE DEVICE
499//**************************************************************************
500
501const device_type NCR5380 = ncr5380_device_config::static_alloc_device_config;
502
503//-------------------------------------------------
504//  via6522_device - constructor
505//-------------------------------------------------
506
507ncr5380_device::ncr5380_device(running_machine &_machine, const ncr5380_device_config &config)
508    : device_t(_machine, config),
509      m_config(config)
510{
511}
512
513//-------------------------------------------------
514//  device_start - device-specific startup
515//-------------------------------------------------
516
517void ncr5380_device::device_start()
518{
519   int i;
520
521   memset(m_5380_Registers, 0, sizeof(m_5380_Registers));
522   memset(m_5380_Data, 0, sizeof(m_5380_Data));
523   memset(m_scsi_devices, 0, sizeof(m_scsi_devices));
524
525   m_next_req_flag = 0;
526
527   // try to open the devices
528   for (i = 0; i < m_config.scsidevs->devs_present; i++)
529   {
530      SCSIAllocInstance( machine,
531            m_config.scsidevs->devices[i].scsiClass,
532            &m_scsi_devices[m_config.scsidevs->devices[i].scsiID],
533            m_config.scsidevs->devices[i].diskregion );
490534   }
535
536   state_save_register_device_item_array(this, 0, m_5380_Registers);
537   state_save_register_device_item_array(this, 0, m_Command);
538   state_save_register_device_item_array(this, 0, m_5380_Data);
539   state_save_register_device_item(this, 0, m_last_id);
540   state_save_register_device_item(this, 0, m_cmd_ptr);
541   state_save_register_device_item(this, 0, m_d_ptr);
542   state_save_register_device_item(this, 0, m_d_limit);
543   state_save_register_device_item(this, 0, m_next_req_flag);
491544}
492#endif
493545
494#if NCR5380_DEVICE_CONVERSION
495DEFINE_LEGACY_DEVICE(NCR5380, ncr5380);
546//-------------------------------------------------
547//  device_reset - device-specific reset
548//-------------------------------------------------
549
550void ncr5380_device::device_reset()
551{
552   memset(m_5380_Registers, 0, sizeof(m_5380_Registers));
553   memset(m_5380_Data, 0, sizeof(m_5380_Data));
554   memset(m_scsi_devices, 0, sizeof(m_scsi_devices));
555
556   m_next_req_flag = 0;
557   m_cmd_ptr = 0;
558   m_d_ptr = 0;
559   m_d_limit = 0;
560   m_last_id = 0;
561}
562
563UINT8 ncr5380_device::read(UINT8 offset)
564{
565   return 0;
566}
567
568void ncr5380_device::write(UINT8 offset, UINT8 data)
569{
570}
571
572void ncr5380_device::read_data(int bytes, UINT8 *pData)
573{
574}
575
576void ncr5380_device::write_data(int bytes, UINT8 *pData)
577{
578}
579
580void *ncr5380_device::get_scsi_device(int id)
581{
582   return NULL;
583}
496584#endif
src/mess/machine/ncr5380.h
r9035r9036
88
99#include "machine/scsidev.h"
1010
11#define NCR5380_DEVICE_CONVERSION (0)
11#define USE_5380_DEVICE (0)
1212
1313struct NCR5380interface
1414{
r9035r9036
4343extern void ncr5380_read_data(int bytes, UINT8 *pData);
4444extern void ncr5380_write_data(int bytes, UINT8 *pData);
4545extern void *ncr5380_get_device(int id);
46extern void ncr5380_scan_devices( running_machine *machine );
4647extern READ8_HANDLER(ncr5380_r);
4748extern WRITE8_HANDLER(ncr5380_w);
4849
4950// device stuff
51#if USE_5380_DEVICE
52#define MDRV_NCR5380_ADD(_tag, _clock, _intrf) \
53    MDRV_DEVICE_ADD(_tag, NCR5380, _clock) \
54    MDRV_DEVICE_CONFIG(_intrf)
5055
51#if NCR5380_DEVICE_CONVERSION
52DECLARE_LEGACY_DEVICE(NCR5380, ncr5380);
53#endif
56class ncr5380_device_config : public device_config, public NCR5380interface
57{
58   friend class ncr5380_device;
5459
60   // construction/destruction
61   ncr5380_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
62
63public:
64   // allocators
65   static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
66   virtual device_t *alloc_device(running_machine &machine) const;
67
68protected:
69   // device_config overrides
70   virtual void device_config_complete();
71};
72
73class ncr5380_device : public device_t
74{
75   friend class ncr5380_device_config;
76
77   // construction/destruction
78   ncr5380_device(running_machine &_machine, const ncr5380_device_config &_config);
79
80public:
81   UINT8 read(UINT8 offset);
82   void write(UINT8 offset, UINT8 data);
83
84   void read_data(int bytes, UINT8 *pData);
85   void write_data(int bytes, UINT8 *pData);
86
87   void *get_scsi_device(int id);
88
89protected:
90   // device-level overrides
91   virtual void device_start();
92   virtual void device_reset();
93
94private:
95   SCSIInstance *m_scsi_devices[8];
96
97   UINT8 m_5380_Registers[8];
98   UINT8 m_last_id;
99   UINT8 m_Command[32];
100   INT32 m_cmd_ptr, m_d_ptr, m_d_limit, m_next_req_flag;
101   UINT8 m_5380_Data[512];
102
103   const ncr5380_device_config &m_config;
104};
55105#endif
106#endif
src/mess/machine/mac.c
r9035r9036
358358      }
359359
360360      /* install the memory */
361      if (((mac->mac_model >= MODEL_MAC_LC) && (mac->mac_model <= MODEL_MAC_COLOR_CLASSIC))|| (mac->mac_model == MODEL_MAC_LC_II) || (mac->mac_model == MODEL_MAC_POWERMAC_6100) || (mac->mac_model == MODEL_MAC_CLASSIC_II))
361      if (((mac->mac_model >= MODEL_MAC_LC) && (mac->mac_model <= MODEL_MAC_COLOR_CLASSIC)) || (mac->mac_model == MODEL_MAC_CLASSIC_II))
362362      {
363//         printf("V8 style machine: memory_size = %x (%s)\n", memory_size, is_rom ? "ROM" : "RAM");
364
365         if (is_rom)
366         {
367            mac_install_memory(machine, 0x00000000, memory_size-1, memory_size, memory_data, is_rom, "bank1");
368         }
369         else
370         {   
371            address_space* space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
372            UINT32 v8_internal_mirror_base;
373
374            v8_internal_mirror_base = 0xffffffff;   // default to "none"
375
376            // force unmap of entire RAM region
377            memory_unmap_write(space, 0, 0x9fffff, 0x9fffff, 0);
378
379            // install the total RAM size at 0
380            mac_install_memory(machine, 0x000000, memory_size-1, memory_size, memory_data, is_rom, "bank1");
381
382            // LC has 2 MB built-in, all other V8-style machines have 4 MB
383            if (mac->mac_model == MODEL_MAC_LC)
384            {
385               switch (memory_size / 0x100000)
386               {
387                  case 2:   // 2 MB: RAM at 0 and mirrored at 800000
388                     v8_internal_mirror_base = 0x000000;           
389                     break;
390
391                  case 4:   // 4 MB: 2 MB SIMM at 0, internal RAM at 200000, mirrored at 800000
392                     v8_internal_mirror_base = 0x200000;           
393                     break;
394
395                  case 6: // 6 MB: 4 MB SIMM at 0, internal RAM at 400000, mirrored at 800000
396                     v8_internal_mirror_base = 0x400000;
397                     break;
398
399                  case 10: // 10 MB: 8 MB SIMM at 0, internal RAM at 800000, no mirror
400                     break;
401               }
402            }
403            else
404            {
405               switch (memory_size / 0x100000)
406               {
407                  case 2:   // 2 MB: RAM at 0 and mirrored at 800000
408                  case 4:   // 4 MB: RAM at 0 and mirrored at 800000
409                     v8_internal_mirror_base = 0x000000;           
410                     break;
411
412                  case 6: // 6 MB: 2 MB SIMM at 0, internal RAM at 200000, mirrored at 800000
413                     v8_internal_mirror_base = 0x200000;
414                     break;
415
416                  case 8: // 8 MB: 4 MB SIMM at 0, internal RAM at 400000, mirrored at 800000
417                     v8_internal_mirror_base = 0x400000;
418                     break;
419
420                  case 10: // 10 MB: 8 MB SIMM at 0, internal RAM at 800000, no mirror
421                     break;
422               }
423            }
424
425            if (v8_internal_mirror_base != 0xffffffff)
426            {
427//               printf("V8 style machine: setting internal RAM mirror from offset %x\n", v8_internal_mirror_base);
428               mac_install_memory(machine, 0x800000, 0x9fffff, 0x200000, &memory_data[v8_internal_mirror_base], is_rom, "bank2");
429            }
430         }
431      }
432      else if (mac->mac_model == MODEL_MAC_POWERMAC_6100)
433      {
363434         mac_install_memory(machine, 0x00000000, memory_size-1, memory_size, memory_data, is_rom, "bank1");
364435      }
365436      else if ((mac->mac_model == MODEL_MAC_IICI) || (mac->mac_model == MODEL_MAC_IISI))
r9035r9036
26772748 * Main
26782749 * *************************************************************************/
26792750
2751static const SCSIConfigTable dev_table =
2752{
2753   2,                                      /* 2 SCSI devices */
2754   {
2755    { SCSI_ID_6, "harddisk1", SCSI_DEVICE_HARDDISK },  /* SCSI ID 6, using disk1, and it's a harddisk */
2756    { SCSI_ID_5, "harddisk2", SCSI_DEVICE_HARDDISK }   /* SCSI ID 5, using disk2, and it's a harddisk */
2757   }
2758};
2759
2760static const struct NCR5380interface macplus_5380intf =
2761{
2762   &dev_table,   // SCSI device table
2763   mac_scsi_irq   // IRQ (unconnected on the Mac Plus)
2764};
2765
2766static void macscsi_exit(running_machine &machine)
2767{
2768   ncr5380_exit(&macplus_5380intf);
2769}
2770
26802771MACHINE_START( mac )
26812772{
26822773   mac_state *mac = machine->driver_data<mac_state>();
r9035r9036
26972788   // clear mac state struct
26982789   model_save = mac->mac_model;
26992790   timer_save = mac->inquiry_timeout;
2700   //memset(mac, 0, sizeof(mac_state));
27012791   mac->mac_model = model_save;
27022792   mac->inquiry_timeout = timer_save;
27032793
r9035r9036
27242814      adb_reset(mac);
27252815   }
27262816
2817   if (mac->mac_model >= MODEL_MAC_PLUS)
2818   {
2819      ncr5380_scan_devices(machine);
2820   }
2821
27272822   if ((mac->mac_model == MODEL_MAC_SE) || (mac->mac_model == MODEL_MAC_CLASSIC))
27282823   {
27292824      mac_set_sound_buffer(machine->device("custom"), 1);
r9035r9036
28572952   mac_driver_init(machine, MODEL_MAC_512KE);
28582953}
28592954
2860static const SCSIConfigTable dev_table =
2861{
2862   2,                                      /* 2 SCSI devices */
2863   {
2864    { SCSI_ID_6, "harddisk1", SCSI_DEVICE_HARDDISK },  /* SCSI ID 6, using disk1, and it's a harddisk */
2865    { SCSI_ID_5, "harddisk2", SCSI_DEVICE_HARDDISK }   /* SCSI ID 5, using disk2, and it's a harddisk */
2866   }
2867};
2868
2869static const struct NCR5380interface macplus_5380intf =
2870{
2871   &dev_table,   // SCSI device table
2872   mac_scsi_irq   // IRQ (unconnected on the Mac Plus)
2873};
2874
2875static void macscsi_exit(running_machine &machine)
2876{
2877   ncr5380_exit(&macplus_5380intf);
2878}
2879
28802955MACHINE_START( macscsi )
28812956{
28822957   MACHINE_START_CALL(mac);
28832958
28842959   ncr5380_init(machine, &macplus_5380intf);
2885
28862960   machine->add_notifier(MACHINE_NOTIFY_EXIT, macscsi_exit);
28872961}
28882962
src/mess/drivers/mac.c
r9035r9036
862862
863863   MDRV_RAM_MODIFY("messram")
864864   MDRV_RAM_DEFAULT_SIZE("4M")
865   MDRV_RAM_EXTRA_OPTIONS("8M,12M,16M,20M,24M,28M,32M,36M")
865   MDRV_RAM_EXTRA_OPTIONS("6M,8M,10M")
866866MACHINE_CONFIG_END
867867
868868static MACHINE_CONFIG_DERIVED( maclc3, maclc )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team