| 138 | } |
| 139 | |
| 140 | void PrimaryDevice::RequestSense() |
| 141 | { |
| 142 | int lun = GetController()->GetEffectiveLun(); |
| 143 | |
| 144 | // Note: According to the SCSI specs the LUN handling for REQUEST SENSE non-existing LUNs do *not* result |
| 145 | // in CHECK CONDITION. Only the Sense Key and ASC are set in order to signal the non-existing LUN. |
| 146 | if (!GetController()->HasDeviceForLun(lun)) { |
| 147 | // LUN 0 can be assumed to be present (required to call RequestSense() below) |
| 148 | assert(GetController()->HasDeviceForLun(0)); |
| 149 | |
| 150 | lun = 0; |
| 151 | |
| 152 | // Do not raise an exception here because the rest of the code must be executed |
| 153 | GetController()->Error(sense_key::illegal_request, asc::invalid_lun); |
| 154 | |
| 155 | GetController()->SetStatus(status::good); |
| 156 | } |
| 157 | |
| 158 | vector<byte> buf = GetController()->GetDeviceForLun(lun)->HandleRequestSense(); |
| 159 | |
| 160 | const size_t allocation_length = min(buf.size(), static_cast<size_t>(GetController()->GetCmdByte(4))); |
| 161 | |
| 162 | memcpy(GetController()->GetBuffer().data(), buf.data(), allocation_length); |
| 163 | GetController()->SetLength(static_cast<uint32_t>(allocation_length)); |
| 164 | |
| 165 | EnterDataInPhase(); |
| 166 | } |
| 167 | |
| 168 | void PrimaryDevice::SendDiagnostic() |
| 169 | { |
nothing calls this directly
no test coverage detected