Add common SCSI MMC routine for getting drive capabilities.

This commit is contained in:
rocky
2004-06-27 22:00:08 +00:00
parent 878bdc80da
commit f313c9f68b
4 changed files with 32 additions and 35 deletions

View File

@@ -1,5 +1,5 @@
/* /*
$Id: scsi_mmc.h,v 1.4 2004/06/26 01:08:46 rocky Exp $ $Id: scsi_mmc.h,v 1.5 2004/06/27 22:00:08 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -48,6 +48,18 @@
#define CDIO_MMC_GPCMD_READ_CD 0xbe #define CDIO_MMC_GPCMD_READ_CD 0xbe
#define CDIO_MMC_GPCMD_READ_MSF 0xb9 #define CDIO_MMC_GPCMD_READ_MSF 0xb9
/*! Page codes for MODE SENSE and MODE SET. */
#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_POWER_PAGE 0x1a
#define CDIO_MMC_FAULT_FAIL_PAGE 0x1c
#define CDIO_MMC_TO_PROTECT_PAGE 0x1d
#define CDIO_MMC_CAPABILITIES_PAGE 0x2a
#define CDIO_MMC_ALL_PAGES 0x3f
/*! This is listed as optional in ATAPI 2.6, but is (curiously) /*! This is listed as optional in ATAPI 2.6, but is (curiously)
missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji
Table 377 as an MMC command for SCSi devices though... Most ATAPI Table 377 as an MMC command for SCSi devices though... Most ATAPI
@@ -81,4 +93,11 @@
#define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(rec, val) \ #define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(rec, val) \
rec[9] = val; rec[9] = val;
/*!
On input A MODE_SENSE command was issued and we have the results
in p. We interpret this and return a bit mask set according to the
capabilities.
*/
cdio_drive_cap_t cdio_get_drive_cap_mmc(const uint8_t *p);
#endif /* __SCSI_MMC_H__ */ #endif /* __SCSI_MMC_H__ */

View File

@@ -1,5 +1,5 @@
/* /*
$Id: freebsd_cam.c,v 1.13 2004/06/25 20:49:56 rocky Exp $ $Id: freebsd_cam.c,v 1.14 2004/06/27 22:00:09 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.13 2004/06/25 20:49:56 rocky Exp $"; static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.14 2004/06/27 22:00:09 rocky Exp $";
#ifdef HAVE_FREEBSD_CDROM #ifdef HAVE_FREEBSD_CDROM
@@ -173,7 +173,7 @@ static cdio_drive_cap_t
get_drive_cap_freebsd_cam (img_private_t *env) get_drive_cap_freebsd_cam (img_private_t *env)
{ {
int32_t i_drivetype = 0; int32_t i_drivetype = 0;
char buf[192] = { 0, }; uint8_t buf[192] = { 0, };
int rc; int rc;
memset(&env->ccb, 0, sizeof(env->ccb)); memset(&env->ccb, 0, sizeof(env->ccb));
@@ -188,7 +188,8 @@ get_drive_cap_freebsd_cam (img_private_t *env)
/* Initialize my_scsi_cdb as a Mode Select(6) */ /* Initialize my_scsi_cdb as a Mode Select(6) */
CDIO_MMC_SET_COMMAND(env->ccb.csio.cdb_io.cdb_bytes, CDIO_MMC_MODE_SENSE); CDIO_MMC_SET_COMMAND(env->ccb.csio.cdb_io.cdb_bytes, CDIO_MMC_MODE_SENSE);
env->ccb.csio.cdb_io.cdb_bytes[1] = 0x0; env->ccb.csio.cdb_io.cdb_bytes[1] = 0x0;
env->ccb.csio.cdb_io.cdb_bytes[2] = 0x2a; /* MODE_PAGE_CAPABILITIES*/ /* use ALL_PAGES?*/
env->ccb.csio.cdb_io.cdb_bytes[2] = CDIO_MMC_CAPABILITIES_PAGE;
env->ccb.csio.cdb_io.cdb_bytes[3] = 0; /* Not used */ env->ccb.csio.cdb_io.cdb_bytes[3] = 0; /* Not used */
env->ccb.csio.cdb_io.cdb_bytes[4] = 128; env->ccb.csio.cdb_io.cdb_bytes[4] = 128;
env->ccb.csio.cdb_io.cdb_bytes[5] = 0; /* Not used */ env->ccb.csio.cdb_io.cdb_bytes[5] = 0; /* Not used */
@@ -202,19 +203,7 @@ get_drive_cap_freebsd_cam (img_private_t *env)
if(rc == 0) { if(rc == 0) {
unsigned int n=buf[3]+4; unsigned int n=buf[3]+4;
/* Reader? */ i_drivetype |= cdio_get_drive_cap_mmc(&(buf[n]));
if (buf[n+5] & 0x01) i_drivetype |= CDIO_DRIVE_CAP_CD_AUDIO;
if (buf[n+2] & 0x02) i_drivetype |= CDIO_DRIVE_CAP_CD_RW;
if (buf[n+2] & 0x08) i_drivetype |= CDIO_DRIVE_CAP_DVD;
/* Writer? */
if (buf[n+3] & 0x01) i_drivetype |= CDIO_DRIVE_CAP_CD_R;
if (buf[n+3] & 0x10) i_drivetype |= CDIO_DRIVE_CAP_DVD_R;
if (buf[n+3] & 0x20) i_drivetype |= CDIO_DRIVE_CAP_DVD_RAM;
if (buf[n+6] & 0x08) i_drivetype |= CDIO_DRIVE_CAP_OPEN_TRAY;
if (buf[n+6] >> 5 != 0) i_drivetype |= CDIO_DRIVE_CAP_CLOSE_TRAY;
} else { } else {
i_drivetype = CDIO_DRIVE_CAP_CD_AUDIO | CDIO_DRIVE_CAP_UNKNOWN; i_drivetype = CDIO_DRIVE_CAP_CD_AUDIO | CDIO_DRIVE_CAP_UNKNOWN;
} }

