From 60d4805d557eb1e50ca2d527811fb50fdb041403 Mon Sep 17 00:00:00 2001 From: AJR Date: Thu, 11 Jul 2019 14:20:16 -0400 Subject: Move modern SCSI CD/HD devices into src/devices/bus/nscsi (nw) --- scripts/src/bus.lua | 18 + scripts/src/machine.lua | 9 - scripts/target/mame/arcade.lua | 1 + scripts/target/mame/mess.lua | 1 + src/devices/bus/a2bus/a2hsscsi.cpp | 4 +- src/devices/bus/a2bus/a2scsi.cpp | 4 +- src/devices/bus/amiga/zorro/a590.cpp | 4 +- src/devices/bus/hp_dio/hp98265a.cpp | 4 +- src/devices/bus/isa/aha1542b.cpp | 2 +- src/devices/bus/isa/aha174x.cpp | 2 +- src/devices/bus/isa/asc88.cpp | 2 +- src/devices/bus/isa/bt54x.cpp | 4 +- src/devices/bus/isa/tekram_dc820.cpp | 2 +- src/devices/bus/isa/ultra14f.cpp | 2 +- src/devices/bus/isa/ultra24f.cpp | 2 +- src/devices/bus/nscsi/cd.cpp | 659 +++++++++++++++++++++++++++++++++++ src/devices/bus/nscsi/cd.h | 126 +++++++ src/devices/bus/nscsi/hd.cpp | 524 ++++++++++++++++++++++++++++ src/devices/bus/nscsi/hd.h | 38 ++ src/devices/bus/nscsi/s1410.cpp | 152 ++++++++ src/devices/bus/nscsi/s1410.h | 78 +++++ src/devices/machine/nscsi_cd.cpp | 659 ----------------------------------- src/devices/machine/nscsi_cd.h | 126 ------- src/devices/machine/nscsi_hd.cpp | 524 ---------------------------- src/devices/machine/nscsi_hd.h | 38 -- src/devices/machine/nscsi_s1410.cpp | 152 -------- src/devices/machine/nscsi_s1410.h | 78 ----- src/mame/drivers/4dpi.cpp | 4 +- src/mame/drivers/ampro.cpp | 4 +- src/mame/drivers/cps3.cpp | 2 +- src/mame/drivers/decstation.cpp | 4 +- src/mame/drivers/indy_indigo2.cpp | 4 +- src/mame/drivers/krz2000.cpp | 4 +- src/mame/drivers/lb186.cpp | 2 +- src/mame/drivers/next.cpp | 4 +- src/mame/drivers/r9751.cpp | 4 +- src/mame/drivers/rastersp.cpp | 2 +- src/mame/drivers/sun3.cpp | 4 +- src/mame/drivers/sun4.cpp | 4 +- src/mame/drivers/tti.cpp | 4 +- src/mame/includes/interpro.h | 4 +- src/mame/includes/jazz.h | 4 +- src/mame/includes/mips.h | 4 +- src/mame/machine/hpc1.cpp | 4 +- 44 files changed, 1644 insertions(+), 1633 deletions(-) create mode 100644 src/devices/bus/nscsi/cd.cpp create mode 100644 src/devices/bus/nscsi/cd.h create mode 100644 src/devices/bus/nscsi/hd.cpp create mode 100644 src/devices/bus/nscsi/hd.h create mode 100644 src/devices/bus/nscsi/s1410.cpp create mode 100644 src/devices/bus/nscsi/s1410.h delete mode 100644 src/devices/machine/nscsi_cd.cpp delete mode 100644 src/devices/machine/nscsi_cd.h delete mode 100644 src/devices/machine/nscsi_hd.cpp delete mode 100644 src/devices/machine/nscsi_hd.h delete mode 100644 src/devices/machine/nscsi_s1410.cpp delete mode 100644 src/devices/machine/nscsi_s1410.h diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index e1bf27c50b9..20b368b0772 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -2140,6 +2140,24 @@ if (BUSES["A2GAMEIO"]~=null) then } end +--------------------------------------------------- +-- +--@src/devices/bus/nscsi/cd.h,BUSES["NSCSI"] = true +--@src/devices/bus/nscsi/hd.h,BUSES["NSCSI"] = true +--@src/devices/bus/nscsi/s1410.h,BUSES["NSCSI"] = true +--------------------------------------------------- + +if (BUSES["NSCSI"]~=null) then + files { + MAME_DIR .. "src/devices/bus/nscsi/cd.cpp", + MAME_DIR .. "src/devices/bus/nscsi/cd.h", + MAME_DIR .. "src/devices/bus/nscsi/hd.cpp", + MAME_DIR .. "src/devices/bus/nscsi/hd.h", + MAME_DIR .. "src/devices/bus/nscsi/s1410.cpp", + MAME_DIR .. "src/devices/bus/nscsi/s1410.h", + } +end + --------------------------------------------------- -- --@src/devices/bus/nubus/nubus.h,BUSES["NUBUS"] = true diff --git a/scripts/src/machine.lua b/scripts/src/machine.lua index 09192e522bc..39435e18798 100644 --- a/scripts/src/machine.lua +++ b/scripts/src/machine.lua @@ -2224,9 +2224,6 @@ end -- --@src/devices/machine/nscsi_bus.h,MACHINES["NSCSI"] = true --@src/devices/machine/nscsi_cb.h,MACHINES["NSCSI"] = true ---@src/devices/machine/nscsi_cd.h,MACHINES["NSCSI"] = true ---@src/devices/machine/nscsi_hd.h,MACHINES["NSCSI"] = true ---@src/devices/machine/nscsi_s1410.h,MACHINES["NSCSI"] = true --------------------------------------------------- if (MACHINES["NSCSI"]~=null) then @@ -2235,12 +2232,6 @@ if (MACHINES["NSCSI"]~=null) then MAME_DIR .. "src/devices/machine/nscsi_bus.h", MAME_DIR .. "src/devices/machine/nscsi_cb.cpp", MAME_DIR .. "src/devices/machine/nscsi_cb.h", - MAME_DIR .. "src/devices/machine/nscsi_cd.cpp", - MAME_DIR .. "src/devices/machine/nscsi_cd.h", - MAME_DIR .. "src/devices/machine/nscsi_hd.cpp", - MAME_DIR .. "src/devices/machine/nscsi_hd.h", - MAME_DIR .. "src/devices/machine/nscsi_s1410.cpp", - MAME_DIR .. "src/devices/machine/nscsi_s1410.h", } end diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua index 70176340ecd..4430d442e01 100644 --- a/scripts/target/mame/arcade.lua +++ b/scripts/target/mame/arcade.lua @@ -732,6 +732,7 @@ BUSES["MIDI"] = true BUSES["NEOGEO"] = true BUSES["NEOGEO_CTRL"] = true --BUSES["NES"] = true +BUSES["NSCSI"] = true --BUSES["NUBUS"] = true --BUSES["O2"] = true --BUSES["ORICEXT"] = true diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index 52ebdba7c27..6ef5035ea2a 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -808,6 +808,7 @@ BUSES["NEOGEO_CTRL"] = true BUSES["NES"] = true BUSES["NES_CTRL"] = true BUSES["NEWBRAIN"] = true +BUSES["NSCSI"] = true BUSES["NUBUS"] = true BUSES["O2"] = true BUSES["ORICEXT"] = true diff --git a/src/devices/bus/a2bus/a2hsscsi.cpp b/src/devices/bus/a2bus/a2hsscsi.cpp index 83455dc913a..c9bc0210175 100644 --- a/src/devices/bus/a2bus/a2hsscsi.cpp +++ b/src/devices/bus/a2bus/a2hsscsi.cpp @@ -40,8 +40,8 @@ #include "emu.h" #include "a2hsscsi.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" /*************************************************************************** PARAMETERS diff --git a/src/devices/bus/a2bus/a2scsi.cpp b/src/devices/bus/a2bus/a2scsi.cpp index 87e7c86dddc..3d4c7ac6cb6 100644 --- a/src/devices/bus/a2bus/a2scsi.cpp +++ b/src/devices/bus/a2bus/a2scsi.cpp @@ -33,8 +33,8 @@ #include "emu.h" #include "a2scsi.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" /*************************************************************************** PARAMETERS diff --git a/src/devices/bus/amiga/zorro/a590.cpp b/src/devices/bus/amiga/zorro/a590.cpp index 045a0eab7c8..f9dc313fcb2 100644 --- a/src/devices/bus/amiga/zorro/a590.cpp +++ b/src/devices/bus/amiga/zorro/a590.cpp @@ -11,8 +11,8 @@ #include "emu.h" #include "a590.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" //************************************************************************** diff --git a/src/devices/bus/hp_dio/hp98265a.cpp b/src/devices/bus/hp_dio/hp98265a.cpp index c5c28eeda6b..5c0194b48a4 100644 --- a/src/devices/bus/hp_dio/hp98265a.cpp +++ b/src/devices/bus/hp_dio/hp98265a.cpp @@ -10,8 +10,8 @@ #include "hp98265a.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "machine/mb87030.h" #define VERBOSE 0 diff --git a/src/devices/bus/isa/aha1542b.cpp b/src/devices/bus/isa/aha1542b.cpp index dd4a011f82f..53cd4a8cb64 100644 --- a/src/devices/bus/isa/aha1542b.cpp +++ b/src/devices/bus/isa/aha1542b.cpp @@ -12,10 +12,10 @@ #include "emu.h" #include "aha1542b.h" +#include "bus/nscsi/hd.h" #include "cpu/i8085/i8085.h" #include "machine/gen_latch.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_hd.h" DEFINE_DEVICE_TYPE(AHA1542A, aha1542a_device, "aha1542a", "AHA-1542A SCSI Controller") diff --git a/src/devices/bus/isa/aha174x.cpp b/src/devices/bus/isa/aha174x.cpp index f650e9efdf8..39fd0aef9fe 100644 --- a/src/devices/bus/isa/aha174x.cpp +++ b/src/devices/bus/isa/aha174x.cpp @@ -33,10 +33,10 @@ #include "emu.h" #include "aha174x.h" +#include "bus/nscsi/hd.h" #include "machine/aic6250.h" #include "machine/i82355.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_hd.h" DEFINE_DEVICE_TYPE(AHA1740, aha1740_device, "aha1740", "AHA-1740 Fast SCSI Host Adapter") DEFINE_DEVICE_TYPE(AHA1742A, aha1742a_device, "aha1742a", "AHA-1742A Fast SCSI Host Adapter") diff --git a/src/devices/bus/isa/asc88.cpp b/src/devices/bus/isa/asc88.cpp index 00db6f498d5..43dc83987aa 100644 --- a/src/devices/bus/isa/asc88.cpp +++ b/src/devices/bus/isa/asc88.cpp @@ -16,8 +16,8 @@ #include "emu.h" #include "asc88.h" +#include "bus/nscsi/hd.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_hd.h" DEFINE_DEVICE_TYPE(ASC88, asc88_device, "asc88", "ASC-88 SCSI Adapter") diff --git a/src/devices/bus/isa/bt54x.cpp b/src/devices/bus/isa/bt54x.cpp index d8ef31a848f..fe6516b8a84 100644 --- a/src/devices/bus/isa/bt54x.cpp +++ b/src/devices/bus/isa/bt54x.cpp @@ -17,10 +17,10 @@ #include "emu.h" #include "bt54x.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "machine/ncr5390.h" //#include "machine/ncr86c05.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" DEFINE_DEVICE_TYPE(BT542B, bt542b_device, "bt542b", "BusTek BT-542B SCSI Host Adapter") // Rev. G or earlier DEFINE_DEVICE_TYPE(BT542BH, bt542bh_device, "bt542bh", "BusLogic BT-542B SCSI Host Adapter (Rev. H)") diff --git a/src/devices/bus/isa/tekram_dc820.cpp b/src/devices/bus/isa/tekram_dc820.cpp index ab2375856ce..f9747c3385d 100644 --- a/src/devices/bus/isa/tekram_dc820.cpp +++ b/src/devices/bus/isa/tekram_dc820.cpp @@ -23,11 +23,11 @@ #include "emu.h" #include "tekram_dc820.h" +#include "bus/nscsi/hd.h" #include "cpu/i86/i186.h" #include "machine/i82355.h" #include "machine/ncr5390.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_hd.h" DEFINE_DEVICE_TYPE(TEKRAM_DC320B, tekram_dc320b_device, "dc320b", "Tekram DC-320B SCSI Controller") DEFINE_DEVICE_TYPE(TEKRAM_DC320E, tekram_dc320e_device, "dc320e", "Tekram DC-320E SCSI Controller") diff --git a/src/devices/bus/isa/ultra14f.cpp b/src/devices/bus/isa/ultra14f.cpp index 3ae8cb79811..e3cc88fd969 100644 --- a/src/devices/bus/isa/ultra14f.cpp +++ b/src/devices/bus/isa/ultra14f.cpp @@ -9,10 +9,10 @@ #include "emu.h" #include "ultra14f.h" +#include "bus/nscsi/hd.h" #include "cpu/m68000/m68000.h" #include "machine/ncr5390.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_hd.h" DEFINE_DEVICE_TYPE(ULTRA14F, ultra14f_device, "ultra14f", "Ultra-14F SCSI Host Adapter") diff --git a/src/devices/bus/isa/ultra24f.cpp b/src/devices/bus/isa/ultra24f.cpp index 46341bed4c2..cdb8f0c7501 100644 --- a/src/devices/bus/isa/ultra24f.cpp +++ b/src/devices/bus/isa/ultra24f.cpp @@ -9,10 +9,10 @@ #include "emu.h" #include "ultra24f.h" +#include "bus/nscsi/hd.h" #include "cpu/m68000/m68000.h" #include "machine/ncr5390.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_hd.h" DEFINE_DEVICE_TYPE(ULTRA24F, ultra24f_device, "ultra24f", "Ultra-24F SCSI Host Adapter") diff --git a/src/devices/bus/nscsi/cd.cpp b/src/devices/bus/nscsi/cd.cpp new file mode 100644 index 00000000000..19b32cc785a --- /dev/null +++ b/src/devices/bus/nscsi/cd.cpp @@ -0,0 +1,659 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +#include "emu.h" +#include "bus/nscsi/cd.h" + +#define VERBOSE 0 +#include "logmacro.h" + +DEFINE_DEVICE_TYPE(NSCSI_CDROM, nscsi_cdrom_device, "scsi_cdrom", "SCSI CD-ROM") +DEFINE_DEVICE_TYPE(NSCSI_CDROM_SGI, nscsi_cdrom_sgi_device, "scsi_cdrom_sgi", "SCSI CD-ROM SGI") +DEFINE_DEVICE_TYPE(NSCSI_RRD45, nscsi_dec_rrd45_device, "nrrd45", "RRD45 CD-ROM (New)") +DEFINE_DEVICE_TYPE(NSCSI_XM3301, nscsi_toshiba_xm3301_device, "nxm3301", "XM-3301TA CD-ROM (New)") +DEFINE_DEVICE_TYPE(NSCSI_XM5301SUN, nscsi_toshiba_xm5301_sun_device, "nxm5301sun", "XM-5301B Sun 4x CD-ROM (New)") +DEFINE_DEVICE_TYPE(NSCSI_XM5401SUN, nscsi_toshiba_xm5401_sun_device, "nxm5401sun", "XM-5401B Sun 4x CD-ROM (New)") +DEFINE_DEVICE_TYPE(NSCSI_XM5701, nscsi_toshiba_xm5701_device, "nxm5701", "XM-5701B 12x CD-ROM (New)") +DEFINE_DEVICE_TYPE(NSCSI_XM5701SUN, nscsi_toshiba_xm5701_sun_device, "nxm5701sun", "XM-5701B Sun 12x CD-ROM (New)") +DEFINE_DEVICE_TYPE(NSCSI_CDROM_APPLE, nscsi_cdrom_apple_device, "scsi_cdrom_apple", "Apple SCSI CD-ROM") + +nscsi_cdrom_device::nscsi_cdrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_cdrom_device(mconfig, NSCSI_CDROM, tag, owner, "Sony", "CDU-76S", "1.0", 0x00, 0x05) +{ +} + +nscsi_cdrom_sgi_device::nscsi_cdrom_sgi_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_cdrom_device(mconfig, NSCSI_CDROM_SGI, tag, owner, "Sony", "CDU-76S", "1.0", 0x00, 0x05) +{ +} + +nscsi_dec_rrd45_device::nscsi_dec_rrd45_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_cdrom_device(mconfig, NSCSI_RRD45, tag, owner, "DEC ", "RRD45 (C) DEC ", "0436", 0x98, 0x02) +{ +} + +nscsi_toshiba_xm3301_device::nscsi_toshiba_xm3301_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_cdrom_device(mconfig, NSCSI_XM3301, tag, owner, "TOSHIBA ", "CD-ROM XM-3301TA", "0272", 0x88, 0x02) +{ +} + +nscsi_toshiba_xm5301_sun_device::nscsi_toshiba_xm5301_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_cdrom_device(mconfig, NSCSI_XM5301SUN, tag, owner, "TOSHIBA ", "XM-5301TASUN4XCD", "2915", 0x98, 0x02) +{ +} + +nscsi_toshiba_xm5401_sun_device::nscsi_toshiba_xm5401_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_cdrom_device(mconfig, NSCSI_XM5401SUN, tag, owner, "TOSHIBA ", "XM-5401TASUN4XCD", "1036", 0x98, 0x02) +{ +} + +nscsi_toshiba_xm5701_device::nscsi_toshiba_xm5701_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_cdrom_device(mconfig, NSCSI_XM5701, tag, owner, "TOSHIBA ", "CD-ROM XM-5701TA", "3136", 0x98, 0x02) +{ +} + +nscsi_toshiba_xm5701_sun_device::nscsi_toshiba_xm5701_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_cdrom_device(mconfig, NSCSI_XM5701SUN, tag, owner, "TOSHIBA ", "XM5701TASUN12XCD", "0997", 0x98, 0x02) +{ +} + +nscsi_cdrom_apple_device::nscsi_cdrom_apple_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_cdrom_device(mconfig, NSCSI_CDROM_APPLE, tag, owner, "Sony", "CDU-76S", "1.0", 0x00, 0x05) +{ +} + +nscsi_cdrom_device::nscsi_cdrom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) + : nscsi_full_device(mconfig, type, tag, owner, clock) + , cdrom(nullptr) + , bytes_per_block(bytes_per_sector) + , lba(0) + , cur_sector(0) + , image(*this, "image") +{ +} + +void nscsi_cdrom_device::device_start() +{ + nscsi_full_device::device_start(); + save_item(NAME(sector_buffer)); + save_item(NAME(lba)); + save_item(NAME(cur_sector)); + save_item(NAME(bytes_per_block)); +} + +void nscsi_cdrom_device::device_reset() +{ + nscsi_full_device::device_reset(); + cdrom = image->get_cdrom_file(); + lba = 0; + cur_sector = -1; +} + +void nscsi_cdrom_device::device_add_mconfig(machine_config &config) +{ + CDROM(config, image).set_interface("cdrom"); +} + +int nscsi_cdrom_device::to_msf(int frame) +{ + int m = frame / (75 * 60); + int s = (frame / 75) % 60; + int f = frame % 75; + + return (m << 16) | (s << 8) | f; +} + +void nscsi_cdrom_device::set_block_size(u32 block_size) +{ + assert_always(bytes_per_sector % block_size == 0, "block size must be a factor of sector size"); + + bytes_per_block = block_size; +}; + + +uint8_t nscsi_cdrom_device::scsi_get_data(int id, int pos) +{ + if(id != 2) + return nscsi_full_device::scsi_get_data(id, pos); + const int sector = (lba * bytes_per_block + pos) / bytes_per_sector; + const int extra_pos = (lba * bytes_per_block) % bytes_per_sector; + if(sector != cur_sector) { + cur_sector = sector; + if(!cdrom_read_data(cdrom, sector, sector_buffer, CD_TRACK_MODE1)) { + LOG("CD READ ERROR sector %d!\n", sector); + std::fill_n(sector_buffer, sizeof(sector_buffer), 0); + } + } + return sector_buffer[(pos + extra_pos) & (bytes_per_sector - 1)]; +} + +void nscsi_cdrom_device::scsi_put_data(int id, int pos, uint8_t data) +{ + if(id != 2) { + nscsi_full_device::scsi_put_data(id, pos, data); + return; + } + + // process mode parameter header and one block descriptor + if(pos < sizeof(mode_data)) { + mode_data[pos] = data; + + // is this the last byte of the mode parameter block descriptor? + if(pos == sizeof(mode_data) - 1) + // is there exactly one block descriptor? + if(mode_data[3] == 8) + set_block_size((mode_data[9] << 16) | (mode_data[10] << 8) | (mode_data[11] << 0)); + } +} + +void nscsi_cdrom_device::return_no_cd() +{ + sense(false, SK_NOT_READY, SK_ASC_MEDIUM_NOT_PRESENT); + scsi_status_complete(SS_CHECK_CONDITION); +} + +void nscsi_cdrom_device::scsi_command() +{ + int blocks; + + // check for media change + if((cdrom != image->get_cdrom_file()) && (scsi_cmdbuf[0] != SC_INQUIRY)) + { + // clear media change condition + cdrom = image->get_cdrom_file(); + cur_sector = -1; + + // report unit attention condition + sense(false, SK_UNIT_ATTENTION); + scsi_status_complete(SS_CHECK_CONDITION); + return; + } + + switch(scsi_cmdbuf[0]) { + case SC_TEST_UNIT_READY: + LOG("command TEST UNIT READY\n"); + if(cdrom) + scsi_status_complete(SS_GOOD); + else + return_no_cd(); + break; + + case SC_READ_6: + if(!cdrom) { + return_no_cd(); + break; + } + + lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3]; + blocks = scsi_cmdbuf[4]; + if(!blocks) + blocks = 256; + + LOG("command READ start=%08x blocks=%04x\n", lba, blocks); + + scsi_data_in(2, blocks*bytes_per_block); + scsi_status_complete(SS_GOOD); + break; + + case SC_INQUIRY: { + int lun = get_lun(scsi_cmdbuf[1] >> 5); + LOG("command INQUIRY lun=%d EVPD=%d page=%d alloc=%02x link=%02x\n", + lun, scsi_cmdbuf[1] & 1, scsi_cmdbuf[2], scsi_cmdbuf[4], scsi_cmdbuf[5]); + + /* + * 7.5.3 Selection of an invalid logical unit + * + * The logical unit may not be valid because: + * a) the target does not support the logical unit (e.g. some targets + * support only one peripheral device). In response to an INQUIRY + * command, the target shall return the INQUIRY data with the + * peripheral qualifier set to the value required in 8.2.5.1. + * + * If the logic from the specification above is applied, Sun SCSI probe + * code gets confused and reports multiple valid logical units are + * attached; proper behaviour is produced when check condition status + * is returned with sense data ILLEGAL REQUEST and LOGICAL UNIT NOT + * SUPPORTED. + */ + int page = scsi_cmdbuf[2]; + int size = scsi_cmdbuf[4]; + switch(page) { + case 0: + std::fill_n(scsi_cmdbuf, 36, 0); + + if (lun != 0) + scsi_cmdbuf[0] = 0x7f; + else + scsi_cmdbuf[0] = 0x05; // device is present, device is CD/DVD (MMC-3) + scsi_cmdbuf[1] = 0x80; // media is removable + scsi_cmdbuf[2] = compliance; // device complies with SPC-3 standard + scsi_cmdbuf[3] = 0x02; // response data format = SPC-3 standard + scsi_cmdbuf[4] = 0x20; // additional length + scsi_cmdbuf[7] = inquiry_data; + strncpy((char *)&scsi_cmdbuf[8], manufacturer, 8); + strncpy((char *)&scsi_cmdbuf[16], product, 16); + strncpy((char *)&scsi_cmdbuf[32], revision, 4); + + // vendor and product information must be padded with spaces + for(int i = 8; i < 36; i++) + if(scsi_cmdbuf[i] == 0) + scsi_cmdbuf[i] = 0x20; + + if(size > 36) + size = 36; + scsi_data_in(SBUF_MAIN, size); + break; + } + scsi_status_complete(SS_GOOD); + break; + } + + case SC_MODE_SELECT_6: + LOG("command MODE SELECT 6 length %d\n", scsi_cmdbuf[4]); + + // accept mode select parameter data + if(scsi_cmdbuf[4]) + scsi_data_out(2, scsi_cmdbuf[4]); + + scsi_status_complete(SS_GOOD); + break; + + case SC_START_STOP_UNIT: + LOG("command %s UNIT%s\n", (scsi_cmdbuf[4] & 0x1) ? "START" : "STOP", + (scsi_cmdbuf[4] & 0x2) ? (scsi_cmdbuf[4] & 0x1) ? " (LOAD)" : " (EJECT)" : ""); + scsi_status_complete(SS_GOOD); + break; + + case SC_RECIEVE_DIAG_RES: { + LOG("command RECIEVE DIAGNOSTICS RESULTS"); + int size = (scsi_cmdbuf[3] << 8) | scsi_cmdbuf[4]; + int pos = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 6; + scsi_cmdbuf[pos++] = 0; // ROM is OK + scsi_cmdbuf[pos++] = 0; // RAM is OK + scsi_cmdbuf[pos++] = 0; // Data buffer is OK + scsi_cmdbuf[pos++] = 0; // Interface is OK + scsi_cmdbuf[pos++] = 0; + if(size > pos) + size = pos; + scsi_data_in(0, size); + scsi_status_complete(SS_GOOD); + break; + } + + case SC_SEND_DIAGNOSTICS: { + LOG("command SEND DIAGNOSTICS"); + int size = (scsi_cmdbuf[3] << 8) | scsi_cmdbuf[4]; + if(scsi_cmdbuf[1] & 4) { + // Self-test + scsi_status_complete(SS_GOOD); + break; + } + int pos = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 6; + scsi_cmdbuf[pos++] = 0; // ROM is OK + scsi_cmdbuf[pos++] = 0; // RAM is OK + scsi_cmdbuf[pos++] = 0; // Data buffer is OK + scsi_cmdbuf[pos++] = 0; // Interface is OK + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + if(size > pos) + size = pos; + scsi_data_in(0, size); + scsi_status_complete(SS_GOOD); + break; + } + + case SC_READ_CAPACITY: { + if(!cdrom) { + return_no_cd(); + break; + } + + LOG("command READ CAPACITY\n"); + + // get the last used block on the disc + const u32 temp = cdrom_get_track_start(cdrom, 0xaa) * (bytes_per_sector / bytes_per_block) - 1; + + scsi_cmdbuf[0] = (temp>>24) & 0xff; + scsi_cmdbuf[1] = (temp>>16) & 0xff; + scsi_cmdbuf[2] = (temp>>8) & 0xff; + scsi_cmdbuf[3] = (temp & 0xff); + scsi_cmdbuf[4] = 0; + scsi_cmdbuf[5] = 0; + scsi_cmdbuf[6] = (bytes_per_block>>8)&0xff; + scsi_cmdbuf[7] = (bytes_per_block & 0xff); + + scsi_data_in(SBUF_MAIN, 8); + scsi_status_complete(SS_GOOD); + break; + } + + case SC_READ_10: + lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5]; + blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8]; + + LOG("command READ EXTENDED start=%08x blocks=%04x\n", lba, blocks); + if(!cdrom) { + return_no_cd(); + break; + } + + scsi_data_in(2, blocks*bytes_per_block); + scsi_status_complete(SS_GOOD); + break; + + case SC_MODE_SENSE_6: { + int lun = get_lun(scsi_cmdbuf[1] >> 5); + LOG("command MODE SENSE 6 lun=%d page=%02x alloc=%02x link=%02x\n", + lun, scsi_cmdbuf[2] & 0x3f, scsi_cmdbuf[4], scsi_cmdbuf[5]); + if(lun) { + bad_lun(); + return; + } + + int page = scsi_cmdbuf[2] & 0x3f; + int size = scsi_cmdbuf[4]; + int pos = 1; + scsi_cmdbuf[pos++] = 0x00; // medium type + scsi_cmdbuf[pos++] = 0x80; // WP, cache + + // get the last used block on the disc + const u32 temp = cdrom_get_track_start(cdrom, 0xaa) * (bytes_per_sector / bytes_per_block) - 1; + scsi_cmdbuf[pos++] = 0x08; // Block descriptor length + + scsi_cmdbuf[pos++] = 0x00; // density code + scsi_cmdbuf[pos++] = (temp>>16) & 0xff; + scsi_cmdbuf[pos++] = (temp>>8) & 0xff; + scsi_cmdbuf[pos++] = (temp & 0xff); + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = (bytes_per_block>>8)&0xff; + scsi_cmdbuf[pos++] = (bytes_per_block & 0xff); + + bool fail = false; + int pmax = page == 0x3f ? 0x3e : page; + int pmin = page == 0x3f ? 0x00 : page; + for(int p=pmax; p >= pmin; p--) { + switch(p) { + case 0x00: // Vendor specific (does not require page format) + scsi_cmdbuf[pos++] = 0x80; // PS, page id + scsi_cmdbuf[pos++] = 0x02; // Page length + scsi_cmdbuf[pos++] = 0x00; // Meh + scsi_cmdbuf[pos++] = 0x00; // Double meh + break; + + case 0x01: // Read-write error recovery + scsi_cmdbuf[pos++] = 0x01; // PS, page id + scsi_cmdbuf[pos++] = 0x0a; // Page length + scsi_cmdbuf[pos++] = 0x01; + scsi_cmdbuf[pos++] = 0x01; + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; + break; + + case 0x02: // Disconnect/reconnect control parameters (guessed) + scsi_cmdbuf[pos++] = 0x82; // PS, page id + scsi_cmdbuf[pos++] = 0x0e; // Page length + scsi_cmdbuf[pos++] = 0xe6; // Buffer full ratio, 90% + scsi_cmdbuf[pos++] = 0x1a; // Buffer empty ratio, 10% + scsi_cmdbuf[pos++] = 0x00; // Bus inactivity limit, 0 + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; // Disconnect time limit, 0 + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; // Connect time limit, 0 + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; // Maximum burst size, 0 + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = 0x00; // EMDP, Dimm, DTDC + scsi_cmdbuf[pos++] = 0x00; // Reserved + scsi_cmdbuf[pos++] = 0x00; // Reserved + scsi_cmdbuf[pos++] = 0x00; // Reserved + break; + + default: + if (page != 0x3f) { + LOG("mode sense page %02x unhandled\n", p); + fail = true; + } + break; + } + } + scsi_cmdbuf[0] = pos; + if(pos > size) + pos = size; + + if (!fail) { + scsi_data_in(0, pos); + scsi_status_complete(SS_GOOD); + } else { + scsi_status_complete(SS_CHECK_CONDITION); + sense(false, SK_ILLEGAL_REQUEST, SK_ASC_INVALID_FIELD_IN_CDB); + } + break; + } + + case SC_PREVENT_ALLOW_MEDIUM_REMOVAL: + // TODO: support eject prevention + LOG("command %s MEDIUM REMOVAL\n", (scsi_cmdbuf[4] & 0x1) ? "PREVENT" : "ALLOW"); + scsi_status_complete(SS_GOOD); + break; + + case SC_READ_TOC_PMA_ATIP: { + /* + Track numbers are problematic here: 0 = lead-in, 0xaa = lead-out. + That makes sense in terms of how real-world CDs are referred to, but + our internal routines for tracks use "0" as track 1. That probably + should be fixed... + */ + static const char *const format_names[16] = { + "TOC", + "Session info", + "Full TOC", + "PMA", + "ATIP" + "Reserved 5", + "Reserved 6", + "Reserved 7", + "Reserved 8", + "Reserved 9", + "Reserved 10", + "Reserved 11", + "Reserved 12", + "Reserved 13", + "Reserved 14", + "Reserved 15" + }; + + bool msf = (scsi_cmdbuf[1] & 0x2) != 0; + u16 size = (scsi_cmdbuf[7] << 7) | scsi_cmdbuf[8]; + u8 format = scsi_cmdbuf[2] & 15; + + /// SFF8020 legacy format field (see T10/1836-D Revision 2g page 643) + if(!format) + format = (scsi_cmdbuf[9] >> 6) & 3; + + LOG("command READ TOC PMA ATIP, format %s msf=%d size=%d\n", format_names[format], msf, size); + + int pos = 0; + switch (format) { + case 0: { + int start_track = scsi_cmdbuf[6]; + int end_track = cdrom_get_last_track(cdrom); + + int tracks; + if(start_track == 0) + tracks = end_track + 1; + else if(start_track <= end_track) + tracks = (end_track - start_track) + 2; + else if(start_track <= 0xaa) + tracks = 1; + else + tracks = 0; + + int len = 2 + (tracks * 8); + + // the returned TOC DATA LENGTH must be the full amount, + // regardless of how much we're able to pass back due to size + scsi_cmdbuf[pos++] = (len>>8) & 0xff; + scsi_cmdbuf[pos++] = (len & 0xff); + scsi_cmdbuf[pos++] = 1; + scsi_cmdbuf[pos++] = cdrom_get_last_track(cdrom); + + if (start_track == 0) + start_track = 1; + + for(int i = 0; i < tracks; i++) { + int track = start_track + i; + int cdrom_track = track - 1; + if(i == tracks-1) { + track = 0xaa; + cdrom_track = 0xaa; + } + + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = cdrom_get_adr_control(cdrom, cdrom_track); + scsi_cmdbuf[pos++] = track; + scsi_cmdbuf[pos++] = 0; + + u32 tstart = cdrom_get_track_start(cdrom, cdrom_track); + + if(msf) + tstart = to_msf(tstart+150); + + scsi_cmdbuf[pos++] = (tstart>>24) & 0xff; + scsi_cmdbuf[pos++] = (tstart>>16) & 0xff; + scsi_cmdbuf[pos++] = (tstart>>8) & 0xff; + scsi_cmdbuf[pos++] = (tstart & 0xff); + } + break; + } + + case 1: { + int len = 2 + (8 * 1); + + scsi_cmdbuf[pos++] = (len>>8) & 0xff; + scsi_cmdbuf[pos++] = (len & 0xff); + scsi_cmdbuf[pos++] = 1; + scsi_cmdbuf[pos++] = 1; + + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = cdrom_get_adr_control(cdrom, 0); + scsi_cmdbuf[pos++] = 1; + scsi_cmdbuf[pos++] = 0; + + u32 tstart = cdrom_get_track_start(cdrom, 0); + + if (msf) + tstart = to_msf(tstart+150); + + scsi_cmdbuf[pos++] = (tstart>>24) & 0xff; + scsi_cmdbuf[pos++] = (tstart>>16) & 0xff; + scsi_cmdbuf[pos++] = (tstart>>8) & 0xff; + scsi_cmdbuf[pos++] = (tstart & 0xff); + break; + } + + default: + LOG("Unhandled format %d\n", format_names[format]); + break; + } + + if(pos) { + if(pos > size) + pos = size; + + scsi_data_in(0, pos); + scsi_status_complete(SS_GOOD); + } else { + // report unit attention condition + scsi_status_complete(SS_CHECK_CONDITION); + sense(false, SK_ILLEGAL_REQUEST); + break; + } + break; + } + + default: + nscsi_full_device::scsi_command(); + break; + } +} + +enum sgi_scsi_command_e : uint8_t { + /* + * The SGI supplied CD-ROM drives (and possibly those from some other vendors) + * identify themselves as hard disk drives at poweron, and after SCSI bus resets, + * until issued a vendor specific command (0xc9). This is done because older + * systems would otherwise be unable to boot and load miniroots from CD, due to + * their design (they attempted to protect the user from booting from + * "ridiculous" devices, long before CD-ROM drives existed). The SGI drives are + * sent a command to "revert" to CD-ROM inquiry information during boot if on + * a SCSI bus handled by the PROM, but not all possible buses are handled by all + * PROMs; additionally, a SCSI bus reset causes the CD-ROM drives to revert to + * the poweron default, and this could happen before the hardware inventory code + * in the kernel runs, if there are SCSI problems. + */ + SGI_HD2CDROM = 0xc9, +}; + +void nscsi_cdrom_sgi_device::scsi_command() +{ + switch (scsi_cmdbuf[0]) { + case SGI_HD2CDROM: + LOG("command SGI_HD2CDROM"); + // No need to do anything (yet). Just acknowledge the command. + scsi_status_complete(SS_GOOD); + break; + + default: + nscsi_cdrom_device::scsi_command(); + break; + } +} + +bool nscsi_cdrom_sgi_device::scsi_command_done(uint8_t command, uint8_t length) +{ + switch (command) { + case SGI_HD2CDROM: + return length == 10; + + default: + return nscsi_full_device::scsi_command_done(command, length); + } +} +/* + The Apple II SCSI Card firmware demands that ASC on a failing TEST_UNIT_READY be either 0x28 or 0xb0. + 0x28 is MEDIA_CHANGED, 0xb0 is vendor-specific. If the drive returns the normal 0x3A for disc-not-present, + the firmware assumes the drive is broken and retries the TEST_UNIT_READY for 60 seconds before giving up + and booting the machine. +*/ +void nscsi_cdrom_apple_device::scsi_command() +{ + switch (scsi_cmdbuf[0]) { + case SC_TEST_UNIT_READY: + LOG("command TEST UNIT READY (AppleCD)\n"); + if(cdrom) + { + scsi_status_complete(SS_GOOD); + } + else + { + sense(false, SK_NOT_READY, 0xb0); + scsi_status_complete(SS_CHECK_CONDITION); + } + break; + + default: + nscsi_cdrom_device::scsi_command(); + break; + } +} diff --git a/src/devices/bus/nscsi/cd.h b/src/devices/bus/nscsi/cd.h new file mode 100644 index 00000000000..1a87e150b13 --- /dev/null +++ b/src/devices/bus/nscsi/cd.h @@ -0,0 +1,126 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +#ifndef MAME_BUS_NSCSI_CD_H +#define MAME_BUS_NSCSI_CD_H + +#pragma once + +#include "machine/nscsi_bus.h" +#include "imagedev/chd_cd.h" +#include "cdrom.h" + +class nscsi_cdrom_device : public nscsi_full_device +{ +public: + nscsi_cdrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + + void set_block_size(u32 block_size); + +protected: + nscsi_cdrom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock = 0); + + nscsi_cdrom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const char *mfr, const char *product, const char *rev, uint8_t inq_data, uint8_t compliance) + : nscsi_cdrom_device(mconfig, type, tag, owner, 0) + { + strncpy(manufacturer, mfr, 8); + strncpy(this->product, product, 16); + strncpy(revision, rev, 4); + inquiry_data = inq_data; + this->compliance = compliance; + } + + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_add_mconfig(machine_config &config) override; + + virtual void scsi_command() override; + virtual uint8_t scsi_get_data(int id, int pos) override; + virtual void scsi_put_data(int buf, int offset, uint8_t data) override; + + cdrom_file *cdrom; + +private: + static constexpr uint32_t bytes_per_sector = 2048; + + uint8_t sector_buffer[bytes_per_sector]; + uint32_t bytes_per_block; + int lba, cur_sector; + required_device image; + uint8_t mode_data[12]; + + char manufacturer[8]; + char product[16]; + char revision[4]; + uint8_t inquiry_data; + uint8_t compliance; + + void return_no_cd(); + static int to_msf(int frame); +}; + +class nscsi_cdrom_sgi_device : public nscsi_cdrom_device +{ +public: + nscsi_cdrom_sgi_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + +protected: + virtual void scsi_command() override; + virtual bool scsi_command_done(uint8_t command, uint8_t length) override; +}; + +class nscsi_dec_rrd45_device : public nscsi_cdrom_device +{ +public: + nscsi_dec_rrd45_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + +class nscsi_toshiba_xm3301_device : public nscsi_cdrom_device +{ +public: + nscsi_toshiba_xm3301_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + +class nscsi_toshiba_xm5301_sun_device : public nscsi_cdrom_device +{ +public: + nscsi_toshiba_xm5301_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + +class nscsi_toshiba_xm5401_sun_device : public nscsi_cdrom_device +{ +public: + nscsi_toshiba_xm5401_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + +class nscsi_toshiba_xm5701_device : public nscsi_cdrom_device +{ +public: + nscsi_toshiba_xm5701_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + +class nscsi_toshiba_xm5701_sun_device : public nscsi_cdrom_device +{ +public: + nscsi_toshiba_xm5701_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); +}; + +class nscsi_cdrom_apple_device : public nscsi_cdrom_device +{ +public: + nscsi_cdrom_apple_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + +protected: + virtual void scsi_command() override; +}; + +DECLARE_DEVICE_TYPE(NSCSI_CDROM, nscsi_cdrom_device) +DECLARE_DEVICE_TYPE(NSCSI_CDROM_SGI, nscsi_cdrom_sgi_device) +DECLARE_DEVICE_TYPE(NSCSI_RRD45, nscsi_dec_rrd45_device) +DECLARE_DEVICE_TYPE(NSCSI_XM3301, nscsi_toshiba_xm3301_device) +DECLARE_DEVICE_TYPE(NSCSI_XM5301SUN, nscsi_toshiba_xm5301_sun_device) +DECLARE_DEVICE_TYPE(NSCSI_XM5401SUN, nscsi_toshiba_xm5401_sun_device) +DECLARE_DEVICE_TYPE(NSCSI_XM5701, nscsi_toshiba_xm5701_device) +DECLARE_DEVICE_TYPE(NSCSI_XM5701SUN, nscsi_toshiba_xm5701_sun_device) +DECLARE_DEVICE_TYPE(NSCSI_CDROM_APPLE, nscsi_cdrom_apple_device) + +#endif // MAME_BUS_NSCSI_CD_H diff --git a/src/devices/bus/nscsi/hd.cpp b/src/devices/bus/nscsi/hd.cpp new file mode 100644 index 00000000000..f2639673a92 --- /dev/null +++ b/src/devices/bus/nscsi/hd.cpp @@ -0,0 +1,524 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +#include "emu.h" +#include "bus/nscsi/hd.h" +#include "imagedev/harddriv.h" + +#define LOG_GENERAL (1U << 0) +#define LOG_COMMAND (1U << 1) +#define LOG_DATA (1U << 2) + +#define VERBOSE 0 + +#include "logmacro.h" + +DEFINE_DEVICE_TYPE(NSCSI_HARDDISK, nscsi_harddisk_device, "scsi_harddisk", "SCSI Hard Disk") + +nscsi_harddisk_device::nscsi_harddisk_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_harddisk_device(mconfig, NSCSI_HARDDISK, tag, owner, clock) +{ +} + +nscsi_harddisk_device::nscsi_harddisk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : + nscsi_full_device(mconfig, type, tag, owner, clock), image(*this, "image"), harddisk(nullptr), lba(0), cur_lba(0), blocks(0), bytes_per_sector(0) +{ +} + +void nscsi_harddisk_device::device_start() +{ + nscsi_full_device::device_start(); + save_item(NAME(block)); + save_item(NAME(lba)); + save_item(NAME(cur_lba)); + save_item(NAME(blocks)); + save_item(NAME(bytes_per_sector)); +} + +void nscsi_harddisk_device::device_reset() +{ + nscsi_full_device::device_reset(); + harddisk = image->get_hard_disk_file(); + if(!harddisk) { + scsi_id = -1; + bytes_per_sector = 0; + } else { + const hard_disk_info *hdinfo = hard_disk_get_info(harddisk); + bytes_per_sector = hdinfo->sectorbytes; + + chd_file *chd = image->get_chd_file(); + if(chd != nullptr) + chd->read_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, m_inquiry_data); + } + cur_lba = -1; +} + +void nscsi_harddisk_device::device_add_mconfig(machine_config &config) +{ + HARDDISK(config, image).set_interface("scsi_hdd"); +} + +uint8_t nscsi_harddisk_device::scsi_get_data(int id, int pos) +{ + uint8_t data = 0; + if(id != 2) + { + data = nscsi_full_device::scsi_get_data(id, pos); + } + else + { + int clba = lba + pos / bytes_per_sector; + if(clba != cur_lba) { + cur_lba = clba; + if(!hard_disk_read(harddisk, cur_lba, block)) { + LOG("HD READ ERROR !\n"); + memset(block, 0, sizeof(block)); + } + } + data = block[pos % bytes_per_sector]; + } + LOGMASKED(LOG_DATA, "nscsi_hd: scsi_get_data, id:%d pos:%d data:%02x %c\n", id, pos, data, data >= 0x20 && data < 0x7f ? (char)data : ' '); + return data; +} + +void nscsi_harddisk_device::scsi_put_data(int id, int pos, uint8_t data) +{ + LOGMASKED(LOG_DATA, "nscsi_hd: scsi_put_data, id:%d pos:%d data:%02x %c\n", id, pos, data, data >= 0x20 && data < 0x7f ? (char)data : ' '); + if(id != 2) { + nscsi_full_device::scsi_put_data(id, pos, data); + return; + } + + int offset = pos % bytes_per_sector; + block[offset] = data; + cur_lba = lba + pos / bytes_per_sector; + if(offset == bytes_per_sector-1) { + if(!hard_disk_write(harddisk, cur_lba, block)) + LOG("HD WRITE ERROR !\n"); + } +} + +void nscsi_harddisk_device::scsi_command() +{ + if(scsi_cmdbuf[0] != SC_READ_6) { + LOGMASKED(LOG_COMMAND, "%02x %02x %02x %02x %02x %02x\n", + scsi_cmdbuf[0], scsi_cmdbuf[1], scsi_cmdbuf[2], + scsi_cmdbuf[3], scsi_cmdbuf[4], scsi_cmdbuf[5]); + } + + switch(scsi_cmdbuf[0]) { + case SC_TEST_UNIT_READY: + LOG("command TEST UNIT READY\n"); + scsi_status_complete(SS_GOOD); + break; + + case SC_READ_6: + lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3]; + blocks = scsi_cmdbuf[4]; + if(!blocks) + blocks = 256; + + LOG("command READ start=%08x blocks=%04x\n", lba, blocks); + + scsi_data_in(2, blocks*bytes_per_sector); + scsi_status_complete(SS_GOOD); + break; + + case SC_WRITE_6: + lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3]; + blocks = scsi_cmdbuf[4]; + if(!blocks) + blocks = 256; + + LOG("command WRITE start=%08x blocks=%04x\n", lba, blocks); + + scsi_data_out(2, blocks*bytes_per_sector); + scsi_status_complete(SS_GOOD); + break; + + case SC_INQUIRY: { + int lun = get_lun(scsi_cmdbuf[1] >> 5); + LOG("command INQUIRY lun=%d EVPD=%d page=%d alloc=%02x link=%02x\n", + lun, scsi_cmdbuf[1] & 1, scsi_cmdbuf[2], scsi_cmdbuf[4], scsi_cmdbuf[5]); + + int page = scsi_cmdbuf[2]; + int size = scsi_cmdbuf[4]; + switch(page) { + case 0: + std::fill_n(scsi_cmdbuf, 148, 0); + + // vendor and product information must be padded with spaces + std::fill_n(&scsi_cmdbuf[8], 28, 0x20); + + // From Seagate SCSI Commands Reference Manual (http://www.seagate.com/staticfiles/support/disc/manuals/scsi/100293068a.pdf), page 73: + // If the SCSI target device is not capable of supporting a peripheral device connected to this logical unit, the + // device server shall set these fields to 7Fh (i.e., PERIPHERAL QUALIFIER field set to 011b and PERIPHERAL DEVICE + // TYPE set to 1Fh). + if (lun != 0) + scsi_cmdbuf[0] = 0x7f; + else + scsi_cmdbuf[0] = 0x00; // device is direct-access (e.g. hard disk) + scsi_cmdbuf[1] = 0x00; // media is not removable + scsi_cmdbuf[2] = 0x05; // device complies with SPC-3 standard + scsi_cmdbuf[3] = 0x01; // response data format = CCS + scsi_cmdbuf[4] = 52; // additional length + if(m_inquiry_data.empty()) { + LOG("IDNT tag not found in chd metadata, using default inquiry data\n"); + + // Apple HD SC setup utility needs to see this + strcpy((char *)&scsi_cmdbuf[8], " SEAGATE"); + strcpy((char *)&scsi_cmdbuf[16], " ST225N"); + strcpy((char *)&scsi_cmdbuf[32], "1.00"); + scsi_cmdbuf[36] = 0x00; // # of extents high + scsi_cmdbuf[37] = 0x08; // # of extents low + scsi_cmdbuf[38] = 0x00; // group 0 commands 0-1f + scsi_cmdbuf[39] = 0x99; // commands 0,3,4,7 + scsi_cmdbuf[40] = 0xa0; // commands 8, a + scsi_cmdbuf[41] = 0x27; // commands 12,15,16,17 + scsi_cmdbuf[42] = 0x34; // commands 1a,1b,1d + scsi_cmdbuf[43] = 0x01; // group 1 commands 20-3f + scsi_cmdbuf[44] = 0x04; + scsi_cmdbuf[45] = 0xa0; + scsi_cmdbuf[46] = 0x01; + scsi_cmdbuf[47] = 0x18; + scsi_cmdbuf[48] = 0x07; // group 7 commands e0-ff + scsi_cmdbuf[49] = 0x00; + scsi_cmdbuf[50] = 0xa0; // commands 8, a + scsi_cmdbuf[51] = 0x00; + scsi_cmdbuf[52] = 0x00; + scsi_cmdbuf[53] = 0xff; // end of list + } + else + std::copy_n(m_inquiry_data.begin(), std::min(m_inquiry_data.size(), size_t(48)), &scsi_cmdbuf[8]); + + if(size > 56) + size = 56; + scsi_data_in(0, size); + break; + } + scsi_status_complete(SS_GOOD); + break; + } + + case SC_MODE_SENSE_6: { + int lun = get_lun(scsi_cmdbuf[1] >> 5); + LOG("command MODE SENSE 6 lun=%d page=%02x alloc=%02x link=%02x\n", + lun, scsi_cmdbuf[2] & 0x3f, scsi_cmdbuf[4], scsi_cmdbuf[5]); + if(lun) { + bad_lun(); + return; + } + + int page = scsi_cmdbuf[2] & 0x3f; + int size = scsi_cmdbuf[4]; + int pos = 1; + scsi_cmdbuf[pos++] = 0x00; // medium type + scsi_cmdbuf[pos++] = 0x00; // WP, cache + + hard_disk_info *info = hard_disk_get_info(harddisk); + uint32_t dsize = info->cylinders * info->heads * info->sectors - 1; + scsi_cmdbuf[pos++] = 0x08; // Block descriptor length + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = (dsize>>16) & 0xff; + scsi_cmdbuf[pos++] = (dsize>>8) & 0xff; + scsi_cmdbuf[pos++] = (dsize & 0xff); + scsi_cmdbuf[pos++] = 0x00; + scsi_cmdbuf[pos++] = (info->sectorbytes>>16)&0xff; + scsi_cmdbuf[pos++] = (info->sectorbytes>>8)&0xff; + scsi_cmdbuf[pos++] = (info->sectorbytes & 0xff); + + int pmax = page == 0x3f ? 0x3e : page; + int pmin = page == 0x3f ? 0x00 : page; + + bool fail = false; + for(int p=pmax; p >= pmin; p--) { + switch(p) { + case 0x00: // Unit attention parameters page (weird) + scsi_cmdbuf[pos++] = 0x80; // PS, page id + scsi_cmdbuf[pos++] = 0x02; // Page length + scsi_cmdbuf[pos++] = 0x00; // Meh + scsi_cmdbuf[pos++] = 0x00; // Double meh + break; + + case 0x01: // read-write error recovery page + scsi_cmdbuf[pos++] = 0x01; // !PS, page id + scsi_cmdbuf[pos++] = 0x0a; // page length + scsi_cmdbuf[pos++] = 0; // various bits + scsi_cmdbuf[pos++] = 0; // read retry count + scsi_cmdbuf[pos++] = 0; // correction span + scsi_cmdbuf[pos++] = 0; // head offset count + scsi_cmdbuf[pos++] = 0; // data strobe offset count + scsi_cmdbuf[pos++] = 0; // reserved + scsi_cmdbuf[pos++] = 0; // write retry count + scsi_cmdbuf[pos++] = 0; // reserved + scsi_cmdbuf[pos++] = 0; // recovery time limit (msb) + scsi_cmdbuf[pos++] = 0; // recovery time limit (lsb) + break; + + case 0x02: // disconnect-reconnect page + scsi_cmdbuf[pos++] = 0x02; // !PS, page id + scsi_cmdbuf[pos++] = 0x0e; // page length + scsi_cmdbuf[pos++] = 0; // buffer full ratio + scsi_cmdbuf[pos++] = 0; // buffer empty ratio + scsi_cmdbuf[pos++] = 0; // bus inactivity limit (msb) + scsi_cmdbuf[pos++] = 0; // bus inactivity limit (lsb) + scsi_cmdbuf[pos++] = 0; // disconnect time limit (msb) + scsi_cmdbuf[pos++] = 0; // disconnect time limit (lsb) + scsi_cmdbuf[pos++] = 0; // connect time limit (msb) + scsi_cmdbuf[pos++] = 0; // connect time limit (lsb) + scsi_cmdbuf[pos++] = 0; // maximum burst size (msb) + scsi_cmdbuf[pos++] = 0; // maximum burst size (lsb) + scsi_cmdbuf[pos++] = 0; // reserved + scsi_cmdbuf[pos++] = 0; // reserved + scsi_cmdbuf[pos++] = 0; // reserved + scsi_cmdbuf[pos++] = 0; // reserved + break; + + case 0x03: { // Format parameters page + scsi_cmdbuf[pos++] = 0x83; // PS, page id + scsi_cmdbuf[pos++] = 0x16; // Page length + scsi_cmdbuf[pos++] = (info->cylinders * info->heads) >> 8; // Track/zone + scsi_cmdbuf[pos++] = info->cylinders * info->heads; // Track/zone + scsi_cmdbuf[pos++] = 0x00; // Alt sect/zone + scsi_cmdbuf[pos++] = 0x00; // Alt sect/zone + scsi_cmdbuf[pos++] = 0x00; // Alt track/zone + scsi_cmdbuf[pos++] = 0x00; // Alt track/zone + scsi_cmdbuf[pos++] = 0x00; // Alt track/volume + scsi_cmdbuf[pos++] = 0x00; // Alt track/volume + scsi_cmdbuf[pos++] = info->sectors >> 8; // Sectors/track + scsi_cmdbuf[pos++] = info->sectors; // Sectors/track + scsi_cmdbuf[pos++] = info->sectorbytes >> 8; // Bytes/sector + scsi_cmdbuf[pos++] = info->sectorbytes; // Bytes/sector + scsi_cmdbuf[pos++] = 0x00; // Interleave + scsi_cmdbuf[pos++] = 0x00; // Interleave + scsi_cmdbuf[pos++] = 0x00; // Track skew + scsi_cmdbuf[pos++] = 0x00; // Track skew + scsi_cmdbuf[pos++] = 0x00; // Cylinder skew + scsi_cmdbuf[pos++] = 0x00; // Cylinder skew + scsi_cmdbuf[pos++] = 0x00; // Sectoring type + scsi_cmdbuf[pos++] = 0x00; // Reserved + scsi_cmdbuf[pos++] = 0x00; // Reserved + scsi_cmdbuf[pos++] = 0x00; // Reserved + break; + } + + case 0x04: { // Rigid drive geometry page + scsi_cmdbuf[pos++] = 0x84; // PS, page id + scsi_cmdbuf[pos++] = 0x16; // Page length + scsi_cmdbuf[pos++] = info->cylinders >> 16; // Cylinders + scsi_cmdbuf[pos++] = info->cylinders >> 8; // Cylinders + scsi_cmdbuf[pos++] = info->cylinders; // Cylinders + scsi_cmdbuf[pos++] = info->heads; // Heads + scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - write precomp + scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - write precomp + scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - write precomp + scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - reduced write current + scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - reduced write current + scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - reduced write current + scsi_cmdbuf[pos++] = 0x00; // Drive step rate + scsi_cmdbuf[pos++] = 0x00; // Drive step rate + scsi_cmdbuf[pos++] = 0x00; // Landing zone cylinder + scsi_cmdbuf[pos++] = 0x00; // Landing zone cylinder + scsi_cmdbuf[pos++] = 0x00; // Landing zone cylinder + scsi_cmdbuf[pos++] = 0x00; // RPL + scsi_cmdbuf[pos++] = 0x00; // Rotational offset + scsi_cmdbuf[pos++] = 0x00; // Reserved + scsi_cmdbuf[pos++] = uint8_t(10000 >> 8); // Medium rotation rate + scsi_cmdbuf[pos++] = uint8_t(10000); // Medium rotation rate + scsi_cmdbuf[pos++] = 0x00; // Reserved + scsi_cmdbuf[pos++] = 0x00; // Reserved + break; + } + + case 0x08: // caching page + scsi_cmdbuf[pos++] = 0x08; // !PS, page id + scsi_cmdbuf[pos++] = 0x0a; // page length + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + break; + + case 0x30: { // Apple firmware ID page + scsi_cmdbuf[pos++] = 0xb0; // cPS, page id + scsi_cmdbuf[pos++] = 0x16; // Page length + scsi_cmdbuf[pos++] = 'A'; + scsi_cmdbuf[pos++] = 'P'; + scsi_cmdbuf[pos++] = 'P'; + scsi_cmdbuf[pos++] = 'L'; + scsi_cmdbuf[pos++] = 'E'; + scsi_cmdbuf[pos++] = ' '; + scsi_cmdbuf[pos++] = 'C'; + scsi_cmdbuf[pos++] = 'O'; + scsi_cmdbuf[pos++] = 'M'; + scsi_cmdbuf[pos++] = 'P'; + scsi_cmdbuf[pos++] = 'U'; + scsi_cmdbuf[pos++] = 'T'; + scsi_cmdbuf[pos++] = 'E'; + scsi_cmdbuf[pos++] = 'R'; + scsi_cmdbuf[pos++] = ','; + scsi_cmdbuf[pos++] = ' '; + scsi_cmdbuf[pos++] = 'I'; + scsi_cmdbuf[pos++] = 'N'; + scsi_cmdbuf[pos++] = 'C'; + scsi_cmdbuf[pos++] = ' '; + scsi_cmdbuf[pos++] = ' '; + scsi_cmdbuf[pos++] = ' '; + break; + } + + default: + if (page != 0x3f) { + LOG("mode sense page %02x unhandled\n", page); + fail = true; + } + break; + } + } + + if (!fail) { + scsi_cmdbuf[0] = pos; + if (pos > size) + pos = size; + + scsi_data_in(0, pos); + scsi_status_complete(SS_GOOD); + } else { + scsi_status_complete(SS_CHECK_CONDITION); + sense(false, SK_ILLEGAL_REQUEST, SK_ASC_INVALID_FIELD_IN_CDB); + } + break; + } + + case SC_START_STOP_UNIT: + LOG("command %s UNIT\n", (scsi_cmdbuf[4] & 0x1) ? "START" : "STOP"); + scsi_status_complete(SS_GOOD); + break; + + case SC_RECIEVE_DIAG_RES: { + LOG("command RECIEVE DIAGNOSTICS RESULTS"); + int size = (scsi_cmdbuf[3] << 8) | scsi_cmdbuf[4]; + int pos = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 6; + scsi_cmdbuf[pos++] = 0; // ROM is OK + scsi_cmdbuf[pos++] = 0; // RAM is OK + scsi_cmdbuf[pos++] = 0; // Data buffer is OK + scsi_cmdbuf[pos++] = 0; // Interface is OK + scsi_cmdbuf[pos++] = 0; + if(size > pos) + size = pos; + scsi_data_in(0, size); + scsi_status_complete(SS_GOOD); + break; + } + + case SC_SEND_DIAGNOSTICS: { + LOG("command SEND DIAGNOSTICS"); + int size = (scsi_cmdbuf[3] << 8) | scsi_cmdbuf[4]; + if(scsi_cmdbuf[1] & 4) { + // Self-test + scsi_status_complete(SS_GOOD); + break; + } + int pos = 0; + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 6; + scsi_cmdbuf[pos++] = 0; // ROM is OK + scsi_cmdbuf[pos++] = 0; // RAM is OK + scsi_cmdbuf[pos++] = 0; // Data buffer is OK + scsi_cmdbuf[pos++] = 0; // Interface is OK + scsi_cmdbuf[pos++] = 0; + scsi_cmdbuf[pos++] = 0; + if(size > pos) + size = pos; + scsi_data_in(0, size); + scsi_status_complete(SS_GOOD); + break; + } + + case SC_READ_CAPACITY: { + LOG("command READ CAPACITY\n"); + + hard_disk_info *info = hard_disk_get_info(harddisk); + uint32_t size = info->cylinders * info->heads * info->sectors - 1; + + scsi_cmdbuf[0] = (size>>24) & 0xff; + scsi_cmdbuf[1] = (size>>16) & 0xff; + scsi_cmdbuf[2] = (size>>8) & 0xff; + scsi_cmdbuf[3] = (size & 0xff); + scsi_cmdbuf[4] = (info->sectorbytes>>24)&0xff; + scsi_cmdbuf[5] = (info->sectorbytes>>16)&0xff; + scsi_cmdbuf[6] = (info->sectorbytes>>8)&0xff; + scsi_cmdbuf[7] = (info->sectorbytes & 0xff); + + scsi_data_in(0, 8); + scsi_status_complete(SS_GOOD); + break; + } + + case SC_READ_10: + lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5]; + blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8]; + + LOG("command READ EXTENDED start=%08x blocks=%04x\n",lba, blocks); + + scsi_data_in(2, blocks*bytes_per_sector); + scsi_status_complete(SS_GOOD); + break; + + case SC_WRITE_10: + lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5]; + blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8]; + + LOG("command WRITE EXTENDED start=%08x blocks=%04x\n", lba, blocks); + + scsi_data_out(2, blocks*bytes_per_sector); + scsi_status_complete(SS_GOOD); + break; + + case SC_FORMAT_UNIT: + LOG("command FORMAT UNIT:%s%s%s%s%s\n", + (scsi_cmdbuf[1] & 0x80) ? " FMT-PINFO" : "", + (scsi_cmdbuf[1] & 0x40) ? " RTO_REQ" : "", + (scsi_cmdbuf[1] & 0x20) ? " LONG-LIST" : "", + (scsi_cmdbuf[1] & 0x10) ? " FMTDATA" : "", + (scsi_cmdbuf[1] & 0x08) ? " CMPLIST" : ""); + { + hard_disk_info *info = hard_disk_get_info(harddisk); + auto block = std::make_unique(info->sectorbytes); + for(int cyl = 0; cyl < info->cylinders; cyl++) { + for(int head = 0; head < info->heads; head++) { + for(int sector = 0; sector < info->sectors; sector++) { + hard_disk_write(harddisk, cyl * head * sector, block.get()); + } + } + } + } + scsi_status_complete(SS_GOOD); + break; + + case SC_MODE_SELECT_6: + LOG("command MODE SELECT\n"); + scsi_status_complete(SS_GOOD); + break; + + case SC_VERIFY: + LOG("command VERIFY BytChk %d\n", !!(scsi_cmdbuf[1] & 0x02)); + if (!(scsi_cmdbuf[1] & 0x02)) + scsi_status_complete(SS_GOOD); + else + scsi_unknown_command(); + break; + + default: + LOG("command %02x ***UNKNOWN***\n", scsi_cmdbuf[0]); + nscsi_full_device::scsi_command(); + break; + } +} diff --git a/src/devices/bus/nscsi/hd.h b/src/devices/bus/nscsi/hd.h new file mode 100644 index 00000000000..7ee1f851d26 --- /dev/null +++ b/src/devices/bus/nscsi/hd.h @@ -0,0 +1,38 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +#ifndef MAME_BUS_NSCSI_HD_H +#define MAME_BUS_NSCSI_HD_H + +#pragma once + +#include "machine/nscsi_bus.h" +#include "imagedev/harddriv.h" + +class nscsi_harddisk_device : public nscsi_full_device +{ +public: + nscsi_harddisk_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + nscsi_harddisk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_add_mconfig(machine_config &config) override; + + virtual void scsi_command() override; + virtual uint8_t scsi_get_data(int id, int pos) override; + virtual void scsi_put_data(int buf, int offset, uint8_t data) override; + + required_device image; + uint8_t block[512]; + hard_disk_file *harddisk; + int lba, cur_lba, blocks; + int bytes_per_sector; + + std::vector m_inquiry_data; +}; + +DECLARE_DEVICE_TYPE(NSCSI_HARDDISK, nscsi_harddisk_device) + +#endif // MAME_BUS_NSCSI_HD_H diff --git a/src/devices/bus/nscsi/s1410.cpp b/src/devices/bus/nscsi/s1410.cpp new file mode 100644 index 00000000000..5ecf65ef693 --- /dev/null +++ b/src/devices/bus/nscsi/s1410.cpp @@ -0,0 +1,152 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +#include "emu.h" +#include "bus/nscsi/s1410.h" + +DEFINE_DEVICE_TYPE(NSCSI_S1410, nscsi_s1410_device, "scsi_s1410", "S1410 Hard Disk") + +nscsi_s1410_device::nscsi_s1410_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + nscsi_harddisk_device(mconfig, NSCSI_S1410, tag, owner, clock) +{ +} + +void nscsi_s1410_device::device_reset() +{ + nscsi_harddisk_device::device_reset(); + + // initialize drive characteristics + params[0] = 0; + params[1] = 153; + params[2] = 4; + params[3] = 0; + params[4] = 128; + params[5] = 0; + params[6] = 64; + params[7] = 11; +} + +void nscsi_s1410_device::scsi_command() +{ + switch(scsi_cmdbuf[0]) { + case SC_TEST_UNIT_READY: + case SC_REZERO: + case SC_REQUEST_SENSE: + case SC_REASSIGN_BLOCKS: + case SC_READ: + case SC_WRITE: + case SC_SEEK: + if (scsi_cmdbuf[1] >> 5) { + scsi_status_complete(SS_NOT_READY); + } else { + nscsi_harddisk_device::scsi_command(); + } + break; + + case SC_FORMAT_UNIT: + if (scsi_cmdbuf[1] >> 5) { + scsi_status_complete(SS_NOT_READY); + return; + } + + scsi_status_complete(SS_GOOD); + break; + + case SC_FORMAT_TRACK: { + if (scsi_cmdbuf[1] >> 5) { + scsi_status_complete(SS_NOT_READY); + return; + } + + lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3]; + blocks = (bytes_per_sector == 256) ? 32 : 17; + + int track_length = blocks*bytes_per_sector; + std::vector data(track_length); + memset(&data[0], 0xc6, track_length); + + if(!hard_disk_write(harddisk, lba, &data[0])) { + logerror("%s: HD WRITE ERROR !\n", tag()); + scsi_status_complete(SS_FORMAT_ERROR); + } else { + scsi_status_complete(SS_GOOD); + } + } + break; + + case SC_FORMAT_ALT_TRACK: + if (scsi_cmdbuf[1] >> 5) { + scsi_status_complete(SS_NOT_READY); + return; + } + + scsi_data_in(2, 3); + scsi_status_complete(SS_GOOD); + break; + + case SC_INIT_DRIVE_PARAMS: + scsi_data_in(2, 8); + scsi_status_complete(SS_GOOD); + break; + + case SC_WRITE_SECTOR_BUFFER: + scsi_data_in(2, 512); + scsi_status_complete(SS_GOOD); + break; + + case SC_READ_SECTOR_BUFFER: + scsi_data_out(2, 512); + scsi_status_complete(SS_GOOD); + break; + + case SC_CHECK_TRACK_FORMAT: + if (scsi_cmdbuf[1] >> 5) { + scsi_status_complete(SS_NOT_READY); + return; + } + scsi_status_complete(SS_GOOD); + break; + + case SC_READ_ECC_BURST: + case SC_RAM_DIAG: + case SC_DRIVE_DIAG: + case SC_CONTROLLER_DIAG: + case SC_READ_LONG: + case SC_WRITE_LONG: + scsi_status_complete(SS_GOOD); + break; + + default: + logerror("%s: command %02x ***UNKNOWN***\n", tag(), scsi_cmdbuf[0]); + break; + } +} + +uint8_t nscsi_s1410_device::scsi_get_data(int id, int pos) +{ + switch(scsi_cmdbuf[0]) { + case SC_READ_SECTOR_BUFFER: + return block[pos]; + + default: + return nscsi_harddisk_device::scsi_get_data(id, pos); + } +} + +void nscsi_s1410_device::scsi_put_data(int id, int pos, uint8_t data) +{ + switch(scsi_cmdbuf[0]) { + case SC_FORMAT_ALT_TRACK: + break; + + case SC_INIT_DRIVE_PARAMS: + params[pos] = data; + break; + + case SC_WRITE_SECTOR_BUFFER: + block[pos] = data; + break; + + default: + return nscsi_harddisk_device::scsi_put_data(id, pos, data); + } +} diff --git a/src/devices/bus/nscsi/s1410.h b/src/devices/bus/nscsi/s1410.h new file mode 100644 index 00000000000..bd44a53c830 --- /dev/null +++ b/src/devices/bus/nscsi/s1410.h @@ -0,0 +1,78 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +#ifndef MAME_MACHINE_NSCSI_S1410_H +#define MAME_MACHINE_NSCSI_S1410_H + +#pragma once + +#include "machine/nscsi_bus.h" +#include "bus/nscsi/hd.h" + +class nscsi_s1410_device : public nscsi_harddisk_device +{ +public: + nscsi_s1410_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + // SCSI status returns + enum { + SS_GOOD = 0x00, + SS_NO_INDEX = 0x01, + SS_NO_SEEK_COMPLETE = 0x02, + SS_WRITE_FAULT = 0x03, + SS_NOT_READY = 0x04, + SS_TK00_NOT_FOUND = 0x06, + SS_SEEK_IN_PROGRESS = 0x08, + SS_ID_FIELD_ERROR = 0x10, + SS_DATA_ERROR = 0x11, + SS_SAM_NOT_FOUND = 0x12, + SS_SECTOR_NOT_FOUND = 0x14, + SS_SEEK_ERROR = 0x15, + SS_ECC = 0x18, + SS_BAD_TRACK = 0x19, + SS_FORMAT_ERROR = 0x1a, + SS_ALT_TRACK = 0x1c, + SS_ALT_TRACK_DEFECT = 0x1d, + SS_ALT_TRACK_NOT_FOUND = 0x1e, + SS_ALT_TRACK_SAME = 0x1f, + SS_RAM_ERROR = 0x30, + SS_ROM_ERROR = 0x31, + SS_ECC_CHECK_FAILURE = 0x32 + }; + + // SCSI commands + enum { + SC_TEST_UNIT_READY = 0x00, + SC_REZERO = 0x01, + SC_REQUEST_SENSE = 0x03, + SC_FORMAT_UNIT = 0x04, + SC_CHECK_TRACK_FORMAT = 0x05, + SC_FORMAT_TRACK = 0x06, + SC_REASSIGN_BLOCKS = 0x07, + SC_READ = 0x08, + SC_WRITE = 0x0a, + SC_SEEK = 0x0b, + SC_INIT_DRIVE_PARAMS = 0x0c, + SC_READ_ECC_BURST = 0x0d, + SC_FORMAT_ALT_TRACK = 0x0e, + SC_WRITE_SECTOR_BUFFER = 0x0f, + SC_READ_SECTOR_BUFFER = 0x10, + SC_RAM_DIAG = 0xe0, + SC_DRIVE_DIAG = 0xe3, + SC_CONTROLLER_DIAG = 0xe4, + SC_READ_LONG = 0xe5, + SC_WRITE_LONG = 0xe6 + }; + + virtual void device_reset() override; + + virtual void scsi_command() override; + virtual uint8_t scsi_get_data(int id, int pos) override; + virtual void scsi_put_data(int buf, int offset, uint8_t data) override; + + uint8_t params[8]; +}; + +DECLARE_DEVICE_TYPE(NSCSI_S1410, nscsi_s1410_device) + +#endif // MAME_BUS_NSCSI_S1410_H diff --git a/src/devices/machine/nscsi_cd.cpp b/src/devices/machine/nscsi_cd.cpp deleted file mode 100644 index ebfa49f1cae..00000000000 --- a/src/devices/machine/nscsi_cd.cpp +++ /dev/null @@ -1,659 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -#include "emu.h" -#include "machine/nscsi_cd.h" - -#define VERBOSE 0 -#include "logmacro.h" - -DEFINE_DEVICE_TYPE(NSCSI_CDROM, nscsi_cdrom_device, "scsi_cdrom", "SCSI CD-ROM") -DEFINE_DEVICE_TYPE(NSCSI_CDROM_SGI, nscsi_cdrom_sgi_device, "scsi_cdrom_sgi", "SCSI CD-ROM SGI") -DEFINE_DEVICE_TYPE(NSCSI_RRD45, nscsi_dec_rrd45_device, "nrrd45", "RRD45 CD-ROM (New)") -DEFINE_DEVICE_TYPE(NSCSI_XM3301, nscsi_toshiba_xm3301_device, "nxm3301", "XM-3301TA CD-ROM (New)") -DEFINE_DEVICE_TYPE(NSCSI_XM5301SUN, nscsi_toshiba_xm5301_sun_device, "nxm5301sun", "XM-5301B Sun 4x CD-ROM (New)") -DEFINE_DEVICE_TYPE(NSCSI_XM5401SUN, nscsi_toshiba_xm5401_sun_device, "nxm5401sun", "XM-5401B Sun 4x CD-ROM (New)") -DEFINE_DEVICE_TYPE(NSCSI_XM5701, nscsi_toshiba_xm5701_device, "nxm5701", "XM-5701B 12x CD-ROM (New)") -DEFINE_DEVICE_TYPE(NSCSI_XM5701SUN, nscsi_toshiba_xm5701_sun_device, "nxm5701sun", "XM-5701B Sun 12x CD-ROM (New)") -DEFINE_DEVICE_TYPE(NSCSI_CDROM_APPLE, nscsi_cdrom_apple_device, "scsi_cdrom_apple", "Apple SCSI CD-ROM") - -nscsi_cdrom_device::nscsi_cdrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_cdrom_device(mconfig, NSCSI_CDROM, tag, owner, "Sony", "CDU-76S", "1.0", 0x00, 0x05) -{ -} - -nscsi_cdrom_sgi_device::nscsi_cdrom_sgi_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_cdrom_device(mconfig, NSCSI_CDROM_SGI, tag, owner, "Sony", "CDU-76S", "1.0", 0x00, 0x05) -{ -} - -nscsi_dec_rrd45_device::nscsi_dec_rrd45_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_cdrom_device(mconfig, NSCSI_RRD45, tag, owner, "DEC ", "RRD45 (C) DEC ", "0436", 0x98, 0x02) -{ -} - -nscsi_toshiba_xm3301_device::nscsi_toshiba_xm3301_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_cdrom_device(mconfig, NSCSI_XM3301, tag, owner, "TOSHIBA ", "CD-ROM XM-3301TA", "0272", 0x88, 0x02) -{ -} - -nscsi_toshiba_xm5301_sun_device::nscsi_toshiba_xm5301_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_cdrom_device(mconfig, NSCSI_XM5301SUN, tag, owner, "TOSHIBA ", "XM-5301TASUN4XCD", "2915", 0x98, 0x02) -{ -} - -nscsi_toshiba_xm5401_sun_device::nscsi_toshiba_xm5401_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_cdrom_device(mconfig, NSCSI_XM5401SUN, tag, owner, "TOSHIBA ", "XM-5401TASUN4XCD", "1036", 0x98, 0x02) -{ -} - -nscsi_toshiba_xm5701_device::nscsi_toshiba_xm5701_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_cdrom_device(mconfig, NSCSI_XM5701, tag, owner, "TOSHIBA ", "CD-ROM XM-5701TA", "3136", 0x98, 0x02) -{ -} - -nscsi_toshiba_xm5701_sun_device::nscsi_toshiba_xm5701_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_cdrom_device(mconfig, NSCSI_XM5701SUN, tag, owner, "TOSHIBA ", "XM5701TASUN12XCD", "0997", 0x98, 0x02) -{ -} - -nscsi_cdrom_apple_device::nscsi_cdrom_apple_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_cdrom_device(mconfig, NSCSI_CDROM_APPLE, tag, owner, "Sony", "CDU-76S", "1.0", 0x00, 0x05) -{ -} - -nscsi_cdrom_device::nscsi_cdrom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : nscsi_full_device(mconfig, type, tag, owner, clock) - , cdrom(nullptr) - , bytes_per_block(bytes_per_sector) - , lba(0) - , cur_sector(0) - , image(*this, "image") -{ -} - -void nscsi_cdrom_device::device_start() -{ - nscsi_full_device::device_start(); - save_item(NAME(sector_buffer)); - save_item(NAME(lba)); - save_item(NAME(cur_sector)); - save_item(NAME(bytes_per_block)); -} - -void nscsi_cdrom_device::device_reset() -{ - nscsi_full_device::device_reset(); - cdrom = image->get_cdrom_file(); - lba = 0; - cur_sector = -1; -} - -void nscsi_cdrom_device::device_add_mconfig(machine_config &config) -{ - CDROM(config, image).set_interface("cdrom"); -} - -int nscsi_cdrom_device::to_msf(int frame) -{ - int m = frame / (75 * 60); - int s = (frame / 75) % 60; - int f = frame % 75; - - return (m << 16) | (s << 8) | f; -} - -void nscsi_cdrom_device::set_block_size(u32 block_size) -{ - assert_always(bytes_per_sector % block_size == 0, "block size must be a factor of sector size"); - - bytes_per_block = block_size; -}; - - -uint8_t nscsi_cdrom_device::scsi_get_data(int id, int pos) -{ - if(id != 2) - return nscsi_full_device::scsi_get_data(id, pos); - const int sector = (lba * bytes_per_block + pos) / bytes_per_sector; - const int extra_pos = (lba * bytes_per_block) % bytes_per_sector; - if(sector != cur_sector) { - cur_sector = sector; - if(!cdrom_read_data(cdrom, sector, sector_buffer, CD_TRACK_MODE1)) { - LOG("CD READ ERROR sector %d!\n", sector); - std::fill_n(sector_buffer, sizeof(sector_buffer), 0); - } - } - return sector_buffer[(pos + extra_pos) & (bytes_per_sector - 1)]; -} - -void nscsi_cdrom_device::scsi_put_data(int id, int pos, uint8_t data) -{ - if(id != 2) { - nscsi_full_device::scsi_put_data(id, pos, data); - return; - } - - // process mode parameter header and one block descriptor - if(pos < sizeof(mode_data)) { - mode_data[pos] = data; - - // is this the last byte of the mode parameter block descriptor? - if(pos == sizeof(mode_data) - 1) - // is there exactly one block descriptor? - if(mode_data[3] == 8) - set_block_size((mode_data[9] << 16) | (mode_data[10] << 8) | (mode_data[11] << 0)); - } -} - -void nscsi_cdrom_device::return_no_cd() -{ - sense(false, SK_NOT_READY, SK_ASC_MEDIUM_NOT_PRESENT); - scsi_status_complete(SS_CHECK_CONDITION); -} - -void nscsi_cdrom_device::scsi_command() -{ - int blocks; - - // check for media change - if((cdrom != image->get_cdrom_file()) && (scsi_cmdbuf[0] != SC_INQUIRY)) - { - // clear media change condition - cdrom = image->get_cdrom_file(); - cur_sector = -1; - - // report unit attention condition - sense(false, SK_UNIT_ATTENTION); - scsi_status_complete(SS_CHECK_CONDITION); - return; - } - - switch(scsi_cmdbuf[0]) { - case SC_TEST_UNIT_READY: - LOG("command TEST UNIT READY\n"); - if(cdrom) - scsi_status_complete(SS_GOOD); - else - return_no_cd(); - break; - - case SC_READ_6: - if(!cdrom) { - return_no_cd(); - break; - } - - lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3]; - blocks = scsi_cmdbuf[4]; - if(!blocks) - blocks = 256; - - LOG("command READ start=%08x blocks=%04x\n", lba, blocks); - - scsi_data_in(2, blocks*bytes_per_block); - scsi_status_complete(SS_GOOD); - break; - - case SC_INQUIRY: { - int lun = get_lun(scsi_cmdbuf[1] >> 5); - LOG("command INQUIRY lun=%d EVPD=%d page=%d alloc=%02x link=%02x\n", - lun, scsi_cmdbuf[1] & 1, scsi_cmdbuf[2], scsi_cmdbuf[4], scsi_cmdbuf[5]); - - /* - * 7.5.3 Selection of an invalid logical unit - * - * The logical unit may not be valid because: - * a) the target does not support the logical unit (e.g. some targets - * support only one peripheral device). In response to an INQUIRY - * command, the target shall return the INQUIRY data with the - * peripheral qualifier set to the value required in 8.2.5.1. - * - * If the logic from the specification above is applied, Sun SCSI probe - * code gets confused and reports multiple valid logical units are - * attached; proper behaviour is produced when check condition status - * is returned with sense data ILLEGAL REQUEST and LOGICAL UNIT NOT - * SUPPORTED. - */ - int page = scsi_cmdbuf[2]; - int size = scsi_cmdbuf[4]; - switch(page) { - case 0: - std::fill_n(scsi_cmdbuf, 36, 0); - - if (lun != 0) - scsi_cmdbuf[0] = 0x7f; - else - scsi_cmdbuf[0] = 0x05; // device is present, device is CD/DVD (MMC-3) - scsi_cmdbuf[1] = 0x80; // media is removable - scsi_cmdbuf[2] = compliance; // device complies with SPC-3 standard - scsi_cmdbuf[3] = 0x02; // response data format = SPC-3 standard - scsi_cmdbuf[4] = 0x20; // additional length - scsi_cmdbuf[7] = inquiry_data; - strncpy((char *)&scsi_cmdbuf[8], manufacturer, 8); - strncpy((char *)&scsi_cmdbuf[16], product, 16); - strncpy((char *)&scsi_cmdbuf[32], revision, 4); - - // vendor and product information must be padded with spaces - for(int i = 8; i < 36; i++) - if(scsi_cmdbuf[i] == 0) - scsi_cmdbuf[i] = 0x20; - - if(size > 36) - size = 36; - scsi_data_in(SBUF_MAIN, size); - break; - } - scsi_status_complete(SS_GOOD); - break; - } - - case SC_MODE_SELECT_6: - LOG("command MODE SELECT 6 length %d\n", scsi_cmdbuf[4]); - - // accept mode select parameter data - if(scsi_cmdbuf[4]) - scsi_data_out(2, scsi_cmdbuf[4]); - - scsi_status_complete(SS_GOOD); - break; - - case SC_START_STOP_UNIT: - LOG("command %s UNIT%s\n", (scsi_cmdbuf[4] & 0x1) ? "START" : "STOP", - (scsi_cmdbuf[4] & 0x2) ? (scsi_cmdbuf[4] & 0x1) ? " (LOAD)" : " (EJECT)" : ""); - scsi_status_complete(SS_GOOD); - break; - - case SC_RECIEVE_DIAG_RES: { - LOG("command RECIEVE DIAGNOSTICS RESULTS"); - int size = (scsi_cmdbuf[3] << 8) | scsi_cmdbuf[4]; - int pos = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 6; - scsi_cmdbuf[pos++] = 0; // ROM is OK - scsi_cmdbuf[pos++] = 0; // RAM is OK - scsi_cmdbuf[pos++] = 0; // Data buffer is OK - scsi_cmdbuf[pos++] = 0; // Interface is OK - scsi_cmdbuf[pos++] = 0; - if(size > pos) - size = pos; - scsi_data_in(0, size); - scsi_status_complete(SS_GOOD); - break; - } - - case SC_SEND_DIAGNOSTICS: { - LOG("command SEND DIAGNOSTICS"); - int size = (scsi_cmdbuf[3] << 8) | scsi_cmdbuf[4]; - if(scsi_cmdbuf[1] & 4) { - // Self-test - scsi_status_complete(SS_GOOD); - break; - } - int pos = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 6; - scsi_cmdbuf[pos++] = 0; // ROM is OK - scsi_cmdbuf[pos++] = 0; // RAM is OK - scsi_cmdbuf[pos++] = 0; // Data buffer is OK - scsi_cmdbuf[pos++] = 0; // Interface is OK - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - if(size > pos) - size = pos; - scsi_data_in(0, size); - scsi_status_complete(SS_GOOD); - break; - } - - case SC_READ_CAPACITY: { - if(!cdrom) { - return_no_cd(); - break; - } - - LOG("command READ CAPACITY\n"); - - // get the last used block on the disc - const u32 temp = cdrom_get_track_start(cdrom, 0xaa) * (bytes_per_sector / bytes_per_block) - 1; - - scsi_cmdbuf[0] = (temp>>24) & 0xff; - scsi_cmdbuf[1] = (temp>>16) & 0xff; - scsi_cmdbuf[2] = (temp>>8) & 0xff; - scsi_cmdbuf[3] = (temp & 0xff); - scsi_cmdbuf[4] = 0; - scsi_cmdbuf[5] = 0; - scsi_cmdbuf[6] = (bytes_per_block>>8)&0xff; - scsi_cmdbuf[7] = (bytes_per_block & 0xff); - - scsi_data_in(SBUF_MAIN, 8); - scsi_status_complete(SS_GOOD); - break; - } - - case SC_READ_10: - lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5]; - blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8]; - - LOG("command READ EXTENDED start=%08x blocks=%04x\n", lba, blocks); - if(!cdrom) { - return_no_cd(); - break; - } - - scsi_data_in(2, blocks*bytes_per_block); - scsi_status_complete(SS_GOOD); - break; - - case SC_MODE_SENSE_6: { - int lun = get_lun(scsi_cmdbuf[1] >> 5); - LOG("command MODE SENSE 6 lun=%d page=%02x alloc=%02x link=%02x\n", - lun, scsi_cmdbuf[2] & 0x3f, scsi_cmdbuf[4], scsi_cmdbuf[5]); - if(lun) { - bad_lun(); - return; - } - - int page = scsi_cmdbuf[2] & 0x3f; - int size = scsi_cmdbuf[4]; - int pos = 1; - scsi_cmdbuf[pos++] = 0x00; // medium type - scsi_cmdbuf[pos++] = 0x80; // WP, cache - - // get the last used block on the disc - const u32 temp = cdrom_get_track_start(cdrom, 0xaa) * (bytes_per_sector / bytes_per_block) - 1; - scsi_cmdbuf[pos++] = 0x08; // Block descriptor length - - scsi_cmdbuf[pos++] = 0x00; // density code - scsi_cmdbuf[pos++] = (temp>>16) & 0xff; - scsi_cmdbuf[pos++] = (temp>>8) & 0xff; - scsi_cmdbuf[pos++] = (temp & 0xff); - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = (bytes_per_block>>8)&0xff; - scsi_cmdbuf[pos++] = (bytes_per_block & 0xff); - - bool fail = false; - int pmax = page == 0x3f ? 0x3e : page; - int pmin = page == 0x3f ? 0x00 : page; - for(int p=pmax; p >= pmin; p--) { - switch(p) { - case 0x00: // Vendor specific (does not require page format) - scsi_cmdbuf[pos++] = 0x80; // PS, page id - scsi_cmdbuf[pos++] = 0x02; // Page length - scsi_cmdbuf[pos++] = 0x00; // Meh - scsi_cmdbuf[pos++] = 0x00; // Double meh - break; - - case 0x01: // Read-write error recovery - scsi_cmdbuf[pos++] = 0x01; // PS, page id - scsi_cmdbuf[pos++] = 0x0a; // Page length - scsi_cmdbuf[pos++] = 0x01; - scsi_cmdbuf[pos++] = 0x01; - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; - break; - - case 0x02: // Disconnect/reconnect control parameters (guessed) - scsi_cmdbuf[pos++] = 0x82; // PS, page id - scsi_cmdbuf[pos++] = 0x0e; // Page length - scsi_cmdbuf[pos++] = 0xe6; // Buffer full ratio, 90% - scsi_cmdbuf[pos++] = 0x1a; // Buffer empty ratio, 10% - scsi_cmdbuf[pos++] = 0x00; // Bus inactivity limit, 0 - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; // Disconnect time limit, 0 - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; // Connect time limit, 0 - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; // Maximum burst size, 0 - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = 0x00; // EMDP, Dimm, DTDC - scsi_cmdbuf[pos++] = 0x00; // Reserved - scsi_cmdbuf[pos++] = 0x00; // Reserved - scsi_cmdbuf[pos++] = 0x00; // Reserved - break; - - default: - if (page != 0x3f) { - LOG("mode sense page %02x unhandled\n", p); - fail = true; - } - break; - } - } - scsi_cmdbuf[0] = pos; - if(pos > size) - pos = size; - - if (!fail) { - scsi_data_in(0, pos); - scsi_status_complete(SS_GOOD); - } else { - scsi_status_complete(SS_CHECK_CONDITION); - sense(false, SK_ILLEGAL_REQUEST, SK_ASC_INVALID_FIELD_IN_CDB); - } - break; - } - - case SC_PREVENT_ALLOW_MEDIUM_REMOVAL: - // TODO: support eject prevention - LOG("command %s MEDIUM REMOVAL\n", (scsi_cmdbuf[4] & 0x1) ? "PREVENT" : "ALLOW"); - scsi_status_complete(SS_GOOD); - break; - - case SC_READ_TOC_PMA_ATIP: { - /* - Track numbers are problematic here: 0 = lead-in, 0xaa = lead-out. - That makes sense in terms of how real-world CDs are referred to, but - our internal routines for tracks use "0" as track 1. That probably - should be fixed... - */ - static const char *const format_names[16] = { - "TOC", - "Session info", - "Full TOC", - "PMA", - "ATIP" - "Reserved 5", - "Reserved 6", - "Reserved 7", - "Reserved 8", - "Reserved 9", - "Reserved 10", - "Reserved 11", - "Reserved 12", - "Reserved 13", - "Reserved 14", - "Reserved 15" - }; - - bool msf = (scsi_cmdbuf[1] & 0x2) != 0; - u16 size = (scsi_cmdbuf[7] << 7) | scsi_cmdbuf[8]; - u8 format = scsi_cmdbuf[2] & 15; - - /// SFF8020 legacy format field (see T10/1836-D Revision 2g page 643) - if(!format) - format = (scsi_cmdbuf[9] >> 6) & 3; - - LOG("command READ TOC PMA ATIP, format %s msf=%d size=%d\n", format_names[format], msf, size); - - int pos = 0; - switch (format) { - case 0: { - int start_track = scsi_cmdbuf[6]; - int end_track = cdrom_get_last_track(cdrom); - - int tracks; - if(start_track == 0) - tracks = end_track + 1; - else if(start_track <= end_track) - tracks = (end_track - start_track) + 2; - else if(start_track <= 0xaa) - tracks = 1; - else - tracks = 0; - - int len = 2 + (tracks * 8); - - // the returned TOC DATA LENGTH must be the full amount, - // regardless of how much we're able to pass back due to size - scsi_cmdbuf[pos++] = (len>>8) & 0xff; - scsi_cmdbuf[pos++] = (len & 0xff); - scsi_cmdbuf[pos++] = 1; - scsi_cmdbuf[pos++] = cdrom_get_last_track(cdrom); - - if (start_track == 0) - start_track = 1; - - for(int i = 0; i < tracks; i++) { - int track = start_track + i; - int cdrom_track = track - 1; - if(i == tracks-1) { - track = 0xaa; - cdrom_track = 0xaa; - } - - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = cdrom_get_adr_control(cdrom, cdrom_track); - scsi_cmdbuf[pos++] = track; - scsi_cmdbuf[pos++] = 0; - - u32 tstart = cdrom_get_track_start(cdrom, cdrom_track); - - if(msf) - tstart = to_msf(tstart+150); - - scsi_cmdbuf[pos++] = (tstart>>24) & 0xff; - scsi_cmdbuf[pos++] = (tstart>>16) & 0xff; - scsi_cmdbuf[pos++] = (tstart>>8) & 0xff; - scsi_cmdbuf[pos++] = (tstart & 0xff); - } - break; - } - - case 1: { - int len = 2 + (8 * 1); - - scsi_cmdbuf[pos++] = (len>>8) & 0xff; - scsi_cmdbuf[pos++] = (len & 0xff); - scsi_cmdbuf[pos++] = 1; - scsi_cmdbuf[pos++] = 1; - - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = cdrom_get_adr_control(cdrom, 0); - scsi_cmdbuf[pos++] = 1; - scsi_cmdbuf[pos++] = 0; - - u32 tstart = cdrom_get_track_start(cdrom, 0); - - if (msf) - tstart = to_msf(tstart+150); - - scsi_cmdbuf[pos++] = (tstart>>24) & 0xff; - scsi_cmdbuf[pos++] = (tstart>>16) & 0xff; - scsi_cmdbuf[pos++] = (tstart>>8) & 0xff; - scsi_cmdbuf[pos++] = (tstart & 0xff); - break; - } - - default: - LOG("Unhandled format %d\n", format_names[format]); - break; - } - - if(pos) { - if(pos > size) - pos = size; - - scsi_data_in(0, pos); - scsi_status_complete(SS_GOOD); - } else { - // report unit attention condition - scsi_status_complete(SS_CHECK_CONDITION); - sense(false, SK_ILLEGAL_REQUEST); - break; - } - break; - } - - default: - nscsi_full_device::scsi_command(); - break; - } -} - -enum sgi_scsi_command_e : uint8_t { - /* - * The SGI supplied CD-ROM drives (and possibly those from some other vendors) - * identify themselves as hard disk drives at poweron, and after SCSI bus resets, - * until issued a vendor specific command (0xc9). This is done because older - * systems would otherwise be unable to boot and load miniroots from CD, due to - * their design (they attempted to protect the user from booting from - * "ridiculous" devices, long before CD-ROM drives existed). The SGI drives are - * sent a command to "revert" to CD-ROM inquiry information during boot if on - * a SCSI bus handled by the PROM, but not all possible buses are handled by all - * PROMs; additionally, a SCSI bus reset causes the CD-ROM drives to revert to - * the poweron default, and this could happen before the hardware inventory code - * in the kernel runs, if there are SCSI problems. - */ - SGI_HD2CDROM = 0xc9, -}; - -void nscsi_cdrom_sgi_device::scsi_command() -{ - switch (scsi_cmdbuf[0]) { - case SGI_HD2CDROM: - LOG("command SGI_HD2CDROM"); - // No need to do anything (yet). Just acknowledge the command. - scsi_status_complete(SS_GOOD); - break; - - default: - nscsi_cdrom_device::scsi_command(); - break; - } -} - -bool nscsi_cdrom_sgi_device::scsi_command_done(uint8_t command, uint8_t length) -{ - switch (command) { - case SGI_HD2CDROM: - return length == 10; - - default: - return nscsi_full_device::scsi_command_done(command, length); - } -} -/* - The Apple II SCSI Card firmware demands that ASC on a failing TEST_UNIT_READY be either 0x28 or 0xb0. - 0x28 is MEDIA_CHANGED, 0xb0 is vendor-specific. If the drive returns the normal 0x3A for disc-not-present, - the firmware assumes the drive is broken and retries the TEST_UNIT_READY for 60 seconds before giving up - and booting the machine. -*/ -void nscsi_cdrom_apple_device::scsi_command() -{ - switch (scsi_cmdbuf[0]) { - case SC_TEST_UNIT_READY: - LOG("command TEST UNIT READY (AppleCD)\n"); - if(cdrom) - { - scsi_status_complete(SS_GOOD); - } - else - { - sense(false, SK_NOT_READY, 0xb0); - scsi_status_complete(SS_CHECK_CONDITION); - } - break; - - default: - nscsi_cdrom_device::scsi_command(); - break; - } -} diff --git a/src/devices/machine/nscsi_cd.h b/src/devices/machine/nscsi_cd.h deleted file mode 100644 index 9f10e52023a..00000000000 --- a/src/devices/machine/nscsi_cd.h +++ /dev/null @@ -1,126 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -#ifndef MAME_MACHINE_NSCSI_CD_H -#define MAME_MACHINE_NSCSI_CD_H - -#pragma once - -#include "machine/nscsi_bus.h" -#include "imagedev/chd_cd.h" -#include "cdrom.h" - -class nscsi_cdrom_device : public nscsi_full_device -{ -public: - nscsi_cdrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); - - void set_block_size(u32 block_size); - -protected: - nscsi_cdrom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock = 0); - - nscsi_cdrom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const char *mfr, const char *product, const char *rev, uint8_t inq_data, uint8_t compliance) - : nscsi_cdrom_device(mconfig, type, tag, owner, 0) - { - strncpy(manufacturer, mfr, 8); - strncpy(this->product, product, 16); - strncpy(revision, rev, 4); - inquiry_data = inq_data; - this->compliance = compliance; - } - - virtual void device_start() override; - virtual void device_reset() override; - virtual void device_add_mconfig(machine_config &config) override; - - virtual void scsi_command() override; - virtual uint8_t scsi_get_data(int id, int pos) override; - virtual void scsi_put_data(int buf, int offset, uint8_t data) override; - - cdrom_file *cdrom; - -private: - static constexpr uint32_t bytes_per_sector = 2048; - - uint8_t sector_buffer[bytes_per_sector]; - uint32_t bytes_per_block; - int lba, cur_sector; - required_device image; - uint8_t mode_data[12]; - - char manufacturer[8]; - char product[16]; - char revision[4]; - uint8_t inquiry_data; - uint8_t compliance; - - void return_no_cd(); - static int to_msf(int frame); -}; - -class nscsi_cdrom_sgi_device : public nscsi_cdrom_device -{ -public: - nscsi_cdrom_sgi_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); - -protected: - virtual void scsi_command() override; - virtual bool scsi_command_done(uint8_t command, uint8_t length) override; -}; - -class nscsi_dec_rrd45_device : public nscsi_cdrom_device -{ -public: - nscsi_dec_rrd45_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); -}; - -class nscsi_toshiba_xm3301_device : public nscsi_cdrom_device -{ -public: - nscsi_toshiba_xm3301_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); -}; - -class nscsi_toshiba_xm5301_sun_device : public nscsi_cdrom_device -{ -public: - nscsi_toshiba_xm5301_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); -}; - -class nscsi_toshiba_xm5401_sun_device : public nscsi_cdrom_device -{ -public: - nscsi_toshiba_xm5401_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); -}; - -class nscsi_toshiba_xm5701_device : public nscsi_cdrom_device -{ -public: - nscsi_toshiba_xm5701_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); -}; - -class nscsi_toshiba_xm5701_sun_device : public nscsi_cdrom_device -{ -public: - nscsi_toshiba_xm5701_sun_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); -}; - -class nscsi_cdrom_apple_device : public nscsi_cdrom_device -{ -public: - nscsi_cdrom_apple_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); - -protected: - virtual void scsi_command() override; -}; - -DECLARE_DEVICE_TYPE(NSCSI_CDROM, nscsi_cdrom_device) -DECLARE_DEVICE_TYPE(NSCSI_CDROM_SGI, nscsi_cdrom_sgi_device) -DECLARE_DEVICE_TYPE(NSCSI_RRD45, nscsi_dec_rrd45_device) -DECLARE_DEVICE_TYPE(NSCSI_XM3301, nscsi_toshiba_xm3301_device) -DECLARE_DEVICE_TYPE(NSCSI_XM5301SUN, nscsi_toshiba_xm5301_sun_device) -DECLARE_DEVICE_TYPE(NSCSI_XM5401SUN, nscsi_toshiba_xm5401_sun_device) -DECLARE_DEVICE_TYPE(NSCSI_XM5701, nscsi_toshiba_xm5701_device) -DECLARE_DEVICE_TYPE(NSCSI_XM5701SUN, nscsi_toshiba_xm5701_sun_device) -DECLARE_DEVICE_TYPE(NSCSI_CDROM_APPLE, nscsi_cdrom_apple_device) - -#endif // MAME_MACHINE_NSCSI_CD_H diff --git a/src/devices/machine/nscsi_hd.cpp b/src/devices/machine/nscsi_hd.cpp deleted file mode 100644 index 5d320a75158..00000000000 --- a/src/devices/machine/nscsi_hd.cpp +++ /dev/null @@ -1,524 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -#include "emu.h" -#include "machine/nscsi_hd.h" -#include "imagedev/harddriv.h" - -#define LOG_GENERAL (1U << 0) -#define LOG_COMMAND (1U << 1) -#define LOG_DATA (1U << 2) - -#define VERBOSE 0 - -#include "logmacro.h" - -DEFINE_DEVICE_TYPE(NSCSI_HARDDISK, nscsi_harddisk_device, "scsi_harddisk", "SCSI Hard Disk") - -nscsi_harddisk_device::nscsi_harddisk_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_harddisk_device(mconfig, NSCSI_HARDDISK, tag, owner, clock) -{ -} - -nscsi_harddisk_device::nscsi_harddisk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : - nscsi_full_device(mconfig, type, tag, owner, clock), image(*this, "image"), harddisk(nullptr), lba(0), cur_lba(0), blocks(0), bytes_per_sector(0) -{ -} - -void nscsi_harddisk_device::device_start() -{ - nscsi_full_device::device_start(); - save_item(NAME(block)); - save_item(NAME(lba)); - save_item(NAME(cur_lba)); - save_item(NAME(blocks)); - save_item(NAME(bytes_per_sector)); -} - -void nscsi_harddisk_device::device_reset() -{ - nscsi_full_device::device_reset(); - harddisk = image->get_hard_disk_file(); - if(!harddisk) { - scsi_id = -1; - bytes_per_sector = 0; - } else { - const hard_disk_info *hdinfo = hard_disk_get_info(harddisk); - bytes_per_sector = hdinfo->sectorbytes; - - chd_file *chd = image->get_chd_file(); - if(chd != nullptr) - chd->read_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, m_inquiry_data); - } - cur_lba = -1; -} - -void nscsi_harddisk_device::device_add_mconfig(machine_config &config) -{ - HARDDISK(config, image).set_interface("scsi_hdd"); -} - -uint8_t nscsi_harddisk_device::scsi_get_data(int id, int pos) -{ - uint8_t data = 0; - if(id != 2) - { - data = nscsi_full_device::scsi_get_data(id, pos); - } - else - { - int clba = lba + pos / bytes_per_sector; - if(clba != cur_lba) { - cur_lba = clba; - if(!hard_disk_read(harddisk, cur_lba, block)) { - LOG("HD READ ERROR !\n"); - memset(block, 0, sizeof(block)); - } - } - data = block[pos % bytes_per_sector]; - } - LOGMASKED(LOG_DATA, "nscsi_hd: scsi_get_data, id:%d pos:%d data:%02x %c\n", id, pos, data, data >= 0x20 && data < 0x7f ? (char)data : ' '); - return data; -} - -void nscsi_harddisk_device::scsi_put_data(int id, int pos, uint8_t data) -{ - LOGMASKED(LOG_DATA, "nscsi_hd: scsi_put_data, id:%d pos:%d data:%02x %c\n", id, pos, data, data >= 0x20 && data < 0x7f ? (char)data : ' '); - if(id != 2) { - nscsi_full_device::scsi_put_data(id, pos, data); - return; - } - - int offset = pos % bytes_per_sector; - block[offset] = data; - cur_lba = lba + pos / bytes_per_sector; - if(offset == bytes_per_sector-1) { - if(!hard_disk_write(harddisk, cur_lba, block)) - LOG("HD WRITE ERROR !\n"); - } -} - -void nscsi_harddisk_device::scsi_command() -{ - if(scsi_cmdbuf[0] != SC_READ_6) { - LOGMASKED(LOG_COMMAND, "%02x %02x %02x %02x %02x %02x\n", - scsi_cmdbuf[0], scsi_cmdbuf[1], scsi_cmdbuf[2], - scsi_cmdbuf[3], scsi_cmdbuf[4], scsi_cmdbuf[5]); - } - - switch(scsi_cmdbuf[0]) { - case SC_TEST_UNIT_READY: - LOG("command TEST UNIT READY\n"); - scsi_status_complete(SS_GOOD); - break; - - case SC_READ_6: - lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3]; - blocks = scsi_cmdbuf[4]; - if(!blocks) - blocks = 256; - - LOG("command READ start=%08x blocks=%04x\n", lba, blocks); - - scsi_data_in(2, blocks*bytes_per_sector); - scsi_status_complete(SS_GOOD); - break; - - case SC_WRITE_6: - lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3]; - blocks = scsi_cmdbuf[4]; - if(!blocks) - blocks = 256; - - LOG("command WRITE start=%08x blocks=%04x\n", lba, blocks); - - scsi_data_out(2, blocks*bytes_per_sector); - scsi_status_complete(SS_GOOD); - break; - - case SC_INQUIRY: { - int lun = get_lun(scsi_cmdbuf[1] >> 5); - LOG("command INQUIRY lun=%d EVPD=%d page=%d alloc=%02x link=%02x\n", - lun, scsi_cmdbuf[1] & 1, scsi_cmdbuf[2], scsi_cmdbuf[4], scsi_cmdbuf[5]); - - int page = scsi_cmdbuf[2]; - int size = scsi_cmdbuf[4]; - switch(page) { - case 0: - std::fill_n(scsi_cmdbuf, 148, 0); - - // vendor and product information must be padded with spaces - std::fill_n(&scsi_cmdbuf[8], 28, 0x20); - - // From Seagate SCSI Commands Reference Manual (http://www.seagate.com/staticfiles/support/disc/manuals/scsi/100293068a.pdf), page 73: - // If the SCSI target device is not capable of supporting a peripheral device connected to this logical unit, the - // device server shall set these fields to 7Fh (i.e., PERIPHERAL QUALIFIER field set to 011b and PERIPHERAL DEVICE - // TYPE set to 1Fh). - if (lun != 0) - scsi_cmdbuf[0] = 0x7f; - else - scsi_cmdbuf[0] = 0x00; // device is direct-access (e.g. hard disk) - scsi_cmdbuf[1] = 0x00; // media is not removable - scsi_cmdbuf[2] = 0x05; // device complies with SPC-3 standard - scsi_cmdbuf[3] = 0x01; // response data format = CCS - scsi_cmdbuf[4] = 52; // additional length - if(m_inquiry_data.empty()) { - LOG("IDNT tag not found in chd metadata, using default inquiry data\n"); - - // Apple HD SC setup utility needs to see this - strcpy((char *)&scsi_cmdbuf[8], " SEAGATE"); - strcpy((char *)&scsi_cmdbuf[16], " ST225N"); - strcpy((char *)&scsi_cmdbuf[32], "1.00"); - scsi_cmdbuf[36] = 0x00; // # of extents high - scsi_cmdbuf[37] = 0x08; // # of extents low - scsi_cmdbuf[38] = 0x00; // group 0 commands 0-1f - scsi_cmdbuf[39] = 0x99; // commands 0,3,4,7 - scsi_cmdbuf[40] = 0xa0; // commands 8, a - scsi_cmdbuf[41] = 0x27; // commands 12,15,16,17 - scsi_cmdbuf[42] = 0x34; // commands 1a,1b,1d - scsi_cmdbuf[43] = 0x01; // group 1 commands 20-3f - scsi_cmdbuf[44] = 0x04; - scsi_cmdbuf[45] = 0xa0; - scsi_cmdbuf[46] = 0x01; - scsi_cmdbuf[47] = 0x18; - scsi_cmdbuf[48] = 0x07; // group 7 commands e0-ff - scsi_cmdbuf[49] = 0x00; - scsi_cmdbuf[50] = 0xa0; // commands 8, a - scsi_cmdbuf[51] = 0x00; - scsi_cmdbuf[52] = 0x00; - scsi_cmdbuf[53] = 0xff; // end of list - } - else - std::copy_n(m_inquiry_data.begin(), std::min(m_inquiry_data.size(), size_t(48)), &scsi_cmdbuf[8]); - - if(size > 56) - size = 56; - scsi_data_in(0, size); - break; - } - scsi_status_complete(SS_GOOD); - break; - } - - case SC_MODE_SENSE_6: { - int lun = get_lun(scsi_cmdbuf[1] >> 5); - LOG("command MODE SENSE 6 lun=%d page=%02x alloc=%02x link=%02x\n", - lun, scsi_cmdbuf[2] & 0x3f, scsi_cmdbuf[4], scsi_cmdbuf[5]); - if(lun) { - bad_lun(); - return; - } - - int page = scsi_cmdbuf[2] & 0x3f; - int size = scsi_cmdbuf[4]; - int pos = 1; - scsi_cmdbuf[pos++] = 0x00; // medium type - scsi_cmdbuf[pos++] = 0x00; // WP, cache - - hard_disk_info *info = hard_disk_get_info(harddisk); - uint32_t dsize = info->cylinders * info->heads * info->sectors - 1; - scsi_cmdbuf[pos++] = 0x08; // Block descriptor length - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = (dsize>>16) & 0xff; - scsi_cmdbuf[pos++] = (dsize>>8) & 0xff; - scsi_cmdbuf[pos++] = (dsize & 0xff); - scsi_cmdbuf[pos++] = 0x00; - scsi_cmdbuf[pos++] = (info->sectorbytes>>16)&0xff; - scsi_cmdbuf[pos++] = (info->sectorbytes>>8)&0xff; - scsi_cmdbuf[pos++] = (info->sectorbytes & 0xff); - - int pmax = page == 0x3f ? 0x3e : page; - int pmin = page == 0x3f ? 0x00 : page; - - bool fail = false; - for(int p=pmax; p >= pmin; p--) { - switch(p) { - case 0x00: // Unit attention parameters page (weird) - scsi_cmdbuf[pos++] = 0x80; // PS, page id - scsi_cmdbuf[pos++] = 0x02; // Page length - scsi_cmdbuf[pos++] = 0x00; // Meh - scsi_cmdbuf[pos++] = 0x00; // Double meh - break; - - case 0x01: // read-write error recovery page - scsi_cmdbuf[pos++] = 0x01; // !PS, page id - scsi_cmdbuf[pos++] = 0x0a; // page length - scsi_cmdbuf[pos++] = 0; // various bits - scsi_cmdbuf[pos++] = 0; // read retry count - scsi_cmdbuf[pos++] = 0; // correction span - scsi_cmdbuf[pos++] = 0; // head offset count - scsi_cmdbuf[pos++] = 0; // data strobe offset count - scsi_cmdbuf[pos++] = 0; // reserved - scsi_cmdbuf[pos++] = 0; // write retry count - scsi_cmdbuf[pos++] = 0; // reserved - scsi_cmdbuf[pos++] = 0; // recovery time limit (msb) - scsi_cmdbuf[pos++] = 0; // recovery time limit (lsb) - break; - - case 0x02: // disconnect-reconnect page - scsi_cmdbuf[pos++] = 0x02; // !PS, page id - scsi_cmdbuf[pos++] = 0x0e; // page length - scsi_cmdbuf[pos++] = 0; // buffer full ratio - scsi_cmdbuf[pos++] = 0; // buffer empty ratio - scsi_cmdbuf[pos++] = 0; // bus inactivity limit (msb) - scsi_cmdbuf[pos++] = 0; // bus inactivity limit (lsb) - scsi_cmdbuf[pos++] = 0; // disconnect time limit (msb) - scsi_cmdbuf[pos++] = 0; // disconnect time limit (lsb) - scsi_cmdbuf[pos++] = 0; // connect time limit (msb) - scsi_cmdbuf[pos++] = 0; // connect time limit (lsb) - scsi_cmdbuf[pos++] = 0; // maximum burst size (msb) - scsi_cmdbuf[pos++] = 0; // maximum burst size (lsb) - scsi_cmdbuf[pos++] = 0; // reserved - scsi_cmdbuf[pos++] = 0; // reserved - scsi_cmdbuf[pos++] = 0; // reserved - scsi_cmdbuf[pos++] = 0; // reserved - break; - - case 0x03: { // Format parameters page - scsi_cmdbuf[pos++] = 0x83; // PS, page id - scsi_cmdbuf[pos++] = 0x16; // Page length - scsi_cmdbuf[pos++] = (info->cylinders * info->heads) >> 8; // Track/zone - scsi_cmdbuf[pos++] = info->cylinders * info->heads; // Track/zone - scsi_cmdbuf[pos++] = 0x00; // Alt sect/zone - scsi_cmdbuf[pos++] = 0x00; // Alt sect/zone - scsi_cmdbuf[pos++] = 0x00; // Alt track/zone - scsi_cmdbuf[pos++] = 0x00; // Alt track/zone - scsi_cmdbuf[pos++] = 0x00; // Alt track/volume - scsi_cmdbuf[pos++] = 0x00; // Alt track/volume - scsi_cmdbuf[pos++] = info->sectors >> 8; // Sectors/track - scsi_cmdbuf[pos++] = info->sectors; // Sectors/track - scsi_cmdbuf[pos++] = info->sectorbytes >> 8; // Bytes/sector - scsi_cmdbuf[pos++] = info->sectorbytes; // Bytes/sector - scsi_cmdbuf[pos++] = 0x00; // Interleave - scsi_cmdbuf[pos++] = 0x00; // Interleave - scsi_cmdbuf[pos++] = 0x00; // Track skew - scsi_cmdbuf[pos++] = 0x00; // Track skew - scsi_cmdbuf[pos++] = 0x00; // Cylinder skew - scsi_cmdbuf[pos++] = 0x00; // Cylinder skew - scsi_cmdbuf[pos++] = 0x00; // Sectoring type - scsi_cmdbuf[pos++] = 0x00; // Reserved - scsi_cmdbuf[pos++] = 0x00; // Reserved - scsi_cmdbuf[pos++] = 0x00; // Reserved - break; - } - - case 0x04: { // Rigid drive geometry page - scsi_cmdbuf[pos++] = 0x84; // PS, page id - scsi_cmdbuf[pos++] = 0x16; // Page length - scsi_cmdbuf[pos++] = info->cylinders >> 16; // Cylinders - scsi_cmdbuf[pos++] = info->cylinders >> 8; // Cylinders - scsi_cmdbuf[pos++] = info->cylinders; // Cylinders - scsi_cmdbuf[pos++] = info->heads; // Heads - scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - write precomp - scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - write precomp - scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - write precomp - scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - reduced write current - scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - reduced write current - scsi_cmdbuf[pos++] = 0x00; // Starting cylinder - reduced write current - scsi_cmdbuf[pos++] = 0x00; // Drive step rate - scsi_cmdbuf[pos++] = 0x00; // Drive step rate - scsi_cmdbuf[pos++] = 0x00; // Landing zone cylinder - scsi_cmdbuf[pos++] = 0x00; // Landing zone cylinder - scsi_cmdbuf[pos++] = 0x00; // Landing zone cylinder - scsi_cmdbuf[pos++] = 0x00; // RPL - scsi_cmdbuf[pos++] = 0x00; // Rotational offset - scsi_cmdbuf[pos++] = 0x00; // Reserved - scsi_cmdbuf[pos++] = uint8_t(10000 >> 8); // Medium rotation rate - scsi_cmdbuf[pos++] = uint8_t(10000); // Medium rotation rate - scsi_cmdbuf[pos++] = 0x00; // Reserved - scsi_cmdbuf[pos++] = 0x00; // Reserved - break; - } - - case 0x08: // caching page - scsi_cmdbuf[pos++] = 0x08; // !PS, page id - scsi_cmdbuf[pos++] = 0x0a; // page length - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - break; - - case 0x30: { // Apple firmware ID page - scsi_cmdbuf[pos++] = 0xb0; // cPS, page id - scsi_cmdbuf[pos++] = 0x16; // Page length - scsi_cmdbuf[pos++] = 'A'; - scsi_cmdbuf[pos++] = 'P'; - scsi_cmdbuf[pos++] = 'P'; - scsi_cmdbuf[pos++] = 'L'; - scsi_cmdbuf[pos++] = 'E'; - scsi_cmdbuf[pos++] = ' '; - scsi_cmdbuf[pos++] = 'C'; - scsi_cmdbuf[pos++] = 'O'; - scsi_cmdbuf[pos++] = 'M'; - scsi_cmdbuf[pos++] = 'P'; - scsi_cmdbuf[pos++] = 'U'; - scsi_cmdbuf[pos++] = 'T'; - scsi_cmdbuf[pos++] = 'E'; - scsi_cmdbuf[pos++] = 'R'; - scsi_cmdbuf[pos++] = ','; - scsi_cmdbuf[pos++] = ' '; - scsi_cmdbuf[pos++] = 'I'; - scsi_cmdbuf[pos++] = 'N'; - scsi_cmdbuf[pos++] = 'C'; - scsi_cmdbuf[pos++] = ' '; - scsi_cmdbuf[pos++] = ' '; - scsi_cmdbuf[pos++] = ' '; - break; - } - - default: - if (page != 0x3f) { - LOG("mode sense page %02x unhandled\n", page); - fail = true; - } - break; - } - } - - if (!fail) { - scsi_cmdbuf[0] = pos; - if (pos > size) - pos = size; - - scsi_data_in(0, pos); - scsi_status_complete(SS_GOOD); - } else { - scsi_status_complete(SS_CHECK_CONDITION); - sense(false, SK_ILLEGAL_REQUEST, SK_ASC_INVALID_FIELD_IN_CDB); - } - break; - } - - case SC_START_STOP_UNIT: - LOG("command %s UNIT\n", (scsi_cmdbuf[4] & 0x1) ? "START" : "STOP"); - scsi_status_complete(SS_GOOD); - break; - - case SC_RECIEVE_DIAG_RES: { - LOG("command RECIEVE DIAGNOSTICS RESULTS"); - int size = (scsi_cmdbuf[3] << 8) | scsi_cmdbuf[4]; - int pos = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 6; - scsi_cmdbuf[pos++] = 0; // ROM is OK - scsi_cmdbuf[pos++] = 0; // RAM is OK - scsi_cmdbuf[pos++] = 0; // Data buffer is OK - scsi_cmdbuf[pos++] = 0; // Interface is OK - scsi_cmdbuf[pos++] = 0; - if(size > pos) - size = pos; - scsi_data_in(0, size); - scsi_status_complete(SS_GOOD); - break; - } - - case SC_SEND_DIAGNOSTICS: { - LOG("command SEND DIAGNOSTICS"); - int size = (scsi_cmdbuf[3] << 8) | scsi_cmdbuf[4]; - if(scsi_cmdbuf[1] & 4) { - // Self-test - scsi_status_complete(SS_GOOD); - break; - } - int pos = 0; - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 6; - scsi_cmdbuf[pos++] = 0; // ROM is OK - scsi_cmdbuf[pos++] = 0; // RAM is OK - scsi_cmdbuf[pos++] = 0; // Data buffer is OK - scsi_cmdbuf[pos++] = 0; // Interface is OK - scsi_cmdbuf[pos++] = 0; - scsi_cmdbuf[pos++] = 0; - if(size > pos) - size = pos; - scsi_data_in(0, size); - scsi_status_complete(SS_GOOD); - break; - } - - case SC_READ_CAPACITY: { - LOG("command READ CAPACITY\n"); - - hard_disk_info *info = hard_disk_get_info(harddisk); - uint32_t size = info->cylinders * info->heads * info->sectors - 1; - - scsi_cmdbuf[0] = (size>>24) & 0xff; - scsi_cmdbuf[1] = (size>>16) & 0xff; - scsi_cmdbuf[2] = (size>>8) & 0xff; - scsi_cmdbuf[3] = (size & 0xff); - scsi_cmdbuf[4] = (info->sectorbytes>>24)&0xff; - scsi_cmdbuf[5] = (info->sectorbytes>>16)&0xff; - scsi_cmdbuf[6] = (info->sectorbytes>>8)&0xff; - scsi_cmdbuf[7] = (info->sectorbytes & 0xff); - - scsi_data_in(0, 8); - scsi_status_complete(SS_GOOD); - break; - } - - case SC_READ_10: - lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5]; - blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8]; - - LOG("command READ EXTENDED start=%08x blocks=%04x\n",lba, blocks); - - scsi_data_in(2, blocks*bytes_per_sector); - scsi_status_complete(SS_GOOD); - break; - - case SC_WRITE_10: - lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5]; - blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8]; - - LOG("command WRITE EXTENDED start=%08x blocks=%04x\n", lba, blocks); - - scsi_data_out(2, blocks*bytes_per_sector); - scsi_status_complete(SS_GOOD); - break; - - case SC_FORMAT_UNIT: - LOG("command FORMAT UNIT:%s%s%s%s%s\n", - (scsi_cmdbuf[1] & 0x80) ? " FMT-PINFO" : "", - (scsi_cmdbuf[1] & 0x40) ? " RTO_REQ" : "", - (scsi_cmdbuf[1] & 0x20) ? " LONG-LIST" : "", - (scsi_cmdbuf[1] & 0x10) ? " FMTDATA" : "", - (scsi_cmdbuf[1] & 0x08) ? " CMPLIST" : ""); - { - hard_disk_info *info = hard_disk_get_info(harddisk); - auto block = std::make_unique(info->sectorbytes); - for(int cyl = 0; cyl < info->cylinders; cyl++) { - for(int head = 0; head < info->heads; head++) { - for(int sector = 0; sector < info->sectors; sector++) { - hard_disk_write(harddisk, cyl * head * sector, block.get()); - } - } - } - } - scsi_status_complete(SS_GOOD); - break; - - case SC_MODE_SELECT_6: - LOG("command MODE SELECT\n"); - scsi_status_complete(SS_GOOD); - break; - - case SC_VERIFY: - LOG("command VERIFY BytChk %d\n", !!(scsi_cmdbuf[1] & 0x02)); - if (!(scsi_cmdbuf[1] & 0x02)) - scsi_status_complete(SS_GOOD); - else - scsi_unknown_command(); - break; - - default: - LOG("command %02x ***UNKNOWN***\n", scsi_cmdbuf[0]); - nscsi_full_device::scsi_command(); - break; - } -} diff --git a/src/devices/machine/nscsi_hd.h b/src/devices/machine/nscsi_hd.h deleted file mode 100644 index 5ddbf3e8519..00000000000 --- a/src/devices/machine/nscsi_hd.h +++ /dev/null @@ -1,38 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -#ifndef MAME_MACHINE_NSCSI_HD_H -#define MAME_MACHINE_NSCSI_HD_H - -#pragma once - -#include "machine/nscsi_bus.h" -#include "imagedev/harddriv.h" - -class nscsi_harddisk_device : public nscsi_full_device -{ -public: - nscsi_harddisk_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - nscsi_harddisk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - - virtual void device_start() override; - virtual void device_reset() override; - virtual void device_add_mconfig(machine_config &config) override; - - virtual void scsi_command() override; - virtual uint8_t scsi_get_data(int id, int pos) override; - virtual void scsi_put_data(int buf, int offset, uint8_t data) override; - - required_device image; - uint8_t block[512]; - hard_disk_file *harddisk; - int lba, cur_lba, blocks; - int bytes_per_sector; - - std::vector m_inquiry_data; -}; - -DECLARE_DEVICE_TYPE(NSCSI_HARDDISK, nscsi_harddisk_device) - -#endif // MAME_MACHINE_NSCSI_HD_H diff --git a/src/devices/machine/nscsi_s1410.cpp b/src/devices/machine/nscsi_s1410.cpp deleted file mode 100644 index 7b39b28a76c..00000000000 --- a/src/devices/machine/nscsi_s1410.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -#include "emu.h" -#include "machine/nscsi_s1410.h" - -DEFINE_DEVICE_TYPE(NSCSI_S1410, nscsi_s1410_device, "scsi_s1410", "S1410 Hard Disk") - -nscsi_s1410_device::nscsi_s1410_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - nscsi_harddisk_device(mconfig, NSCSI_S1410, tag, owner, clock) -{ -} - -void nscsi_s1410_device::device_reset() -{ - nscsi_harddisk_device::device_reset(); - - // initialize drive characteristics - params[0] = 0; - params[1] = 153; - params[2] = 4; - params[3] = 0; - params[4] = 128; - params[5] = 0; - params[6] = 64; - params[7] = 11; -} - -void nscsi_s1410_device::scsi_command() -{ - switch(scsi_cmdbuf[0]) { - case SC_TEST_UNIT_READY: - case SC_REZERO: - case SC_REQUEST_SENSE: - case SC_REASSIGN_BLOCKS: - case SC_READ: - case SC_WRITE: - case SC_SEEK: - if (scsi_cmdbuf[1] >> 5) { - scsi_status_complete(SS_NOT_READY); - } else { - nscsi_harddisk_device::scsi_command(); - } - break; - - case SC_FORMAT_UNIT: - if (scsi_cmdbuf[1] >> 5) { - scsi_status_complete(SS_NOT_READY); - return; - } - - scsi_status_complete(SS_GOOD); - break; - - case SC_FORMAT_TRACK: { - if (scsi_cmdbuf[1] >> 5) { - scsi_status_complete(SS_NOT_READY); - return; - } - - lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3]; - blocks = (bytes_per_sector == 256) ? 32 : 17; - - int track_length = blocks*bytes_per_sector; - std::vector data(track_length); - memset(&data[0], 0xc6, track_length); - - if(!hard_disk_write(harddisk, lba, &data[0])) { - logerror("%s: HD WRITE ERROR !\n", tag()); - scsi_status_complete(SS_FORMAT_ERROR); - } else { - scsi_status_complete(SS_GOOD); - } - } - break; - - case SC_FORMAT_ALT_TRACK: - if (scsi_cmdbuf[1] >> 5) { - scsi_status_complete(SS_NOT_READY); - return; - } - - scsi_data_in(2, 3); - scsi_status_complete(SS_GOOD); - break; - - case SC_INIT_DRIVE_PARAMS: - scsi_data_in(2, 8); - scsi_status_complete(SS_GOOD); - break; - - case SC_WRITE_SECTOR_BUFFER: - scsi_data_in(2, 512); - scsi_status_complete(SS_GOOD); - break; - - case SC_READ_SECTOR_BUFFER: - scsi_data_out(2, 512); - scsi_status_complete(SS_GOOD); - break; - - case SC_CHECK_TRACK_FORMAT: - if (scsi_cmdbuf[1] >> 5) { - scsi_status_complete(SS_NOT_READY); - return; - } - scsi_status_complete(SS_GOOD); - break; - - case SC_READ_ECC_BURST: - case SC_RAM_DIAG: - case SC_DRIVE_DIAG: - case SC_CONTROLLER_DIAG: - case SC_READ_LONG: - case SC_WRITE_LONG: - scsi_status_complete(SS_GOOD); - break; - - default: - logerror("%s: command %02x ***UNKNOWN***\n", tag(), scsi_cmdbuf[0]); - break; - } -} - -uint8_t nscsi_s1410_device::scsi_get_data(int id, int pos) -{ - switch(scsi_cmdbuf[0]) { - case SC_READ_SECTOR_BUFFER: - return block[pos]; - - default: - return nscsi_harddisk_device::scsi_get_data(id, pos); - } -} - -void nscsi_s1410_device::scsi_put_data(int id, int pos, uint8_t data) -{ - switch(scsi_cmdbuf[0]) { - case SC_FORMAT_ALT_TRACK: - break; - - case SC_INIT_DRIVE_PARAMS: - params[pos] = data; - break; - - case SC_WRITE_SECTOR_BUFFER: - block[pos] = data; - break; - - default: - return nscsi_harddisk_device::scsi_put_data(id, pos, data); - } -} diff --git a/src/devices/machine/nscsi_s1410.h b/src/devices/machine/nscsi_s1410.h deleted file mode 100644 index a6234d4c027..00000000000 --- a/src/devices/machine/nscsi_s1410.h +++ /dev/null @@ -1,78 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -#ifndef MAME_MACHINE_NSCSI_S1410_H -#define MAME_MACHINE_NSCSI_S1410_H - -#pragma once - -#include "machine/nscsi_bus.h" -#include "machine/nscsi_hd.h" - -class nscsi_s1410_device : public nscsi_harddisk_device -{ -public: - nscsi_s1410_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - -protected: - // SCSI status returns - enum { - SS_GOOD = 0x00, - SS_NO_INDEX = 0x01, - SS_NO_SEEK_COMPLETE = 0x02, - SS_WRITE_FAULT = 0x03, - SS_NOT_READY = 0x04, - SS_TK00_NOT_FOUND = 0x06, - SS_SEEK_IN_PROGRESS = 0x08, - SS_ID_FIELD_ERROR = 0x10, - SS_DATA_ERROR = 0x11, - SS_SAM_NOT_FOUND = 0x12, - SS_SECTOR_NOT_FOUND = 0x14, - SS_SEEK_ERROR = 0x15, - SS_ECC = 0x18, - SS_BAD_TRACK = 0x19, - SS_FORMAT_ERROR = 0x1a, - SS_ALT_TRACK = 0x1c, - SS_ALT_TRACK_DEFECT = 0x1d, - SS_ALT_TRACK_NOT_FOUND = 0x1e, - SS_ALT_TRACK_SAME = 0x1f, - SS_RAM_ERROR = 0x30, - SS_ROM_ERROR = 0x31, - SS_ECC_CHECK_FAILURE = 0x32 - }; - - // SCSI commands - enum { - SC_TEST_UNIT_READY = 0x00, - SC_REZERO = 0x01, - SC_REQUEST_SENSE = 0x03, - SC_FORMAT_UNIT = 0x04, - SC_CHECK_TRACK_FORMAT = 0x05, - SC_FORMAT_TRACK = 0x06, - SC_REASSIGN_BLOCKS = 0x07, - SC_READ = 0x08, - SC_WRITE = 0x0a, - SC_SEEK = 0x0b, - SC_INIT_DRIVE_PARAMS = 0x0c, - SC_READ_ECC_BURST = 0x0d, - SC_FORMAT_ALT_TRACK = 0x0e, - SC_WRITE_SECTOR_BUFFER = 0x0f, - SC_READ_SECTOR_BUFFER = 0x10, - SC_RAM_DIAG = 0xe0, - SC_DRIVE_DIAG = 0xe3, - SC_CONTROLLER_DIAG = 0xe4, - SC_READ_LONG = 0xe5, - SC_WRITE_LONG = 0xe6 - }; - - virtual void device_reset() override; - - virtual void scsi_command() override; - virtual uint8_t scsi_get_data(int id, int pos) override; - virtual void scsi_put_data(int buf, int offset, uint8_t data) override; - - uint8_t params[8]; -}; - -DECLARE_DEVICE_TYPE(NSCSI_S1410, nscsi_s1410_device) - -#endif // MAME_MACHINE_NSCSI_S1410_H diff --git a/src/mame/drivers/4dpi.cpp b/src/mame/drivers/4dpi.cpp index 4fb914dcf21..95643af993b 100644 --- a/src/mame/drivers/4dpi.cpp +++ b/src/mame/drivers/4dpi.cpp @@ -55,8 +55,8 @@ // buses and connectors #include "machine/nscsi_bus.h" -#include "machine/nscsi_hd.h" -#include "machine/nscsi_cd.h" +#include "bus/nscsi/hd.h" +#include "bus/nscsi/cd.h" #include "bus/rs232/rs232.h" #include "bus/sgikbd/sgikbd.h" #include "bus/rs232/hlemouse.h" diff --git a/src/mame/drivers/ampro.cpp b/src/mame/drivers/ampro.cpp index 2d11883ec3c..409583fff33 100644 --- a/src/mame/drivers/ampro.cpp +++ b/src/mame/drivers/ampro.cpp @@ -23,8 +23,8 @@ of a hard drive of up to 88MB. #include "cpu/z80/z80.h" #include "imagedev/floppy.h" #include "machine/ncr5380n.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "machine/output_latch.h" #include "machine/z80daisy.h" #include "machine/z80ctc.h" diff --git a/src/mame/drivers/cps3.cpp b/src/mame/drivers/cps3.cpp index ad6db84fde7..5986ad19a8a 100644 --- a/src/mame/drivers/cps3.cpp +++ b/src/mame/drivers/cps3.cpp @@ -464,7 +464,7 @@ hardware modification to the security cart..... #include "machine/intelfsh.h" #include "machine/nvram.h" #include "includes/cps3.h" -#include "machine/nscsi_cd.h" +#include "bus/nscsi/cd.h" #include "machine/wd33c9x.h" #include "screen.h" #include "speaker.h" diff --git a/src/mame/drivers/decstation.cpp b/src/mame/drivers/decstation.cpp index 04623dfa6a4..17ffb7eac0d 100644 --- a/src/mame/drivers/decstation.cpp +++ b/src/mame/drivers/decstation.cpp @@ -65,8 +65,8 @@ #include "machine/z80scc.h" #include "machine/ncr5390.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "machine/dec_lk201.h" #include "machine/am79c90.h" #include "machine/dc7085.h" diff --git a/src/mame/drivers/indy_indigo2.cpp b/src/mame/drivers/indy_indigo2.cpp index ca6b520801f..3faea787328 100644 --- a/src/mame/drivers/indy_indigo2.cpp +++ b/src/mame/drivers/indy_indigo2.cpp @@ -64,8 +64,8 @@ #include "machine/hpc3.h" #include "machine/ioc2.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "machine/sgi.h" #include "machine/vino.h" #include "machine/wd33c9x.h" diff --git a/src/mame/drivers/krz2000.cpp b/src/mame/drivers/krz2000.cpp index 6e622905596..213f93c0369 100644 --- a/src/mame/drivers/krz2000.cpp +++ b/src/mame/drivers/krz2000.cpp @@ -24,8 +24,8 @@ #include "machine/bankdev.h" #include "machine/upd765.h" #include "machine/ncr5380n.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "video/t6963c.h" #include "screen.h" #include "emupal.h" diff --git a/src/mame/drivers/lb186.cpp b/src/mame/drivers/lb186.cpp index 92ddb98e54e..b2488e4b979 100644 --- a/src/mame/drivers/lb186.cpp +++ b/src/mame/drivers/lb186.cpp @@ -5,8 +5,8 @@ #include "cpu/i86/i186.h" #include "machine/wd_fdc.h" #include "machine/mc68681.h" +#include "bus/nscsi/hd.h" #include "bus/rs232/rs232.h" -#include "machine/nscsi_hd.h" #include "machine/ncr5380n.h" #include "imagedev/floppy.h" #include "formats/pc_dsk.h" diff --git a/src/mame/drivers/next.cpp b/src/mame/drivers/next.cpp index ace185152d0..013cdd6c270 100644 --- a/src/mame/drivers/next.cpp +++ b/src/mame/drivers/next.cpp @@ -28,8 +28,8 @@ #include "emu.h" #include "includes/next.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "screen.h" #include "softlist.h" diff --git a/src/mame/drivers/r9751.cpp b/src/mame/drivers/r9751.cpp index c7b6d851c9a..0eb7b3a64ba 100644 --- a/src/mame/drivers/r9751.cpp +++ b/src/mame/drivers/r9751.cpp @@ -53,8 +53,8 @@ #include "machine/terminal.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "machine/wd33c9x.h" diff --git a/src/mame/drivers/rastersp.cpp b/src/mame/drivers/rastersp.cpp index 411c4cdff64..6e4fd1fd0ab 100644 --- a/src/mame/drivers/rastersp.cpp +++ b/src/mame/drivers/rastersp.cpp @@ -16,11 +16,11 @@ ****************************************************************************/ #include "emu.h" +#include "bus/nscsi/hd.h" #include "cpu/i386/i386.h" #include "cpu/tms32031/tms32031.h" #include "machine/53c7xx.h" #include "machine/mc146818.h" -#include "machine/nscsi_hd.h" #include "machine/nvram.h" #include "machine/timer.h" #include "sound/dac.h" diff --git a/src/mame/drivers/sun3.cpp b/src/mame/drivers/sun3.cpp index 78e65bf33da..520df9cbe3d 100644 --- a/src/mame/drivers/sun3.cpp +++ b/src/mame/drivers/sun3.cpp @@ -189,8 +189,8 @@ fefc34a - start of mem_size, which queries ECC registers for each memory board #include "machine/z80scc.h" #include "machine/am79c90.h" #include "machine/ncr5380n.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "bus/rs232/rs232.h" #include "bus/sunkbd/sunkbd.h" diff --git a/src/mame/drivers/sun4.cpp b/src/mame/drivers/sun4.cpp index 7f13ed74617..5f3e6d9f8cd 100644 --- a/src/mame/drivers/sun4.cpp +++ b/src/mame/drivers/sun4.cpp @@ -411,6 +411,8 @@ #include "emu.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "bus/rs232/rs232.h" #include "bus/sunkbd/sunkbd.h" #include "bus/sunmouse/sunmouse.h" @@ -422,8 +424,6 @@ #include "machine/bankdev.h" #include "machine/ncr5390.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" #include "machine/nvram.h" #include "machine/ram.h" #include "machine/sun4c_mmu.h" diff --git a/src/mame/drivers/tti.cpp b/src/mame/drivers/tti.cpp index 16e3f606c26..16b1f5b8815 100644 --- a/src/mame/drivers/tti.cpp +++ b/src/mame/drivers/tti.cpp @@ -16,14 +16,14 @@ Other: LED, 20MHz crystal. Next to the MC68901P is another chip just as large (4 ************************************************************************************************************************************/ #include "emu.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "bus/rs232/rs232.h" #include "cpu/m68000/m68000.h" #include "machine/74259.h" #include "machine/eepromser.h" #include "machine/mc68901.h" #include "machine/ncr5390.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" class tti_state : public driver_device { diff --git a/src/mame/includes/interpro.h b/src/mame/includes/interpro.h index ad28c68a546..32db12daba8 100644 --- a/src/mame/includes/interpro.h +++ b/src/mame/includes/interpro.h @@ -24,8 +24,8 @@ #include "machine/ncr5390.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "bus/rs232/rs232.h" diff --git a/src/mame/includes/jazz.h b/src/mame/includes/jazz.h index 8bcf2e7cbbb..e4f1d75f847 100644 --- a/src/mame/includes/jazz.h +++ b/src/mame/includes/jazz.h @@ -34,8 +34,8 @@ // busses and connectors #include "machine/nscsi_bus.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "bus/rs232/rs232.h" #include "bus/pc_kbd/pc_kbdc.h" #include "bus/pc_kbd/keyboards.h" diff --git a/src/mame/includes/mips.h b/src/mame/includes/mips.h index aff93ac1e94..a4c0c9e0462 100644 --- a/src/mame/includes/mips.h +++ b/src/mame/includes/mips.h @@ -29,8 +29,8 @@ // busses and connectors #include "machine/nscsi_bus.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "bus/pc_kbd/pc_kbdc.h" #include "bus/pc_kbd/keyboards.h" diff --git a/src/mame/machine/hpc1.cpp b/src/mame/machine/hpc1.cpp index a4c32d5d5c1..8ffb6e25a14 100644 --- a/src/mame/machine/hpc1.cpp +++ b/src/mame/machine/hpc1.cpp @@ -11,8 +11,8 @@ #include "bus/rs232/rs232.h" #include "bus/rs232/hlemouse.h" #include "machine/nscsi_bus.h" -#include "machine/nscsi_cd.h" -#include "machine/nscsi_hd.h" +#include "bus/nscsi/cd.h" +#include "bus/nscsi/hd.h" #include "bus/sgikbd/sgikbd.h" #include "machine/hpc1.h" #include "speaker.h" -- cgit v1.2.3