mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-03 08:05:40 +00:00
6fc5b4e825
The HD SC setup utility is now looking to read buffer.
59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
//
|
|
// Target.cpp
|
|
// Clock Signal
|
|
//
|
|
// Created by Thomas Harte on 17/08/2019.
|
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
|
//
|
|
|
|
#include "Target.hpp"
|
|
|
|
using namespace SCSI::Target;
|
|
|
|
CommandState::CommandState(const std::vector<uint8_t> &data) : data_(data) {}
|
|
|
|
uint32_t CommandState::address() const {
|
|
switch(data_.size()) {
|
|
default: return 0;
|
|
case 6:
|
|
return
|
|
(uint32_t(data_[1]) << 16) |
|
|
(uint32_t(data_[2]) << 8) |
|
|
uint32_t(data_[3]);
|
|
case 10:
|
|
case 12:
|
|
return
|
|
(uint32_t(data_[1]) << 24) |
|
|
(uint32_t(data_[2]) << 16) |
|
|
(uint32_t(data_[3]) << 8) |
|
|
uint32_t(data_[4]);
|
|
}
|
|
}
|
|
|
|
uint16_t CommandState::number_of_blocks() const {
|
|
switch(data_.size()) {
|
|
default: return 0;
|
|
case 6:
|
|
return uint16_t(data_[4]);
|
|
case 10:
|
|
return uint16_t((data_[7] << 8) | data_[8]);
|
|
}
|
|
}
|
|
|
|
size_t CommandState::allocated_inquiry_bytes() const {
|
|
// 0 means 256 bytes allocated for inquiry.
|
|
return size_t(((data_[4] - 1) & 0xff) + 1);
|
|
}
|
|
|
|
CommandState::ModeSense CommandState::mode_sense_specs() const {
|
|
CommandState::ModeSense specs;
|
|
|
|
specs.exclude_block_descriptors = (data_[1] & 0x08);
|
|
specs.page_control_values = ModeSense::PageControlValues(data_[2] >> 5);
|
|
specs.page_code = data_[2] & 0x3f;
|
|
specs.subpage_code = data_[3];
|
|
specs.allocated_bytes = number_of_blocks();
|
|
|
|
return specs;
|
|
}
|