- Redo types of lsn and lba to allow negative values. Should model MMC3

specs. Add max/min values for lsn.
- More complete MMC command set
This commit is contained in:
rocky
2004-05-11 02:15:42 +00:00
parent aab600b46a
commit 3f6cba2b0a
8 changed files with 81 additions and 45 deletions

6
NEWS
View File

@@ -2,7 +2,9 @@
- Add interface returning drive capabilityes (cdio_get_drive_cap).
- Minimal cdrdao image reading
- Some important (I think) bug fixes
- Redo types of lsn and lba to allow negative values. Should model MMC3
specs. Add max/min values for lsn.
- More complete MMC command set
0.68
- More honest about mode1 reading in backends. Remove some of the bogusness.
@@ -111,4 +113,4 @@
0.1
Routines split off from VCDImager.
$Id: NEWS,v 1.39 2004/05/08 20:36:01 rocky Exp $
$Id: NEWS,v 1.40 2004/05/11 02:15:42 rocky Exp $

View File

@@ -1,5 +1,5 @@
/*
$Id: scsi_mmc.h,v 1.1 2004/05/10 03:28:52 rocky Exp $
$Id: scsi_mmc.h,v 1.2 2004/05/11 02:15:47 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -41,9 +41,12 @@
#define CDIO_MMC_GPCMD_READ_10 0x28
#define CDIO_MMC_GPCMD_READ_SUBCHANNEL 0x42
#define CDIO_MMC_READ_TOC 0x43
#define CDIO_MMC_MODE_SELECT 0x55
#define CDIO_MMC_MODE_SELECT_6 0x15
#define CDIO_MMC_MODE_SENSE_10 0x5a
#define CDIO_MMC_GPCMD_READ_12 0xa8
#define CDIO_MMC_GPCMD_READ_CD 0xbe
#define CDIO_MMC_GPCMD_READ_MSF 0xb9
#define CDIO_MMC_SET_COMMAND(rec, command) \
rec[0] = command

View File

@@ -1,5 +1,5 @@
/*
$Id: sector.h,v 1.11 2004/05/10 03:28:52 rocky Exp $
$Id: sector.h,v 1.12 2004/05/11 02:15:49 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -125,6 +125,9 @@
#define CDIO_CD_MAX_TRACKS 99
#define CDIO_CD_MIN_TRACK_NO 1
#define CDIO_CD_MAX_LSN 450150
#define CDIO_CD_MIN_LSN -450150
#define CDIO_CD_FRAMES_PER_MIN \
(CDIO_CD_FRAMES_PER_SEC*CDIO_CD_SECS_PER_MIN)

View File

@@ -1,5 +1,5 @@
/*
$Id: types.h,v 1.15 2004/05/08 14:07:09 rocky Exp $
$Id: types.h,v 1.16 2004/05/11 02:15:57 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -204,14 +204,19 @@ extern "C" {
typedef uint8_t bitfield_t;
#endif
/*! The type of a Logical Block Address.
/*! The type of a Logical Block Address. We allow for an lba to be
negative to be consistent with an lba, although I'm not sure this
this is possible.
*/
typedef int32_t lba_t;
/*! The type of a Logical Sector Number. Note that an lba lsn be negative
and the MMC3 specs allow for a conversion of a negative lba
@see msf_t
*/
typedef uint32_t lba_t;
/*! The type of an Logical Sector Number. */
typedef uint32_t lsn_t;
typedef int32_t lsn_t;
/*! The type of an track number 0..99. */
typedef uint8_t track_t;
@@ -222,14 +227,16 @@ extern "C" {
#define CDIO_INVALID_TRACK 0xFF
/*!
Constant for invalid LBA
Constant for invalid LBA. It is 151 less than the most negative
LBA -45150. This provide slack for the 150-frame offset in
LBA to LSN 150 conversions
*/
#define CDIO_INVALID_LBA 0xFFFFFFFF
#define CDIO_INVALID_LBA -45301
/*!
Constant for invalid LSN
*/
#define CDIO_INVALID_LSN 0xFFFFFFFF
#define CDIO_INVALID_LSN CDIO_INVALID_LBA
typedef int cdio_fs_anal_t;

View File

@@ -1,5 +1,5 @@
/*
$Id: bincue.c,v 1.16 2004/04/30 06:54:15 rocky Exp $
$Id: bincue.c,v 1.17 2004/05/11 02:15:58 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -24,7 +24,7 @@
(*.cue).
*/
static const char _rcsid[] = "$Id: bincue.c,v 1.16 2004/04/30 06:54:15 rocky Exp $";
static const char _rcsid[] = "$Id: bincue.c,v 1.17 2004/05/11 02:15:58 rocky Exp $";
#include "cdio_assert.h"
#include "cdio_private.h"
@@ -546,7 +546,7 @@ _read_mode1_sector_bincue (void *env, void *data, lsn_t lsn,
Returns 0 if no error.
*/
static int
_read_mode1_sectors_bincue (void *env, void *data, uint32_t lsn,
_read_mode1_sectors_bincue (void *env, void *data, lsn_t lsn,
bool b_form2, unsigned int nblocks)
{
_img_private_t *_obj = env;
@@ -613,7 +613,7 @@ _read_mode2_sector_bincue (void *env, void *data, lsn_t lsn,
Returns 0 if no error.
*/
static int
_read_mode2_sectors_bincue (void *env, void *data, uint32_t lsn,
_read_mode2_sectors_bincue (void *env, void *data, lsn_t lsn,
bool b_form2, unsigned int nblocks)
{
_img_private_t *_obj = env;

View File

@@ -1,5 +1,5 @@
/*
$Id: cdrdao.c,v 1.5 2004/05/08 22:02:28 rocky Exp $
$Id: cdrdao.c,v 1.6 2004/05/11 02:16:00 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
toc reading routine adapted from cuetools
@@ -25,7 +25,7 @@
(*.cue).
*/
static const char _rcsid[] = "$Id: cdrdao.c,v 1.5 2004/05/08 22:02:28 rocky Exp $";
static const char _rcsid[] = "$Id: cdrdao.c,v 1.6 2004/05/11 02:16:00 rocky Exp $";
#include "cdio_assert.h"
#include "cdio_private.h"
@@ -888,7 +888,7 @@ _read_mode1_sector_cdrdao (void *env, void *data, lsn_t lsn,
Returns 0 if no error.
*/
static int
_read_mode1_sectors_cdrdao (void *env, void *data, uint32_t lsn,
_read_mode1_sectors_cdrdao (void *env, void *data, lsn_t lsn,
bool b_form2, unsigned int nblocks)
{
_img_private_t *_obj = env;
@@ -956,7 +956,7 @@ _read_mode2_sector_cdrdao (void *env, void *data, lsn_t lsn,
Returns 0 if no error.
*/
static int
_read_mode2_sectors_cdrdao (void *env, void *data, uint32_t lsn,
_read_mode2_sectors_cdrdao (void *env, void *data, lsn_t lsn,
bool b_form2, unsigned int nblocks)
{
_img_private_t *_obj = env;

View File

@@ -1,5 +1,5 @@
/*
$Id: nrg.c,v 1.12 2004/05/09 16:52:20 rocky Exp $
$Id: nrg.c,v 1.13 2004/05/11 02:16:01 rocky Exp $
Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -48,7 +48,7 @@
#include "cdio_private.h"
#include "_cdio_stdio.h"
static const char _rcsid[] = "$Id: nrg.c,v 1.12 2004/05/09 16:52:20 rocky Exp $";
static const char _rcsid[] = "$Id: nrg.c,v 1.13 2004/05/11 02:16:01 rocky Exp $";
/* structures used */
@@ -898,7 +898,7 @@ _read_mode1_sector_nrg (void *env, void *data, lsn_t lsn,
Returns 0 if no error.
*/
static int
_read_mode1_sectors_nrg (void *env, void *data, uint32_t lsn,
_read_mode1_sectors_nrg (void *env, void *data, lsn_t lsn,
bool b_form2, unsigned nblocks)
{
_img_private_t *_obj = env;
@@ -971,7 +971,7 @@ _read_mode2_sector_nrg (void *env, void *data, lsn_t lsn,
Returns 0 if no error.
*/
static int
_read_mode2_sectors_nrg (void *env, void *data, uint32_t lsn,
_read_mode2_sectors_nrg (void *env, void *data, lsn_t lsn,
bool b_form2, unsigned nblocks)
{
_img_private_t *_obj = env;

View File

@@ -1,5 +1,5 @@
/*
$Id: sector.c,v 1.6 2004/05/09 16:53:01 rocky Exp $
$Id: sector.c,v 1.7 2004/05/11 02:15:58 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
@@ -32,7 +32,7 @@
#endif
static const char _rcsid[] = "$Id: sector.c,v 1.6 2004/05/09 16:53:01 rocky Exp $";
static const char _rcsid[] = "$Id: sector.c,v 1.7 2004/05/11 02:15:58 rocky Exp $";
lba_t
cdio_lba_to_lsn (lba_t lba)
@@ -42,14 +42,35 @@ cdio_lba_to_lsn (lba_t lba)
return lba - CDIO_PREGAP_SECTORS;
}
/*
The below is adapted from cdparanoia code which claims it is
straight from the MMC3 spec.
*/
void
cdio_lba_to_msf (lba_t lba, msf_t *msf)
cdio_lsn_to_msf (lsn_t lsn, msf_t *msf)
{
int m, s, f;
cdio_assert (msf != 0);
msf->m = to_bcd8 (lba / (60 * 75));
msf->s = to_bcd8 ((lba / 75) % 60);
msf->f = to_bcd8 (lba % 75);
if ( lsn >= -CDIO_PREGAP_SECTORS ){
m = (lsn + CDIO_PREGAP_SECTORS) / CDIO_CD_FRAMES_PER_MIN;
lsn -= m * CDIO_CD_FRAMES_PER_MIN;
s = (lsn + CDIO_PREGAP_SECTORS) / CDIO_CD_FRAMES_PER_SEC;
lsn -= s * CDIO_CD_FRAMES_PER_SEC;
f = lsn + CDIO_PREGAP_SECTORS;
} else {
m = (lsn + CDIO_CD_MAX_LSN) / CDIO_CD_FRAMES_PER_MIN;
lsn -= m * (CDIO_CD_FRAMES_PER_MIN);
s = (lsn+CDIO_CD_MAX_LSN) / CDIO_CD_FRAMES_PER_SEC;
lsn -= s * CDIO_CD_FRAMES_PER_SEC;
f = lsn + CDIO_CD_MAX_LSN;
}
msf->m = to_bcd8 (m);
msf->s = to_bcd8 (s);
msf->f = to_bcd8 (f);
}
/* warning, returns new allocated string */
@@ -74,13 +95,13 @@ cdio_lsn_to_lba (lsn_t lsn)
}
void
cdio_lsn_to_msf (lsn_t lsn, msf_t *msf)
cdio_lba_to_msf (lba_t lba, msf_t *msf)
{
cdio_assert (msf != 0);
cdio_lba_to_msf(cdio_lsn_to_lba(lsn), msf);
cdio_lsn_to_msf(cdio_lba_to_lsn(lba), msf);
}
uint32_t
lba_t
cdio_msf_to_lba (const msf_t *msf)
{
uint32_t lba = 0;
@@ -88,17 +109,17 @@ cdio_msf_to_lba (const msf_t *msf)
cdio_assert (msf != 0);
lba = from_bcd8 (msf->m);
lba *= 60;
lba *= CDIO_CD_SECS_PER_MIN;
lba += from_bcd8 (msf->s);
lba *= 75;
lba *= CDIO_CD_FRAMES_PER_SEC;
lba += from_bcd8 (msf->f);
return lba;
}
uint32_t
lba_t
cdio_msf_to_lsn (const msf_t *msf)
{
return cdio_lba_to_lsn(cdio_msf_to_lba (msf));