mirror of https://github.com/akuker/RASCSI.git
Compare commits
9 Commits
2201383445
...
89531b5fc3
Author | SHA1 | Date |
---|---|---|
Daniel Markstedt | 89531b5fc3 | |
Daniel Markstedt | a6a8cadf21 | |
dependabot[bot] | 12bb86db9b | |
dependabot[bot] | b348643ff3 | |
Daniel Markstedt | 3223f2ad64 | |
Daniel Markstedt | 5c74ca177f | |
Daniel Markstedt | 6b867346bc | |
Daniel Markstedt | 806fa25609 | |
Daniel Markstedt | a307a85d2f |
|
@ -29,8 +29,9 @@ using namespace std;
|
|||
using namespace piscsi_util;
|
||||
using namespace network_util;
|
||||
|
||||
const string CTapDriver::BRIDGE_NAME = "piscsi_bridge";
|
||||
// const string CTapDriver::BRIDGE_NAME = "piscsi_bridge";
|
||||
|
||||
#if 0
|
||||
static string br_setif(int br_socket_fd, const string& bridgename, const string& ifname, bool add) {
|
||||
#ifndef __linux__
|
||||
return "if_nametoindex: Linux is required";
|
||||
|
@ -47,6 +48,7 @@ static string br_setif(int br_socket_fd, const string& bridgename, const string&
|
|||
return "";
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
string ip_link(int fd, const char* ifname, bool up) {
|
||||
#ifndef __linux__
|
||||
|
@ -113,6 +115,7 @@ bool CTapDriver::Init(const param_map& const_params)
|
|||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
const int br_socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
||||
if (br_socket_fd < 0) {
|
||||
LogErrno("Can't open bridge socket");
|
||||
|
@ -121,15 +124,17 @@ bool CTapDriver::Init(const param_map& const_params)
|
|||
close(ip_fd);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
auto cleanUp = [&] (const string& error) {
|
||||
LogErrno(error);
|
||||
close(m_hTAP);
|
||||
close(ip_fd);
|
||||
close(br_socket_fd);
|
||||
// close(br_socket_fd);
|
||||
return false;
|
||||
};
|
||||
|
||||
#if 0
|
||||
// Check if the bridge has already been created
|
||||
// TODO Find an alternative to accessing a file, there is most likely a system call/ioctl
|
||||
if (access(string("/sys/class/net/" + BRIDGE_NAME).c_str(), F_OK)) {
|
||||
|
@ -162,6 +167,7 @@ bool CTapDriver::Init(const param_map& const_params)
|
|||
else {
|
||||
spdlog::info(BRIDGE_NAME + " is already available");
|
||||
}
|
||||
#endif
|
||||
|
||||
spdlog::trace(">ip link set piscsi0 up");
|
||||
|
||||
|
@ -169,11 +175,13 @@ bool CTapDriver::Init(const param_map& const_params)
|
|||
return cleanUp(error);
|
||||
}
|
||||
|
||||
#if 0
|
||||
spdlog::trace(">brctl addif " + BRIDGE_NAME + " piscsi0");
|
||||
|
||||
if (const string error = br_setif(br_socket_fd, BRIDGE_NAME, "piscsi0", true); !error.empty()) {
|
||||
return cleanUp(error);
|
||||
}
|
||||
#endif
|
||||
|
||||
spdlog::trace("Getting the MAC address");
|
||||
|
||||
|
@ -186,7 +194,7 @@ bool CTapDriver::Init(const param_map& const_params)
|
|||
memcpy(m_MacAddr.data(), ifr.ifr_hwaddr.sa_data, m_MacAddr.size());
|
||||
|
||||
close(ip_fd);
|
||||
close(br_socket_fd);
|
||||
// close(br_socket_fd);
|
||||
|
||||
spdlog::info("Tap device " + string(ifr.ifr_name) + " created");
|
||||
|
||||
|
@ -197,6 +205,7 @@ bool CTapDriver::Init(const param_map& const_params)
|
|||
void CTapDriver::CleanUp() const
|
||||
{
|
||||
if (m_hTAP != -1) {
|
||||
#if 0
|
||||
if (const int br_socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0); br_socket_fd < 0) {
|
||||
LogErrno("Can't open bridge socket");
|
||||
} else {
|
||||
|
@ -207,6 +216,7 @@ void CTapDriver::CleanUp() const
|
|||
}
|
||||
close(br_socket_fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Release TAP device
|
||||
close(m_hTAP);
|
||||
|
@ -243,6 +253,7 @@ pair<string, string> CTapDriver::ExtractAddressAndMask(const string& s)
|
|||
return { address, netmask };
|
||||
}
|
||||
|
||||
#if 0
|
||||
string CTapDriver::SetUpEth0(int socket_fd, const string& bridge_interface)
|
||||
{
|
||||
#ifdef __linux__
|
||||
|
@ -261,7 +272,9 @@ string CTapDriver::SetUpEth0(int socket_fd, const string& bridge_interface)
|
|||
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
string CTapDriver::SetUpNonEth0(int socket_fd, int ip_fd, const string& s)
|
||||
{
|
||||
#ifdef __linux__
|
||||
|
@ -301,6 +314,7 @@ string CTapDriver::SetUpNonEth0(int socket_fd, int ip_fd, const string& s)
|
|||
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
|
||||
string CTapDriver::IpLink(bool enable) const
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ using namespace std;
|
|||
|
||||
class CTapDriver
|
||||
{
|
||||
static const string BRIDGE_NAME;
|
||||
// static const string BRIDGE_NAME;
|
||||
|
||||
const inline static string DEFAULT_IP = "10.10.20.1/24"; //NOSONAR This hardcoded IP address is safe
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
static string SetUpEth0(int, const string&);
|
||||
//static string SetUpEth0(int, const string&);
|
||||
static string SetUpNonEth0(int, int, const string&);
|
||||
static pair<string, string> ExtractAddressAndMask(const string&);
|
||||
|
||||
|
|
|
@ -696,17 +696,11 @@ uint32_t Disk::GetSectorSizeInBytes() const
|
|||
void Disk::SetSectorSizeInBytes(uint32_t size_in_bytes)
|
||||
{
|
||||
if (!GetSupportedSectorSizes().contains(size_in_bytes)) {
|
||||
throw io_exception("Invalid sector size of " + to_string(size_in_bytes) + " byte(s)");
|
||||
throw io_exception("Invalid sector size of " + to_string(size_in_bytes) + " byte(s)");
|
||||
}
|
||||
uint64_t current_blocks = GetBlockCount();
|
||||
uint32_t current_size_shift_count = size_shift_count;
|
||||
uint64_t current_size = current_blocks << current_size_shift_count;
|
||||
|
||||
size_shift_count = CalculateShiftCount(size_in_bytes);
|
||||
assert(size_shift_count);
|
||||
if ((current_blocks > 0) && (current_size_shift_count > 0)) {
|
||||
SetBlockCount(current_size >> size_shift_count);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Disk::GetConfiguredSectorSize() const
|
||||
|
@ -720,7 +714,7 @@ bool Disk::SetConfiguredSectorSize(uint32_t configured_size)
|
|||
return false;
|
||||
}
|
||||
|
||||
configured_sector_size = configured_size;
|
||||
configured_sector_size = configured_size;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ protected:
|
|||
|
||||
void SetUpCache(off_t, bool = false);
|
||||
void ResizeCache(const string&, bool);
|
||||
bool GetRawMode() const { return (cache?cache->GetRawMode():false); }
|
||||
|
||||
void SetUpModePages(map<int, vector<byte>>&, int, bool) const override;
|
||||
void AddErrorPage(map<int, vector<byte>>&, bool) const;
|
||||
virtual void AddFormatPage(map<int, vector<byte>>&, bool) const;
|
||||
|
|
|
@ -51,7 +51,6 @@ public:
|
|||
~DiskCache() = default;
|
||||
|
||||
void SetRawMode(bool b) { cd_raw = b; } // CD-ROM raw mode setting
|
||||
bool GetRawMode() const { return cd_raw; }
|
||||
|
||||
bool Save(); // Save and release all
|
||||
bool ReadSector(span<uint8_t>, uint32_t); // Sector Read
|
||||
|
|
|
@ -114,7 +114,7 @@ void ModePageDevice::ModeSense10() const
|
|||
EnterDataInPhase();
|
||||
}
|
||||
|
||||
void ModePageDevice::ModeSelect(scsi_command, cdb_t, span<const uint8_t>, int)
|
||||
void ModePageDevice::ModeSelect(scsi_command, cdb_t, span<const uint8_t>, int) const
|
||||
{
|
||||
// There is no default implementation of MODE SELECT
|
||||
throw scsi_exception(sense_key::illegal_request, asc::invalid_command_operation_code);
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
bool Init(const param_map&) override;
|
||||
|
||||
virtual void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int);
|
||||
virtual void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -40,8 +40,7 @@ string scsi_command_util::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uin
|
|||
}
|
||||
length -= offset;
|
||||
|
||||
// treat zero length as valid
|
||||
bool has_valid_page_code = (length == 0);
|
||||
bool has_valid_page_code = false;
|
||||
|
||||
// Parse the pages
|
||||
while (length > 0) {
|
||||
|
@ -63,10 +62,6 @@ string scsi_command_util::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uin
|
|||
|
||||
has_valid_page_code = true;
|
||||
}
|
||||
else if (page == 0x01) {
|
||||
// OpenVMS Alpha 7.3 uses this
|
||||
has_valid_page_code = true;
|
||||
}
|
||||
else {
|
||||
stringstream s;
|
||||
s << "Unknown MODE SELECT page code: $" << setfill('0') << setw(2) << hex << page;
|
||||
|
@ -76,7 +71,7 @@ string scsi_command_util::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uin
|
|||
// Advance to the next page
|
||||
const int size = buf[offset + 1] + 2;
|
||||
|
||||
length -= size + 1;
|
||||
length -= size;
|
||||
offset += size;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,10 +72,12 @@ bool SCSIDaynaPort::Init(const param_map& params)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void SCSIDaynaPort::CleanUp()
|
||||
{
|
||||
tap.CleanUp();
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<uint8_t> SCSIDaynaPort::InquiryInternal() const
|
||||
{
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
~SCSIDaynaPort() override = default;
|
||||
|
||||
bool Init(const param_map&) override;
|
||||
void CleanUp() override;
|
||||
// void CleanUp() override;
|
||||
|
||||
param_map GetDefaultParams() const override { return tap.GetDefaultParams(); }
|
||||
|
||||
|
|
|
@ -67,10 +67,12 @@ bool SCSIBR::Init(const param_map& params)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
void SCSIBR::CleanUp()
|
||||
{
|
||||
tap.CleanUp();
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<uint8_t> SCSIBR::InquiryInternal() const
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
~SCSIBR() override = default;
|
||||
|
||||
bool Init(const param_map&) override;
|
||||
void CleanUp() override;
|
||||
// void CleanUp() override;
|
||||
|
||||
param_map GetDefaultParams() const override { return tap.GetDefaultParams(); }
|
||||
|
||||
|
|
|
@ -165,33 +165,6 @@ vector<uint8_t> SCSICD::InquiryInternal() const
|
|||
return HandleInquiry(device_type::cd_rom, scsi_level, true);
|
||||
}
|
||||
|
||||
void SCSICD::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, int length)
|
||||
{
|
||||
int sector_size = 1 << GetSectorSizeShiftCount();
|
||||
int wanted_sector_size;
|
||||
// skip Block Descriptor
|
||||
int offset = 4;
|
||||
// evaluate Mode Parameter Block Descriptor, sector size
|
||||
wanted_sector_size = scsi_command_util::GetInt16(buf, offset + 6);
|
||||
if (wanted_sector_size != sector_size) {
|
||||
LogDebug("Changing sector size from " + to_string(sector_size) + " to " + to_string(wanted_sector_size));
|
||||
SetSectorSizeInBytes(wanted_sector_size);
|
||||
ClearTrack();
|
||||
CreateDataTrack();
|
||||
FlushCache();
|
||||
string filename;
|
||||
if ((filename = GetFilename()) != "") {
|
||||
// DiskCache fails without a file to compute the cache size
|
||||
ResizeCache(filename, GetRawMode());
|
||||
}
|
||||
}
|
||||
|
||||
if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, sector_size);
|
||||
!result.empty()) {
|
||||
LogWarn(result);
|
||||
}
|
||||
}
|
||||
|
||||
void SCSICD::SetUpModePages(map<int, vector<byte>>& pages, int page, bool changeable) const
|
||||
{
|
||||
Disk::SetUpModePages(pages, page, changeable);
|
||||
|
|
|
@ -34,7 +34,6 @@ public:
|
|||
|
||||
vector<uint8_t> InquiryInternal() const override;
|
||||
int Read(span<uint8_t>, uint64_t) override;
|
||||
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ vector<uint8_t> SCSIHD::InquiryInternal() const
|
|||
return HandleInquiry(device_type::direct_access, scsi_level, IsRemovable());
|
||||
}
|
||||
|
||||
void SCSIHD::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, int length)
|
||||
void SCSIHD::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, int length) const
|
||||
{
|
||||
if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, 1 << GetSectorSizeShiftCount());
|
||||
!result.empty()) {
|
||||
|
@ -97,32 +97,8 @@ void SCSIHD::AddFormatPage(map<int, vector<byte>>& pages, bool changeable) const
|
|||
EnrichFormatPage(pages, changeable, 1 << GetSectorSizeShiftCount());
|
||||
}
|
||||
|
||||
// Page code 37 (25h) - DEC Special Function Control page
|
||||
|
||||
void SCSIHD::AddDECSpecialFunctionControlPage(map<int, vector<byte>>& pages, bool changeable) const
|
||||
{
|
||||
vector<byte> buf(25);
|
||||
|
||||
// No changeable area
|
||||
if (changeable) {
|
||||
pages[0x25] = buf;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
buf[0] = static_cast<byte> (0x25 | 0x80); // page code, high bit set
|
||||
buf[1] = static_cast<byte> (sizeof(buf) - 1);
|
||||
buf[2] = static_cast<byte> (0x01); // drive does not auto-start
|
||||
|
||||
pages[0x25] = buf;
|
||||
}
|
||||
|
||||
void SCSIHD::AddVendorPage(map<int, vector<byte>>& pages, int page, bool changeable) const
|
||||
{
|
||||
// Page code 0x25: DEC Special Function Control page
|
||||
if (page == 0x25 || page == 0x3f) {
|
||||
AddDECSpecialFunctionControlPage(pages, changeable);
|
||||
}
|
||||
// Page code 48
|
||||
if (page == 0x30 || page == 0x3f) {
|
||||
AddAppleVendorModePage(pages, changeable);
|
||||
|
|
|
@ -37,10 +37,9 @@ public:
|
|||
|
||||
// Commands
|
||||
vector<uint8_t> InquiryInternal() const override;
|
||||
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) override;
|
||||
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) const override;
|
||||
|
||||
void AddFormatPage(map<int, vector<byte>>&, bool) const override;
|
||||
void AddDECSpecialFunctionControlPage(map<int, vector<byte>>&, bool) const;
|
||||
void AddVendorPage(map<int, vector<byte>>&, int, bool) const override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -88,7 +88,7 @@ void SCSIMO::AddOptionPage(map<int, vector<byte>>& pages, bool) const
|
|||
// Do not report update blocks
|
||||
}
|
||||
|
||||
void SCSIMO::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, int length)
|
||||
void SCSIMO::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, int length) const
|
||||
{
|
||||
if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, 1 << GetSectorSizeShiftCount());
|
||||
!result.empty()) {
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
void Open() override;
|
||||
|
||||
vector<uint8_t> InquiryInternal() const override;
|
||||
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) override;
|
||||
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) const override;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -360,7 +360,6 @@ class MockSCSIHD : public SCSIHD //NOSONAR Ignore inheritance hierarchy depth in
|
|||
FRIEND_TEST(ScsiHdTest, FinalizeSetup);
|
||||
FRIEND_TEST(ScsiHdTest, GetProductData);
|
||||
FRIEND_TEST(ScsiHdTest, SetUpModePages);
|
||||
FRIEND_TEST(ScsiHdTest, DECSpecialFunctionControlPage);
|
||||
FRIEND_TEST(ScsiHdTest, GetSectorSizes);
|
||||
FRIEND_TEST(ScsiHdTest, ModeSelect);
|
||||
FRIEND_TEST(PiscsiExecutorTest, SetSectorSize);
|
||||
|
@ -388,7 +387,6 @@ class MockSCSICD : public SCSICD //NOSONAR Ignore inheritance hierarchy depth in
|
|||
FRIEND_TEST(ScsiCdTest, GetSectorSizes);
|
||||
FRIEND_TEST(ScsiCdTest, SetUpModePages);
|
||||
FRIEND_TEST(ScsiCdTest, ReadToc);
|
||||
FRIEND_TEST(ScsiCdTest, ModeSelect);
|
||||
|
||||
using SCSICD::SCSICD;
|
||||
};
|
||||
|
|
|
@ -46,11 +46,6 @@ TEST(ScsiCommandUtilTest, ModeSelect6)
|
|||
Property(&scsi_exception::get_asc, asc::invalid_field_in_parameter_list))))
|
||||
<< "Unsupported page 0 was not rejected";
|
||||
|
||||
// Page 1
|
||||
buf[12] = 0x01;
|
||||
EXPECT_NO_THROW(ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, LENGTH, 512))
|
||||
<< "Page 1 is supported";
|
||||
|
||||
// Page 3 (Format Device Page)
|
||||
buf[12] = 0x03;
|
||||
EXPECT_THAT([&] { ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, LENGTH, 512); },
|
||||
|
@ -67,25 +62,7 @@ TEST(ScsiCommandUtilTest, ModeSelect6)
|
|||
Property(&scsi_exception::get_asc, asc::invalid_field_in_parameter_list))))
|
||||
<< "Not enough command parameters";
|
||||
|
||||
// check length computation
|
||||
buf[3] = 8;
|
||||
buf[10] = 2;
|
||||
buf[12] = 1;
|
||||
buf[13] = 10;
|
||||
buf[14] = 0x24;
|
||||
buf[24] = 0;
|
||||
EXPECT_NO_THROW(ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, LENGTH, 512))
|
||||
<< "Multi-page length computation";
|
||||
|
||||
// check length computation
|
||||
buf[3] = 8;
|
||||
buf[10] = 12;
|
||||
buf[12] = 0;
|
||||
buf[13] = 0;
|
||||
buf[14] = 0;
|
||||
buf[24] = 0;
|
||||
EXPECT_NO_THROW(ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, 12, 512))
|
||||
<< "Empty ModeSelect6";
|
||||
EXPECT_FALSE(ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, LENGTH, 512).empty());
|
||||
}
|
||||
|
||||
TEST(ScsiCommandUtilTest, ModeSelect10)
|
||||
|
@ -134,6 +111,8 @@ TEST(ScsiCommandUtilTest, ModeSelect10)
|
|||
Property(&scsi_exception::get_sense_key, sense_key::illegal_request),
|
||||
Property(&scsi_exception::get_asc, asc::invalid_field_in_parameter_list))))
|
||||
<< "Not enough command parameters";
|
||||
|
||||
EXPECT_FALSE(ModeSelect(scsi_command::eCmdModeSelect10, cdb, buf, LENGTH, 512).empty());
|
||||
}
|
||||
|
||||
TEST(ScsiCommandUtilTest, EnrichFormatPage)
|
||||
|
|
|
@ -133,56 +133,3 @@ TEST(ScsiCdTest, ReadToc)
|
|||
|
||||
// Further testing requires filesystem access
|
||||
}
|
||||
|
||||
TEST(ScsiCdTest, ModeSelect)
|
||||
{
|
||||
MockSCSICD cd(0);
|
||||
MockSCSICD cd1(0);
|
||||
vector<int> cmd(6);
|
||||
vector<uint8_t> buf(255);
|
||||
|
||||
// dummy file for DiskCache resize after sector size change
|
||||
path filename = CreateTempFile(2* 2048);
|
||||
cd.SetFilename(string(filename));
|
||||
cd.Open();
|
||||
EXPECT_EQ(2, cd.GetBlockCount());
|
||||
|
||||
cd.SetSectorSizeInBytes(2048);
|
||||
|
||||
// PF
|
||||
cmd[1] = 0x10;
|
||||
// Length
|
||||
buf[3] = 0x08;
|
||||
// 2048 bytes per sector
|
||||
buf[10] = 0x08;
|
||||
// Page 3 (Device Format Page)
|
||||
buf[12] = 0x01;
|
||||
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 2048 is supported";
|
||||
|
||||
// 512 bytes per sector - ModeSelect6
|
||||
buf[10] = 0x02;
|
||||
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 512 is supported";
|
||||
|
||||
// 2048 bytes per sector - ModeSelect6
|
||||
buf[10] = 0x08;
|
||||
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 2048 is supported";
|
||||
|
||||
// 512 bytes per sector - ModeSelect10
|
||||
buf[10] = 0x02;
|
||||
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect10, cmd, buf, 255)) << "MODE SELECT(10) with sector size 512 is supported";
|
||||
|
||||
// unsupported sector size - ModeSelect6
|
||||
buf[10] = 0x04;
|
||||
EXPECT_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255), io_exception) << "MODE SELECT(6) with sector size 1024 is unsupported";
|
||||
|
||||
// sector size not multiple of 512 - ModeSelect6
|
||||
buf[10] = 0x03;
|
||||
EXPECT_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255), io_exception) << "MODE SELECT(6) with sector size 768 is unsupported";
|
||||
|
||||
// cd1 has no dummy file attached, simulating an empty CD drive
|
||||
cd1.SetSectorSizeInBytes(2048);
|
||||
|
||||
// 512 bytes per sector - ModeSelect6
|
||||
buf[10] = 0x02;
|
||||
EXPECT_NO_THROW(cd1.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6), emtpy drive, with sector size 512 is supported";
|
||||
}
|
||||
|
|
|
@ -18,12 +18,11 @@ using namespace filesystem;
|
|||
|
||||
void ScsiHdNecTest_SetUpModePages(map<int, vector<byte>>& pages)
|
||||
{
|
||||
EXPECT_EQ(6, pages.size()) << "Unexpected number of mode pages";
|
||||
EXPECT_EQ(5, pages.size()) << "Unexpected number of mode pages";
|
||||
EXPECT_EQ(12, pages[1].size());
|
||||
EXPECT_EQ(24, pages[3].size());
|
||||
EXPECT_EQ(20, pages[4].size());
|
||||
EXPECT_EQ(12, pages[8].size());
|
||||
EXPECT_EQ(25, pages[37].size());
|
||||
EXPECT_EQ(30, pages[48].size());
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,11 @@
|
|||
|
||||
void ScsiHdTest_SetUpModePages(map<int, vector<byte>>& pages)
|
||||
{
|
||||
EXPECT_EQ(6, pages.size()) << "Unexpected number of mode pages";
|
||||
EXPECT_EQ(5, pages.size()) << "Unexpected number of mode pages";
|
||||
EXPECT_EQ(12, pages[1].size());
|
||||
EXPECT_EQ(24, pages[3].size());
|
||||
EXPECT_EQ(24, pages[4].size());
|
||||
EXPECT_EQ(12, pages[8].size());
|
||||
EXPECT_EQ(25, pages[37].size());
|
||||
EXPECT_EQ(30, pages[48].size());
|
||||
}
|
||||
|
||||
|
@ -102,20 +101,6 @@ TEST(ScsiHdTest, SetUpModePages)
|
|||
ScsiHdTest_SetUpModePages(pages);
|
||||
}
|
||||
|
||||
TEST(ScsiHdTest, DECSpecialFunctionControlPage)
|
||||
{
|
||||
map<int, vector<byte>> pages;
|
||||
vector<byte> buf;
|
||||
MockSCSIHD hd(0, false);
|
||||
|
||||
EXPECT_NO_THROW(hd.SetUpModePages(pages, 0x25, false)) << "MODE SENSE(6) DEC unique page is supported";
|
||||
EXPECT_NE(pages.end(), pages.find(0x25));
|
||||
buf = pages[0x25];
|
||||
EXPECT_EQ(static_cast<byte> (0x25 | 0x80), buf[0]);
|
||||
EXPECT_EQ(static_cast<byte> (0x17), buf[1]);
|
||||
EXPECT_EQ(static_cast<byte> (0x01), buf[2]);
|
||||
}
|
||||
|
||||
TEST(ScsiHdTest, ModeSelect)
|
||||
{
|
||||
MockSCSIHD hd({ 512 });
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
certifi==2023.7.22
|
||||
charset-normalizer==3.3.2
|
||||
idna==3.4
|
||||
idna==3.7
|
||||
protobuf==3.19.5
|
||||
requests==2.31.0
|
||||
urllib3==2.0.7
|
||||
|
|
|
@ -3,7 +3,7 @@ certifi==2024.2.2
|
|||
charset-normalizer==3.3.2
|
||||
click==8.1.7
|
||||
flake8==7.0.0
|
||||
idna==3.6
|
||||
idna==3.7
|
||||
iniconfig==2.0.0
|
||||
MarkupSafe==2.1.5
|
||||
mccabe==0.7.0
|
||||
|
|
Loading…
Reference in New Issue