diff --git a/devices/common/ata/atadefs.h b/devices/common/ata/atadefs.h index 4377b21425..f68dc67373 100644 --- a/devices/common/ata/atadefs.h +++ b/devices/common/ata/atadefs.h @@ -120,6 +120,7 @@ enum ATA_Cmd : uint8_t { NOP = 0x00, ATAPI_SOFT_RESET = 0x08, RECALIBRATE = 0x10, + ATAPI_COMMAND_MODE_SENSE6 = 0x1A, READ_SECTOR = 0x20, READ_SECTOR_NR = 0x21, READ_LONG = 0x22, @@ -128,6 +129,7 @@ enum ATA_Cmd : uint8_t { WRITE_SECTOR_NR = 0x31, WRITE_LONG = 0x32, READ_VERIFY = 0x40, + ATAPI_COMMAND_GET_CONFIG = 0x46, FORMAT_TRACKS = 0x50, IDE_SEEK = 0x70, DIAGNOSTICS = 0x90, @@ -135,6 +137,7 @@ enum ATA_Cmd : uint8_t { ATAPI_PACKET = 0xA0, ATAPI_IDFY_DEV = 0xA1, ATAPI_SERVICE = 0xA2, + ATAPI_READ_DVD_STRUCTURE = 0xAD, READ_MULTIPLE = 0xC4, WRITE_MULTIPLE = 0xC5, SET_MULTIPLE_MODE = 0xC6, diff --git a/devices/common/ata/atapicdrom.cpp b/devices/common/ata/atapicdrom.cpp index aee9a7f3ab..a4903cb3e4 100644 --- a/devices/common/ata/atapicdrom.cpp +++ b/devices/common/ata/atapicdrom.cpp @@ -132,8 +132,19 @@ void AtapiCdrom::perform_packet_command() { this->data_out_phase(); } break; + case ScsiCommand::MODE_SENSE_6: + this->xfer_cnt = this->mode_sense_ex(true, this->cmd_pkt, this->data_buf); + if (!this->xfer_cnt) { + this->present_status(); + } else { + this->r_byte_count = this->xfer_cnt; + this->data_ptr = (uint16_t*)this->data_buf; + this->status_good(); + this->data_out_phase(); + } + break; case ScsiCommand::MODE_SENSE_10: - this->xfer_cnt = this->mode_sense_ex(this->cmd_pkt, this->data_buf); + this->xfer_cnt = this->mode_sense_ex(false, this->cmd_pkt, this->data_buf); if (!this->xfer_cnt) { this->present_status(); } else { diff --git a/devices/storage/cdromdrive.cpp b/devices/storage/cdromdrive.cpp index 19839f311f..9e95898bcf 100644 --- a/devices/storage/cdromdrive.cpp +++ b/devices/storage/cdromdrive.cpp @@ -98,11 +98,11 @@ uint32_t CdromDrive::inquiry(uint8_t *cmd_ptr, uint8_t *data_ptr) { return 36; } -uint32_t CdromDrive::mode_sense_ex(uint8_t *cmd_ptr, uint8_t *data_ptr) { +uint32_t CdromDrive::mode_sense_ex(bool is_sense_6, uint8_t* cmd_ptr, uint8_t* data_ptr) { uint8_t *resp_ptr; uint8_t page_code = cmd_ptr[2] & 0x3F; - uint8_t alloc_len = READ_WORD_BE_U(&cmd_ptr[7]); + uint8_t alloc_len = is_sense_6 ? READ_WORD_BE_U(&cmd_ptr[4]) : READ_WORD_BE_U(&cmd_ptr[7]); std::memset(data_ptr, 0, alloc_len); @@ -137,7 +137,17 @@ uint32_t CdromDrive::mode_sense_ex(uint8_t *cmd_ptr, uint8_t *data_ptr) { WRITE_WORD_BE_A(&resp_ptr[14], 706); // report current speed (4x) data_ptr[1] += 20; // adjust overall length break; + case 0x31: + resp_ptr[1] = 14; // page data length + std::memset(&resp_ptr[2], 0, 14); + resp_ptr[8] = 0x31; + resp_ptr[9] = 6; + resp_ptr[10] = '.'; + resp_ptr[11] = 'A'; + resp_ptr[12] = 'p'; + resp_ptr[13] = 'p'; default: + LOG_F(ERROR, "ATAPI CD-ROM: Invalid Page Code 0x%x", page_code); this->set_error(ScsiSense::ILLEGAL_REQ, ScsiError::INVALID_CDB); return 0; } diff --git a/devices/storage/cdromdrive.h b/devices/storage/cdromdrive.h index a01d6b1838..79146b5b81 100644 --- a/devices/storage/cdromdrive.h +++ b/devices/storage/cdromdrive.h @@ -62,7 +62,7 @@ class CdromDrive : public BlockStorageDevice { void insert_image(std::string filename); virtual uint32_t inquiry(uint8_t *cmd_ptr, uint8_t *data_ptr); - virtual uint32_t mode_sense_ex(uint8_t *cmd_ptr, uint8_t *data_ptr); + virtual uint32_t mode_sense_ex(bool is_sense_6, uint8_t *cmd_ptr, uint8_t *data_ptr); virtual uint32_t request_sense(uint8_t *data_ptr, uint8_t sense_key, uint8_t asc, uint8_t ascq); virtual uint32_t report_capacity(uint8_t *data_ptr);