mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
Merge branch 'master' of https://github.com/mamedev/mame
This commit is contained in:
commit
9b9a015487
@ -3,6 +3,15 @@
|
||||
#include "emu.h"
|
||||
#include "nscsi_bus.h"
|
||||
|
||||
#define LOG_GENERAL (1U << 0)
|
||||
#define LOG_STATE (1U << 1)
|
||||
#define LOG_CONTROL (1U << 2)
|
||||
|
||||
//#define VERBOSE (LOG_GENERAL | LOG_STATE | LOG_CONTROL)
|
||||
#define VERBOSE (LOG_GENERAL)
|
||||
|
||||
#include "logmacro.h"
|
||||
|
||||
DEFINE_DEVICE_TYPE(NSCSI_BUS, nscsi_bus_device, "nscsi_bus", "SCSI Bus (new)")
|
||||
DEFINE_DEVICE_TYPE(NSCSI_CONNECTOR, nscsi_connector, "nscsi_connector", "SCSI Connector Abstraction (new)")
|
||||
|
||||
@ -49,9 +58,8 @@ void nscsi_bus_device::regen_ctrl(int refid)
|
||||
for(int i=0; i<devcnt; i++)
|
||||
ctrl |= dev[i].ctrl;
|
||||
|
||||
if(0) {
|
||||
logerror("%s: ctrl %c%c%c%c%c%c%c%c%c %s %04x -",
|
||||
tag(),
|
||||
if(VERBOSE & LOG_CONTROL) {
|
||||
LOGMASKED(LOG_CONTROL, "ctrl %c%c%c%c%c%c%c%c%c %s %04x\n",
|
||||
ctrl & nscsi_device::S_RST ? 'R' : '.',
|
||||
ctrl & nscsi_device::S_ATN ? 'A' : '.',
|
||||
ctrl & nscsi_device::S_ACK ? 'K' : '.',
|
||||
@ -65,8 +73,7 @@ void nscsi_bus_device::regen_ctrl(int refid)
|
||||
data);
|
||||
for(int i=0; i<devcnt; i++)
|
||||
if(dev[i].ctrl) {
|
||||
logerror(" %d=", i);
|
||||
logerror("%s%s%s%s%s%s%s%s%s",
|
||||
LOGMASKED(LOG_CONTROL, "%d=%s%s%s%s%s%s%s%s%s\n", i,
|
||||
dev[i].ctrl & nscsi_device::S_RST ? "R" : "",
|
||||
dev[i].ctrl & nscsi_device::S_ATN ? "A" : "",
|
||||
dev[i].ctrl & nscsi_device::S_ACK ? "K" : "",
|
||||
@ -77,7 +84,6 @@ void nscsi_bus_device::regen_ctrl(int refid)
|
||||
dev[i].ctrl & nscsi_device::S_SEL ? "S" : "",
|
||||
dev[i].ctrl & nscsi_device::S_BSY ? "B" : "");
|
||||
}
|
||||
logerror("\n");
|
||||
}
|
||||
|
||||
octrl = octrl ^ ctrl;
|
||||
@ -265,14 +271,13 @@ void nscsi_full_device::step(bool timeout)
|
||||
scsi_bus->data_w(scsi_refid, 0);
|
||||
scsi_bus->ctrl_w(scsi_refid, 0, S_ALL);
|
||||
scsi_state = IDLE;
|
||||
logerror("%s: scsi bus reset\n", tag());
|
||||
LOG("scsi bus reset\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(0)
|
||||
logerror("%s: state=%d.%d %s\n",
|
||||
tag(), scsi_state & STATE_MASK, (scsi_state & SUB_MASK) >> SUB_SHIFT,
|
||||
timeout ? "timeout" : "change");
|
||||
LOGMASKED(LOG_STATE, "state=%d.%d %s\n",
|
||||
scsi_state & STATE_MASK, (scsi_state & SUB_MASK) >> SUB_SHIFT,
|
||||
timeout ? "timeout" : "change");
|
||||
|
||||
switch(scsi_state & SUB_MASK ? scsi_state & SUB_MASK : scsi_state & STATE_MASK) {
|
||||
case IDLE:
|
||||
@ -417,7 +422,7 @@ void nscsi_full_device::step(bool timeout)
|
||||
if(ctrl & S_SEL)
|
||||
return;
|
||||
if(ctrl & S_ATN) {
|
||||
logerror("%s: Parity error? Say what?\n", tag());
|
||||
LOG("Parity error? Say what?\n");
|
||||
scsi_state = IDLE;
|
||||
break;
|
||||
}
|
||||
@ -433,9 +438,8 @@ void nscsi_full_device::step(bool timeout)
|
||||
break;
|
||||
|
||||
default:
|
||||
logerror("%s: step() unexpected state %d.%d\n",
|
||||
tag(),
|
||||
scsi_state & STATE_MASK, (scsi_state & SUB_MASK) >> SUB_SHIFT);
|
||||
LOG("step() unexpected state %d.%d\n",
|
||||
scsi_state & STATE_MASK, (scsi_state & SUB_MASK) >> SUB_SHIFT);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
@ -568,7 +572,7 @@ void nscsi_full_device::sense(bool deferred, uint8_t key)
|
||||
|
||||
void nscsi_full_device::scsi_unknown_command()
|
||||
{
|
||||
logerror("%s: Unhandled command %s", tag(), command_names[scsi_cmdbuf[0]]);
|
||||
LOG("Unhandled command %s", command_names[scsi_cmdbuf[0]]);
|
||||
for(int i=0; i != scsi_cmdsize; i++)
|
||||
logerror(" %02x", scsi_cmdbuf[i]);
|
||||
logerror("\n");
|
||||
@ -581,7 +585,7 @@ void nscsi_full_device::scsi_command()
|
||||
{
|
||||
switch(scsi_cmdbuf[0]) {
|
||||
case SC_REQUEST_SENSE:
|
||||
logerror("%s: command REQUEST SENSE\n", tag());
|
||||
LOG("command REQUEST SENSE\n");
|
||||
scsi_data_in(SBUF_SENSE, 8);
|
||||
scsi_status_complete(SS_GOOD);
|
||||
break;
|
||||
@ -598,7 +602,7 @@ void nscsi_full_device::scsi_message()
|
||||
return;
|
||||
}
|
||||
|
||||
logerror("%s: Unknown message", tag());
|
||||
LOG("Unknown message");
|
||||
for(int i=0; i != scsi_cmdsize; i++)
|
||||
logerror(" %02x", scsi_cmdbuf[i]);
|
||||
logerror("\n");
|
||||
|
@ -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,21 @@ 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)
|
||||
{
|
||||
logerror("%s: ", tag());
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
logerror("%02x ", scsi_cmdbuf[i]);
|
||||
}
|
||||
logerror("\n");
|
||||
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]);
|
||||
}
|
||||
#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 +109,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 +121,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 +129,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 +148,37 @@ 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 +188,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 +309,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 +323,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 +351,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 +361,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;
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ protected:
|
||||
hard_disk_file *harddisk;
|
||||
int lba, cur_lba, blocks;
|
||||
int bytes_per_sector;
|
||||
|
||||
std::vector<u8> m_inquiry_data;
|
||||
};
|
||||
|
||||
DECLARE_DEVICE_TYPE(NSCSI_HARDDISK, nscsi_harddisk_device)
|
||||
|
Loading…
Reference in New Issue
Block a user