Compilation fixes and modulization improvements.

This commit is contained in:
rocky
2004-04-30 21:36:53 +00:00
parent a4cc1496e5
commit e853206824
8 changed files with 82 additions and 59 deletions

View File

@@ -1,5 +1,5 @@
/* /*
$Id: freebsd.c,v 1.1 2004/04/30 09:59:54 rocky Exp $ $Id: freebsd.c,v 1.2 2004/04/30 21:36:53 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.1 2004/04/30 09:59:54 rocky Exp $"; static const char _rcsid[] = "$Id: freebsd.c,v 1.2 2004/04/30 21:36:53 rocky Exp $";
#include "freebsd.h" #include "freebsd.h"
@@ -93,7 +93,11 @@ static int
_read_mode2_sector_freebsd (void *env, void *data, lsn_t lsn, _read_mode2_sector_freebsd (void *env, void *data, lsn_t lsn,
bool b_form2) bool b_form2)
{ {
return read_mode2_sector_freebsd_ioctl(env, data, lsn, b_form2); _img_private_t *_obj = env;
if ( _obj->access_mode == _AM_CAM )
return read_mode2_sector_freebsd_ioctl(_obj, data, lsn, b_form2);
else
return read_mode2_sector_freebsd_cam(_obj, data, lsn, b_form2);
} }
/*! /*!
@@ -109,15 +113,19 @@ _read_mode2_sectors_freebsd (void *env, void *data, lsn_t lsn,
int i; int i;
int retval; int retval;
if ( _obj->access_mode == _AM_CAM )
return read_mode2_sectors_freebsd_cam(_obj);
for (i = 0; i < nblocks; i++) { for (i = 0; i < nblocks; i++) {
if (b_form2) { if (b_form2) {
if ( (retval = _read_mode2_sector_freebsd (_obj, if ( (retval = read_mode2_sector_freebsd_ioctl (_obj,
((char *)data) + (M2RAW_SECTOR_SIZE * i), ((char *)data) + (M2RAW_SECTOR_SIZE * i),
lsn + i, true)) ) lsn + i, true)) )
return retval; return retval;
} else { } else {
char buf[M2RAW_SECTOR_SIZE] = { 0, }; char buf[M2RAW_SECTOR_SIZE] = { 0, };
if ( (retval = _read_mode2_sector_freebsd (_obj, buf, lsn + i, true)) ) if ( (retval = read_mode2_sector_freebsd_ioctl (_obj, buf,
lsn + i, true)) )
return retval; return retval;
memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i), memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i),
@@ -131,9 +139,16 @@ _read_mode2_sectors_freebsd (void *env, void *data, lsn_t lsn,
Return the size of the CD in logical block address (LBA) units. Return the size of the CD in logical block address (LBA) units.
*/ */
static uint32_t static uint32_t
_stat_size_freebsd (void *env) _stat_size_freebsd (void *obj)
{ {
return stat_size_freebsd_ioctl(env); _img_private_t *env = obj;
if (NULL == env) return CDIO_INVALID_LBA;
if (_AM_CAM == env->access_mode)
return stat_size_freebsd_cam(env);
else
return stat_size_freebsd_ioctl(env);
} }
/*! /*!
@@ -155,7 +170,10 @@ _set_arg_freebsd (void *env, const char key[], const char value[])
} }
else if (!strcmp (key, "access-mode")) else if (!strcmp (key, "access-mode"))
{ {
return str_to_access_mode_freebsd(value); _obj->access_mode = str_to_access_mode_freebsd(value);
if (_obj->access_mode == _AM_CAM && !_obj->b_cam_init)
return init_freebsd_cam(_obj) ? 1 : -3;
return 0;
} }
else else
return -1; return -1;
@@ -502,13 +520,13 @@ cdio_open_am_freebsd (const char *psz_source_name, const char *psz_access_mode)
ret = cdio_new (_data, &_funcs); ret = cdio_new (_data, &_funcs);
if (ret == NULL) return NULL; if (ret == NULL) return NULL;
if (!cdio_generic_init(_data))
cdio_generic_free (_data);
return NULL;
}
if ( _data->access_mode == _AM_IOCTL ) { if ( _data->access_mode == _AM_IOCTL ) {
if (cdio_generic_init(_data)) return ret;
return ret;
else {
cdio_generic_free (_data);
return NULL;
}
} else { } else {
if (init_freebsd_cam(_data)) if (init_freebsd_cam(_data))
return ret; return ret;

View File

@@ -1,5 +1,5 @@
/* /*
$Id: freebsd.h,v 1.1 2004/04/30 09:59:54 rocky Exp $ $Id: freebsd.h,v 1.2 2004/04/30 21:36:54 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -125,21 +125,22 @@ int eject_media_freebsd_cam (_img_private_t *env);
void free_freebsd_cam (void *obj); void free_freebsd_cam (void *obj);
int read_audio_sectors_freebsd_ioctl (void *env, void *data, lsn_t lsn, int read_audio_sectors_freebsd_ioctl (_img_private_t *env, void *data,
unsigned int nblocks); lsn_t lsn, unsigned int nblocks);
int read_mode2_sector_freebsd_ioctl (void *env, void *data, lsn_t lsn, int read_mode2_sector_freebsd_ioctl (_img_private_t *env, void *data,
bool b_form2); lsn_t lsn, bool b_form2);
int read_mode2_sectors_freebsd_cam (void *env, void *buf, uint32_t lba, int read_mode2_sectors_freebsd_cam (_img_private_t *env, void *buf,
unsigned int nblocks, bool b_form2); uint32_t lba, unsigned int nblocks,
bool b_form2);
bool read_toc_freebsd_ioctl (_img_private_t *_obj); bool read_toc_freebsd_ioctl (_img_private_t *_obj);
/*! /*!
Return the size of the CD in logical block address (LBA) units. Return the size of the CD in logical block address (LBA) units.
*/ */
uint32_t stat_size_freebsd_cam (void *env); uint32_t stat_size_freebsd_cam (_img_private_t *env);
uint32_t stat_size_freebsd_ioctl (void *env); uint32_t stat_size_freebsd_ioctl (_img_private_t *env);
bool init_freebsd_cam (_img_private_t *_obj); bool init_freebsd_cam (_img_private_t *_obj);
void free_freebsd_cam (void *obj); void free_freebsd_cam (void *obj);

