mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Added ATAPI report to DiscImageChef.Device.Report.
This commit is contained in:
@@ -3,4 +3,9 @@ project(DiscImageChef_Device_Report C)
|
||||
|
||||
set(CMAKE_C_STANDARD 90)
|
||||
|
||||
add_executable(DiscImageChef_Device_Report main.c scsi.c scsi.h main.h ata.h ata.c atapi.c atapi.h)
|
||||
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)
|
||||
target_link_libraries(DiscImageChef_Device_Report ${LIBXML2_LIBRARIES})
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
uint8_t feature;
|
||||
@@ -106,6 +107,741 @@ typedef enum
|
||||
ATA_IDENTIFY_DEVICE = 0xEC
|
||||
} AtaCommands;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*
|
||||
Word 0
|
||||
General device configuration
|
||||
On ATAPI devices:
|
||||
Bits 12 to 8 indicate device type as SCSI defined
|
||||
Bits 6 to 5:
|
||||
0 = Device shall set DRQ within 3 ms of receiving PACKET
|
||||
1 = Device shall assert INTRQ when DRQ is set to one
|
||||
2 = Device shall set DRQ within 50 µs of receiving PACKET
|
||||
Bits 1 to 0:
|
||||
0 = 12 byte command packet
|
||||
1 = 16 byte command packet
|
||||
CompactFlash is 0x848A (non magnetic, removable, not MFM, hardsector, and UltraFAST)
|
||||
*/
|
||||
uint16_t GeneralConfiguration;
|
||||
/*
|
||||
Word 1
|
||||
Cylinders in default translation mode
|
||||
Obsoleted in ATA/ATAPI-6
|
||||
*/
|
||||
uint16_t Cylinders;
|
||||
/*
|
||||
Word 2
|
||||
Specific configuration
|
||||
*/
|
||||
uint16_t SpecificConfiguration;
|
||||
/*
|
||||
Word 3
|
||||
Heads in default translation mode
|
||||
Obsoleted in ATA/ATAPI-6
|
||||
*/
|
||||
uint16_t Heads;
|
||||
/*
|
||||
Word 4
|
||||
Unformatted bytes per track in default translation mode
|
||||
Obsoleted in ATA-2
|
||||
*/
|
||||
uint16_t UnformattedBPT;
|
||||
/*
|
||||
Word 5
|
||||
Unformatted bytes per sector in default translation mode
|
||||
Obsoleted in ATA-2
|
||||
*/
|
||||
uint16_t UnformattedBPS;
|
||||
/*
|
||||
Word 6
|
||||
Sectors per track in default translation mode
|
||||
Obsoleted in ATA/ATAPI-6
|
||||
*/
|
||||
uint16_t SectorsPerTrack;
|
||||
/*
|
||||
Words 7 to 8
|
||||
CFA: Number of sectors per card
|
||||
*/
|
||||
uint32_t SectorsPerCard;
|
||||
/*
|
||||
Word 9
|
||||
Vendor unique
|
||||
Obsoleted in ATA/ATAPI-4
|
||||
*/
|
||||
uint16_t VendorWord9;
|
||||
/*
|
||||
Words 10 to 19
|
||||
Device serial number, right justified, padded with spaces
|
||||
*/
|
||||
uint8_t SerialNumber[20];
|
||||
/*
|
||||
Word 20
|
||||
Manufacturer defined
|
||||
Obsoleted in ATA-2
|
||||
0x0001 = single ported single sector buffer
|
||||
0x0002 = dual ported multi sector buffer
|
||||
0x0003 = dual ported multi sector buffer with reading
|
||||
*/
|
||||
uint16_t BufferType;
|
||||
/*
|
||||
Word 21
|
||||
Size of buffer in 512 byte increments
|
||||
Obsoleted in ATA-2
|
||||
*/
|
||||
uint16_t BufferSize;
|
||||
/*
|
||||
Word 22
|
||||
Bytes of ECC available in READ/WRITE LONG commands
|
||||
Obsoleted in ATA/ATAPI-4
|
||||
*/
|
||||
uint16_t EccBytes;
|
||||
/*
|
||||
Words 23 to 26
|
||||
Firmware revision, left justified, padded with spaces
|
||||
*/
|
||||
uint8_t FirmwareRevision[8];
|
||||
/*
|
||||
Words 27 to 46
|
||||
Model number, left justified, padded with spaces
|
||||
*/
|
||||
uint8_t Model[40];
|
||||
/*
|
||||
Word 47 bits 7 to 0
|
||||
Maximum number of sectors that can be transferred per
|
||||
interrupt on read and write multiple commands
|
||||
*/
|
||||
uint8_t MultipleMaxSectors;
|
||||
/*
|
||||
Word 47 bits 15 to 8
|
||||
Vendor unique
|
||||
ATA/ATAPI-4 says it must be 0x80
|
||||
*/
|
||||
uint8_t VendorWord47;
|
||||
/*
|
||||
Word 48
|
||||
ATA-1: Set to 1 if it can perform doubleword I/O
|
||||
ATA-2 to ATA/ATAPI-7: Reserved
|
||||
ATA8-ACS: Trusted Computing feature set
|
||||
*/
|
||||
uint16_t TrustedComputing;
|
||||
/*
|
||||
Word 49
|
||||
Capabilities
|
||||
*/
|
||||
uint16_t Capabilities;
|
||||
/*
|
||||
Word 50
|
||||
Capabilities
|
||||
*/
|
||||
uint16_t Capabilities2;
|
||||
/*
|
||||
Word 51 bits 7 to 0
|
||||
Vendor unique
|
||||
Obsoleted in ATA/ATAPI-4
|
||||
*/
|
||||
uint8_t VendorWord51;
|
||||
/*
|
||||
Word 51 bits 15 to 8
|
||||
Transfer timing mode in PIO
|
||||
Obsoleted in ATA/ATAPI-4
|
||||
*/
|
||||
uint8_t PIOTransferTimingMode;
|
||||
/*
|
||||
Word 52 bits 7 to 0
|
||||
Vendor unique
|
||||
Obsoleted in ATA/ATAPI-4
|
||||
*/
|
||||
uint8_t VendorWord52;
|
||||
/*
|
||||
Word 52 bits 15 to 8
|
||||
Transfer timing mode in DMA
|
||||
Obsoleted in ATA/ATAPI-4
|
||||
*/
|
||||
uint8_t DMATransferTimingMode;
|
||||
/*
|
||||
Word 53 bits 7 to 0
|
||||
Reports if words 54 to 58 are valid
|
||||
*/
|
||||
uint8_t ExtendedIdentify;
|
||||
/*
|
||||
Word 53 bits 15 to 8
|
||||
Free-fall Control Sensitivity
|
||||
*/
|
||||
uint8_t FreeFallSensitivity;
|
||||
/*
|
||||
Word 54
|
||||
Cylinders in current translation mode
|
||||
Obsoleted in ATA/ATAPI-6
|
||||
*/
|
||||
uint16_t CurrentCylinders;
|
||||
/*
|
||||
Word 55
|
||||
Heads in current translation mode
|
||||
Obsoleted in ATA/ATAPI-6
|
||||
*/
|
||||
uint16_t CurrentHeads;
|
||||
/*
|
||||
Word 56
|
||||
Sectors per track in current translation mode
|
||||
Obsoleted in ATA/ATAPI-6
|
||||
*/
|
||||
uint16_t CurrentSectorsPerTrack;
|
||||
/*
|
||||
Words 57 to 58
|
||||
Total sectors currently user-addressable
|
||||
Obsoleted in ATA/ATAPI-6
|
||||
*/
|
||||
uint32_t CurrentSectors;
|
||||
/*
|
||||
Word 59 bits 7 to 0
|
||||
Number of sectors currently set to transfer on a READ/WRITE MULTIPLE command
|
||||
*/
|
||||
uint8_t MultipleSectorNumber;
|
||||
/*
|
||||
Word 59 bits 15 to 8
|
||||
Indicates if <see cref="MultipleSectorNumber"/> is valid
|
||||
*/
|
||||
uint8_t Capabilities3;
|
||||
/*
|
||||
Words 60 to 61
|
||||
If drive supports LBA, how many sectors are addressable using LBA
|
||||
*/
|
||||
uint32_t LBASectors;
|
||||
/*
|
||||
Word 62 bits 7 to 0
|
||||
Single word DMA modes available
|
||||
Obsoleted in ATA/ATAPI-4
|
||||
In ATAPI it's not obsolete, indicates UDMA mode (UDMA7 is instead MDMA0)
|
||||
*/
|
||||
uint8_t DMASupported;
|
||||
/*
|
||||
Word 62 bits 15 to 8
|
||||
Single word DMA mode currently active
|
||||
Obsoleted in ATA/ATAPI-4
|
||||
In ATAPI it's not obsolete, bits 0 and 1 indicate MDMA mode+1,
|
||||
bit 10 indicates DMA is supported and bit 15 indicates DMADIR bit
|
||||
in PACKET is required for DMA transfers
|
||||
*/
|
||||
uint8_t DMAActive;
|
||||
/*
|
||||
Word 63 bits 7 to 0
|
||||
Multiword DMA modes available
|
||||
*/
|
||||
uint8_t MDMASupported;
|
||||
/*
|
||||
Word 63 bits 15 to 8
|
||||
Multiword DMA mode currently active
|
||||
*/
|
||||
uint8_t MDMAActive;
|
||||
|
||||
/*
|
||||
Word 64 bits 7 to 0
|
||||
Supported Advanced PIO transfer modes
|
||||
*/
|
||||
uint8_t APIOSupported;
|
||||
/*
|
||||
Word 64 bits 15 to 8
|
||||
Reserved
|
||||
*/
|
||||
uint8_t ReservedWord64;
|
||||
/*
|
||||
Word 65
|
||||
Minimum MDMA transfer cycle time per word in nanoseconds
|
||||
*/
|
||||
uint16_t MinMDMACycleTime;
|
||||
/*
|
||||
Word 66
|
||||
Recommended MDMA transfer cycle time per word in nanoseconds
|
||||
*/
|
||||
uint16_t RecMDMACycleTime;
|
||||
/*
|
||||
Word 67
|
||||
Minimum PIO transfer cycle time without flow control in nanoseconds
|
||||
*/
|
||||
uint16_t MinPIOCycleTimeNoFlow;
|
||||
/*
|
||||
Word 68
|
||||
Minimum PIO transfer cycle time with IORDY flow control in nanoseconds
|
||||
*/
|
||||
uint16_t MinPIOCycleTimeFlow;
|
||||
|
||||
/*
|
||||
Word 69
|
||||
Additional supported
|
||||
*/
|
||||
uint16_t CommandSet5;
|
||||
/*
|
||||
Word 70
|
||||
Reserved
|
||||
*/
|
||||
uint16_t ReservedWord70;
|
||||
/*
|
||||
Word 71
|
||||
ATAPI: Typical time in ns from receipt of PACKET to release bus
|
||||
*/
|
||||
uint16_t PacketBusRelease;
|
||||
/*
|
||||
Word 72
|
||||
ATAPI: Typical time in ns from receipt of SERVICE to clear BSY
|
||||
*/
|
||||
uint16_t ServiceBusyClear;
|
||||
/*
|
||||
Word 73
|
||||
Reserved
|
||||
*/
|
||||
uint16_t ReservedWord73;
|
||||
/*
|
||||
Word 74
|
||||
Reserved
|
||||
*/
|
||||
uint16_t ReservedWord74;
|
||||
|
||||
/*
|
||||
Word 75
|
||||
Maximum Queue depth
|
||||
*/
|
||||
uint16_t MaxQueueDepth;
|
||||
|
||||
/*
|
||||
Word 76
|
||||
Serial ATA Capabilities
|
||||
*/
|
||||
uint16_t SATACapabilities;
|
||||
/*
|
||||
Word 77
|
||||
Serial ATA Additional Capabilities
|
||||
*/
|
||||
uint16_t SATACapabilities2;
|
||||
|
||||
/*
|
||||
Word 78
|
||||
Supported Serial ATA features
|
||||
*/
|
||||
uint16_t SATAFeatures;
|
||||
/*
|
||||
Word 79
|
||||
Enabled Serial ATA features
|
||||
*/
|
||||
uint16_t EnabledSATAFeatures;
|
||||
|
||||
/*
|
||||
Word 80
|
||||
Major version of ATA/ATAPI standard supported
|
||||
*/
|
||||
uint16_t MajorVersion;
|
||||
/*
|
||||
Word 81
|
||||
Minimum version of ATA/ATAPI standard supported
|
||||
*/
|
||||
uint16_t MinorVersion;
|
||||
|
||||
/*
|
||||
Word 82
|
||||
Supported command/feature sets
|
||||
*/
|
||||
uint16_t CommandSet;
|
||||
/*
|
||||
Word 83
|
||||
Supported command/feature sets
|
||||
*/
|
||||
uint16_t CommandSet2;
|
||||
/*
|
||||
Word 84
|
||||
Supported command/feature sets
|
||||
*/
|
||||
uint16_t CommandSet3;
|
||||
|
||||
/*
|
||||
Word 85
|
||||
Enabled command/feature sets
|
||||
*/
|
||||
uint16_t EnabledCommandSet;
|
||||
/*
|
||||
Word 86
|
||||
Enabled command/feature sets
|
||||
*/
|
||||
uint16_t EnabledCommandSet2;
|
||||
/*
|
||||
Word 87
|
||||
Enabled command/feature sets
|
||||
*/
|
||||
uint16_t EnabledCommandSet3;
|
||||
|
||||
/*
|
||||
Word 88 bits 7 to 0
|
||||
Supported Ultra DMA transfer modes
|
||||
*/
|
||||
uint8_t UDMASupported;
|
||||
/*
|
||||
Word 88 bits 15 to 8
|
||||
Selected Ultra DMA transfer modes
|
||||
*/
|
||||
uint8_t UDMAActive;
|
||||
|
||||
/*
|
||||
Word 89
|
||||
Time required for security erase completion
|
||||
*/
|
||||
uint16_t SecurityEraseTime;
|
||||
/*
|
||||
Word 90
|
||||
Time required for enhanced security erase completion
|
||||
*/
|
||||
uint16_t EnhancedSecurityEraseTime;
|
||||
/*
|
||||
Word 91
|
||||
Current advanced power management value
|
||||
*/
|
||||
uint16_t CurrentAPM;
|
||||
|
||||
/*
|
||||
Word 92
|
||||
Master password revision code
|
||||
*/
|
||||
uint16_t MasterPasswordRevisionCode;
|
||||
/*
|
||||
Word 93
|
||||
Hardware reset result
|
||||
*/
|
||||
uint16_t HardwareResetResult;
|
||||
|
||||
/*
|
||||
Word 94 bits 7 to 0
|
||||
Current AAM value
|
||||
*/
|
||||
uint8_t CurrentAAM;
|
||||
/*
|
||||
Word 94 bits 15 to 8
|
||||
Vendor's recommended AAM value
|
||||
*/
|
||||
uint8_t RecommendedAAM;
|
||||
|
||||
/*
|
||||
Word 95
|
||||
Stream minimum request size
|
||||
*/
|
||||
uint16_t StreamMinReqSize;
|
||||
/*
|
||||
Word 96
|
||||
Streaming transfer time in DMA
|
||||
*/
|
||||
uint16_t StreamTransferTimeDMA;
|
||||
/*
|
||||
Word 97
|
||||
Streaming access latency in DMA and PIO
|
||||
*/
|
||||
uint16_t StreamAccessLatency;
|
||||
/*
|
||||
Words 98 to 99
|
||||
Streaming performance granularity
|
||||
*/
|
||||
uint32_t StreamPerformanceGranularity;
|
||||
|
||||
/*
|
||||
Words 100 to 103
|
||||
48-bit LBA addressable sectors
|
||||
*/
|
||||
uint64_t LBA48Sectors;
|
||||
|
||||
/*
|
||||
Word 104
|
||||
Streaming transfer time in PIO
|
||||
*/
|
||||
uint16_t StreamTransferTimePIO;
|
||||
|
||||
/*
|
||||
Word 105
|
||||
Maximum number of 512-byte block per DATA SET MANAGEMENT command
|
||||
*/
|
||||
uint16_t DataSetMgmtSize;
|
||||
|
||||
/*
|
||||
Word 106
|
||||
Bit 15 should be zero
|
||||
Bit 14 should be one
|
||||
Bit 13 set indicates device has multiple logical sectors per physical sector
|
||||
Bit 12 set indicates logical sector has more than 256 words (512 bytes)
|
||||
Bits 11 to 4 are reserved
|
||||
Bits 3 to 0 indicate power of two of logical sectors per physical sector
|
||||
*/
|
||||
uint16_t PhysLogSectorSize;
|
||||
|
||||
/*
|
||||
Word 107
|
||||
Interseek delay for ISO-7779 acoustic testing, in microseconds
|
||||
*/
|
||||
uint16_t InterseekDelay;
|
||||
|
||||
/*
|
||||
Words 108 to 111
|
||||
World Wide Name
|
||||
*/
|
||||
uint64_t WWN;
|
||||
|
||||
/*
|
||||
Words 112 to 115
|
||||
Reserved for WWN extension to 128 bit
|
||||
*/
|
||||
uint64_t WWNExtension;
|
||||
|
||||
/*
|
||||
Word 116
|
||||
Reserved for technical report
|
||||
*/
|
||||
uint16_t ReservedWord116;
|
||||
|
||||
/*
|
||||
Words 117 to 118
|
||||
Words per logical sector
|
||||
*/
|
||||
uint32_t LogicalSectorWords;
|
||||
|
||||
/*
|
||||
Word 119
|
||||
Supported command/feature sets
|
||||
*/
|
||||
uint16_t CommandSet4;
|
||||
/*
|
||||
Word 120
|
||||
Supported command/feature sets
|
||||
*/
|
||||
uint16_t EnabledCommandSet4;
|
||||
|
||||
/*
|
||||
Words 121 to 125
|
||||
Reserved
|
||||
*/
|
||||
uint16_t ReservedWords121[5];
|
||||
|
||||
/*
|
||||
Word 126
|
||||
ATAPI byte count limit
|
||||
*/
|
||||
uint16_t ATAPIByteCount;
|
||||
|
||||
/*
|
||||
Word 127
|
||||
Removable Media Status Notification feature set support
|
||||
Bits 15 to 2 are reserved
|
||||
Bits 1 to 0 must be 0 for not supported or 1 for supported. 2 and 3 are reserved.
|
||||
Obsoleted in ATA8-ACS
|
||||
*/
|
||||
uint16_t RemovableStatusSet;
|
||||
|
||||
/*
|
||||
Word 128
|
||||
Security status
|
||||
*/
|
||||
uint16_t SecurityStatus;
|
||||
|
||||
/*
|
||||
Words 129 to 159
|
||||
*/
|
||||
uint16_t ReservedWords129[31];
|
||||
|
||||
/*
|
||||
Word 160
|
||||
CFA power mode
|
||||
Bit 15 must be set
|
||||
Bit 13 indicates mode 1 is required for one or more commands
|
||||
Bit 12 indicates mode 1 is disabled
|
||||
Bits 11 to 0 indicates maximum current in mA
|
||||
*/
|
||||
uint16_t CFAPowerMode;
|
||||
|
||||
/*
|
||||
Words 161 to 167
|
||||
Reserved for CFA
|
||||
*/
|
||||
uint16_t ReservedCFA[7];
|
||||
|
||||
/*
|
||||
Word 168
|
||||
Bits 15 to 4, reserved
|
||||
Bits 3 to 0, device nominal form factor
|
||||
*/
|
||||
uint16_t DeviceFormFactor;
|
||||
/*
|
||||
Word 169
|
||||
DATA SET MANAGEMENT support
|
||||
*/
|
||||
uint16_t DataSetMgmt;
|
||||
/*
|
||||
Words 170 to 173
|
||||
Additional product identifier
|
||||
*/
|
||||
uint8_t AdditionalPID[8];
|
||||
|
||||
/*
|
||||
Word 174
|
||||
Reserved
|
||||
*/
|
||||
uint16_t ReservedWord174;
|
||||
/*
|
||||
Word 175
|
||||
Reserved
|
||||
*/
|
||||
uint16_t ReservedWord175;
|
||||
|
||||
/*
|
||||
Words 176 to 195
|
||||
Current media serial number
|
||||
*/
|
||||
uint8_t MediaSerial[40];
|
||||
/*
|
||||
Words 196 to 205
|
||||
Current media manufacturer
|
||||
*/
|
||||
uint8_t MediaManufacturer[20];
|
||||
|
||||
/*
|
||||
Word 206
|
||||
SCT Command Transport features
|
||||
*/
|
||||
uint16_t SCTCommandTransport;
|
||||
|
||||
/*
|
||||
Word 207
|
||||
Reserved for CE-ATA
|
||||
*/
|
||||
uint16_t ReservedCEATAWord207;
|
||||
/*
|
||||
Word 208
|
||||
Reserved for CE-ATA
|
||||
*/
|
||||
uint16_t ReservedCEATAWord208;
|
||||
|
||||
/*
|
||||
Word 209
|
||||
Alignment of logical block within a larger physical block
|
||||
Bit 15 shall be cleared to zero
|
||||
Bit 14 shall be set to one
|
||||
Bits 13 to 0 indicate logical sector offset within the first physical sector
|
||||
*/
|
||||
uint16_t LogicalAlignment;
|
||||
|
||||
/*
|
||||
Words 210 to 211
|
||||
Write/Read/Verify sector count mode 3 only
|
||||
*/
|
||||
uint32_t WRVSectorCountMode3;
|
||||
/*
|
||||
Words 212 to 213
|
||||
Write/Read/Verify sector count mode 2 only
|
||||
*/
|
||||
uint32_t WRVSectorCountMode2;
|
||||
|
||||
/*
|
||||
Word 214
|
||||
NV Cache capabilities
|
||||
Bits 15 to 12 feature set version
|
||||
Bits 11 to 18 power mode feature set version
|
||||
Bits 7 to 5 reserved
|
||||
Bit 4 feature set enabled
|
||||
Bits 3 to 2 reserved
|
||||
Bit 1 power mode feature set enabled
|
||||
Bit 0 power mode feature set supported
|
||||
*/
|
||||
uint16_t NVCacheCaps;
|
||||
/*
|
||||
Words 215 to 216
|
||||
NV Cache Size in Logical BLocks
|
||||
*/
|
||||
uint32_t NVCacheSize;
|
||||
/*
|
||||
Word 217
|
||||
Nominal media rotation rate
|
||||
In ACS-1 meant NV Cache read speed in MB/s
|
||||
*/
|
||||
uint16_t NominalRotationRate;
|
||||
/*
|
||||
Word 218
|
||||
NV Cache write speed in MB/s
|
||||
Reserved since ACS-2
|
||||
*/
|
||||
uint16_t NVCacheWriteSpeed;
|
||||
/*
|
||||
Word 219 bits 7 to 0
|
||||
Estimated device spin up in seconds
|
||||
*/
|
||||
uint8_t NVEstimatedSpinUp;
|
||||
/*
|
||||
Word 219 bits 15 to 8
|
||||
NV Cache reserved
|
||||
*/
|
||||
uint8_t NVReserved;
|
||||
|
||||
/*
|
||||
Word 220 bits 7 to 0
|
||||
Write/Read/Verify feature set current mode
|
||||
*/
|
||||
uint8_t WRVMode;
|
||||
/*
|
||||
Word 220 bits 15 to 8
|
||||
Reserved
|
||||
*/
|
||||
uint8_t WRVReserved;
|
||||
|
||||
/*
|
||||
Word 221
|
||||
Reserved
|
||||
*/
|
||||
uint16_t ReservedWord221;
|
||||
|
||||
/*
|
||||
Word 222
|
||||
Transport major revision number
|
||||
Bits 15 to 12 indicate transport type. 0 parallel, 1 serial, 0xE PCIe.
|
||||
Bits 11 to 0 indicate revision
|
||||
*/
|
||||
uint16_t TransportMajorVersion;
|
||||
/*
|
||||
Word 223
|
||||
Transport minor revision number
|
||||
*/
|
||||
uint16_t TransportMinorVersion;
|
||||
|
||||
/*
|
||||
Words 224 to 229
|
||||
Reserved for CE-ATA
|
||||
*/
|
||||
uint16_t ReservedCEATA224[6];
|
||||
|
||||
/*
|
||||
Words 230 to 233
|
||||
48-bit LBA if Word 69 bit 3 is set
|
||||
*/
|
||||
uint64_t ExtendedUserSectors;
|
||||
|
||||
/*
|
||||
Word 234
|
||||
Minimum number of 512 byte units per DOWNLOAD MICROCODE mode 3
|
||||
*/
|
||||
uint16_t MinDownloadMicroMode3;
|
||||
/*
|
||||
Word 235
|
||||
Maximum number of 512 byte units per DOWNLOAD MICROCODE mode 3
|
||||
*/
|
||||
uint16_t MaxDownloadMicroMode3;
|
||||
|
||||
/*
|
||||
Words 236 to 254
|
||||
*/
|
||||
uint16_t ReservedWords[19];
|
||||
|
||||
/*
|
||||
Word 255 bits 7 to 0
|
||||
Should be 0xA5
|
||||
*/
|
||||
uint8_t Signature;
|
||||
/*
|
||||
Word 255 bits 15 to 8
|
||||
Checksum
|
||||
*/
|
||||
uint8_t Checksum;
|
||||
} IdentifyDevice;
|
||||
|
||||
unsigned char *AtaToCString(unsigned char* string, int len);
|
||||
int SendAtaCommandChs(int fd, AtaRegistersCHS registers, AtaErrorRegistersCHS **errorRegisters, int protocol, int transferRegister, unsigned char *buffer, unsigned int buffer_len, int transferBlocks);
|
||||
int SendAtaCommandLba28(int fd, AtaRegistersLBA28 registers, AtaErrorRegistersLBA28 **errorRegisters, int protocol, int transferRegister, unsigned char *buffer, unsigned int buffer_len, int transferBlocks);
|
||||
|
||||
195
DiscImageChef.Device.Report/atapi_report.c
Normal file
195
DiscImageChef.Device.Report/atapi_report.c
Normal file
@@ -0,0 +1,195 @@
|
||||
//
|
||||
// Created by claunia on 13/12/17.
|
||||
//
|
||||
|
||||
#include <string.h>
|
||||
#include <libxml/xmlwriter.h>
|
||||
#include "atapi_report.h"
|
||||
#include "ata.h"
|
||||
#include "atapi.h"
|
||||
#include "identify_decode.h"
|
||||
|
||||
#define DIC_ATAPI_REPORT_ELEMENT "ATAPI"
|
||||
|
||||
void AtapiReport(int fd, xmlTextWriterPtr xmlWriter)
|
||||
{
|
||||
unsigned char *atapi_ident = NULL;
|
||||
AtaErrorRegistersCHS *ata_error_chs;
|
||||
int error;
|
||||
|
||||
error = IdentifyPacket(fd, &atapi_ident, &ata_error_chs);
|
||||
|
||||
if(error)
|
||||
{
|
||||
fprintf(stderr, "Error {0} requesting IDENTIFY PACKET DEVICE", error);
|
||||
return;
|
||||
}
|
||||
|
||||
IdentifyDevice *identify = malloc(512);
|
||||
memcpy(identify, atapi_ident, 512);
|
||||
|
||||
xmlTextWriterStartElement(xmlWriter, BAD_CAST DIC_ATAPI_REPORT_ELEMENT);
|
||||
|
||||
if((uint64_t)*identify->AdditionalPID != 0 && (uint64_t)*identify->AdditionalPID != 0x2020202020202020)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "AdditionalPid", AtaToCString(identify->AdditionalPID, 8));
|
||||
if(identify->APIOSupported)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "APIOSupported", DecodeTransferMode(le16toh(identify->APIOSupported)));
|
||||
if(identify->ATAPIByteCount)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "ATAPIByteCount", "%u", le16toh(identify->ATAPIByteCount));
|
||||
if(identify->BufferType)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "BufferType", "%u", le16toh(identify->BufferType));
|
||||
if(identify->BufferSize)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "BufferSize", "%u", le16toh(identify->BufferSize));
|
||||
if(identify->Capabilities)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "Capabilities", DecodeCapabilities(le16toh(identify->Capabilities)));
|
||||
if(identify->Capabilities2)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "Capabilities2", DecodeCapabilities2(le16toh(identify->Capabilities2)));
|
||||
if(identify->Capabilities3)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "Capabilities3", DecodeCapabilities3(identify->Capabilities3));
|
||||
if(identify->CFAPowerMode)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "CFAPowerMode", "%u", le16toh(identify->CFAPowerMode));
|
||||
if(identify->CommandSet)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "CommandSet", DecodeCommandSet(le16toh(identify->CommandSet)));
|
||||
if(identify->CommandSet2)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "CommandSet2", DecodeCommandSet2(le16toh(identify->CommandSet2)));
|
||||
if(identify->CommandSet3)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "CommandSet3", DecodeCommandSet3(le16toh(identify->CommandSet3)));
|
||||
if(identify->CommandSet4)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "CommandSet4", DecodeCommandSet4(le16toh(identify->CommandSet4)));
|
||||
if(identify->CommandSet5)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "CommandSet5", DecodeCommandSet5(le16toh(identify->CommandSet5)));
|
||||
if(identify->CurrentAAM)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "CurrentAAM", "%u", identify->CurrentAAM);
|
||||
if(identify->CurrentAPM)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "CurrentAPM", "%u", le16toh(identify->CurrentAPM));
|
||||
if(identify->DataSetMgmt)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "DataSetMgmt", DecodeDataSetMgmt(le16toh(identify->DataSetMgmt)));
|
||||
if(identify->DataSetMgmtSize)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "DataSetMgmtSize", "%u", le16toh(identify->DataSetMgmtSize));
|
||||
if(identify->DeviceFormFactor)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "DeviceFormFactor", DecodeDeviceFormFactor(le16toh(identify->DeviceFormFactor)));
|
||||
if(identify->DMAActive)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "DMAActive", DecodeTransferMode(le16toh(identify->DMAActive)));
|
||||
if(identify->DMASupported)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "DMASupported", DecodeTransferMode(le16toh(identify->DMASupported)));
|
||||
if(identify->DMATransferTimingMode)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "DMATransferTimingMode", "%u", identify->DMATransferTimingMode);
|
||||
if(identify->EnhancedSecurityEraseTime)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "EnhancedSecurityEraseTime", "%u", le16toh(identify->EnhancedSecurityEraseTime));
|
||||
if(identify->EnabledCommandSet)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "EnabledCommandSet", DecodeCommandSet(le16toh(identify->EnabledCommandSet)));
|
||||
if(identify->EnabledCommandSet2)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "EnabledCommandSet2", DecodeCommandSet2(le16toh(identify->EnabledCommandSet2)));
|
||||
if(identify->EnabledCommandSet3)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "EnabledCommandSet3", DecodeCommandSet3(le16toh(identify->EnabledCommandSet3)));
|
||||
if(identify->EnabledCommandSet4)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "EnabledCommandSet4", DecodeCommandSet4(le16toh(identify->EnabledCommandSet4)));
|
||||
if(identify->EnabledSATAFeatures)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "EnabledSATAFeatures", DecodeSATAFeatures(le16toh(identify->EnabledSATAFeatures)));
|
||||
if(identify->ExtendedUserSectors)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "ExtendedUserSectors", "%llu", le64toh(identify->ExtendedUserSectors));
|
||||
if(identify->FreeFallSensitivity)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "FreeFallSensitivity", "%u", identify->FreeFallSensitivity);
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "FirmwareRevision", AtaToCString(identify->FirmwareRevision, 8));
|
||||
if(identify->GeneralConfiguration)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "GeneralConfiguration", DecodeGeneralConfiguration(le16toh(identify->GeneralConfiguration)));
|
||||
if(identify->HardwareResetResult)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "HardwareResetResult", "%u", le16toh(identify->HardwareResetResult));
|
||||
if(identify->InterseekDelay)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "InterseekDelay", "%u", le16toh(identify->InterseekDelay));
|
||||
if(identify->MajorVersion)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "MajorVersion", DecodeMajorVersion(le16toh(identify->MajorVersion)));
|
||||
if(identify->MasterPasswordRevisionCode)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "MasterPasswordRevisionCode", "%u", le16toh(identify->MasterPasswordRevisionCode));
|
||||
if(identify->MaxDownloadMicroMode3)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "MaxDownloadMicroMode3", "%u", le16toh(identify->MaxDownloadMicroMode3));
|
||||
if(identify->MaxQueueDepth)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "MaxQueueDepth", "%u", le16toh(identify->MaxQueueDepth));
|
||||
if(identify->MDMAActive)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "MDMAActive", DecodeTransferMode(le16toh(identify->MDMAActive)));
|
||||
if(identify->MDMASupported)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "MDMASupported", DecodeTransferMode(le16toh(identify->MDMASupported)));
|
||||
if(identify->MinDownloadMicroMode3)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "MinDownloadMicroMode3", "%u", le16toh(identify->MinDownloadMicroMode3));
|
||||
if(identify->MinMDMACycleTime)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "MinMDMACycleTime", "%u", le16toh(identify->MinMDMACycleTime));
|
||||
if(identify->MinorVersion)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "MinorVersion", "%u", le16toh(identify->MinorVersion));
|
||||
if(identify->MinPIOCycleTimeNoFlow)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "MinPIOCycleTimeNoFlow", "%u", le16toh(identify->MinPIOCycleTimeNoFlow));
|
||||
if(identify->MinPIOCycleTimeFlow)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "MinPIOCycleTimeFlow", "%u", le16toh(identify->MinPIOCycleTimeFlow));
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "Model", AtaToCString(identify->Model, 40));
|
||||
if(identify->MultipleMaxSectors)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "MultipleMaxSectors", "%u", identify->MultipleMaxSectors);
|
||||
if(identify->MultipleSectorNumber)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "MultipleSectorNumber", "%u", identify->MultipleSectorNumber);
|
||||
if(identify->NVCacheCaps)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "NVCacheCaps", "%u", le16toh(identify->NVCacheCaps));
|
||||
if(identify->NVCacheSize)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "NVCacheSize", "%u", le32toh(identify->NVCacheSize));
|
||||
if(identify->NVCacheWriteSpeed)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "NVCacheWriteSpeed", "%u", le16toh(identify->NVCacheWriteSpeed));
|
||||
if(identify->NVEstimatedSpinUp)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "NVEstimatedSpinUp", "%u", identify->NVEstimatedSpinUp);
|
||||
if(identify->PacketBusRelease)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "PacketBusRelease", "%u", le16toh(identify->PacketBusRelease));
|
||||
if(identify->PIOTransferTimingMode)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "PIOTransferTimingMode", "%u", identify->PIOTransferTimingMode);
|
||||
if(identify->RecommendedAAM)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "RecommendedAAM", "%u", identify->RecommendedAAM);
|
||||
if(identify->RecMDMACycleTime)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "RecMDMACycleTime", "%u", le16toh(identify->RecMDMACycleTime));
|
||||
if(identify->RemovableStatusSet)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "RemovableStatusSet", "%u", le16toh(identify->RemovableStatusSet));
|
||||
if(identify->SATACapabilities)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "SATACapabilities", DecodeSATACapabilities(le16toh(identify->SATACapabilities)));
|
||||
if(identify->SATACapabilities2)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "SATACapabilities2", DecodeSATACapabilities2(le16toh(identify->SATACapabilities2)));
|
||||
if(identify->SATAFeatures)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "SATAFeatures", DecodeSATAFeatures(le16toh(identify->SATAFeatures)));
|
||||
if(identify->SCTCommandTransport)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "SCTCommandTransport", DecodeSCTCommandTransport(le16toh(identify->SCTCommandTransport)));
|
||||
if(identify->SectorsPerCard)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "SectorsPerCard", "%u", le32toh(identify->SectorsPerCard));
|
||||
if(identify->SecurityEraseTime)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "SecurityEraseTime", "%u", le16toh(identify->SecurityEraseTime));
|
||||
if(identify->SecurityStatus)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "SecurityStatus", DecodeSecurityStatus(le16toh(identify->SecurityStatus)));
|
||||
if(identify->ServiceBusyClear)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "ServiceBusyClear", "%u", le16toh(identify->ServiceBusyClear));
|
||||
if(identify->SpecificConfiguration)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "SpecificConfiguration", DecodeSpecificConfiguration(le16toh(identify->SpecificConfiguration)));
|
||||
if(identify->StreamAccessLatency)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "StreamAccessLatency", "%u", le16toh(identify->StreamAccessLatency));
|
||||
if(identify->StreamMinReqSize)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "StreamMinReqSize", "%u", le16toh(identify->StreamMinReqSize));
|
||||
if(identify->StreamPerformanceGranularity)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "StreamPerformanceGranularity", "%u", le32toh(identify->StreamPerformanceGranularity));
|
||||
if(identify->StreamTransferTimeDMA)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "StreamTransferTimeDMA", "%u", le16toh(identify->StreamTransferTimeDMA));
|
||||
if(identify->StreamTransferTimePIO)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "StreamTransferTimePIO", "%u", le16toh(identify->StreamTransferTimePIO));
|
||||
if(identify->TransportMajorVersion)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "TransportMajorVersion", "%u", le16toh(identify->TransportMajorVersion));
|
||||
if(identify->TransportMinorVersion)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "TransportMinorVersion", "%u", le16toh(identify->TransportMinorVersion));
|
||||
if(identify->TrustedComputing)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "TrustedComputing", DecodeTrustedComputing(le16toh(identify->TrustedComputing)));
|
||||
if(identify->UDMAActive)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "UDMAActive", DecodeTransferMode(le16toh(identify->UDMAActive)));
|
||||
if(identify->UDMASupported)
|
||||
xmlTextWriterWriteElement(xmlWriter, BAD_CAST "UDMASupported", DecodeTransferMode(le16toh(identify->UDMASupported)));
|
||||
if(identify->WRVMode)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "WRVMode", "%u", identify->WRVMode);
|
||||
if(identify->WRVSectorCountMode3)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "WRVSectorCountMode3", "%u", le32toh(identify->WRVSectorCountMode3));
|
||||
if(identify->WRVSectorCountMode2)
|
||||
xmlTextWriterWriteFormatElement(xmlWriter, BAD_CAST "WRVSectorCountMode2", "%u", le32toh(identify->WRVSectorCountMode2));
|
||||
|
||||
xmlTextWriterStartElement(xmlWriter, BAD_CAST "Identify");
|
||||
xmlTextWriterWriteBase64(xmlWriter, atapi_ident, 0, 512);
|
||||
xmlTextWriterEndElement(xmlWriter);
|
||||
|
||||
xmlTextWriterEndElement(xmlWriter);
|
||||
}
|
||||
11
DiscImageChef.Device.Report/atapi_report.h
Normal file
11
DiscImageChef.Device.Report/atapi_report.h
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Created by claunia on 13/12/17.
|
||||
//
|
||||
|
||||
#ifndef DISCIMAGECHEF_DEVICE_REPORT_ATAPI_REPORT_H
|
||||
#define DISCIMAGECHEF_DEVICE_REPORT_ATAPI_REPORT_H
|
||||
|
||||
#include <libxml/xmlwriter.h>
|
||||
|
||||
void AtapiReport(int fd, xmlTextWriterPtr xmlWriter);
|
||||
#endif //DISCIMAGECHEF_DEVICE_REPORT_ATAPI_REPORT_H
|
||||
2406
DiscImageChef.Device.Report/identify_decode.c
Normal file
2406
DiscImageChef.Device.Report/identify_decode.c
Normal file
File diff suppressed because it is too large
Load Diff
27
DiscImageChef.Device.Report/identify_decode.h
Normal file
27
DiscImageChef.Device.Report/identify_decode.h
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Created by claunia on 14/12/17.
|
||||
//
|
||||
|
||||
#ifndef DISCIMAGECHEF_DEVICE_REPORT_IDENTIFY_DECODE_H
|
||||
#define DISCIMAGECHEF_DEVICE_REPORT_IDENTIFY_DECODE_H
|
||||
char *DecodeGeneralConfiguration(uint16_t configuration);
|
||||
char *DecodeTransferMode(uint16_t transferMode);
|
||||
char *DecodeCapabilities(uint16_t capabilities);
|
||||
char *DecodeCapabilities2(uint16_t capabilities);
|
||||
char *DecodeCapabilities3(uint8_t capabilities);
|
||||
char *DecodeCommandSet(uint16_t commandset);
|
||||
char *DecodeCommandSet2(uint16_t commandset);
|
||||
char *DecodeCommandSet3(uint16_t commandset);
|
||||
char *DecodeCommandSet4(uint16_t commandset);
|
||||
char *DecodeCommandSet5(uint16_t commandset);
|
||||
char *DecodeDataSetMgmt(uint16_t datasetmgmt);
|
||||
char *DecodeDeviceFormFactor(uint16_t formfactor);
|
||||
char *DecodeSATAFeatures(uint16_t features);
|
||||
char *DecodeMajorVersion(uint16_t capabilities);
|
||||
char *DecodeSATACapabilities(uint16_t capabilities);
|
||||
char *DecodeSATACapabilities2(uint16_t transport);
|
||||
char *DecodeSCTCommandTransport(uint16_t transport);
|
||||
char *DecodeSecurityStatus(uint16_t status);
|
||||
char *DecodeSpecificConfiguration(uint16_t configuration);
|
||||
char *DecodeTrustedComputing(uint16_t trutedcomputing);
|
||||
#endif //DISCIMAGECHEF_DEVICE_REPORT_IDENTIFY_DECODE_H
|
||||
@@ -8,13 +8,17 @@
|
||||
#include "ata.h"
|
||||
#include "main.h"
|
||||
#include "atapi.h"
|
||||
#include "atapi_report.h"
|
||||
#include <libxml/xmlwriter.h>
|
||||
|
||||
#define DIC_VERSION "3.99.6.0"
|
||||
#define DIC_COPYRIGHT "Copyright © 2011-2017 Natalia Portillo"
|
||||
#define XML_ENCODING "UTF-8"
|
||||
#define DIC_REPORT_ROOT "DicDeviceReport"
|
||||
|
||||
int main(int argc, void *argv[])
|
||||
{
|
||||
int fd;
|
||||
int fd, rc;
|
||||
unsigned char *scsi_sense = NULL;
|
||||
unsigned char *scsi_inq_data = NULL;
|
||||
unsigned char *ata_ident = NULL;
|
||||
@@ -25,6 +29,8 @@ int main(int argc, void *argv[])
|
||||
unsigned char* product;
|
||||
unsigned char* revision;
|
||||
int deviceType = DEVICE_TYPE_UNKNOWN;
|
||||
char* xmlFilename = malloc(NAME_MAX + 1);
|
||||
xmlTextWriterPtr xmlWriter;
|
||||
|
||||
printf("The Disc Image Chef Device Reporter for Linux %s\n", DIC_VERSION);
|
||||
printf("%s\n", DIC_COPYRIGHT);
|
||||
@@ -89,6 +95,53 @@ int main(int argc, void *argv[])
|
||||
printf("Product: %s\n", product);
|
||||
printf("Revision: %s\n", revision);
|
||||
|
||||
if(deviceType != DEVICE_TYPE_ATA && deviceType!=DEVICE_TYPE_ATAPI && deviceType != DEVICE_TYPE_SCSI)
|
||||
{
|
||||
printf("Unsupported device type %s.", DeviceType[deviceType]);
|
||||
return 3;
|
||||
}
|
||||
|
||||
sprintf(xmlFilename, "%s_%s_%s.xml", manufacturer, product, revision);
|
||||
|
||||
xmlWriter = xmlNewTextWriterFilename(xmlFilename, 0);
|
||||
if(xmlWriter == NULL)
|
||||
{
|
||||
printf("Could not create XML report file.\n");
|
||||
return 4;
|
||||
}
|
||||
|
||||
rc = xmlTextWriterStartDocument(xmlWriter, NULL, XML_ENCODING, NULL);
|
||||
if(rc < 0)
|
||||
{
|
||||
printf("Could not create XML report file.\n");
|
||||
return 4;
|
||||
}
|
||||
|
||||
rc = xmlTextWriterStartElement(xmlWriter, BAD_CAST DIC_REPORT_ROOT);
|
||||
if(rc < 0)
|
||||
{
|
||||
printf("Could not create XML report file.\n");
|
||||
return 4;
|
||||
}
|
||||
|
||||
char* xmlComment = malloc(255);
|
||||
sprintf(xmlComment, "Report created with DiscImageChef.Device.Report v%s", DIC_VERSION);
|
||||
rc = xmlTextWriterWriteComment(xmlWriter, xmlComment);
|
||||
if(rc < 0)
|
||||
{
|
||||
printf("Could not create XML report file.\n");
|
||||
return 4;
|
||||
}
|
||||
|
||||
if(deviceType == DEVICE_TYPE_ATAPI)
|
||||
AtapiReport(fd, xmlWriter);
|
||||
|
||||
rc = xmlTextWriterEndDocument(xmlWriter);
|
||||
if (rc < 0) {
|
||||
printf("Could not close XML report file.\n");
|
||||
return 4;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user