Merge branch 'master' of ssh://webhost.codesrc.com/home/michael/projects/SCSI2SD
[SCSI2SD.git] / software / SCSI2SD / src / cdrom.c
index 44d03a3..1c9305f 100755 (executable)
@@ -14,6 +14,8 @@
 //
 //     You should have received a copy of the GNU General Public License
 //     along with SCSI2SD.  If not, see <http://www.gnu.org/licenses/>.
+#pragma GCC push_options
+#pragma GCC optimize("-flto")
 
 #include "device.h"
 #include "scsi.h"
@@ -275,50 +277,43 @@ int scsiCDRomCommand()
        int commandHandled = 1;
 
        uint8 command = scsiDev.cdb[0];
-       if (scsiDev.target->cfg->deviceType == CONFIG_OPTICAL)
+       if (command == 0x43)
        {
-               if (command == 0x43)
-               {
-                       // CD-ROM Read TOC
-                       int MSF = scsiDev.cdb[1] & 0x02 ? 1 : 0;
-                       uint8_t track = scsiDev.cdb[6];
-                       uint16_t allocationLength =
-                               (((uint32_t) scsiDev.cdb[7]) << 8) +
-                               scsiDev.cdb[8];
+               // CD-ROM Read TOC
+               int MSF = scsiDev.cdb[1] & 0x02 ? 1 : 0;
+               uint8_t track = scsiDev.cdb[6];
+               uint16_t allocationLength =
+                       (((uint32_t) scsiDev.cdb[7]) << 8) +
+                       scsiDev.cdb[8];
 
-                       // Reject MMC commands for now, otherwise the TOC data format
-                       // won't be understood.
-                       // The "format" field is reserved for SCSI-2
-                       uint8_t format = scsiDev.cdb[2] & 0x0F;
-                       switch (format)
+               // Reject MMC commands for now, otherwise the TOC data format
+               // won't be understood.
+               // The "format" field is reserved for SCSI-2
+               uint8_t format = scsiDev.cdb[2] & 0x0F;
+               switch (format)
+               {
+                       case 0: doReadTOC(MSF, track, allocationLength); break; // SCSI-2
+                       case 1: doReadSessionInfo(MSF, allocationLength); break; // MMC2
+                       case 2: doReadFullTOC(0, track, allocationLength); break; // MMC2
+                       case 3: doReadFullTOC(1, track, allocationLength); break; // MMC2
+                       default:
                        {
-                               case 0: doReadTOC(MSF, track, allocationLength); break; // SCSI-2
-                               case 1: doReadSessionInfo(MSF, allocationLength); break; // MMC2
-                               case 2: doReadFullTOC(0, track, allocationLength); break; // MMC2
-                               case 3: doReadFullTOC(1, track, allocationLength); break; // MMC2
-                               default:
-                               {
-                                       scsiDev.status = CHECK_CONDITION;
-                                       scsiDev.target->sense.code = ILLEGAL_REQUEST;
-                                       scsiDev.target->sense.asc = INVALID_FIELD_IN_CDB;
-                                       scsiDev.phase = STATUS;
-                               }
+                               scsiDev.status = CHECK_CONDITION;
+                               scsiDev.target->sense.code = ILLEGAL_REQUEST;
+                               scsiDev.target->sense.asc = INVALID_FIELD_IN_CDB;
+                               scsiDev.phase = STATUS;
                        }
                }
-               else if (command == 0x44)
-               {
-                       // CD-ROM Read Header
-                       int MSF = scsiDev.cdb[1] & 0x02 ? 1 : 0;
-                       uint32_t lba = 0; // IGNORED for now
-                       uint16_t allocationLength =
-                               (((uint32_t) scsiDev.cdb[7]) << 8) +
-                               scsiDev.cdb[8];
-                       doReadHeader(MSF, lba, allocationLength);
-               }
-               else
-               {
-                       commandHandled = 0;
-               }
+       }
+       else if (command == 0x44)
+       {
+               // CD-ROM Read Header
+               int MSF = scsiDev.cdb[1] & 0x02 ? 1 : 0;
+               uint32_t lba = 0; // IGNORED for now
+               uint16_t allocationLength =
+                       (((uint32_t) scsiDev.cdb[7]) << 8) +
+                       scsiDev.cdb[8];
+               doReadHeader(MSF, lba, allocationLength);
        }
        else
        {
@@ -327,3 +322,5 @@ int scsiCDRomCommand()
 
        return commandHandled;
 }
+
+#pragma GCC pop_options