mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Added MMC report to DiscImageChef.Device.Report.
This commit is contained in:
@@ -7,5 +7,5 @@ find_package(LibXml2)
|
||||
|
||||
include_directories(${LIBXML2_INCLUDE_DIR})
|
||||
|
||||
add_executable(DiscImageChef_Device_Report main.c scsi.c scsi.h main.h ata.h ata.c atapi.c atapi.h atapi_report.c atapi_report.h identify_decode.c identify_decode.h scsi_report.c scsi_report.h inquiry_decode.c inquiry_decode.h scsi_mode.h scsi_mode.c)
|
||||
add_executable(DiscImageChef_Device_Report main.c scsi.c scsi.h main.h ata.h ata.c atapi.c atapi.h atapi_report.c atapi_report.h identify_decode.c identify_decode.h scsi_report.c scsi_report.h inquiry_decode.c inquiry_decode.h scsi_mode.h scsi_mode.c mmc_report.c mmc_report.h cdrom_mode.h)
|
||||
target_link_libraries(DiscImageChef_Device_Report ${LIBXML2_LIBRARIES})
|
||||
114
DiscImageChef.Device.Report/cdrom_mode.h
Normal file
114
DiscImageChef.Device.Report/cdrom_mode.h
Normal file
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// Created by claunia on 17/12/17.
|
||||
//
|
||||
|
||||
#ifndef DISCIMAGECHEF_DEVICE_REPORT_CDROM_MODE_H
|
||||
#define DISCIMAGECHEF_DEVICE_REPORT_CDROM_MODE_H
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Reserved1;
|
||||
uint8_t RotationControl : 3;
|
||||
uint8_t Reserved2 : 5;
|
||||
uint16_t WriteSpeed;
|
||||
} ModePage_2A_WriteDescriptor;
|
||||
#pragma pack(pop)
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
uint8_t PageCode : 6;
|
||||
uint8_t Reserved1 : 1;
|
||||
/* Parameters can be saved */
|
||||
uint8_t PS : 1;
|
||||
uint8_t PageLength;
|
||||
uint8_t ReadCDR : 1;
|
||||
uint8_t ReadCDRW : 1;
|
||||
uint8_t Method2 : 1;
|
||||
uint8_t ReadDVDROM : 1;
|
||||
uint8_t ReadDVDR : 1;
|
||||
uint8_t ReadDVDRAM : 1;
|
||||
uint8_t Reserved2 : 2;
|
||||
uint8_t WriteCDR : 1;
|
||||
uint8_t WriteCDRW : 1;
|
||||
uint8_t TestWrite : 1;
|
||||
uint8_t Reserved3 : 1;
|
||||
uint8_t WriteDVDR : 1;
|
||||
uint8_t WriteDVDRAM : 1;
|
||||
uint8_t Reserved4 : 2;
|
||||
/* Drive is capable of playing audio */
|
||||
uint8_t AudioPlay : 1;
|
||||
uint8_t Composite : 1;
|
||||
uint8_t DigitalPort1 : 1;
|
||||
uint8_t DigitalPort2 : 1;
|
||||
/* Drive is capable of reading sectors in Mode 2 Form 1 format */
|
||||
uint8_t Mode2Form1 : 1;
|
||||
/* Drive is capable of reading sectors in Mode 2 Form 2 format */
|
||||
uint8_t Mode2Form2 : 1;
|
||||
/* Drive supports multi-session and/or Photo-CD */
|
||||
uint8_t MultiSession : 1;
|
||||
uint8_t BUF : 1;
|
||||
/* Audio can be read as digital data */
|
||||
uint8_t CDDACommand : 1;
|
||||
/* Drive can continue from a loss of streaming on audio reading */
|
||||
uint8_t AccurateCDDA : 1;
|
||||
/* Drive can read interleaved and uncorrected R-W subchannels */
|
||||
uint8_t Subchannel : 1;
|
||||
/* Drive can read, deinterlave and correct R-W subchannels */
|
||||
uint8_t DeinterlaveSubchannel : 1;
|
||||
/* Drive can return C2 pointers */
|
||||
uint8_t C2Pointer : 1;
|
||||
/* Drive can return the media catalogue number */
|
||||
uint8_t UPC : 1;
|
||||
/* Drive can return the ISRC */
|
||||
uint8_t ISRC : 1;
|
||||
uint8_t ReadBarcode : 1;
|
||||
/* Drive can lock media */
|
||||
uint8_t Lock : 1;
|
||||
/* Current lock status */
|
||||
uint8_t LockState : 1;
|
||||
/* Drive's optional prevent jumper status */
|
||||
uint8_t PreventJumper : 1;
|
||||
/* Drive can eject discs */
|
||||
uint8_t Eject : 1;
|
||||
uint8_t Reserved5 : 1;
|
||||
/* Loading Mechanism Type */
|
||||
uint8_t LoadingMechanism : 3;
|
||||
/* Each channel's volume can be controlled independently */
|
||||
uint8_t SeparateChannelVolume : 1;
|
||||
/* Each channel can be muted independently */
|
||||
uint8_t SeparateChannelMute : 1;
|
||||
uint8_t SDP : 1;
|
||||
uint8_t SSS : 1;
|
||||
uint8_t SCC : 1;
|
||||
uint8_t LeadInPW : 1;
|
||||
uint8_t Reserved6 : 2;
|
||||
/* Maximum drive speed in Kbytes/second */
|
||||
uint16_t MaximumSpeed ;
|
||||
/* Supported volume levels */
|
||||
uint16_t SupportedVolumeLevels;
|
||||
/* Buffer size in Kbytes */
|
||||
uint16_t BufferSize;
|
||||
/* Current drive speed in Kbytes/second */
|
||||
uint16_t CurrentSpeed;
|
||||
uint8_t Reserved7;
|
||||
uint8_t Reserved8 : 1;
|
||||
uint8_t BCK : 1;
|
||||
uint8_t RCK : 1;
|
||||
uint8_t LSBF : 1;
|
||||
uint8_t Length : 2;
|
||||
uint8_t Reserved9 : 2;
|
||||
uint16_t MaxWriteSpeed;
|
||||
uint16_t CurrentWriteSpeed;
|
||||
uint16_t CMRSupported;
|
||||
uint8_t Reserved10[3];
|
||||
uint8_t RotationControlSelected : 2;
|
||||
uint8_t Reserved11 : 6;
|
||||
uint16_t CurrentWriteSpeedSelected;
|
||||
uint16_t LogicalWriteSpeedDescriptors;
|
||||
ModePage_2A_WriteDescriptor WriteSpeedPerformanceDescriptors[56];
|
||||
} ModePage_2A;
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif //DISCIMAGECHEF_DEVICE_REPORT_CDROM_MODE_H
|
||||
1627
DiscImageChef.Device.Report/mmc_report.c
Normal file
1627
DiscImageChef.Device.Report/mmc_report.c
Normal file
File diff suppressed because it is too large
Load Diff
23
DiscImageChef.Device.Report/mmc_report.h
Normal file
23
DiscImageChef.Device.Report/mmc_report.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Created by claunia on 17/12/17.
|
||||
//
|
||||
|
||||
#ifndef DISCIMAGECHEF_DEVICE_REPORT_MMC_REPORT_H
|
||||
#define DISCIMAGECHEF_DEVICE_REPORT_MMC_REPORT_H
|
||||
|
||||
void MmcReport(int fd, xmlTextWriterPtr xmlWriter, unsigned char* cdromMode);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int present;
|
||||
size_t len;
|
||||
unsigned char* data;
|
||||
} FeatureDescriptors;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t DataLength;
|
||||
uint16_t CurrentProfile;
|
||||
FeatureDescriptors Descriptors[65536];
|
||||
} SeparatedFeatures;
|
||||
#endif //DISCIMAGECHEF_DEVICE_REPORT_MMC_REPORT_H
|
||||
@@ -539,3 +539,311 @@ int TestUnitReady(int fd, unsigned char **senseBuffer)
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int GetConfiguration(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint16_t startingFeatureNumber, uint8_t RT)
|
||||
{
|
||||
unsigned char cmd_len = 10;
|
||||
uint16_t buffer_len = 8;
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
char cdb[] = {MMC_GET_CONFIGURATION, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
cdb[1] = (uint8_t)(RT & 0x03);
|
||||
cdb[2] = (uint8_t)((startingFeatureNumber & 0xFF00) >> 8);
|
||||
cdb[3] = (uint8_t)(startingFeatureNumber & 0xFF);
|
||||
cdb[7] = (uint8_t)((buffer_len & 0xFF00) >> 8);
|
||||
cdb[8] = (uint8_t)(buffer_len & 0xFF);
|
||||
cdb[9] = 0;
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
if(error)
|
||||
return error;
|
||||
|
||||
buffer_len = (uint16_t)(*(*buffer + 2) << 8) + *(*buffer + 3) + 2;
|
||||
cdb[7] = (uint8_t)((buffer_len & 0xFF00) >> 8);
|
||||
cdb[8] = (uint8_t)(buffer_len & 0xFF);
|
||||
|
||||
free(*buffer);
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
|
||||
error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int ReadTocPmaAtip(int fd, unsigned char **buffer, unsigned char **senseBuffer, int MSF, uint8_t format, uint8_t trackSessionNumber)
|
||||
{
|
||||
unsigned char cmd_len = 10;
|
||||
uint16_t buffer_len = 1024;
|
||||
char cdb[] = {MMC_READ_TOC_PMA_ATIP, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
if((format & 0xF) == 5)
|
||||
buffer_len = 32768;
|
||||
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
|
||||
if(MSF)
|
||||
cdb[1] = 0x02;
|
||||
cdb[2] = (uint8_t)(format & 0x0F);
|
||||
cdb[6] = trackSessionNumber;
|
||||
cdb[7] = (uint8_t)((buffer_len & 0xFF00) >> 8);
|
||||
cdb[8] = (uint8_t)(buffer_len & 0xFF);
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
if(error)
|
||||
return error;
|
||||
|
||||
buffer_len = (uint16_t)(*(*buffer + 0) << 8) + *(*buffer + 1) + 2;
|
||||
cdb[7] = (uint8_t)((buffer_len & 0xFF00) >> 8);
|
||||
cdb[8] = (uint8_t)(buffer_len & 0xFF);
|
||||
|
||||
free(*buffer);
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
|
||||
error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int ReadDiscStructure(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint8_t mediaType, uint32_t address, uint8_t layerNumber, uint8_t format, uint8_t AGID)
|
||||
{
|
||||
unsigned char cmd_len = 12;
|
||||
uint16_t buffer_len = 8;
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
char cdb[] = {MMC_READ_DISC_STRUCTURE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
cdb[1] = (uint8_t)((uint8_t)mediaType & 0x0F);
|
||||
cdb[2] = (uint8_t)((address & 0xFF000000) >> 24);
|
||||
cdb[3] = (uint8_t)((address & 0xFF0000) >> 16);
|
||||
cdb[4] = (uint8_t)((address & 0xFF00) >> 8);
|
||||
cdb[5] = (uint8_t)(address & 0xFF);
|
||||
cdb[6] = layerNumber;
|
||||
cdb[7] = (uint8_t)format;
|
||||
cdb[8] = (uint8_t)((buffer_len & 0xFF00) >> 8);
|
||||
cdb[9] = (uint8_t)(buffer_len & 0xFF);
|
||||
cdb[10] = (uint8_t)((AGID & 0x03) << 6);
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
if(error)
|
||||
return error;
|
||||
|
||||
buffer_len = (uint16_t)(*(*buffer + 0) << 8) + *(*buffer + 1) + 2;
|
||||
cdb[8] = (uint8_t)((buffer_len & 0xFF00) >> 8);
|
||||
cdb[9] = (uint8_t)(buffer_len & 0xFF);
|
||||
|
||||
free(*buffer);
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
|
||||
error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int ReadCd(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t blockSize, uint32_t transferLength, uint8_t expectedSectorType,
|
||||
int DAP, int relAddr, int sync, uint8_t headerCodes, int userData, int edcEcc, uint8_t C2Error, uint8_t subchannel)
|
||||
{
|
||||
unsigned char cmd_len = 12;
|
||||
uint32_t buffer_len = transferLength * blockSize;
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
char cdb[] = {MMC_READ_CD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
cdb[1] = (uint8_t)((uint8_t)expectedSectorType << 2);
|
||||
if(DAP)
|
||||
cdb[1] += 0x02;
|
||||
if(relAddr)
|
||||
cdb[1] += 0x01;
|
||||
cdb[2] = (uint8_t)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (uint8_t)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (uint8_t)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (uint8_t)(lba & 0xFF);
|
||||
cdb[6] = (uint8_t)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[7] = (uint8_t)((transferLength & 0xFF00) >> 8);
|
||||
cdb[8] = (uint8_t)(transferLength & 0xFF);
|
||||
cdb[9] = (uint8_t)((uint8_t)C2Error << 1);
|
||||
cdb[9] += (uint8_t)((uint8_t)headerCodes << 5);
|
||||
if(sync)
|
||||
cdb[9] += 0x80;
|
||||
if(userData)
|
||||
cdb[9] += 0x10;
|
||||
if(edcEcc)
|
||||
cdb[9] += 0x08;
|
||||
cdb[10] = (uint8_t)subchannel;
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int ReadCdMsf(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t startMsf, uint32_t endMsf, uint32_t blockSize, uint8_t expectedSectorType,
|
||||
int DAP, int sync, uint8_t headerCodes, int userData, int edcEcc, uint8_t C2Error, uint8_t subchannel)
|
||||
{
|
||||
unsigned char cmd_len = 12;
|
||||
char cdb[] = {MMC_READ_CD_MSF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
cdb[1] = (uint8_t)((uint8_t)expectedSectorType << 2);
|
||||
if(DAP)
|
||||
cdb[1] += 0x02;
|
||||
cdb[3] = (uint8_t)((startMsf & 0xFF0000) >> 16);
|
||||
cdb[4] = (uint8_t)((startMsf & 0xFF00) >> 8);
|
||||
cdb[5] = (uint8_t)(startMsf & 0xFF);
|
||||
cdb[6] = (uint8_t)((endMsf & 0xFF0000) >> 16);
|
||||
cdb[7] = (uint8_t)((endMsf & 0xFF00) >> 8);
|
||||
cdb[8] = (uint8_t)(endMsf & 0xFF);
|
||||
cdb[9] = (uint8_t)((uint8_t)C2Error << 1);
|
||||
cdb[9] += (uint8_t)((uint8_t)headerCodes << 5);
|
||||
if(sync)
|
||||
cdb[9] += 0x80;
|
||||
if(userData)
|
||||
cdb[9] += 0x10;
|
||||
if(edcEcc)
|
||||
cdb[9] += 0x08;
|
||||
cdb[10] = (uint8_t)subchannel;
|
||||
|
||||
uint32_t transferLength = (uint32_t)((cdb[6] - cdb[3]) * 60 * 75 + (cdb[7] - cdb[4]) * 75 + (cdb[8] - cdb[5]));
|
||||
uint32_t buffer_len = transferLength * blockSize;
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int PlextorReadCdDa(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t blockSize, uint32_t transferLength, uint8_t subchannel)
|
||||
{
|
||||
unsigned char cmd_len = 12;
|
||||
uint32_t buffer_len = transferLength * blockSize;
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
char cdb[] = {PIONEER_READ_CDDA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
cdb[2] = (uint8_t)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (uint8_t)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (uint8_t)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (uint8_t)(lba & 0xFF);
|
||||
cdb[6] = (uint8_t)((transferLength & 0xFF000000) >> 24);
|
||||
cdb[7] = (uint8_t)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[8] = (uint8_t)((transferLength & 0xFF00) >> 8);
|
||||
cdb[9] = (uint8_t)(transferLength & 0xFF);
|
||||
cdb[10] = (uint8_t)subchannel;
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int PlextorReadRawDvd(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t transferLength)
|
||||
{
|
||||
unsigned char cmd_len = 10;
|
||||
uint32_t buffer_len = transferLength * 2064;
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
char cdb[] = {SCSI_READ_BUFFER, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
cdb[1] = 0x02;
|
||||
cdb[3] = (uint8_t)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (uint8_t)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (uint8_t)(lba & 0xFF);
|
||||
cdb[3] = (uint8_t)((buffer_len & 0xFF0000) >> 16);
|
||||
cdb[4] = (uint8_t)((buffer_len & 0xFF00) >> 8);
|
||||
cdb[5] = (uint8_t)(buffer_len & 0xFF);
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int PioneerReadCdDa(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t blockSize, uint32_t transferLength, uint8_t subchannel)
|
||||
{
|
||||
unsigned char cmd_len = 12;
|
||||
uint32_t buffer_len = transferLength * blockSize;
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
char cdb[] = {PIONEER_READ_CDDA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
cdb[2] = (uint8_t)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (uint8_t)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (uint8_t)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (uint8_t)(lba & 0xFF);
|
||||
cdb[7] = (uint8_t)((transferLength & 0xFF0000) >> 16);
|
||||
cdb[8] = (uint8_t)((transferLength & 0xFF00) >> 8);
|
||||
cdb[9] = (uint8_t)(transferLength & 0xFF);
|
||||
cdb[10] = (uint8_t)subchannel;
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int PioneerReadCdDaMsf(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t startMsf, uint32_t endMsf, uint32_t blockSize, uint8_t subchannel)
|
||||
{
|
||||
unsigned char cmd_len = 12;
|
||||
char cdb[] = {PIONEER_READ_CDDA_MSF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
cdb[3] = (uint8_t)((startMsf & 0xFF0000) >> 16);
|
||||
cdb[4] = (uint8_t)((startMsf & 0xFF00) >> 8);
|
||||
cdb[5] = (uint8_t)(startMsf & 0xFF);
|
||||
cdb[7] = (uint8_t)((endMsf & 0xFF0000) >> 16);
|
||||
cdb[8] = (uint8_t)((endMsf & 0xFF00) >> 8);
|
||||
cdb[9] = (uint8_t)(endMsf & 0xFF);
|
||||
cdb[10] = (uint8_t)subchannel;
|
||||
|
||||
uint32_t transferLength = (uint)((cdb[7] - cdb[3]) * 60 * 75 + (cdb[8] - cdb[4]) * 75 + (cdb[9] - cdb[5]));
|
||||
uint32_t buffer_len = transferLength * blockSize;
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int NecReadCdDa(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t transferLength)
|
||||
{
|
||||
unsigned char cmd_len = 12;
|
||||
uint32_t buffer_len = transferLength * 2352;
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
char cdb[] = {NEC_READ_CDDA, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
cdb[2] = (uint8_t)((lba & 0xFF000000) >> 24);
|
||||
cdb[3] = (uint8_t)((lba & 0xFF0000) >> 16);
|
||||
cdb[4] = (uint8_t)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (uint8_t)(lba & 0xFF);
|
||||
cdb[7] = (uint8_t)((transferLength & 0xFF00) >> 8);
|
||||
cdb[8] = (uint8_t)(transferLength & 0xFF);
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int HlDtStReadRawDvd(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t transferLength)
|
||||
{
|
||||
unsigned char cmd_len = 12;
|
||||
uint32_t buffer_len = transferLength * 2064;
|
||||
*buffer = malloc(buffer_len);
|
||||
memset(*buffer, 0, buffer_len);
|
||||
char cdb[] = {HLDTST_VENDOR, 0x48, 0x49, 0x54, 0x01, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
cdb[6] = (uint8_t)((lba & 0xFF000000) >> 24);
|
||||
cdb[7] = (uint8_t)((lba & 0xFF0000) >> 16);
|
||||
cdb[8] = (uint8_t)((lba & 0xFF00) >> 8);
|
||||
cdb[9] = (uint8_t)(lba & 0xFF);
|
||||
cdb[10] = (uint8_t)((buffer_len & 0xFF00) >> 8);
|
||||
cdb[11] = (uint8_t)(buffer_len & 0xFF);
|
||||
|
||||
int error = SendScsiCommand(fd, &cdb, cmd_len, *buffer, buffer_len, senseBuffer, SG_DXFER_FROM_DEV);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,17 @@ int ReadLong16(int fd, unsigned char **buffer, unsigned char **senseBuffer, int
|
||||
int Seek6(int fd, unsigned char **senseBuffer, uint32_t lba);
|
||||
int Seek10(int fd, unsigned char **senseBuffer, uint32_t lba);
|
||||
int TestUnitReady(int fd, unsigned char **senseBuffer);
|
||||
int GetConfiguration(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint16_t startingFeatureNumber, uint8_t RT);
|
||||
int ReadTocPmaAtip(int fd, unsigned char **buffer, unsigned char **senseBuffer, int MSF, uint8_t format, uint8_t trackSessionNumber);
|
||||
int ReadDiscStructure(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint8_t mediaType, uint32_t address, uint8_t layerNumber, uint8_t format, uint8_t AGID);
|
||||
int ReadCd(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t blockSize, uint32_t transferLength, uint8_t expectedSectorType, int DAP, int relAddr, int sync, uint8_t headerCodes, int userData, int edcEcc, uint8_t C2Error, uint8_t subchannel);
|
||||
int ReadCdMsf(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t startMsf, uint32_t endMsf, uint32_t blockSize, uint8_t expectedSectorType, int DAP, int sync, uint8_t headerCodes, int userData, int edcEcc, uint8_t C2Error, uint8_t subchannel);
|
||||
int PlextorReadCdDa(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t blockSize, uint32_t transferLength, uint8_t subchannel);
|
||||
int PlextorReadRawDvd(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t transferLength);
|
||||
int PioneerReadCdDa(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t blockSize, uint32_t transferLength, uint8_t subchannel);
|
||||
int PioneerReadCdDaMsf(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t startMsf, uint32_t endMsf, uint32_t blockSize, uint8_t subchannel);
|
||||
int NecReadCdDa(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t transferLength);
|
||||
int HlDtStReadRawDvd(int fd, unsigned char **buffer, unsigned char **senseBuffer, uint32_t lba, uint32_t transferLength);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -51,11 +62,21 @@ typedef enum
|
||||
SCSI_READ_10 = 0x28,
|
||||
SCSI_READ_LONG = 0x3E,
|
||||
SCSI_SEEK_10 = 0x2B,
|
||||
SCSI_READ_BUFFER = 0x3C,
|
||||
MMC_READ_TOC_PMA_ATIP = 0x43,
|
||||
MMC_GET_CONFIGURATION = 0x46,
|
||||
SCSI_MODE_SENSE_10 = 0x5A,
|
||||
SCSI_ATA_PASSTHROUGH_16 = 0x85,
|
||||
SCSI_READ_16 = 0x88,
|
||||
SCSI_SERVICE_ACTION_IN = 0x9E,
|
||||
SCSI_READ_12 = 0xA8,
|
||||
MMC_READ_DISC_STRUCTURE = 0xAD,
|
||||
MMC_READ_CD_MSF = 0xB9,
|
||||
MMC_READ_CD = 0xBE,
|
||||
NEC_READ_CDDA = 0xD4,
|
||||
PIONEER_READ_CDDA = 0xD8,
|
||||
PIONEER_READ_CDDA_MSF = 0xD9,
|
||||
HLDTST_VENDOR = 0xE7,
|
||||
} ScsiCommands;
|
||||
|
||||
typedef enum
|
||||
@@ -72,6 +93,253 @@ typedef enum
|
||||
SCSI_READ_LONG_16 = 0x11,
|
||||
} ScsiServiceActionIn;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DISC_STRUCTURE_DVD = 0x00,
|
||||
DISC_STRUCTURE_BD = 0x01,
|
||||
} MmcDiscStructureMediaType;
|
||||
|
||||
// TODO: Stylize this
|
||||
typedef enum
|
||||
{
|
||||
// Generic Format Codes
|
||||
|
||||
/// <summary>
|
||||
/// AACS Volume Identifier
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_AACSVolId = 0x80,
|
||||
/// <summary>
|
||||
/// AACS Pre-recorded Media Serial Number
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_AACSMediaSerial = 0x81,
|
||||
/// <summary>
|
||||
/// AACS Media Identifier
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_AACSMediaId = 0x82,
|
||||
/// <summary>
|
||||
/// AACS Lead-in Media Key Block
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_AACSMKB = 0x83,
|
||||
/// <summary>
|
||||
/// AACS Data Keys
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_AACSDataKeys = 0x84,
|
||||
/// <summary>
|
||||
/// AACS LBA extents
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_AACSLBAExtents = 0x85,
|
||||
/// <summary>
|
||||
/// CPRM Media Key Block specified by AACS
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_AACSMKBCPRM = 0x86,
|
||||
/// <summary>
|
||||
/// Recognized format layers
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_RecognizedFormatLayers = 0x90,
|
||||
/// <summary>
|
||||
/// Write protection status
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_WriteProtectionStatus = 0xC0,
|
||||
/// <summary>
|
||||
/// READ/SEND DISC STRUCTURE capability list
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_CapabilityList = 0xFF,
|
||||
|
||||
// DVD Disc Structures
|
||||
/// <summary>
|
||||
/// DVD Lead-in Physical Information
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_PhysicalInformation = 0x00,
|
||||
/// <summary>
|
||||
/// DVD Lead-in Copyright Information
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_CopyrightInformation = 0x01,
|
||||
/// <summary>
|
||||
/// CSS/CPPM Disc key
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DiscKey = 0x02,
|
||||
/// <summary>
|
||||
/// DVD Burst Cutting Area
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_BurstCuttingArea = 0x03,
|
||||
/// <summary>
|
||||
/// DVD Lead-in Disc Manufacturing Information
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DiscManufacturingInformation = 0x04,
|
||||
/// <summary>
|
||||
/// DVD Copyright Information from specified sector
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_SectorCopyrightInformation = 0x05,
|
||||
/// <summary>
|
||||
/// CSS/CPPM Media Identifier
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_MediaIdentifier = 0x06,
|
||||
/// <summary>
|
||||
/// CSS/CPPM Media Key Block
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_MediaKeyBlock = 0x07,
|
||||
/// <summary>
|
||||
/// DDS from DVD-RAM
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DVDRAM_DDS = 0x08,
|
||||
/// <summary>
|
||||
/// DVD-RAM Medium Status
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DVDRAM_MediumStatus = 0x09,
|
||||
/// <summary>
|
||||
/// DVD-RAM Spare Area Information
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DVDRAM_SpareAreaInformation = 0x0A,
|
||||
/// <summary>
|
||||
/// DVD-RAM Recording Type Information
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DVDRAM_RecordingType = 0x0B,
|
||||
/// <summary>
|
||||
/// DVD-R/-RW RMD in last Border-out
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_LastBorderOutRMD = 0x0C,
|
||||
/// <summary>
|
||||
/// Specified RMD from last recorded Border-out
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_SpecifiedRMD = 0x0D,
|
||||
/// <summary>
|
||||
/// DVD-R/-RW Lead-in pre-recorded information
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_PreRecordedInfo = 0x0E,
|
||||
/// <summary>
|
||||
/// DVD-R/-RW Media Identifier
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DVDR_MediaIdentifier = 0x0F,
|
||||
/// <summary>
|
||||
/// DVD-R/-RW Physical Format Information
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DVDR_PhysicalInformation = 0x10,
|
||||
/// <summary>
|
||||
/// ADIP
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_ADIP = 0x11,
|
||||
/// <summary>
|
||||
/// HD DVD Lead-in Copyright Protection Information
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_HDDVD_CopyrightInformation = 0x12,
|
||||
/// <summary>
|
||||
/// AACS Lead-in Copyright Data Section
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DVD_AACS = 0x15,
|
||||
/// <summary>
|
||||
/// HD DVD-R Medium Status
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_HDDVDR_MediumStatus = 0x19,
|
||||
/// <summary>
|
||||
/// HD DVD-R Last recorded RMD in the latest RMZ
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_HDDVDR_LastRMD = 0x1A,
|
||||
/// <summary>
|
||||
/// DVD+/-R DL and DVD-Download DL layer capacity
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DVDR_LayerCapacity = 0x20,
|
||||
/// <summary>
|
||||
/// DVD-R DL Middle Zone start address
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_MiddleZoneStart = 0x21,
|
||||
/// <summary>
|
||||
/// DVD-R DL Jump Interval Size
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_JumpIntervalSize = 0x22,
|
||||
/// <summary>
|
||||
/// DVD-R DL Start LBA of the manual layer jump
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_ManualLayerJumpStartLBA = 0x23,
|
||||
/// <summary>
|
||||
/// DVD-R DL Remapping information of the specified Anchor Point
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_RemapAnchorPoint = 0x24,
|
||||
/// <summary>
|
||||
/// Disc Control Block
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DCB = 0x30,
|
||||
|
||||
// BD Disc Structures
|
||||
/// <summary>
|
||||
/// Blu-ray Disc Information
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_DiscInformation = 0x00,
|
||||
/// <summary>
|
||||
/// Blu-ray Burst Cutting Area
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_BD_BurstCuttingArea = 0x03,
|
||||
/// <summary>
|
||||
/// Blu-ray DDS
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_BD_DDS = 0x08,
|
||||
/// <summary>
|
||||
/// Blu-ray Cartridge Status
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_CartridgeStatus = 0x09,
|
||||
/// <summary>
|
||||
/// Blu-ray Spare Area Information
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_BD_SpareAreaInformation = 0x0A,
|
||||
/// <summary>
|
||||
/// Unmodified DFL
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_RawDFL = 0x12,
|
||||
/// <summary>
|
||||
/// Physical Access Control
|
||||
/// </summary>
|
||||
DISC_STRUCTURE_PAC = 0x30
|
||||
} MmcDiscStructureFormat;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MMC_SECTOR_ALL = 0,
|
||||
MMC_SECTOR_CDDA = 1,
|
||||
MMC_SECTOR_MODE1 = 2,
|
||||
MMC_SECTOR_MODE2 = 3,
|
||||
MMC_SECTOR_MODE2F1 = 4,
|
||||
MMC_SECTOR_MODE2F2 = 5
|
||||
} MmcSectorTypes;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MMC_HEADER_NONE = 0,
|
||||
MMC_HEADER_ONLY = 1,
|
||||
MMC_SUBHEADER_ONLY = 2,
|
||||
MMC_HEADER_ALL = 3
|
||||
} MmcHeaderCodes;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MMC_ERROR_NONE = 0,
|
||||
MMC_ERROR_C2 = 1,
|
||||
MMC_ERROR_C2_AND_BLOCK = 2
|
||||
} MmcErrorField;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MMC_SUBCHANNEL_NONE = 0,
|
||||
MMC_SUBCHANNEL_RAW = 1,
|
||||
MMC_SUBCHANNEL_Q16 = 2,
|
||||
MMC_SUBCHANNEL_RW = 4
|
||||
} MmcSubchannel;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PIONEER_SUBCHANNEL_NONE = 0,
|
||||
PIONEER_SUBCHANNEL_Q16 = 1,
|
||||
PIONEER_SUBCHANNEL_ALL = 2,
|
||||
PIONEER_SUBCHANNEL_ONLY = 3
|
||||
} PioneerSubchannel;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PLEXTOR_SUBCHANNEL_NONE = 0,
|
||||
PLEXTOR_SUBCHANNEL_Q16 = 1,
|
||||
PLEXTOR_SUBCHANNEL_PACK = 2,
|
||||
PLEXTOR_SUBCHANNEL_ALL = 3,
|
||||
PLEXTOR_SUBCHANNEL_RAW_C2 = 8
|
||||
} PlextorSubchannel;
|
||||
|
||||
// SCSI INQUIRY command response
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "scsi.h"
|
||||
#include "inquiry_decode.h"
|
||||
#include "scsi_mode.h"
|
||||
#include "mmc_report.h"
|
||||
|
||||
void ScsiReport(int fd, xmlTextWriterPtr xmlWriter)
|
||||
{
|
||||
@@ -200,7 +201,8 @@ void ScsiReport(int fd, xmlTextWriterPtr xmlWriter)
|
||||
xmlTextWriterEndElement(xmlWriter);
|
||||
}
|
||||
|
||||
DecodedMode *decMode;
|
||||
DecodedMode *decMode = NULL;
|
||||
unsigned char* cdromMode = NULL;
|
||||
|
||||
if(supportsMode10)
|
||||
decMode = DecodeMode10(mode10Response, inquiry->PeripheralDeviceType);
|
||||
@@ -235,7 +237,7 @@ void ScsiReport(int fd, xmlTextWriterPtr xmlWriter)
|
||||
|
||||
if(page == 0x2A && subpage == 0x00)
|
||||
{
|
||||
// TODO: Decode CD-ROM page
|
||||
cdromMode = decMode->Pages[0x2A][0x00];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,7 +247,7 @@ void ScsiReport(int fd, xmlTextWriterPtr xmlWriter)
|
||||
|
||||
if(inquiry->PeripheralDeviceType == 0x05) // MultiMediaDevice
|
||||
{
|
||||
// TODO: Report MMC
|
||||
MmcReport(fd, xmlWriter, cdromMode);
|
||||
}
|
||||
else if(inquiry->PeripheralDeviceType == 0x01) // SequentialAccess
|
||||
{
|
||||
@@ -416,7 +418,7 @@ void ScsiReport(int fd, xmlTextWriterPtr xmlWriter)
|
||||
}
|
||||
}
|
||||
|
||||
printf("Trying SCSI READ LONG (10)...\n");
|
||||
printf("Trying SCSI READ LONG (16)...\n");
|
||||
ReadLong16(fd, &buffer, &sense, FALSE, 0, 0xFFFF);
|
||||
if((sense[0] == 0x70 || sense[0] == 0x71) && (sense[2] & 0x0F) == 0x05 && sense[12] == 0x24 && sense[13] == 0x00)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "SupportsReadLong16", "%s", "true");
|
||||
@@ -616,7 +618,7 @@ void ScsiReport(int fd, xmlTextWriterPtr xmlWriter)
|
||||
}
|
||||
}
|
||||
|
||||
printf("Trying SCSI READ LONG (10)...\n");
|
||||
printf("Trying SCSI READ LONG (16)...\n");
|
||||
ReadLong16(fd, &buffer, &sense, FALSE, 0, 0xFFFF);
|
||||
if((sense[0] == 0x70 || sense[0] == 0x71) && (sense[2] & 0x0F) == 0x05 && sense[12] == 0x24 && sense[13] == 0x00)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "SupportsReadLong16", "%s", "true");
|
||||
|
||||
Reference in New Issue
Block a user