|
| 1 | +// SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause |
| 2 | + |
| 3 | +#[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 4 | +pub struct SenseTriple(u8, u8, u8); |
| 5 | + |
| 6 | +impl SenseTriple { |
| 7 | + pub fn to_fixed_sense(self) -> Vec<u8> { |
| 8 | + vec![ |
| 9 | + 0x70, // response code (fixed, current); valid bit (0) |
| 10 | + 0x0, // reserved |
| 11 | + self.0, // sk; various upper bits 0 |
| 12 | + 0x0, 0x0, 0x0, 0x0, // information |
| 13 | + 0xa, // add'l sense length |
| 14 | + 0x0, 0x0, 0x0, 0x0, // cmd-specific information |
| 15 | + self.1, // asc |
| 16 | + self.2, // ascq |
| 17 | + 0x0, // field-replacable unit code |
| 18 | + 0x0, 0x0, 0x0, // sense-key-sepcific information |
| 19 | + ] |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +const NO_SENSE: u8 = 0; |
| 24 | +const MEDIUM_ERROR: u8 = 0x3; |
| 25 | +const ILLEGAL_REQUEST: u8 = 0x5; |
| 26 | + |
| 27 | +pub const NO_ADDITIONAL_SENSE_INFORMATION: SenseTriple = SenseTriple(NO_SENSE, 0, 0); |
| 28 | + |
| 29 | +pub const INVALID_COMMAND_OPERATION_CODE: SenseTriple = SenseTriple(ILLEGAL_REQUEST, 0x20, 0x0); |
| 30 | +pub const LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE: SenseTriple = SenseTriple(ILLEGAL_REQUEST, 0x21, 0x0); |
| 31 | +pub const INVALID_FIELD_IN_CDB: SenseTriple = SenseTriple(ILLEGAL_REQUEST, 0x24, 0x0); |
| 32 | +pub const LOGICAL_UNIT_NOT_SUPPORTED: SenseTriple = SenseTriple(ILLEGAL_REQUEST, 0x21, 0x0); |
| 33 | +pub const SAVING_PARAMETERS_NOT_SUPPORTED: SenseTriple = SenseTriple(ILLEGAL_REQUEST, 0x39, 0x0); |
| 34 | + |
| 35 | +pub const UNRECOVERED_READ_ERROR: SenseTriple = SenseTriple(MEDIUM_ERROR, 0x11, 0x0); |
0 commit comments