Diff for /np2/cbus/atapicmd.c between versions 1.4 and 1.7

version 1.4, 2005/03/05 11:58:02 version 1.7, 2005/04/05 13:48:09
Line 17 Line 17
 #include        "atapicmd.h"  #include        "atapicmd.h"
 #include        "sxsi.h"  #include        "sxsi.h"
   
   #define YUIDEBUG
   
   
 // INQUIRY  // INQUIRY
 static const UINT8 cdrom_inquiry[] = {  static const UINT8 cdrom_inquiry[] = {
   #ifdef YUIDEBUG
           // うちのドライブの奴 NECCDは Product Level 3.00以上で modesense10のコードがちげー
           0x05,   // CD-ROM
           0x80,   // bit7: Removable Medium Bit, other: Reserved
           0x00,   // version [7-6: ISO, ECMA: 5-3, 2-0: ANSI(00)]
           0x21,   // 7-4: ATAPI version, 3-0: Response Data Format
           0x1f,   // Additional length
           0x00,0x00,0x00, // Reserved
           'N', 'E', 'C', ' ', ' ', ' ', ' ', ' ', // Vendor ID
           'C', 'D', '-', 'R', 'O', 'M', ' ', 'D', // Product ID
           'R', 'I', 'V', 'E', ':', '2', '5', '1', // Product ID
           '4', '.', '0', '9'      // Product Revision Level
   #else
         0x05,   // CD-ROM          0x05,   // CD-ROM
         0x80,   // bit7: Removable Medium Bit, other: Reserved          0x80,   // bit7: Removable Medium Bit, other: Reserved
         0x00,   // version [7-6: ISO, ECMA: 5-3, 2-0: ANSI(00)]          0x00,   // version [7-6: ISO, ECMA: 5-3, 2-0: ANSI(00)]
Line 30  static const UINT8 cdrom_inquiry[] = { Line 45  static const UINT8 cdrom_inquiry[] = {
         'C', 'D', '-', 'R', 'O', 'M', ' ', 'D', // Product ID          'C', 'D', '-', 'R', 'O', 'M', ' ', 'D', // Product ID
         'R', 'I', 'V', 'E', ' ', ' ', ' ', ' ', // Product ID          'R', 'I', 'V', 'E', ' ', ' ', ' ', ' ', // Product ID
         '1', '.', '0', ' '      // Product Revision Level          '1', '.', '0', ' '      // Product Revision Level
   #endif
 };  };
   
 static void senddata(IDEDRV drv, UINT size, UINT limit) {  static void senddata(IDEDRV drv, UINT size, UINT limit) {
Line 99  static void atapi_cmd_read_capacity(IDED Line 115  static void atapi_cmd_read_capacity(IDED
 static void atapi_cmd_read(IDEDRV drv, UINT32 lba, UINT32 leng);  static void atapi_cmd_read(IDEDRV drv, UINT32 lba, UINT32 leng);
 static void atapi_cmd_mode_select(IDEDRV drv);  static void atapi_cmd_mode_select(IDEDRV drv);
 static void atapi_cmd_mode_sense(IDEDRV drv);  static void atapi_cmd_mode_sense(IDEDRV drv);
   static void atapi_cmd_readsubch(IDEDRV drv);
 static void atapi_cmd_readtoc(IDEDRV drv);  static void atapi_cmd_readtoc(IDEDRV drv);
   
 void atapicmd_a0(IDEDRV drv) {  void atapicmd_a0(IDEDRV drv) {
Line 178  void atapicmd_a0(IDEDRV drv) { Line 195  void atapicmd_a0(IDEDRV drv) {
                 atapi_cmd_mode_sense(drv);                  atapi_cmd_mode_sense(drv);
                 break;                  break;
   
           case 0x42:
                   TRACEOUT(("atapicmd: read sub channel"));
                   atapi_cmd_readsubch(drv);
                   break;
   
         case 0x43:              // read TOC          case 0x43:              // read TOC
                 TRACEOUT(("atapicmd: read TOC"));                  TRACEOUT(("atapicmd: read TOC"));
                 atapi_cmd_readtoc(drv);                  atapi_cmd_readtoc(drv);
Line 318  static const BYTE defval_pagecode_0e[PC_ Line 340  static const BYTE defval_pagecode_0e[PC_
         0x0e, 0x0e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x4b,          0x0e, 0x0e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x4b,
         0x01, 0xff, 0x02, 0xff, 0x00, 0x00, 0x00, 0x00,          0x01, 0xff, 0x02, 0xff, 0x00, 0x00, 0x00, 0x00,
 };  };
   
 static const BYTE defval_pagecode_2a[PC_2A_SIZE] = {  static const BYTE defval_pagecode_2a[PC_2A_SIZE] = {
   #ifdef YUIDEBUG
           0x2a, 0x12, 0x00, 0x00, 0x71, 0x65, 0x89, 0x07,
           0x02, 0xc2, 0x00, 0xff, 0x00, 0x80, 0x02, 0xc2,
           0x00, 0x00, 0x00, 0x00,
   #else
         0x2a, 0x12, 0x00, 0x00, 0x00, 0x00, 0x20, 0x03,          0x2a, 0x12, 0x00, 0x00, 0x00, 0x00, 0x20, 0x03,
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00,          0x00, 0x00, 0x00, 0x00,
   #endif
 };  };
   
 // 0x55: MODE SELECT  // 0x55: MODE SELECT
Line 364  static void atapi_cmd_mode_sense(IDEDRV  Line 393  static void atapi_cmd_mode_sense(IDEDRV 
         if (!(drv->media & IDEIO_MEDIA_LOADED)) {          if (!(drv->media & IDEIO_MEDIA_LOADED)) {
                 drv->buf[2] = 0x70;     // Door closed, no disc present                  drv->buf[2] = 0x70;     // Door closed, no disc present
         }          }
           else if ((drv->media & (IDEIO_MEDIA_COMBINE)) == IDEIO_MEDIA_AUDIO) {
                   drv->buf[2] = 0x02;     // 120mm CD-ROM audio only
           }
           else if ((drv->media & (IDEIO_MEDIA_COMBINE)) == IDEIO_MEDIA_COMBINE) {
                   drv->buf[2] = 0x03;     // 120mm CD-ROM data & audio combined
           }
         else {          else {
                 drv->buf[2] = 0x00;     // 120mm CD-ROM data only                  drv->buf[2] = 0x01;     // 120mm CD-ROM data only
         }          }
         cnt = 8;          cnt = 8;
         if (cnt > leng) {          if (cnt > leng) {
Line 441  static void atapi_cmd_mode_sense(IDEDRV  Line 476  static void atapi_cmd_mode_sense(IDEDRV 
                 if (cnt > leng) {                  if (cnt > leng) {
                         goto length_exceeded;                          goto length_exceeded;
                 }                  }
   #if 0
                   /*FALLTHROUGH*/
   
           case 0x00:
   #endif
                 break;                  break;
   
         default:          default:
Line 468  length_exceeded: Line 508  length_exceeded:
         senddata(drv, cnt, leng);          senddata(drv, cnt, leng);
 }  }
   
 static void atapi_cmd_readtoc(IDEDRV drv) {  
   
   static void atapi_cmd_readsubch(IDEDRV drv) {
   
           SXSIDEV sxsi;
         UINT    leng;          UINT    leng;
         UINT    format;  
   
           sxsi = sxsi_getptr(drv->sxsidrv);
           if ((sxsi == NULL) || (sxsi->devtype != SXSIDEV_CDROM) ||
                   (!(sxsi->flag & SXSIFLAG_READY))) {
                   senderror(drv);
                   return;
           }
         leng = (drv->buf[7] << 8) + drv->buf[8];          leng = (drv->buf[7] << 8) + drv->buf[8];
         format = (drv->buf[9] >> 6);          switch(drv->buf[3]) {
         TRACEOUT(("atapi_cmd_readtoc fmt=%d leng=%d", format, leng));                  case 0x01:                      // CD-ROM current pos
         switch(format) {                          ZeroMemory(drv->buf, 16);
                 case 1: // multi session                          drv->buf[4] = 0x01;
                         ZeroMemory(drv->buf, 12);                          senddata(drv, 16, leng);
                         drv->buf[1] = 0x0a;  
                         drv->buf[2] = 0x01;  
                         drv->buf[3] = 0x01;  
                         senddata(drv, 12, leng);  
                         break;                          break;
   
                 default:                  default:
Line 491  static void atapi_cmd_readtoc(IDEDRV drv Line 534  static void atapi_cmd_readtoc(IDEDRV drv
         }          }
 }  }
   
   static void atapi_cmd_readtoc(IDEDRV drv) {
   
           SXSIDEV sxsi;
           UINT    leng;
           UINT    format;
           UINT    datasize;
   
           sxsi = sxsi_getptr(drv->sxsidrv);
           if ((sxsi == NULL) || (sxsi->devtype != SXSIDEV_CDROM) ||
                   (!(sxsi->flag & SXSIFLAG_READY))) {
                   senderror(drv);
                   return;
           }
   
           leng = (drv->buf[7] << 8) + drv->buf[8];
           format = (drv->buf[9] >> 6);
           TRACEOUT(("atapi_cmd_readtoc fmt=%d leng=%d", format, leng));
   
           switch (format) {
           case 0: // track info
                   datasize = sxsicd_gettocinfo(sxsi, drv->buf + 2);
                   drv->buf[0] = (UINT8)(datasize >> 8);
                   drv->buf[1] = (UINT8)(datasize >> 0);
                   senddata(drv, datasize + 2, leng);
                   break;
   
           case 1: // multi session
                   ZeroMemory(drv->buf, 12);
                   drv->buf[1] = 0x0a;
                   drv->buf[2] = 0x01;
                   drv->buf[3] = 0x01;
                   drv->buf[5] = 0x14;
                   drv->buf[6] = 0x01;
                   drv->buf[10] = 0x02;
                   senddata(drv, 12, leng);
                   break;
   
           default:
                   senderror(drv);
                   break;
           }
   }
   
 #endif  /* SUPPORT_IDEIO */  #endif  /* SUPPORT_IDEIO */

Removed from v.1.4  
changed lines
  Added in v.1.7


RetroPC.NET-CVS <cvs@retropc.net>