src/mess/machine/ncr5380.c
| r9035 | r9036 | |
| 58 | 58 | static INT32 cmd_ptr, d_ptr, d_limit, next_req_flag; |
| 59 | 59 | static UINT8 n5380_Data[512]; |
| 60 | 60 | |
| 61 | | #if NCR5380_DEVICE_CONVERSION |
| 62 | | typedef struct _ncr5380_t ncr5380_t; |
| 63 | | struct _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 | | |
| 76 | 61 | // get the length of a SCSI command based on it's command byte type |
| 77 | 62 | static int get_cmd_len(int cbyte) |
| 78 | 63 | { |
| r9035 | r9036 | |
| 380 | 365 | |
| 381 | 366 | void ncr5380_init( running_machine *machine, const struct NCR5380interface *interface ) |
| 382 | 367 | { |
| 383 | | int i; |
| 384 | | |
| 385 | 368 | // save interface pointer for later |
| 386 | 369 | intf = interface; |
| 387 | 370 | |
| 388 | 371 | memset(n5380_Registers, 0, sizeof(n5380_Registers)); |
| 372 | memset(n5380_Data, 0, sizeof(n5380_Data)); |
| 389 | 373 | memset(devices, 0, sizeof(devices)); |
| 390 | 374 | |
| 391 | 375 | 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 | | |
| 399 | 376 | state_save_register_item_array(machine, "ncr5380", NULL, 0, n5380_Registers); |
| 400 | 377 | state_save_register_item_array(machine, "ncr5380", NULL, 0, n5380_Command); |
| 401 | 378 | state_save_register_item_array(machine, "ncr5380", NULL, 0, n5380_Data); |
| r9035 | r9036 | |
| 406 | 383 | state_save_register_item(machine, "ncr5380", NULL, 0, next_req_flag); |
| 407 | 384 | } |
| 408 | 385 | |
| 386 | void 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 | |
| 409 | 404 | void ncr5380_exit( const struct NCR5380interface *interface ) |
| 410 | 405 | { |
| 411 | 406 | int i; |
| r9035 | r9036 | |
| 458 | 453 | return NULL; |
| 459 | 454 | } |
| 460 | 455 | |
| 461 | | /* device interface */ |
| 462 | | #if NCR5380_DEVICE_CONVERSION |
| 463 | | static DEVICE_START( ncr5380 ) |
| 456 | #if USE_5380_DEVICE |
| 457 | //************************************************************************** |
| 458 | // DEVICE CONFIGURATION |
| 459 | //************************************************************************** |
| 460 | |
| 461 | ncr5380_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) |
| 464 | 463 | { |
| 465 | 464 | } |
| 466 | 465 | |
| 466 | device_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 | } |
| 467 | 470 | |
| 468 | | static DEVICE_RESET( ncr5380 ) |
| 471 | device_t *ncr5380_device_config::alloc_device(running_machine &machine) const |
| 469 | 472 | { |
| 473 | return auto_alloc(&machine, ncr5380_device(machine, *this)); |
| 470 | 474 | } |
| 471 | 475 | |
| 476 | //------------------------------------------------- |
| 477 | // device_config_complete - perform any |
| 478 | // operations now that the configuration is |
| 479 | // complete |
| 480 | //------------------------------------------------- |
| 472 | 481 | |
| 473 | | DEVICE_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; |
| 482 | void 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; |
| 478 | 488 | |
| 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 | } |
| 483 | 496 | |
| 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 | |
| 501 | const device_type NCR5380 = ncr5380_device_config::static_alloc_device_config; |
| 502 | |
| 503 | //------------------------------------------------- |
| 504 | // via6522_device - constructor |
| 505 | //------------------------------------------------- |
| 506 | |
| 507 | ncr5380_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 | |
| 517 | void 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 ); |
| 490 | 534 | } |
| 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); |
| 491 | 544 | } |
| 492 | | #endif |
| 493 | 545 | |
| 494 | | #if NCR5380_DEVICE_CONVERSION |
| 495 | | DEFINE_LEGACY_DEVICE(NCR5380, ncr5380); |
| 546 | //------------------------------------------------- |
| 547 | // device_reset - device-specific reset |
| 548 | //------------------------------------------------- |
| 549 | |
| 550 | void 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 | |
| 563 | UINT8 ncr5380_device::read(UINT8 offset) |
| 564 | { |
| 565 | return 0; |
| 566 | } |
| 567 | |
| 568 | void ncr5380_device::write(UINT8 offset, UINT8 data) |
| 569 | { |
| 570 | } |
| 571 | |
| 572 | void ncr5380_device::read_data(int bytes, UINT8 *pData) |
| 573 | { |
| 574 | } |
| 575 | |
| 576 | void ncr5380_device::write_data(int bytes, UINT8 *pData) |
| 577 | { |
| 578 | } |
| 579 | |
| 580 | void *ncr5380_device::get_scsi_device(int id) |
| 581 | { |
| 582 | return NULL; |
| 583 | } |
| 496 | 584 | #endif |
src/mess/machine/ncr5380.h
| r9035 | r9036 | |
| 8 | 8 | |
| 9 | 9 | #include "machine/scsidev.h" |
| 10 | 10 | |
| 11 | | #define NCR5380_DEVICE_CONVERSION (0) |
| 11 | #define USE_5380_DEVICE (0) |
| 12 | 12 | |
| 13 | 13 | struct NCR5380interface |
| 14 | 14 | { |
| r9035 | r9036 | |
| 43 | 43 | extern void ncr5380_read_data(int bytes, UINT8 *pData); |
| 44 | 44 | extern void ncr5380_write_data(int bytes, UINT8 *pData); |
| 45 | 45 | extern void *ncr5380_get_device(int id); |
| 46 | extern void ncr5380_scan_devices( running_machine *machine ); |
| 46 | 47 | extern READ8_HANDLER(ncr5380_r); |
| 47 | 48 | extern WRITE8_HANDLER(ncr5380_w); |
| 48 | 49 | |
| 49 | 50 | // 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) |
| 50 | 55 | |
| 51 | | #if NCR5380_DEVICE_CONVERSION |
| 52 | | DECLARE_LEGACY_DEVICE(NCR5380, ncr5380); |
| 53 | | #endif |
| 56 | class ncr5380_device_config : public device_config, public NCR5380interface |
| 57 | { |
| 58 | friend class ncr5380_device; |
| 54 | 59 | |
| 60 | // construction/destruction |
| 61 | ncr5380_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); |
| 62 | |
| 63 | public: |
| 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 | |
| 68 | protected: |
| 69 | // device_config overrides |
| 70 | virtual void device_config_complete(); |
| 71 | }; |
| 72 | |
| 73 | class 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 | |
| 80 | public: |
| 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 | |
| 89 | protected: |
| 90 | // device-level overrides |
| 91 | virtual void device_start(); |
| 92 | virtual void device_reset(); |
| 93 | |
| 94 | private: |
| 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 | }; |
| 55 | 105 | #endif |
| 106 | #endif |
src/mess/machine/mac.c
| r9035 | r9036 | |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /* 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)) |
| 362 | 362 | { |
| 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 | { |
| 363 | 434 | mac_install_memory(machine, 0x00000000, memory_size-1, memory_size, memory_data, is_rom, "bank1"); |
| 364 | 435 | } |
| 365 | 436 | else if ((mac->mac_model == MODEL_MAC_IICI) || (mac->mac_model == MODEL_MAC_IISI)) |
| r9035 | r9036 | |
| 2677 | 2748 | * Main |
| 2678 | 2749 | * *************************************************************************/ |
| 2679 | 2750 | |
| 2751 | static 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 | |
| 2760 | static const struct NCR5380interface macplus_5380intf = |
| 2761 | { |
| 2762 | &dev_table, // SCSI device table |
| 2763 | mac_scsi_irq // IRQ (unconnected on the Mac Plus) |
| 2764 | }; |
| 2765 | |
| 2766 | static void macscsi_exit(running_machine &machine) |
| 2767 | { |
| 2768 | ncr5380_exit(&macplus_5380intf); |
| 2769 | } |
| 2770 | |
| 2680 | 2771 | MACHINE_START( mac ) |
| 2681 | 2772 | { |
| 2682 | 2773 | mac_state *mac = machine->driver_data<mac_state>(); |
| r9035 | r9036 | |
| 2697 | 2788 | // clear mac state struct |
| 2698 | 2789 | model_save = mac->mac_model; |
| 2699 | 2790 | timer_save = mac->inquiry_timeout; |
| 2700 | | //memset(mac, 0, sizeof(mac_state)); |
| 2701 | 2791 | mac->mac_model = model_save; |
| 2702 | 2792 | mac->inquiry_timeout = timer_save; |
| 2703 | 2793 | |
| r9035 | r9036 | |
| 2724 | 2814 | adb_reset(mac); |
| 2725 | 2815 | } |
| 2726 | 2816 | |
| 2817 | if (mac->mac_model >= MODEL_MAC_PLUS) |
| 2818 | { |
| 2819 | ncr5380_scan_devices(machine); |
| 2820 | } |
| 2821 | |
| 2727 | 2822 | if ((mac->mac_model == MODEL_MAC_SE) || (mac->mac_model == MODEL_MAC_CLASSIC)) |
| 2728 | 2823 | { |
| 2729 | 2824 | mac_set_sound_buffer(machine->device("custom"), 1); |
| r9035 | r9036 | |
| 2857 | 2952 | mac_driver_init(machine, MODEL_MAC_512KE); |
| 2858 | 2953 | } |
| 2859 | 2954 | |
| 2860 | | static 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 | | |
| 2869 | | static const struct NCR5380interface macplus_5380intf = |
| 2870 | | { |
| 2871 | | &dev_table, // SCSI device table |
| 2872 | | mac_scsi_irq // IRQ (unconnected on the Mac Plus) |
| 2873 | | }; |
| 2874 | | |
| 2875 | | static void macscsi_exit(running_machine &machine) |
| 2876 | | { |
| 2877 | | ncr5380_exit(&macplus_5380intf); |
| 2878 | | } |
| 2879 | | |
| 2880 | 2955 | MACHINE_START( macscsi ) |
| 2881 | 2956 | { |
| 2882 | 2957 | MACHINE_START_CALL(mac); |
| 2883 | 2958 | |
| 2884 | 2959 | ncr5380_init(machine, &macplus_5380intf); |
| 2885 | | |
| 2886 | 2960 | machine->add_notifier(MACHINE_NOTIFY_EXIT, macscsi_exit); |
| 2887 | 2961 | } |
| 2888 | 2962 | |