View File

@@ -1,5 +1,5 @@
/* /*
$Id: freebsd_cam.c,v 1.1 2004/04/30 09:59:54 rocky Exp $ $Id: freebsd_cam.c,v 1.2 2004/04/30 21:36:54 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.1 2004/04/30 09:59:54 rocky Exp $"; static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.2 2004/04/30 21:36:54 rocky Exp $";
#ifdef HAVE_FREEBSD_CDROM #ifdef HAVE_FREEBSD_CDROM
@@ -63,8 +63,6 @@ bool
init_freebsd_cam (_img_private_t *_obj) init_freebsd_cam (_img_private_t *_obj)
{ {
char pass[100]; char pass[100];
if (_obj->gen.init)
return true;
_obj->cam=NULL; _obj->cam=NULL;
memset (&_obj->ccb, 0, sizeof(_obj->ccb)); memset (&_obj->ccb, 0, sizeof(_obj->ccb));
@@ -160,10 +158,9 @@ _set_bsize (_img_private_t *_obj, unsigned int bsize)
} }
int int
read_mode2_sectors_freebsd_cam (void *env, void *buf, uint32_t lba, read_mode2_sectors_freebsd_cam (_img_private_t *_obj, void *buf, uint32_t lba,
unsigned int nblocks, bool b_form2) unsigned int nblocks, bool b_form2)
{ {
_img_private_t *_obj = env;
int retval = 0; int retval = 0;
memset(&_obj->ccb,0,sizeof(_obj->ccb)); memset(&_obj->ccb,0,sizeof(_obj->ccb));
_obj->ccb.ccb_h.path_id = _obj->cam->path_id; _obj->ccb.ccb_h.path_id = _obj->cam->path_id;
@@ -216,11 +213,8 @@ read_mode2_sectors_freebsd_cam (void *env, void *buf, uint32_t lba,
Return the size of the CD in logical block address (LBA) units. Return the size of the CD in logical block address (LBA) units.
*/ */
uint32_t uint32_t
stat_size_freebsd_cam (void *env) stat_size_freebsd_cam (_img_private_t *_obj)
{ {
_img_private_t *_obj = env;
uint8_t buf[12] = { 0, }; uint8_t buf[12] = { 0, };
uint32_t retval; uint32_t retval;
@@ -234,9 +228,10 @@ stat_size_freebsd_cam (void *env)
sizeof(_obj->ccb.csio.sense_data), 0, 30*1000); sizeof(_obj->ccb.csio.sense_data), 0, 30*1000);
_obj->ccb.csio.cdb_len = 8+1; _obj->ccb.csio.cdb_len = 8+1;
_obj->ccb.csio.cdb_io.cdb_bytes[0] = CDIO_MMC_READ_TOC; CDIO_MMC_SET_COMMAND(_obj->ccb.csio.cdb_io.cdb_bytes, CDIO_MMC_READ_TOC);
_obj->ccb.csio.cdb_io.cdb_bytes[1] = 0; /* lba; msf: 0x2 */ _obj->ccb.csio.cdb_io.cdb_bytes[1] = 0; /* lba; msf: 0x2 */
_obj->ccb.csio.cdb_io.cdb_bytes[6] = CDIO_CDROM_LEADOUT_TRACK; CDIO_MMC_SET_START_TRACK(_obj->ccb.csio.cdb_io.cdb_bytes,
CDIO_CDROM_LEADOUT_TRACK);
_obj->ccb.csio.cdb_io.cdb_bytes[8] = 12; /* ? */ _obj->ccb.csio.cdb_io.cdb_bytes[8] = 12; /* ? */
_obj->ccb.csio.data_ptr = buf; _obj->ccb.csio.data_ptr = buf;

