src/mess/machine/mac.c
| r2419 | r2420 | |
| 1387 | 1387 | |
| 1388 | 1388 | static const SCSIConfigTable dev_table = |
| 1389 | 1389 | { |
| 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 | } |
| 1393 | 1395 | }; |
| 1394 | 1396 | |
| 1395 | 1397 | static const struct NCR5380interface macplus_5380intf = |
| r2419 | r2420 | |
| 1398 | 1400 | NULL // IRQ (unconnected on the Mac Plus) |
| 1399 | 1401 | }; |
| 1400 | 1402 | |
| 1403 | MACHINE_START( macscsi ) |
| 1404 | { |
| 1405 | ncr5380_init(&macplus_5380intf); |
| 1406 | } |
| 1407 | |
| 1401 | 1408 | DRIVER_INIT(macplus) |
| 1402 | 1409 | { |
| 1403 | 1410 | mac_driver_init(MODEL_MAC_PLUS); |
| 1404 | | |
| 1405 | | ncr5380_init(&macplus_5380intf); |
| 1406 | 1411 | } |
| 1407 | 1412 | |
| 1408 | 1413 | DRIVER_INIT(macse) |
| 1409 | 1414 | { |
| 1410 | 1415 | mac_driver_init(MODEL_MAC_SE); |
| 1411 | | |
| 1412 | | ncr5380_init(&macplus_5380intf); |
| 1413 | 1416 | } |
| 1414 | 1417 | |
| 1415 | 1418 | DRIVER_INIT(macclassic) |
| 1416 | 1419 | { |
| 1417 | 1420 | mac_driver_init(MODEL_MAC_CLASSIC); |
| 1418 | | |
| 1419 | | ncr5380_init(&macplus_5380intf); |
| 1420 | 1421 | } |
| 1421 | 1422 | |
| 1422 | 1423 | static void mac_vblank_irq(running_machine *machine) |
src/mess/machine/ncr5380.c
| r2419 | r2420 | |
| 49 | 49 | "DMA initiator rec" |
| 50 | 50 | }; |
| 51 | 51 | |
| 52 | | typedef struct |
| 53 | | { |
| 54 | | void *data; // device's "this" pointer |
| 55 | | pSCSIDispatch handler; // device's handler routine |
| 56 | | } SCSIDev; |
| 57 | | |
| 58 | | static SCSIDev devices[8]; // SCSI IDs 0-7 |
| 52 | static SCSIInstance *devices[8]; // SCSI IDs 0-7 |
| 59 | 53 | static const struct NCR5380interface *intf; |
| 60 | 54 | |
| 61 | 55 | static UINT8 n5380_Registers[8]; |
| r2419 | r2420 | |
| 64 | 58 | static INT32 cmd_ptr, d_ptr, d_limit; |
| 65 | 59 | static UINT8 n5380_Data[512]; |
| 66 | 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 | |
| 67 | 76 | // get the length of a SCSI command based on it's command byte type |
| 68 | 77 | static int get_cmd_len(int cbyte) |
| 69 | 78 | { |
| r2419 | r2420 | |
| 172 | 181 | if (get_cmd_len(n5380_Command[0]) == cmd_ptr) |
| 173 | 182 | { |
| 174 | 183 | 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]); |
| 176 | 185 | |
| 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); |
| 178 | 188 | |
| 189 | if (VERBOSE) |
| 190 | logerror("NCR5380: Command returned %d bytes\n", d_limit); |
| 191 | |
| 179 | 192 | d_ptr = 0; |
| 180 | 193 | |
| 181 | 194 | // is data available? |
| r2419 | r2420 | |
| 203 | 216 | // if the device exists, make the bus busy. |
| 204 | 217 | // otherwise don't. |
| 205 | 218 | |
| 206 | | if (devices[last_id].handler) |
| 219 | if (devices[last_id]) |
| 207 | 220 | { |
| 221 | if (VERBOSE) |
| 222 | logerror("NCR5380: Giving the bus for ID %d\n", last_id); |
| 208 | 223 | n5380_Registers[R5380_BUSSTATUS] |= 0x40; |
| 209 | 224 | } |
| 210 | 225 | else |
| 211 | 226 | { |
| 227 | if (VERBOSE) |
| 228 | logerror("NCR5380: Rejecting the bus for ID %d\n", last_id); |
| 212 | 229 | n5380_Registers[R5380_BUSSTATUS] &= ~0x40; |
| 213 | 230 | } |
| 214 | 231 | } |
| r2419 | r2420 | |
| 333 | 350 | return rv; |
| 334 | 351 | } |
| 335 | 352 | |
| 336 | | extern void ncr5380_init( const struct NCR5380interface *interface ) |
| 353 | void ncr5380_init( const struct NCR5380interface *interface ) |
| 337 | 354 | { |
| 338 | 355 | int i; |
| 339 | 356 | |
| r2419 | r2420 | |
| 346 | 363 | // try to open the devices |
| 347 | 364 | for (i = 0; i < interface->scsidevs->devs_present; i++) |
| 348 | 365 | { |
| 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 ); |
| 352 | 367 | } |
| 353 | 368 | |
| 354 | 369 | state_save_register_item_array("ncr5380", 0, n5380_Registers); |
| r2419 | r2420 | |
| 360 | 375 | state_save_register_item("ncr5380", 0, d_limit); |
| 361 | 376 | } |
| 362 | 377 | |
| 378 | void 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 | |
| 363 | 389 | void ncr5380_read_data(int bytes, UINT8 *pData) |
| 364 | 390 | { |
| 365 | | if (devices[last_id].handler) |
| 391 | if (devices[last_id]) |
| 366 | 392 | { |
| 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); |
| 368 | 396 | } |
| 369 | 397 | else |
| 370 | 398 | { |
| r2419 | r2420 | |
| 374 | 402 | |
| 375 | 403 | void ncr5380_write_data(int bytes, UINT8 *pData) |
| 376 | 404 | { |
| 377 | | if (devices[last_id].handler) |
| 405 | if (devices[last_id]) |
| 378 | 406 | { |
| 379 | | devices[last_id].handler(SCSIOP_WRITE_DATA, devices[last_id].data, bytes, pData); |
| 407 | SCSIWriteData(devices[last_id], pData, bytes); |
| 380 | 408 | } |
| 381 | 409 | else |
| 382 | 410 | { |
| r2419 | r2420 | |
| 388 | 416 | { |
| 389 | 417 | void *ret; |
| 390 | 418 | |
| 391 | | if (devices[id].handler) |
| 419 | if (devices[id]) |
| 392 | 420 | { |
| 393 | 421 | 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); |
| 395 | 423 | |
| 396 | 424 | return ret; |
| 397 | 425 | } |
| 398 | 426 | |
| 399 | 427 | return NULL; |
| 400 | 428 | } |
| 429 | |
| 430 | /* device interface */ |
| 431 | #if NCR5380_DEVICE_CONVERSION |
| 432 | static DEVICE_START( ncr5380 ) |
| 433 | { |
| 434 | } |
| 435 | |
| 436 | |
| 437 | static DEVICE_RESET( ncr5380 ) |
| 438 | { |
| 439 | } |
| 440 | |
| 441 | |
| 442 | static DEVICE_SET_INFO( ncr5380 ) |
| 443 | { |
| 444 | switch ( state ) |
| 445 | { |
| 446 | /* no parameters to set */ |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | |
| 451 | DEVICE_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 |