scsi_mmc.c: doc change

FreeBSD: use generic routines more often. Initialize TOC before
getting drive capabilities (seems to be desired, not completely sure
or sure why this would be so.)
This commit is contained in:
rocky
2004-08-01 11:28:00 +00:00
parent 008d86d309
commit 83f987275e
3 changed files with 24 additions and 47 deletions

View File

@@ -1,5 +1,5 @@
/* /*
$Id: freebsd.c,v 1.33 2004/07/31 09:26:31 rocky Exp $ $Id: freebsd.c,v 1.34 2004/08/01 11:28:00 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: freebsd.c,v 1.33 2004/07/31 09:26:31 rocky Exp $"; static const char _rcsid[] = "$Id: freebsd.c,v 1.34 2004/08/01 11:28:00 rocky Exp $";
#include "freebsd.h" #include "freebsd.h"
@@ -196,8 +196,12 @@ read_toc_freebsd (_img_private_t *p_env)
return false; return false;
} }
p_env->gen.i_first_track = p_env->tochdr.starting_track;
p_env->gen.i_tracks = p_env->tochdr.ending_track -
p_env->gen.i_first_track + 1;
j=0; j=0;
for ( i = FIRST_TRACK_NUM; i <= p_env->tochdr.ending_track; i++, j++) { for (i=p_env->gen.i_first_track; i<=p_env->gen.i_tracks; i++, j++) {
p_env->tocent[j].track = i; p_env->tocent[j].track = i;
p_env->tocent[j].address_format = CD_LBA_FORMAT; p_env->tocent[j].address_format = CD_LBA_FORMAT;
@@ -258,20 +262,6 @@ _get_arg_freebsd (void *user_data, const char key[])
return NULL; return NULL;
} }
/*!
Return the number of of the first track.
CDIO_INVALID_TRACK is returned on error.
*/
static track_t
_get_first_track_num_freebsd(void *user_data)
{
_img_private_t *p_env = user_data;
if (!p_env->gen.toc_init) read_toc_freebsd (p_env) ;
return p_env->gen.toc_init ? FIRST_TRACK_NUM : CDIO_INVALID_TRACK;
}
/*! /*!
Return the media catalog number MCN. Return the media catalog number MCN.
@@ -301,6 +291,8 @@ get_drive_cap_freebsd (const void *p_user_data,
const _img_private_t *p_env = p_user_data; const _img_private_t *p_env = p_user_data;
if (!p_env->gen.toc_init) read_toc_freebsd (p_env) ;
if (p_env->access_mode == _AM_CAM) if (p_env->access_mode == _AM_CAM)
get_drive_cap_freebsd_cam (p_env, p_read_cap, p_write_cap, p_misc_cap); get_drive_cap_freebsd_cam (p_env, p_read_cap, p_write_cap, p_misc_cap);
@@ -310,7 +302,7 @@ get_drive_cap_freebsd (const void *p_user_data,
Run a SCSI MMC command. Run a SCSI MMC command.
p_user_data internal CD structure. p_user_data internal CD structure.
i_timeout time in milliseconds we will wait for the command i_timeout_ms time in milliseconds we will wait for the command
to complete. If this value is -1, use the default to complete. If this value is -1, use the default
time-out value. time-out value.
i_cdb Size of p_cdb i_cdb Size of p_cdb
@@ -322,7 +314,7 @@ get_drive_cap_freebsd (const void *p_user_data,
Return 0 if no error. Return 0 if no error.
*/ */
static int static int
run_scsi_cmd_frebsd( const void *p_user_data, unsigned int i_timeout_ms, run_scsi_cmd_freebsd( const void *p_user_data, unsigned int i_timeout_ms,
unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb, unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, scsi_mmc_direction_t e_direction,
unsigned int i_buf, /*in/out*/ void *p_buf ) unsigned int i_buf, /*in/out*/ void *p_buf )
@@ -330,27 +322,12 @@ run_scsi_cmd_frebsd( const void *p_user_data, unsigned int i_timeout_ms,
const _img_private_t *p_env = p_user_data; const _img_private_t *p_env = p_user_data;
if (p_env->access_mode == _AM_CAM) if (p_env->access_mode == _AM_CAM)
return run_scsi_cmd_frebsd_cam( p_user_data, i_timeout, i_cdb, p_cdb, return run_scsi_cmd_freebsd_cam( p_user_data, i_timeout_ms, i_cdb, p_cdb,
e_direction, i_buf, p_buf ); e_direction, i_buf, p_buf );
else else
return 2; return 2;
} }
/*!
Return the number of tracks in the current medium.
CDIO_INVALID_TRACK is returned on error.
*/
static track_t
_get_num_tracks_freebsd(void *user_data)
{
_img_private_t *p_env = user_data;
if (!p_env->gen.toc_init) read_toc_freebsd (p_env) ;
return p_env->gen.toc_init ? TOTAL_TRACKS : CDIO_INVALID_TRACK;
}
/*! /*!
Get format of track. Get format of track.
@@ -578,9 +555,9 @@ cdio_open_am_freebsd (const char *psz_orig_source_name,
.get_default_device = cdio_get_default_device_freebsd, .get_default_device = cdio_get_default_device_freebsd,
.get_devices = cdio_get_devices_freebsd, .get_devices = cdio_get_devices_freebsd,
.get_drive_cap = get_drive_cap_freebsd, .get_drive_cap = get_drive_cap_freebsd,
.get_first_track_num= _get_first_track_num_freebsd, .get_first_track_num= get_first_track_num_generic,
.get_mcn = _get_mcn_freebsd, .get_mcn = _get_mcn_freebsd,
.get_num_tracks = _get_num_tracks_freebsd, .get_num_tracks = get_num_tracks_generic,
.get_track_format = _get_track_format_freebsd, .get_track_format = _get_track_format_freebsd,
.get_track_green = _get_track_green_freebsd, .get_track_green = _get_track_green_freebsd,
.get_track_lba = _get_track_lba_freebsd, .get_track_lba = _get_track_lba_freebsd,
@@ -590,7 +567,7 @@ cdio_open_am_freebsd (const char *psz_orig_source_name,
.read_audio_sectors = _read_audio_sectors_freebsd, .read_audio_sectors = _read_audio_sectors_freebsd,
.read_mode2_sector = _read_mode2_sector_freebsd, .read_mode2_sector = _read_mode2_sector_freebsd,
.read_mode2_sectors = _read_mode2_sectors_freebsd, .read_mode2_sectors = _read_mode2_sectors_freebsd,
.run_scsi_mmc_cmd = run_scsi_cmd_frebsd, .run_scsi_mmc_cmd = run_scsi_cmd_freebsd,
.set_arg = _set_arg_freebsd, .set_arg = _set_arg_freebsd,
.stat_size = _stat_size_freebsd .stat_size = _stat_size_freebsd
}; };

View File

@@ -1,5 +1,5 @@
/* /*
$Id: freebsd_cam.c,v 1.27 2004/07/31 09:26:31 rocky Exp $ $Id: freebsd_cam.c,v 1.28 2004/08/01 11:28:00 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.27 2004/07/31 09:26:31 rocky Exp $"; static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.28 2004/08/01 11:28:00 rocky Exp $";
#ifdef HAVE_FREEBSD_CDROM #ifdef HAVE_FREEBSD_CDROM
@@ -41,7 +41,7 @@ static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.27 2004/07/31 09:26:31 rock
Run a SCSI MMC command. Run a SCSI MMC command.
p_user_data internal CD structure. p_user_data internal CD structure.
i_timeout time in milliseconds we will wait for the command i_timeout_ms time in milliseconds we will wait for the command
to complete. If this value is -1, use the default to complete. If this value is -1, use the default
time-out value. time-out value.
i_cdb Size of p_cdb i_cdb Size of p_cdb
@@ -53,7 +53,7 @@ static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.27 2004/07/31 09:26:31 rock
Return 0 if no error. Return 0 if no error.
*/ */
int int
run_scsi_cmd_freebsd_cam( const void *p_user_data, int i_timeout, run_scsi_cmd_freebsd_cam( const void *p_user_data, unsigned int i_timeout_ms,
unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb, unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, scsi_mmc_direction_t e_direction,
unsigned int i_buf, /*in/out*/ void *p_buf ) unsigned int i_buf, /*in/out*/ void *p_buf )
@@ -67,7 +67,7 @@ run_scsi_cmd_freebsd_cam( const void *p_user_data, int i_timeout,
ccb.ccb_h.path_id = p_env->cam->path_id; ccb.ccb_h.path_id = p_env->cam->path_id;
ccb.ccb_h.target_id = p_env->cam->target_id; ccb.ccb_h.target_id = p_env->cam->target_id;
ccb.ccb_h.target_lun = p_env->cam->target_lun; ccb.ccb_h.target_lun = p_env->cam->target_lun;
ccb.ccb_h.timeout = i_timeout; ccb.ccb_h.timeout = i_timeout_ms;
cam_fill_csio (&(ccb.csio), 1, NULL, cam_fill_csio (&(ccb.csio), 1, NULL,
CAM_DEV_QFRZDIS, MSG_SIMPLE_Q_TAG, NULL, 0, CAM_DEV_QFRZDIS, MSG_SIMPLE_Q_TAG, NULL, 0,

View File

@@ -1,6 +1,6 @@
/* Common SCSI Multimedia Command (MMC) routines. /* Common SCSI Multimedia Command (MMC) routines.
$Id: scsi_mmc.c,v 1.18 2004/07/31 07:43:26 rocky Exp $ $Id: scsi_mmc.c,v 1.19 2004/08/01 11:28:00 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -98,13 +98,13 @@ scsi_mmc_get_cmd_len(uint8_t scsi_cmd)
We return 0 if command completed successfully and 1 if not. We return 0 if command completed successfully and 1 if not.
*/ */
int int
scsi_mmc_run_cmd( const CdIo *p_cdio, unsigned int i_timeout, scsi_mmc_run_cmd( const CdIo *p_cdio, unsigned int i_timeout_ms,
const scsi_mmc_cdb_t *p_cdb, const scsi_mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, unsigned int i_buf, scsi_mmc_direction_t e_direction, unsigned int i_buf,
/*in/out*/ void *p_buf ) /*in/out*/ void *p_buf )
{ {
if (p_cdio && p_cdio->op.run_scsi_mmc_cmd) { if (p_cdio && p_cdio->op.run_scsi_mmc_cmd) {
return p_cdio->op.run_scsi_mmc_cmd(p_cdio->env, i_timeout, return p_cdio->op.run_scsi_mmc_cmd(p_cdio->env, i_timeout_ms,
scsi_mmc_get_cmd_len(p_cdb->field[0]), scsi_mmc_get_cmd_len(p_cdb->field[0]),
p_cdb, e_direction, i_buf, p_buf); p_cdb, e_direction, i_buf, p_buf);
} else } else