MIRAGE_Sector object

MIRAGE_Sector object — Object representing a sector

Synopsis

#include <mirage.h>

enum                MIRAGE_Sector_MCSB;
enum                MIRAGE_Sector_SubchannelFormat;
enum                MIRAGE_Sector_ValidData;
                    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);

Object Hierarchy

  GObject
   +----MIRAGE_Object
         +----MIRAGE_Sector

Description

MIRAGE_Sector object represents a sector. It provides access to the sector data, generating it if needed.

Details

enum MIRAGE_Sector_MCSB

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.

MIRAGE_MCSB_SYNC

sync pattern

MIRAGE_MCSB_SUBHEADER

subheader

MIRAGE_MCSB_HEADER

header

MIRAGE_MCSB_DATA

user data

MIRAGE_MCSB_EDC_ECC

EDC/ECC code

MIRAGE_MCSB_C2_2

C2 layer 2 error

MIRAGE_MCSB_C2_1

C2 layer 1 error

enum MIRAGE_Sector_SubchannelFormat

typedef enum {
    MIRAGE_SUBCHANNEL_PW = 0x01,
    MIRAGE_SUBCHANNEL_PQ = 0x02,
    MIRAGE_SUBCHANNEL_RW = 0x03
} MIRAGE_Sector_SubchannelFormat;

Subchannel selection flags.

MIRAGE_SUBCHANNEL_PW

PW subchannel; 96 bytes, interleaved P-W

MIRAGE_SUBCHANNEL_PQ

PQ subchannel; 16 bytes, Q subchannel

MIRAGE_SUBCHANNEL_RW

RW subchannel; 96 bytes, deinterleaved R-W

enum MIRAGE_Sector_ValidData

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.

MIRAGE_VALID_SYNC

sync pattern valid

MIRAGE_VALID_HEADER

header valid

MIRAGE_VALID_SUBHEADER

subheader valid

MIRAGE_VALID_DATA

user data valid

MIRAGE_VALID_EDC_ECC

EDC/ECC data valid

MIRAGE_VALID_SUBCHAN

subchannel valid

MIRAGE_Sector

typedef struct _MIRAGE_Sector MIRAGE_Sector;

Contains private data only, and should be accessed using the functions below.


mirage_sector_feed_data ()

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.

Note

Intended for internal use.

self :

a MIRAGE_Sector

address :

address the sector represents. Given in sectors.

track :

track the sector belongs to

error :

location to store error, or NULL

Returns :

TRUE on success, FALSE on failure

mirage_sector_get_sector_type ()

gboolean            mirage_sector_get_sector_type       (MIRAGE_Sector *self,
                                                         gint *type,
                                                         GError **error);

Retrieves sector type (track mode); one of MIRAGE_TrackModes.

self :

a MIRAGE_Sector

type :

location to store sector type

error :

location to store error, or NULL

Returns :

TRUE on success, FALSE on failure

mirage_sector_get_sync ()

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.

self :

a MIRAGE_Sector

ret_buf :

location to store pointer to buffer containing sync pattern, or NULL

ret_len :

location to store length of sync pattern, or NULL. Length is given in bytes.

error :

location to store error, or NULL

Returns :

TRUE on success, FALSE on failure

mirage_sector_get_header ()

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.

self :

a MIRAGE_Sector

ret_buf :

location to store pointer to buffer containing header, or NULL

ret_len :

location to store length of header, or NULL. Length is given in bytes.

error :

location to store error, or NULL

Returns :

TRUE on success, FALSE on failure

mirage_sector_get_subheader ()

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.

self :

a MIRAGE_Sector

ret_buf :

location to store pointer to buffer containing subheader, or NULL

ret_len :

location to store length of subheader, or NULL. Length is given in bytes.

error :

location to store error, or NULL

Returns :

TRUE on success, FALSE on failure

mirage_sector_get_data ()

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.

self :

a MIRAGE_Sector

ret_buf :

location to store pointer to buffer containing user data, or NULL

ret_len :

location to store length of user data, or NULL. Length is given in bytes.

error :

location to store error, or NULL

Returns :

TRUE on success, FALSE on failure

mirage_sector_get_edc_ecc ()

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.

self :

a MIRAGE_Sector

ret_buf :

location to store pointer to buffer containing EDC/ECC data, or NULL

ret_len :

location to store length of EDC/ECC data, or NULL. Length is given in bytes.

error :

location to store error, or NULL

Returns :

TRUE on success, FALSE on failure

mirage_sector_get_subchannel ()

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.

self :

a MIRAGE_Sector

format :

subchannel format

ret_buf :

location to store pointer to buffer containing subchannel, or NULL

ret_len :

location to store length of subchannel data, or NULL. Length is given in bytes.

error :

location to store error, or NULL

Returns :

TRUE on success, FALSE on failure

mirage_sector_verify_lec ()

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.

self :

a MIRAGE_Sector

Returns :

TRUE if sector passes verification (i.e. no L-EC errors are detected) otherwise FALSE

mirage_sector_verify_subchannel_crc ()

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.

self :

a MIRAGE_Sector

Returns :

TRUE if sector's Q subchannel CRC passes verification otherwise FALSE

See Also

MIRAGE_Track