View File

@@ -1,5 +1,5 @@
/* /*
$Id: freebsd_ioctl.c,v 1.1 2004/04/30 09:59:54 rocky Exp $ $Id: freebsd_ioctl.c,v 1.2 2004/04/30 21:36:54 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_ioctl.c,v 1.1 2004/04/30 09:59:54 rocky Exp $"; static const char _rcsid[] = "$Id: freebsd_ioctl.c,v 1.2 2004/04/30 21:36:54 rocky Exp $";
#ifdef HAVE_FREEBSD_CDROM #ifdef HAVE_FREEBSD_CDROM
@@ -74,10 +74,9 @@ cdio_is_cdrom_freebsd_ioctl(char *drive, char *mnttype)
Returns 0 if no error. Returns 0 if no error.
*/ */
int int
read_audio_sectors_freebsd_ioctl (void *env, void *data, lsn_t lsn, read_audio_sectors_freebsd_ioctl (_img_private_t *_obj, void *data, lsn_t lsn,
unsigned int nblocks) unsigned int nblocks)
{ {
_img_private_t *_obj = env;
unsigned char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; unsigned char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
struct ioc_read_audio cdda; struct ioc_read_audio cdda;
@@ -101,7 +100,7 @@ read_audio_sectors_freebsd_ioctl (void *env, void *data, lsn_t lsn,
from lsn. Returns 0 if no error. from lsn. Returns 0 if no error.
*/ */
int int
read_mode2_sector_freebsd_ioctl (void *env, void *data, lsn_t lsn, read_mode2_sector_freebsd_ioctl (_img_private_t *env, void *data, lsn_t lsn,
bool b_form2) bool b_form2)
{ {
char buf[M2RAW_SECTOR_SIZE] = { 0, }; char buf[M2RAW_SECTOR_SIZE] = { 0, };
@@ -122,10 +121,8 @@ read_mode2_sector_freebsd_ioctl (void *env, void *data, lsn_t lsn,
Return the size of the CD in logical block address (LBA) units. Return the size of the CD in logical block address (LBA) units.
*/ */
uint32_t uint32_t
stat_size_freebsd_ioctl (void *env) stat_size_freebsd_ioctl (_img_private_t *_obj)
{ {
_img_private_t *_obj = env;
struct ioc_read_toc_single_entry tocent; struct ioc_read_toc_single_entry tocent;
uint32_t size; uint32_t size;

View File

@@ -1,5 +1,5 @@
/* /*
$Id: aspi32.c,v 1.2 2004/04/30 06:54:15 rocky Exp $ $Id: aspi32.c,v 1.3 2004/04/30 21:36:54 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.2 2004/04/30 06:54:15 rocky Exp $"; static const char _rcsid[] = "$Id: aspi32.c,v 1.3 2004/04/30 21:36:54 rocky Exp $";
#include <cdio/cdio.h> #include <cdio/cdio.h>
#include <cdio/sector.h> #include <cdio/sector.h>
@@ -320,9 +320,7 @@ wnaspi32_mmc_read_sectors (_img_private_t *env, void *data, lsn_t lsn,
ssc.SRB_PostProc = (LPVOID) hEvent; ssc.SRB_PostProc = (LPVOID) hEvent;
ssc.SRB_CDBLen = 12; ssc.SRB_CDBLen = 12;
/* Operation code */ CDIO_MMC_SET_COMMAND(ssc.CDBByte, CDIO_MMC_GPCMD_READ_CD));
ssc.CDBByte[ 0 ] = CDIO_MMC_GPCMD_READ_CD;
CDIO_MMC_SET_READ_TYPE(ssc.CDBByte, sector_type); CDIO_MMC_SET_READ_TYPE(ssc.CDBByte, sector_type);
CDIO_MMC_SET_READ_LBA(ssc.CDBByte, lsn); CDIO_MMC_SET_READ_LBA(ssc.CDBByte, lsn);
CDIO_MMC_SET_READ_LENGTH(ssc.CDBByte, nblocks); CDIO_MMC_SET_READ_LENGTH(ssc.CDBByte, nblocks);
@@ -417,13 +415,13 @@ wnaspi32_read_toc (_img_private_t *env)
ssc.SRB_CDBLen = 10; ssc.SRB_CDBLen = 10;
/* Operation code */ /* Operation code */
ssc.CDBByte[ 0 ] = READ_TOC; CDIO_MMC_SET_COMMAND(ssc.CDBByte, CDIO_MMC_READ_TOC);
/* Format */ /* Format */
ssc.CDBByte[ 2 ] = READ_TOC_FORMAT_TOC; ssc.CDBByte[ 2 ] = READ_TOC_FORMAT_TOC;
/* Starting track */ /* Starting track */
ssc.CDBByte[ 6 ] = 0; CDIO_MMC_SET_START_TRACK(ssc.CDBByte, 0);
/* Allocation length and buffer */ /* Allocation length and buffer */
ssc.SRB_BufLen = sizeof( p_tocheader ); ssc.SRB_BufLen = sizeof( p_tocheader );

View File

@@ -1,5 +1,5 @@
/* /*
$Id: win32.c,v 1.9 2004/04/30 07:33:51 rocky Exp $ $Id: win32.c,v 1.10 2004/04/30 21:36:54 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: win32.c,v 1.9 2004/04/30 07:33:51 rocky Exp $"; static const char _rcsid[] = "$Id: win32.c,v 1.10 2004/04/30 21:36:54 rocky Exp $";
#include <cdio/cdio.h> #include <cdio/cdio.h>
#include <cdio/sector.h> #include <cdio/sector.h>
@@ -337,7 +337,14 @@ _set_arg_win32 (void *user_data, const char key[], const char value[])
} }
else if (!strcmp (key, "access-mode")) else if (!strcmp (key, "access-mode"))
{ {
return str_to_access_mode_win32(value); _obj->access_mode = str_to_access_mode_win32(value);
if (_obj->access_mode == _AM_ASPI && !_obj->b_aspi_init)
return winaspi_init_win32(_obj) ? 1 : -3;
else if (_obj->access_mode == _AM_IOCTL && !_obj->b_ioctl_init)
return win32ioctl_init_win32(_obj) ? 1 : -3;
else
return -4;
return 0;
} }
else else
return -1; return -1;

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_linux.c,v 1.40 2004/04/30 06:54:15 rocky Exp $ $Id: _cdio_linux.c,v 1.41 2004/04/30 21:36:53 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.40 2004/04/30 06:54:15 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.41 2004/04/30 21:36:53 rocky Exp $";
#include <string.h> #include <string.h>
@@ -306,7 +306,8 @@ _read_packet_mode2_sectors_mmc (int fd, void *buf, lba_t lba,
memset (&cgc, 0, sizeof (struct cdrom_generic_command)); memset (&cgc, 0, sizeof (struct cdrom_generic_command));
cgc.cmd[0] = use_read_10 ? GPCMD_READ_10 : CDIO_MMC_GPCMD_READ_CD; CDIO_MMC_SET_COMMAND(cgc.cmd,
use_read_10 ? GPCMD_READ_10 : CDIO_MMC_GPCMD_READ_CD);
CDIO_MMC_SET_READ_LBA(cgc.cmd, lba); CDIO_MMC_SET_READ_LBA(cgc.cmd, lba);
CDIO_MMC_SET_READ_LENGTH(cgc.cmd, nblocks); CDIO_MMC_SET_READ_LENGTH(cgc.cmd, nblocks);
@@ -701,7 +702,7 @@ _eject_media_mmc(int fd)
scsi_cmd.inlen = 0; scsi_cmd.inlen = 0;
scsi_cmd.outlen = 0; scsi_cmd.outlen = 0;
scsi_cmd.cmd[0] = START_STOP; CDIO_MMC_SET_COMMAND(scsi_cmd.cmd, CDIO_MMC_START_STOP);
scsi_cmd.cmd[1] = 0; scsi_cmd.cmd[1] = 0;
scsi_cmd.cmd[2] = 0; scsi_cmd.cmd[2] = 0;
scsi_cmd.cmd[3] = 0; scsi_cmd.cmd[3] = 0;
@@ -713,7 +714,7 @@ _eject_media_mmc(int fd)
scsi_cmd.inlen = 0; scsi_cmd.inlen = 0;
scsi_cmd.outlen = 0; scsi_cmd.outlen = 0;
scsi_cmd.cmd[0] = START_STOP; CDIO_MMC_SET_COMMAND(scsi_cmd.cmd, CDIO_MMC_START_STOP);
scsi_cmd.cmd[1] = 0; scsi_cmd.cmd[1] = 0;
scsi_cmd.cmd[2] = 0; scsi_cmd.cmd[2] = 0;
scsi_cmd.cmd[3] = 0; scsi_cmd.cmd[3] = 0;

View File

@@ -1,5 +1,5 @@
/* /*
$Id: scsi_mmc.h,v 1.9 2004/04/27 03:05:23 rocky Exp $ $Id: scsi_mmc.h,v 1.10 2004/04/30 21:36:53 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -45,6 +45,9 @@
#define CDIO_MMC_GPCMD_READ_12 0xa8 #define CDIO_MMC_GPCMD_READ_12 0xa8
#define CDIO_MMC_GPCMD_READ_CD 0xbe #define CDIO_MMC_GPCMD_READ_CD 0xbe
#define CDIO_MMC_SET_COMMAND(rec, command) \
rec[0] = command
#define CDIO_MMC_SET_READ_TYPE(rec, sector_type) \ #define CDIO_MMC_SET_READ_TYPE(rec, sector_type) \
rec[1] = (sector_type << 2) rec[1] = (sector_type << 2)
@@ -55,6 +58,9 @@
rec[4] = (lba >> 8) & 0xff; \ rec[4] = (lba >> 8) & 0xff; \
rec[5] = (lba ) & 0xff rec[5] = (lba ) & 0xff
#define CDIO_MMC_SET_START_TRACK(rec, command) \
rec[6] = command
#define CDIO_MMC_SET_READ_LENGTH(rec, len) \ #define CDIO_MMC_SET_READ_LENGTH(rec, len) \
rec[6] = (len >> 16) & 0xff; \ rec[6] = (len >> 16) & 0xff; \
rec[7] = (len >> 8) & 0xff; \ rec[7] = (len >> 8) & 0xff; \