View File

@@ -1,5 +1,5 @@
/* /*
$Id: aspi32.c,v 1.10 2004/06/27 15:29:22 rocky Exp $ $Id: aspi32.c,v 1.11 2004/06/27 22:00:10 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: aspi32.c,v 1.10 2004/06/27 15:29:22 rocky Exp $"; static const char _rcsid[] = "$Id: aspi32.c,v 1.11 2004/06/27 22:00:10 rocky Exp $";
#include <cdio/cdio.h> #include <cdio/cdio.h>
#include <cdio/sector.h> #include <cdio/sector.h>
@@ -708,7 +708,7 @@ get_drive_cap_aspi (const _img_private_t *env)
/* Operation code */ /* Operation code */
CDIO_MMC_SET_COMMAND(ssc.CDBByte, CDIO_MMC_MODE_SENSE_10); CDIO_MMC_SET_COMMAND(ssc.CDBByte, CDIO_MMC_MODE_SENSE_10);
ssc.CDBByte[1] = 0x0; ssc.CDBByte[1] = 0x0;
ssc.CDBByte[2] = 0x3F; /* try narrower 0x2a "mode-page" ? */ ssc.CDBByte[2] = CDIO_MMC_ALL_PAGES;
ssc.CDBByte[7] = 0x01; ssc.CDBByte[7] = 0x01;
ssc.CDBByte[8] = 0x00; ssc.CDBByte[8] = 0x00;
@@ -751,19 +751,7 @@ get_drive_cap_aspi (const _img_private_t *env)
/* Don't handle theses yet. */ /* Don't handle theses yet. */
break; break;
case CDRCAPS: case CDRCAPS:
/* Reader? */ i_drivetype |= cdio_get_drive_cap_mmc(p);
if (p[5] & 0x01) i_drivetype |= CDIO_DRIVE_CAP_CD_AUDIO;
if (p[2] & 0x02) i_drivetype |= CDIO_DRIVE_CAP_CD_RW;
if (p[2] & 0x08) i_drivetype |= CDIO_DRIVE_CAP_DVD;
/* Writer? */
if (p[3] & 0x01) i_drivetype |= CDIO_DRIVE_CAP_CD_R;
if (p[3] & 0x10) i_drivetype |= CDIO_DRIVE_CAP_DVD_R;
if (p[3] & 0x20) i_drivetype |= CDIO_DRIVE_CAP_DVD_RAM;
if (p[6] & 0x08) i_drivetype |= CDIO_DRIVE_CAP_OPEN_TRAY;
if (p[6] >> 5 != 0)
i_drivetype |= CDIO_DRIVE_CAP_CLOSE_TRAY;
break; break;
default: ; default: ;
} }

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.39 2004/06/23 09:25:30 rocky Exp $ # $Id: Makefile.am,v 1.40 2004/06/27 22:00:09 rocky Exp $
# #
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> # Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
# #
@@ -85,6 +85,7 @@ libcdio_sources = \
MSWindows/win32.c \ MSWindows/win32.c \
MSWindows/win32.h \ MSWindows/win32.h \
sector.c \ sector.c \
scsi_mmc.c \
util.c util.c
lib_LTLIBRARIES = libcdio.la libiso9660.la lib_LTLIBRARIES = libcdio.la libiso9660.la