summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/nscsi_hd.cpp
diff options
context:
space:
mode:
author Patrick Mackinlay <pmackinlay@hotmail.com>2017-12-20 08:45:09 +0700
committer Patrick Mackinlay <pmackinlay@hotmail.com>2017-12-20 08:45:09 +0700
commit09a8ca238e9b3823e3300bee0178f9b9395b1947 (patch)
tree8f944d8243df790dee9aad4838595dbfc18f0fb2 /src/devices/machine/nscsi_hd.cpp
parentac0083d4e0473ca56d8f9030fc41454bdc51158a (diff)
nscsi: use chd idnt metadata for inquiry
Also use logmacro.h logging.
Diffstat (limited to 'src/devices/machine/nscsi_hd.cpp')
-rw-r--r--src/devices/machine/nscsi_hd.cpp117
1 files changed, 63 insertions, 54 deletions
diff --git a/src/devices/machine/nscsi_hd.cpp b/src/devices/machine/nscsi_hd.cpp
index 7650d4063f0..e04dd881f83 100644
--- a/src/devices/machine/nscsi_hd.cpp
+++ b/src/devices/machine/nscsi_hd.cpp
@@ -4,6 +4,13 @@
#include "machine/nscsi_hd.h"
#include "imagedev/harddriv.h"
+#define LOG_GENERAL (1U << 0)
+#define LOG_COMMAND (1U << 1)
+
+#define VERBOSE (LOG_GENERAL)
+
+#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) :
@@ -37,6 +44,10 @@ void nscsi_harddisk_device::device_reset()
} else {
const hard_disk_info *hdinfo = hard_disk_get_info(harddisk);
bytes_per_sector = hdinfo->sectorbytes;
+
+ chd_file *chd = hd->get_chd_file();
+ if (chd != nullptr)
+ chd->read_metadata(HARD_DISK_IDENT_METADATA_TAG, 0, m_inquiry_data);
}
cur_lba = -1;
}
@@ -55,7 +66,7 @@ uint8_t nscsi_harddisk_device::scsi_get_data(int id, int pos)
if(clba != cur_lba) {
cur_lba = clba;
if(!hard_disk_read(harddisk, cur_lba, block)) {
- logerror("%s: HD READ ERROR !\n", tag());
+ LOG("HD READ ERROR !\n");
memset(block, 0, sizeof(block));
}
}
@@ -74,27 +85,23 @@ void nscsi_harddisk_device::scsi_put_data(int id, int pos, uint8_t data)
int clba = lba + pos / bytes_per_sector;
if(offset == bytes_per_sector-1) {
if(!hard_disk_write(harddisk, clba, block))
- logerror("%s: HD WRITE ERROR !\n", tag());
+ LOG("HD WRITE ERROR !\n");
}
}
void nscsi_harddisk_device::scsi_command()
{
- #if 0
- if (scsi_cmdbuf[0] != SC_READ)
+
+ if ((VERBOSE & LOG_COMMAND) && scsi_cmdbuf[0] != SC_READ_6)
{
- logerror("%s: ", tag());
- for (int i = 0; i < 6; i++)
- {
- logerror("%02x ", scsi_cmdbuf[i]);
- }
- logerror("\n");
+ 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]);
}
- #endif
switch(scsi_cmdbuf[0]) {
case SC_TEST_UNIT_READY:
- logerror("%s: command TEST UNIT READY\n", tag());
+ LOG("command TEST UNIT READY\n");
scsi_status_complete(SS_GOOD);
break;
@@ -104,8 +111,7 @@ void nscsi_harddisk_device::scsi_command()
if(!blocks)
blocks = 256;
- logerror("%s: command READ start=%08x blocks=%04x\n",
- tag(), lba, blocks);
+ LOG("command READ start=%08x blocks=%04x\n", lba, blocks);
scsi_data_in(2, blocks*bytes_per_sector);
scsi_status_complete(SS_GOOD);
@@ -117,8 +123,7 @@ void nscsi_harddisk_device::scsi_command()
if(!blocks)
blocks = 256;
- logerror("%s: command WRITE start=%08x blocks=%04x\n",
- tag(), lba, blocks);
+ LOG("command WRITE start=%08x blocks=%04x\n", lba, blocks);
scsi_data_out(2, blocks*bytes_per_sector);
scsi_status_complete(SS_GOOD);
@@ -126,9 +131,8 @@ void nscsi_harddisk_device::scsi_command()
case SC_INQUIRY: {
int lun = get_lun(scsi_cmdbuf[1] >> 5);
- logerror("%s: command INQUIRY lun=%d EVPD=%d page=%d alloc=%02x link=%02x\n",
- tag(),
- lun, scsi_cmdbuf[1] & 1, scsi_cmdbuf[2], scsi_cmdbuf[4], scsi_cmdbuf[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];
@@ -146,30 +150,38 @@ void nscsi_harddisk_device::scsi_command()
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
- // Apple HD SC setup utility needs to see this
- strcpy((char *)&scsi_cmdbuf[8], " SEAGATE");
- strcpy((char *)&scsi_cmdbuf[15], " ST225N");
- strcpy((char *)&scsi_cmdbuf[31], "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
- if(size > 54)
- size = 54;
+ 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[15], " ST225N");
+ strcpy((char *)&scsi_cmdbuf[31], "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;
}
@@ -179,9 +191,8 @@ void nscsi_harddisk_device::scsi_command()
case SC_MODE_SENSE_6: {
int lun = get_lun(scsi_cmdbuf[1] >> 5);
- logerror("%s: command MODE SENSE 6 lun=%d page=%02x alloc=%02x link=%02x\n",
- tag(),
- lun, scsi_cmdbuf[2] & 0x3f, scsi_cmdbuf[4], scsi_cmdbuf[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;
@@ -301,7 +312,7 @@ void nscsi_harddisk_device::scsi_command()
}
default:
- logerror("%s: mode sense page %02x unhandled\n", tag(), page);
+ LOG("mode sense page %02x unhandled\n", page);
break;
}
}
@@ -315,12 +326,12 @@ void nscsi_harddisk_device::scsi_command()
}
case SC_START_STOP_UNIT:
- logerror("%s: command START STOP UNIT\n", tag());
+ LOG("command START STOP UNIT\n");
scsi_status_complete(SS_GOOD);
break;
case SC_READ_CAPACITY: {
- logerror("%s: command READ CAPACITY\n", tag());
+ LOG("command READ CAPACITY\n");
hard_disk_info *info = hard_disk_get_info(harddisk);
uint32_t size = info->cylinders * info->heads * info->sectors - 1;
@@ -343,8 +354,7 @@ void nscsi_harddisk_device::scsi_command()
lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5];
blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8];
- logerror("%s: command READ EXTENDED start=%08x blocks=%04x\n",
- tag(), lba, blocks);
+ LOG("command READ EXTENDED start=%08x blocks=%04x\n",lba, blocks);
scsi_data_in(2, blocks*bytes_per_sector);
scsi_status_complete(SS_GOOD);
@@ -354,15 +364,14 @@ void nscsi_harddisk_device::scsi_command()
lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5];
blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8];
- logerror("%s: command WRITE EXTENDED start=%08x blocks=%04x\n",
- tag(), lba, blocks);
+ 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;
default:
- logerror("%s: command %02x ***UNKNOWN***\n", tag(), scsi_cmdbuf[0]);
+ LOG("command %02x ***UNKNOWN***\n", scsi_cmdbuf[0]);
nscsi_full_device::scsi_command();
break;
}