From 4058457e524a255ed4ba4a3847c74d8613bb3c34 Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 8 Jul 2004 06:29:45 +0000 Subject: [PATCH] Sun drive capabilities improved. Sun and Windows ASPI use common MODE_SENSE defines defines now. --- include/cdio/scsi_mmc.h | 3 ++- lib/MSWindows/aspi32.c | 14 +++++++------- lib/MSWindows/aspi32.h | 10 +--------- lib/_cdio_sunos.c | 42 +++++++++++++++++++++++++++++++---------- 4 files changed, 42 insertions(+), 27 deletions(-) diff --git a/include/cdio/scsi_mmc.h b/include/cdio/scsi_mmc.h index 60de66f3..ef62179b 100644 --- a/include/cdio/scsi_mmc.h +++ b/include/cdio/scsi_mmc.h @@ -1,5 +1,5 @@ /* - $Id: scsi_mmc.h,v 1.6 2004/07/08 01:27:59 rocky Exp $ + $Id: scsi_mmc.h,v 1.7 2004/07/08 06:29:45 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -54,6 +54,7 @@ #define CDIO_MMC_R_W_ERROR_PAGE 0x01 #define CDIO_MMC_WRITE_PARMS_PAGE 0x05 #define CDIO_MMC_AUDIO_CTL_PAGE 0x0e +#define CDIO_MMC_CDR_PARMS_PAGE 0x0d #define CDIO_MMC_POWER_PAGE 0x1a #define CDIO_MMC_FAULT_FAIL_PAGE 0x1c #define CDIO_MMC_TO_PROTECT_PAGE 0x1d diff --git a/lib/MSWindows/aspi32.c b/lib/MSWindows/aspi32.c index 998ca855..6c95f943 100644 --- a/lib/MSWindows/aspi32.c +++ b/lib/MSWindows/aspi32.c @@ -1,5 +1,5 @@ /* - $Id: aspi32.c,v 1.13 2004/07/08 01:28:01 rocky Exp $ + $Id: aspi32.c,v 1.14 2004/07/08 06:30:01 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: aspi32.c,v 1.13 2004/07/08 01:28:01 rocky Exp $"; +static const char _rcsid[] = "$Id: aspi32.c,v 1.14 2004/07/08 06:30:01 rocky Exp $"; #include #include @@ -746,12 +746,12 @@ get_drive_cap_aspi (const _img_private_t *env) which = p[0] & 0x3F; switch( which ) { - case CDRAUDIOCTL: - case READERRREC: - case CDRPARMS: - /* Don't handle theses yet. */ + case CDIO_MMC_AUDIO_CTL_PAGE: + case CDIO_MMC_R_W_ERROR_PAGE: + case CDIO_MMC_CDR_PARMS_PAGE: + /* Don't handle these yet. */ break; - case CDRCAPS: + case CDIO_MMC_CAPABILITIES_PAGE: i_drivetype |= cdio_get_drive_cap_mmc(p); break; default: ; diff --git a/lib/MSWindows/aspi32.h b/lib/MSWindows/aspi32.h index c56d5cb0..2315a6ab 100644 --- a/lib/MSWindows/aspi32.h +++ b/lib/MSWindows/aspi32.h @@ -1,6 +1,6 @@ /* Win32 aspi specific */ /* - $Id: aspi32.h,v 1.3 2004/06/28 00:24:03 rocky Exp $ + $Id: aspi32.h,v 1.4 2004/07/08 06:30:17 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -145,14 +145,6 @@ struct SRB_ExecSCSICmd unsigned char SenseArea[SENSE_LEN+2]; }; -/*! - Values and structures used in MODE SENSE 10 command. -*/ -#define READERRREC 0x01 -#define CDRPARMS 0x0D -#define CDRAUDIOCTL 0x0E -#define CDRCAPS 0x2A - /***************************************************************************** %%% SRB - HOST ADAPTER INQUIRY - SC_HA_INQUIRY (0) %%% *****************************************************************************/ diff --git a/lib/_cdio_sunos.c b/lib/_cdio_sunos.c index 4e6b8212..e5cd5a53 100644 --- a/lib/_cdio_sunos.c +++ b/lib/_cdio_sunos.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_sunos.c,v 1.43 2004/07/08 05:19:27 rocky Exp $ + $Id: _cdio_sunos.c,v 1.44 2004/07/08 06:29:58 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -38,7 +38,7 @@ #ifdef HAVE_SOLARIS_CDROM -static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.43 2004/07/08 05:19:27 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.44 2004/07/08 06:29:58 rocky Exp $"; #ifdef HAVE_GLOB_H #include @@ -517,26 +517,48 @@ _cdio_get_drive_cap_solaris (const void *user_data) memset(&my_rq_buf, 0, sizeof(my_rq_buf)); /* Initialize my_scsi_cdb as a Mode Select(6) */ - CDIO_MMC_SET_COMMAND(my_scsi_cdb, CDIO_MMC_GPCMD_MODE_SENSE); + CDIO_MMC_SET_COMMAND(my_scsi_cdb, CDIO_MMC_GPCMD_MODE_SENSE_10); my_scsi_cdb[1] = 0x0; - my_scsi_cdb[2] = CDIO_MMC_CAPABILITIES_PAGE; - my_scsi_cdb[3] = 0; /* Not used */ - my_scsi_cdb[4] = 128; - my_scsi_cdb[5] = 0; /* Not used */ + my_scsi_cdb[2] = CDIO_MMC_ALL_PAGES; + my_scsi_cdb[7] = 0x01; + my_scsi_cdb[8] = 0x00; my_cmd.uscsi_flags = (USCSI_READ|USCSI_RQENABLE); /* We're going get data */ my_cmd.uscsi_timeout = 15; /* Allow 15 seconds for completion */ my_cmd.uscsi_cdb = my_scsi_cdb; /* We'll be using the array above for the CDB */ my_cmd.uscsi_bufaddr = buf; /* The block and page data is stored here */ my_cmd.uscsi_buflen = sizeof(buf); - my_cmd.uscsi_cdblen = 6; /* The CDB is 6 bytes long */ + my_cmd.uscsi_cdblen = 12; my_cmd.uscsi_rqlen = 24; /* The request sense buffer (only valid on a check condition) is 26 bytes long */ my_cmd.uscsi_rqbuf = my_rq_buf; /* Pointer to the request sense buffer */ rc = ioctl(env->gen.fd, USCSICMD, &my_cmd); if(rc == 0) { - unsigned int n=buf[3]+4; - i_drivetype |= cdio_get_drive_cap_mmc(&(buf[n])); + uint8_t *p; + int lenData = ((unsigned int)buf[0] << 8) + buf[1]; + uint8_t *pMax = buf + 256; + + i_drivetype = 0; + /* set to first sense mask, and then walk through the masks */ + p = buf + 8; + while( (p < &(buf[2+lenData])) && (p < pMax) ) { + uint8_t which; + + which = p[0] & 0x3F; + switch( which ) + { + case CDIO_MMC_AUDIO_CTL_PAGE: + case CDIO_MMC_R_W_ERROR_PAGE: + case CDIO_MMC_CDR_PARMS_PAGE: + /* Don't handle these yet. */ + break; + case CDIO_MMC_CAPABILITIES_PAGE: + i_drivetype |= cdio_get_drive_cap_mmc(p); + break; + default: ; + } + p += (p[1] + 2); + } } else { cdio_info("%s: %s\n", "error in ioctl USCSICMD MODE_SELECT", strerror(errno));