diff --git a/example/sample10.c b/example/sample10.c index bbc78772..ad83bdd7 100644 --- a/example/sample10.c +++ b/example/sample10.c @@ -1,5 +1,5 @@ /* - $Id: sample10.c,v 1.4 2004/08/07 03:37:46 rocky Exp $ + $Id: sample10.c,v 1.5 2004/08/07 09:42:34 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -56,14 +56,15 @@ main(int argc, const char *argv[]) sizeof(buf), &buf); if (i_status == 0) { uint8_t *p; - uint32_t lenData = (unsigned int) CDIO_MMC_GET_LEN32(buf); - uint8_t *pMax = buf + 65530; + uint32_t i_data; + uint8_t *p_max = buf + 65530; + i_data = (unsigned int) CDIO_MMC_GET_LEN32(buf); /* set to first sense feature code, and then walk through the masks */ p = buf + 8; - while( (p < &(buf[lenData])) && (p < pMax) ) { + while( (p < &(buf[i_data])) && (p < p_max) ) { uint16_t i_feature; - uint8_t i_feature_len = p[3]; + uint8_t i_feature_additional = p[3]; i_feature = CDIO_MMC_GET_LEN16(p); switch( i_feature ) @@ -71,7 +72,7 @@ main(int argc, const char *argv[]) uint8_t *q; case CDIO_MMC_FEATURE_PROFILE_LIST: printf("Profile List Feature\n"); - for ( q = p+4 ; q < p + i_feature_len ; q += 4 ) { + for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) { int i_profile=CDIO_MMC_GET_LEN16(q); switch (i_profile) { case CDIO_MMC_FEATURE_PROF_NON_REMOVABLE: @@ -255,9 +256,6 @@ main(int argc, const char *argv[]) case CDIO_MMC_FEATURE_CD_SAO: printf("CD Mastering (Session at Once) Feature\n"); break; - case CDIO_MMC_FEATURE_POWER_MGMT: - printf("Initiator and device directed power management\n"); - break; case CDIO_MMC_FEATURE_CDDA_EXT_PLAY: printf("CD Audio External Play Feature\n"); printf("\tSCAN command is %ssupported\n", @@ -294,7 +292,7 @@ main(int argc, const char *argv[]) default: printf("Unknown feature code %x\n", i_feature); } - p += i_feature_len + 4; + p += i_feature_additional + 4; } } else { printf("Didn't get all feature codes\n"); diff --git a/lib/FreeBSD/freebsd_cam.c b/lib/FreeBSD/freebsd_cam.c index 6f453635..a54cbbdb 100644 --- a/lib/FreeBSD/freebsd_cam.c +++ b/lib/FreeBSD/freebsd_cam.c @@ -1,5 +1,5 @@ /* - $Id: freebsd_cam.c,v 1.30 2004/08/01 11:51:20 rocky Exp $ + $Id: freebsd_cam.c,v 1.31 2004/08/07 09:42:34 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -26,7 +26,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.30 2004/08/01 11:51:20 rocky Exp $"; +static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.31 2004/08/07 09:42:34 rocky Exp $"; #ifdef HAVE_FREEBSD_CDROM @@ -60,6 +60,7 @@ run_scsi_cmd_freebsd_cam( const void *p_user_data, unsigned int i_timeout_ms, { const _img_private_t *p_env = p_user_data; int i_status; + int direction = CAM_DEV_QFRZDIS; union ccb ccb; if (!p_env || !p_env->cam) return -2; @@ -71,18 +72,16 @@ run_scsi_cmd_freebsd_cam( const void *p_user_data, unsigned int i_timeout_ms, ccb.ccb_h.target_lun = p_env->cam->target_lun; ccb.ccb_h.timeout = i_timeout_ms; + if (!i_cdb) + direction |= CAM_DIR_NONE; + else + direction |= (e_direction == SCSI_MMC_DATA_READ)?CAM_DIR_IN : CAM_DIR_OUT; cam_fill_csio (&(ccb.csio), 1, NULL, - CAM_DEV_QFRZDIS, MSG_SIMPLE_Q_TAG, NULL, 0, + direction | CAM_DEV_QFRZDIS, MSG_SIMPLE_Q_TAG, p_buf, i_buf, sizeof(ccb.csio.sense_data), 0, 30*1000); memcpy(ccb.csio.cdb_io.cdb_bytes, p_cdb, i_cdb); - ccb.csio.ccb_h.flags = (SCSI_MMC_DATA_READ == e_direction) - ? CAM_DIR_OUT : CAM_DIR_IN; - - ccb.csio.data_ptr = p_buf; - ccb.csio.dxfer_len = i_buf; - ccb.csio.cdb_len = scsi_mmc_get_cmd_len(ccb.csio.cdb_io.cdb_bytes[0]); @@ -156,75 +155,6 @@ free_freebsd_cam (void *user_data) free (p_env); } -/**** - The below are really rough guesses. They are here in the hope - they can be used as a starting point for someone who knows what - they are doing. -*******/ -#if 1 -/*! - Return the the kind of drive capabilities of device. - - */ -void -get_drive_cap_freebsd_cam (const _img_private_t *p_env, - cdio_drive_read_cap_t *p_read_cap, - cdio_drive_write_cap_t *p_write_cap, - cdio_drive_misc_cap_t *p_misc_cap) -{ - scsi_mmc_cdb_t cdb = {{0, }}; - uint8_t buf[256] = { 0, }; - int i_status; - - CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_MODE_SENSE_10); - cdb.field[1] = 0x0; - cdb.field[2] = CDIO_MMC_ALL_PAGES; - cdb.field[7] = 0x01; - cdb.field[8] = 0x00; - - i_status = run_scsi_cmd_freebsd_cam(p_env, DEFAULT_TIMEOUT_MSECS, - scsi_mmc_get_cmd_len(cdb.field[0]), - &cdb, SCSI_MMC_DATA_READ, - sizeof(buf), buf); - if (0 == i_status) { - uint8_t *p; - int lenData = ((unsigned int)buf[0] << 8) + buf[1]; - uint8_t *pMax = buf + 256; - - *p_read_cap = 0; - *p_write_cap = 0; - *p_misc_cap = 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: - scsi_mmc_get_drive_cap(p, p_read_cap, p_write_cap, p_misc_cap); - break; - default: ; - } - p += (p[1] + 2); - } - } else { - cdio_info("error in aspi USCSICMD MODE_SELECT"); - *p_read_cap = CDIO_DRIVE_CAP_UNKNOWN; - *p_write_cap = CDIO_DRIVE_CAP_UNKNOWN; - *p_misc_cap = CDIO_DRIVE_CAP_UNKNOWN; - } -} - -#endif - static int _set_bsize (_img_private_t *p_env, unsigned int bsize) { diff --git a/lib/scsi_mmc.c b/lib/scsi_mmc.c index 50b4305d..19b6ca75 100644 --- a/lib/scsi_mmc.c +++ b/lib/scsi_mmc.c @@ -1,6 +1,6 @@ /* Common SCSI Multimedia Command (MMC) routines. - $Id: scsi_mmc.c,v 1.22 2004/08/06 22:13:14 rocky Exp $ + $Id: scsi_mmc.c,v 1.23 2004/08/07 09:42:34 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -265,20 +265,21 @@ scsi_mmc_get_drive_cap_private (const void *p_env, sizeof(buf), &buf); if (0 == i_status) { uint8_t *p; - uint16_t lenData = (unsigned int) CDIO_MMC_GET_LEN16(buf); - uint8_t *pMax = buf + 256; - + uint16_t i_data; + uint8_t *p_max = buf + 256; + + i_data = (unsigned int) CDIO_MMC_GET_LEN16(buf); *p_read_cap = 0; *p_write_cap = 0; *p_misc_cap = 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; + while( (p < &(buf[2+i_data])) && (p < p_max) ) { + uint8_t which_page; - which = p[0] & 0x3F; - switch( which ) + which_page = p[0] & 0x3F; + switch( which_page ) { case CDIO_MMC_AUDIO_CTL_PAGE: case CDIO_MMC_R_W_ERROR_PAGE: diff --git a/src/util.c b/src/util.c index bb3d1f39..03994fb7 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,5 @@ /* - $Id: util.c,v 1.16 2004/08/07 03:37:46 rocky Exp $ + $Id: util.c,v 1.17 2004/08/07 09:42:34 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -106,14 +106,16 @@ print_mmc_drive_features(CdIo *p_cdio) sizeof(buf), &buf); if (i_status == 0) { uint8_t *p; - uint32_t lenData = (unsigned int) CDIO_MMC_GET_LEN32(buf); - uint8_t *pMax = buf + 65530; + uint32_t i_data; + uint8_t *p_max = buf + 65530; + i_data = (unsigned int) CDIO_MMC_GET_LEN32(buf); + /* set to first sense feature code, and then walk through the masks */ p = buf + 8; - while( (p < &(buf[lenData])) && (p < pMax) ) { + while( (p < &(buf[i_data])) && (p < p_max) ) { uint16_t i_feature; - uint8_t i_feature_len = p[3]; + uint8_t i_feature_additional = p[3]; i_feature = CDIO_MMC_GET_LEN16(p); switch( i_feature ) @@ -121,7 +123,7 @@ print_mmc_drive_features(CdIo *p_cdio) uint8_t *q; case CDIO_MMC_FEATURE_PROFILE_LIST: printf("Profile List Feature\n"); - for ( q = p+4 ; q < p + i_feature_len ; q += 4 ) { + for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) { int i_profile=CDIO_MMC_GET_LEN16(q); switch (i_profile) { case CDIO_MMC_FEATURE_PROF_NON_REMOVABLE: @@ -341,7 +343,7 @@ print_mmc_drive_features(CdIo *p_cdio) default: printf("Unknown feature code %x\n", i_feature); } - p += i_feature_len + 4; + p += i_feature_additional + 4; } } else { printf("Didn't get all feature codes\n");