//--------------------------------------------------------------------------- // // SCSI Target Emulator PiSCSI // for Raspberry Pi // // Copyright (C) 2022-2023 Uwe Seimet // // Shared code for SCSI command implementations // //--------------------------------------------------------------------------- #pragma once #include "shared/scsi.h" #include #include #include #include #include using namespace std; namespace scsi_command_util { string ModeSelect(scsi_defs::scsi_command, cdb_t, span, int, int); void EnrichFormatPage(map>&, bool, int); void AddAppleVendorModePage(map>&, bool); int GetInt16(const auto buf, int offset) { assert(buf.size() > static_cast(offset) + 1); return (static_cast(buf[offset]) << 8) | buf[offset + 1]; }; template void SetInt16(vector& buf, int offset, int value) { assert(buf.size() > static_cast(offset) + 1); buf[offset] = static_cast(value >> 8); buf[offset + 1] = static_cast(value); } template void SetInt32(vector& buf, int offset, uint32_t value) { assert(buf.size() > static_cast(offset) + 3); buf[offset] = static_cast(value >> 24); buf[offset + 1] = static_cast(value >> 16); buf[offset + 2] = static_cast(value >> 8); buf[offset + 3] = static_cast(value); } int GetInt24(span, int); uint32_t GetInt32(span , int); uint64_t GetInt64(span, int); void SetInt64(vector&, int, uint64_t); }