Skip to content

Commit

Permalink
machine/nscsi_bus.cpp/.h: Add some more framework for future support …
Browse files Browse the repository at this point in the history
…of later SCSI command sets. [R. Belmont]

nscsi/hd.cpp: Support SYNCHRONIZE CACHE command, fix off-by-1 MODE SENSE size reporting. [R. Belmont]
  • Loading branch information
rb6502 committed Nov 30, 2024
1 parent baeadec commit 5da955a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/devices/bus/nscsi/hd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void nscsi_harddisk_device::scsi_command()
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++] = 0x26; // various bits
scsi_cmdbuf[pos++] = 0; // read retry count
scsi_cmdbuf[pos++] = 0; // correction span
scsi_cmdbuf[pos++] = 0; // head offset count
Expand Down Expand Up @@ -384,7 +384,7 @@ void nscsi_harddisk_device::scsi_command()
}

if (!fail) {
scsi_cmdbuf[0] = pos;
scsi_cmdbuf[0] = pos - 1;
if (pos > size)
pos = size;

Expand Down Expand Up @@ -444,6 +444,11 @@ void nscsi_harddisk_device::scsi_command()
break;
}

case SC_SYNCHRONIZE_CACHE:
LOG("command SYNCHRONIZE CACHE (10)\n");
scsi_status_complete(SS_GOOD);
break;

case SC_READ_CAPACITY: {
LOG("command READ CAPACITY\n");

Expand Down
16 changes: 9 additions & 7 deletions src/devices/machine/nscsi_bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#define LOG_DATA (1U << 4)
#define LOG_DATA_SENT (1U << 5)

//#define VERBOSE (LOG_GENERAL | LOG_STATE | LOG_CONTROL | LOG_DATA)
#define VERBOSE (LOG_UNSUPPORTED)
#define LOG_OUTPUT_FUNC osd_printf_info

#include "logmacro.h"

Expand Down Expand Up @@ -217,13 +217,13 @@ const char *const nscsi_full_device::command_names[256] = {
/* 50 */ "XDWRITE", "READ_DISC_INFORMATION/XPWRITE", "READ_TRACK_INFORMATION/XDREAD", "RESERVE_TRACK", "SEND_OPC_INFORMATION", "MODE_SELECT_10", "RESERVE_10", "RELEASE_10",
/* 58 */ "REPAIR_TRACK", "READ_MASTER_CUE", "MODE_SENSE_10", "CLOSE_TRACK_SESSION", "READ_BUFFER_CAPACITY", "SEND_CUE_SHEET", "PERSISTENT_RESERVE_IN", "PERSISTENT_RESERVE_OUT",
/* 80 */ "XDWRITE_EXTENDED", "REBUILD", "REGENERATE", "EXTENDED_COPY", "RECEIVE_COPY_RESULTS", "?", "?", "?",
/* 88 */ "?", "?", "?", "?", "?", "?", "?", "?",
/* 90 */ "?", "?", "?", "?", "?", "?", "?", "?",
/* 98 */ "?", "?", "?", "?", "?", "?", "?", "?",
/* 88 */ "?", "?", "WRITE_16", "?", "?", "?", "?", "?",
/* 90 */ "?", "SYNCHRONIZE_CACHE_16", "?", "WRITE_SAME_16", "?", "?", "?", "?",
/* 98 */ "?", "?", "?", "?", "?", "?", "READ_CAPACITY_166/READ_LONG_16", "WRITE_LONG_16",
/* a0 */ "REPORT_LUNS", "BLANK", "SEND_EVENT", "REPORT_DEVICE_IDENTIFIER/SEND_KEY", "SET_DEVICE_IDENTIFIER/REPORT_KEY", "PLAY_AUDIO_12", "LOAD_UNLOAD_MEDIUM", "MOVE_MEDIUM_ATTACHED/SET_READ_AHEAD",
/* a8 */ "READ_12", "PLAY_RELATIVE_12", "WRITE_12", "?", "ERASE_12/GET_PERFORMANCE", "READ_DVD_STRUCTURE", "WRITE_AND_VERIFY_12", "VERIFY_12",
/* b0 */ "SEARCH_DATA_HIGH_12", "SEARCH_DATA_EQUAL_12", "SEARCH_DATA_LOW_12", "SET_LIMITS_12", "READ_ELEMENT_STATUS_ATTACHED", "?", "SET_STREAMING", "READ_DEFECT_DATA_12",
/* b8 */ "?", "READ_CD_MSF", "SCAN_MMC", "SET_CD_SPEED", "PLAY_CD", "MECHANISM_STATUS", "READ_CD", "SEND_DVD_STRUCTURE",
/* b8 */ "?", "READ_CD_MSF", "SCAN_MMC", "SET_CD_SPEED", "PLAY_CD/SPARE_IN", "MECHANISM_STATUS/SPARE_OUT", "READ_CD", "SEND_DVD_STRUCTURE",
/* c0 */ "?", "?", "?", "?", "?", "?", "?", "?",
/* c8 */ "?", "?", "?", "?", "?", "?", "?", "?",
/* d0 */ "?", "?", "?", "?", "?", "?", "?", "?",
Expand Down Expand Up @@ -532,7 +532,7 @@ void nscsi_full_device::scsi_put_data(int id, int pos, uint8_t data)
scsi_sense_buffer[pos] = data;
break;
default:
fatalerror("nscsi_full_device::scsi_put_data - unknown id\n");
fatalerror("nscsi_full_device::scsi_put_data - unknown id %d\n", id);
}
}

Expand All @@ -553,7 +553,9 @@ bool nscsi_full_device::scsi_command_done(uint8_t command, uint8_t length)
case 4: return true;
case 5: return length == 12;
case 6: return true;
case 7: return true;
case 7: return length == 32;
case 8: return length == 16;
case 9: return length == 16;
}
return true;
}
Expand Down
8 changes: 8 additions & 0 deletions src/devices/machine/nscsi_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,12 @@ class nscsi_full_device : public nscsi_device, public nscsi_slot_card_interface
SC_REGENERATE = 0x82,
SC_EXTENDED_COPY = 0x83,
SC_RECEIVE_COPY_RESULTS = 0x84,
SC_WRITE_16 = 0x8a,
SC_SYNCHRONIZE_CACHE_16 = 0x91,
SC_WRITE_SAME_16 = 0x93,
SC_READ_CAPACITY_16 = 0x9e,
SC_READ_LONG_16 = 0x9e,
SC_WRITE_LONG_16 = 0x9f,
SC_REPORT_LUNS = 0xa0,
SC_BLANK = 0xa1,
SC_SEND_EVENT = 0xa2,
Expand Down Expand Up @@ -633,7 +639,9 @@ class nscsi_full_device : public nscsi_device, public nscsi_slot_card_interface
SC_SCAN_MMC = 0xba,
SC_SET_CD_SPEED = 0xbb,
SC_PLAY_CD = 0xbc,
SC_SPARE_IN = 0xbc,
SC_MECHANISM_STATUS = 0xbd,
SC_SPARE_OUT = 0xbd,
SC_READ_CD = 0xbe,
SC_SEND_DVD_STRUCTURE = 0xbf
};
Expand Down

0 comments on commit 5da955a

Please sign in to comment.