Ticket #482: PL2773_DataOut_ver1.patch

File PL2773_DataOut_ver1.patch, 5.3 KB (added by TomVe, 9 years ago)

Patch against SVN rev. 4009

  • scsiata.cpp

     
    11531153bool usbprolific_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out)
    11541154{
    11551155  if (!ata_cmd_is_supported(in,
    1156 //    ata_device::supports_data_out |       // Does not work - better disable for now
     1156    ata_device::supports_data_out |
    11571157    ata_device::supports_48bit_hi_null |
     1158    ata_device::supports_output_regs |
    11581159    ata_device::supports_smart_status,
    11591160    "Prolific" )
    11601161  )
     
    11621163
    11631164  scsi_cmnd_io io_hdr;
    11641165  memset(&io_hdr, 0, sizeof(io_hdr));
     1166  unsigned char cmd_rw = 0x10;  // Read
    11651167
    11661168  switch (in.direction) {
    11671169    case ata_cmd_in::no_data:
     
    11771179      io_hdr.dxfer_dir = DXFER_TO_DEVICE;
    11781180      io_hdr.dxfer_len = in.size;
    11791181      io_hdr.dxferp = (unsigned char *)in.buffer;
     1182      cmd_rw = 0x0; // Write
    11801183      break;
    11811184    default:
    11821185      return set_err(EINVAL);
     
    11911194  // D8 15 0 D1 06 7B 0 0 2 0 1 1 4F C2 A0 B0     // SMART Read thresholds
    11921195  // D8 15 0 D4 06 7B 0 0 0 0 0 1 4F C2 A0 B0     // SMART Execute self test
    11931196  // D7  0 0  0 06 7B 0 0 0 0 0 0 0 0 0 0         // Read status registers, Reads 16 bytes of data
     1197  // Additional DATA OUT support based on document from Prolific
    11941198
    11951199  // Build pass through command
    11961200  unsigned char cdb[16];
    1197   cdb[ 0] = 0xD8;  // Prolific ATA pass through? (OPERATION CODE)
    1198   cdb[ 1] = 0x15;  // Magic?
    1199   cdb[ 2] = 0x0;   // Always 0?
    1200   cdb[ 3] = in.in_regs.features;        // SMART command
    1201   cdb[ 4] = 0x06;  // VendorID magic? (Prolific VendorID: 0x067B)
    1202   cdb[ 5] = 0x7B;  // VendorID magic? (Prolific VendorID: 0x067B)
    1203   cdb[ 6] = 0;     // Always 0?
    1204   cdb[ 7] = 0;     // Always 0?
    1205   cdb[ 8] = (unsigned char)(io_hdr.dxfer_len >> 8);     // 2 when reading a sector
    1206   cdb[ 9] = (unsigned char)(io_hdr.dxfer_len     );     // Always 0? - Seems ok
    1207   cdb[10] = in.in_regs.sector_count;    // 0 when starting selftest
    1208   cdb[11] = in.in_regs.lba_low;         // LBA(7:0)   - Works for Log Address!
    1209   cdb[12] = in.in_regs.lba_mid;         // LBA(15:8)  - 0x4F
    1210   cdb[13] = in.in_regs.lba_high;        // LBA(23:16) - 0xC2
    1211   cdb[14] = 0xA0;                       // Is A0 for both drives attached
    1212   cdb[15] = in.in_regs.command;         // ATA command
     1201  cdb[ 0] = 0xD8;         // Operation Code (D8 = Prolific ATA pass through)
     1202  cdb[ 1] = cmd_rw|0x5;   // Read(0x10)/Write(0x0) | NORMAL(0x5)/PREFIX(0x0)(?)
     1203  cdb[ 2] = 0x0;          // Reserved
     1204  cdb[ 3] = in.in_regs.features;        // Feature register (SMART command)
     1205  cdb[ 4] = 0x06;         // Check Word (VendorID magic, Prolific: 0x067B)
     1206  cdb[ 5] = 0x7B;         // Check Word (VendorID magic, Prolific: 0x067B)
     1207  cdb[ 6] = (unsigned char)(io_hdr.dxfer_len >> 24);  // Length MSB
     1208  cdb[ 7] = (unsigned char)(io_hdr.dxfer_len >> 16);  // Length ...
     1209  cdb[ 8] = (unsigned char)(io_hdr.dxfer_len >>  8);  // Length ...
     1210  cdb[ 9] = (unsigned char)(io_hdr.dxfer_len      );  // Length LSB
     1211  cdb[10] = in.in_regs.sector_count;    // Sector Count
     1212  cdb[11] = in.in_regs.lba_low;         // LBA Low (7:0)
     1213  cdb[12] = in.in_regs.lba_mid;         // LBA Mid (15:8)
     1214  cdb[13] = in.in_regs.lba_high;        // LBA High (23:16)
     1215  cdb[14] = in.in_regs.device | 0xA0;   // Device/Head
     1216  cdb[15] = in.in_regs.command;         // ATA Command Register (only PIO supported)
    12131217  // Use '-r scsiioctl,1' to print CDB for debug purposes
    12141218
    12151219  io_hdr.cmnd = cdb;
     
    12291233    io_hdr.dxferp = regbuf;
    12301234
    12311235    memset(cdb, 0, sizeof(cdb));
    1232     cdb[ 0] = 0xD7;  // Prolific read registers?
    1233     cdb[ 4] = 0x06;  // VendorID magic? (Prolific VendorID: 0x067B)
    1234     cdb[ 5] = 0x7B;  // VendorID magic? (Prolific VendorID: 0x067B)
     1236    cdb[ 0] = 0xD7;  // Prolific read registers
     1237    cdb[ 4] = 0x06;  // Check Word (VendorID magic, Prolific: 0x067B)
     1238    cdb[ 5] = 0x7B;  // Check Word (VendorID magic, Prolific: 0x067B)
    12351239    io_hdr.cmnd = cdb;
    12361240    io_hdr.cmnd_len = sizeof(cdb);
    12371241
     
    12411245
    12421246    // Use '-r scsiioctl,2' to print input registers for debug purposes
    12431247    // Example: 50 00 00 00 00 01 4f 00  c2 00 a0 da 00 b0 00 50
    1244     // out.out_regs.status       = regbuf[0];  // Guess: Was seen go 51 to indicate error
    1245     // out.out_regs.error        = regbuf[1];  // Guess: Was seen go 04 to indicate ABRT
    1246     // out.out_regs.sector_count = regbuf[X];  // Not found...
    1247     out.out_regs.lba_low      = regbuf[4];  // Found by testing Log Address
    1248     out.out_regs.lba_mid      = regbuf[6];  // Needed for SMART STATUS
    1249     out.out_regs.lba_high     = regbuf[8];  // Needed for SMART STATUS
    1250     out.out_regs.device       = regbuf[10]; // Always A0?
    1251     //                           = regbuf[11]; // ATA Feature
    1252     //                           = regbuf[13]; // ATA Command
     1248    out.out_regs.status       = regbuf[0];  // Status
     1249    out.out_regs.error        = regbuf[1];  // Error
     1250    out.out_regs.sector_count = regbuf[2];  // Sector Count (7:0)
     1251    out.out_regs.lba_low      = regbuf[4];  // LBA Low (7:0)
     1252    out.out_regs.lba_mid      = regbuf[6];  // LBA Mid (7:0)
     1253    out.out_regs.lba_high     = regbuf[8];  // LBA High (7:0)
     1254    out.out_regs.device       = regbuf[10]; // Device/Head
     1255    //                          = regbuf[11]; // ATA Feature (7:0)
     1256    //                          = regbuf[13]; // ATA Command
    12531257  }
    12541258
    12551259  return true;