![]() |
![]() |
![]() |
libMirage Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy |
#include <mirage.h> enum MIRAGE_Sector_MCSB; enum MIRAGE_Sector_SubchannelFormat; enum MIRAGE_Sector_ValidData; struct MIRAGE_Sector; gboolean mirage_sector_feed_data (MIRAGE_Sector *self
,gint address
,GObject *track
,GError **error
); gboolean mirage_sector_get_sector_type (MIRAGE_Sector *self
,gint *type
,GError **error
); gboolean mirage_sector_get_sync (MIRAGE_Sector *self
,const guint8 **ret_buf
,gint *ret_len
,GError **error
); gboolean mirage_sector_get_header (MIRAGE_Sector *self
,const guint8 **ret_buf
,gint *ret_len
,GError **error
); gboolean mirage_sector_get_subheader (MIRAGE_Sector *self
,const guint8 **ret_buf
,gint *ret_len
,GError **error
); gboolean mirage_sector_get_data (MIRAGE_Sector *self
,const guint8 **ret_buf
,gint *ret_len
,GError **error
); gboolean mirage_sector_get_edc_ecc (MIRAGE_Sector *self
,const guint8 **ret_buf
,gint *ret_len
,GError **error
); gboolean mirage_sector_get_subchannel (MIRAGE_Sector *self
,gint format
,const guint8 **ret_buf
,gint *ret_len
,GError **error
); gboolean mirage_sector_verify_lec (MIRAGE_Sector *self
); gboolean mirage_sector_verify_subchannel_crc (MIRAGE_Sector *self
);
MIRAGE_Sector object represents a sector. It provides access to the sector data, generating it if needed.
typedef enum { MIRAGE_MCSB_SYNC = 0x80, MIRAGE_MCSB_SUBHEADER = 0x40, MIRAGE_MCSB_HEADER = 0x20, MIRAGE_MCSB_DATA = 0x10, MIRAGE_MCSB_EDC_ECC = 0x08, MIRAGE_MCSB_C2_2 = 0x04, MIRAGE_MCSB_C2_1 = 0x02, } MIRAGE_Sector_MCSB;
Main channel selection flags.
typedef enum { MIRAGE_SUBCHANNEL_PW = 0x01, MIRAGE_SUBCHANNEL_PQ = 0x02, MIRAGE_SUBCHANNEL_RW = 0x03 } MIRAGE_Sector_SubchannelFormat;
Subchannel selection flags.
typedef enum { MIRAGE_VALID_SYNC = 0x01, MIRAGE_VALID_HEADER = 0x02, MIRAGE_VALID_SUBHEADER = 0x04, MIRAGE_VALID_DATA = 0x08, MIRAGE_VALID_EDC_ECC = 0x10, MIRAGE_VALID_SUBCHAN = 0x20, } MIRAGE_Sector_ValidData;
Sector data validity flags.
struct MIRAGE_Sector;
Contains private data only, and should be accessed using the functions below.
gboolean mirage_sector_feed_data (MIRAGE_Sector *self
,gint address
,GObject *track
,GError **error
);
Feeds data to sector. It finds appropriate fragment to feed from, reads data into sector object and sets data validity flags.
|
a MIRAGE_Sector |
|
address the sector represents. Given in sectors. |
|
track the sector belongs to |
|
location to store error, or NULL
|
Returns : |
TRUE on success, FALSE on failure |
gboolean mirage_sector_get_sector_type (MIRAGE_Sector *self
,gint *type
,GError **error
);
Retrieves sector type (track mode); one of MIRAGE_TrackModes.
|
a MIRAGE_Sector |
|
location to store sector type |
|
location to store error, or NULL
|
Returns : |
TRUE on success, FALSE on failure |
gboolean mirage_sector_get_sync (MIRAGE_Sector *self
,const guint8 **ret_buf
,gint *ret_len
,GError **error
);
Retrieves sector's sync pattern. The pointer to appropriate location in
sector's data buffer is stored into ret_buf
; therefore, the buffer should not
be modified.
If sync pattern is not provided by image file(s), it is generated.
gboolean mirage_sector_get_header (MIRAGE_Sector *self
,const guint8 **ret_buf
,gint *ret_len
,GError **error
);
Retrieves sector's header. The pointer to appropriate location in
sector's data buffer is stored into ret_buf
; therefore, the buffer should not
be modified.
If header is not provided by image file(s), it is generated.
gboolean mirage_sector_get_subheader (MIRAGE_Sector *self
,const guint8 **ret_buf
,gint *ret_len
,GError **error
);
Retrieves sector's subheader. The pointer to appropriate location in
sector's data buffer is stored into ret_buf
; therefore, the buffer should not
be modified.
If subheader is not provided by image file(s), it is generated.
gboolean mirage_sector_get_data (MIRAGE_Sector *self
,const guint8 **ret_buf
,gint *ret_len
,GError **error
);
Retrieves sector's user data. The pointer to appropriate location in
sector's data buffer is stored into ret_buf
; therefore, the buffer should not
be modified.
gboolean mirage_sector_get_edc_ecc (MIRAGE_Sector *self
,const guint8 **ret_buf
,gint *ret_len
,GError **error
);
Retrieves sector's EDC/ECC data. The pointer to appropriate location in
sector's data buffer is stored into ret_buf
; therefore, the buffer should not
be modified.
If EDC/ECC data is not provided by image file(s), it is generated.
gboolean mirage_sector_get_subchannel (MIRAGE_Sector *self
,gint format
,const guint8 **ret_buf
,gint *ret_len
,GError **error
);
Retrieves sector's subchannel. type
must be one of MIRAGE_Sector_SubchannelFormat.
The pointer to appropriate location in sector's data buffer is stored into
ret_buf
; therefore, the buffer should not be modified.
If subchannel is not provided by image file(s), it is generated.
|
a MIRAGE_Sector |
|
subchannel format |
|
location to store pointer to buffer containing subchannel, or NULL
|
|
location to store length of subchannel data, or NULL . Length is given in bytes. |
|
location to store error, or NULL
|
Returns : |
TRUE on success, FALSE on failure |
gboolean mirage_sector_verify_lec (MIRAGE_Sector *self
);
Verifies the sector data in terms of L-EC error detection/correction. Data sectors (Mode 1, Mode 2 Form 1 and Mode 2 Form 2) contain error detection/error correction codes which is part of so called layered error correction. This function calculates the EDC for sector data and compares it with EDC provided by the image file.
As a result of comparison, the sectors with intentionally faulty EDC (and possibly ECC, though ECC is not verified) can be discovered.
This function requires EDC/ECC data to be provided by the image. If it
is not provided, it would be generated by MIRAGE_Sector on first access
via mirage_sector_get_edc_ecc()
using the same algorithm as the one used
by this function. Therefore, in case of EDC/ECC data missing, the verification
automatically succeeds.
|
a MIRAGE_Sector |
Returns : |
TRUE if sector passes verification (i.e. no L-EC errors are detected) otherwise FALSE
|
gboolean mirage_sector_verify_subchannel_crc (MIRAGE_Sector *self
);
Verifies the Q subchannel's CRC for the sector.
As a result of comparison, the sectors with intentionally faulty Q subchannel can be discovered.
This function requires subchannel data to be provided by the image. If it
is not provided, it would be generated by MIRAGE_Sector on first access
via mirage_sector_get_subchannel()
using the same algorithm as the one used
by this function. Therefore, in case of subchannel data missing, the verification
automatically succeeds.
|
a MIRAGE_Sector |
Returns : |
TRUE if sector's Q subchannel CRC passes verification otherwise FALSE
|