2019-08-18 03:43:42 +00:00
|
|
|
//
|
2019-08-22 03:22:58 +00:00
|
|
|
// Target.cpp
|
2019-08-18 03:43:42 +00:00
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 17/08/2019.
|
|
|
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2019-08-22 03:22:58 +00:00
|
|
|
#include "Target.hpp"
|
2019-08-18 03:43:42 +00:00
|
|
|
|
2019-08-20 02:47:01 +00:00
|
|
|
using namespace SCSI::Target;
|
|
|
|
|
2019-08-22 02:37:39 +00:00
|
|
|
CommandState::CommandState(const std::vector<uint8_t> &data) : data_(data) {}
|
2019-08-20 02:47:01 +00:00
|
|
|
|
2019-08-22 02:37:39 +00:00
|
|
|
uint32_t CommandState::address() {
|
2019-08-20 02:47:01 +00:00
|
|
|
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]);
|
2019-08-19 02:39:27 +00:00
|
|
|
}
|
2019-08-20 02:47:01 +00:00
|
|
|
}
|
2019-08-19 02:39:27 +00:00
|
|
|
|
2019-08-22 02:37:39 +00:00
|
|
|
uint16_t CommandState::number_of_blocks() {
|
2019-08-20 02:47:01 +00:00
|
|
|
switch(data_.size()) {
|
|
|
|
default: return 0;
|
|
|
|
case 6:
|
|
|
|
return uint16_t(data_[4]);
|
|
|
|
case 10:
|
|
|
|
return uint16_t((data_[7] << 8) | data_[8]);
|
2019-08-18 03:43:42 +00:00
|
|
|
}
|
|
|
|
}
|