Search
lxdream.org :: lxdream/src/gdrom/gdrom.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdrom.h
changeset 149:d88dd2e9a190
prev143:9446fb6df0c5
next152:d42a4c5cc709
author nkeynes
date Sat May 20 06:24:49 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Add disc info + spin up (probably seek) commands
view annotate diff log raw
     1 /**
     2  * $Id: gdrom.h,v 1.5 2006-05-20 06:24:49 nkeynes Exp $
     3  *
     4  * This file defines the structures and functions used by the GD-Rom
     5  * disc driver. (ie, the modules that supply a CD image to be used by the
     6  * system).
     7  *
     8  * Copyright (c) 2005 Nathan Keynes.
     9  *
    10  * This program is free software; you can redistribute it and/or modify
    11  * it under the terms of the GNU General Public License as published by
    12  * the Free Software Foundation; either version 2 of the License, or
    13  * (at your option) any later version.
    14  *
    15  * This program is distributed in the hope that it will be useful,
    16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  * GNU General Public License for more details.
    19  */
    21 #ifndef dream_gdrom_H
    22 #define dream_gdrom_H 1
    24 #include "dream.h"
    26 typedef uint16_t gdrom_error_t;
    28 struct gdrom_toc {
    29     uint32_t track[99];
    30     uint32_t first, last, leadout;
    31 };
    33 #define GDROM_PREGAP 150  /* Sectors */
    35 extern uint32_t gdrom_sector_size[];
    36 #define GDROM_SECTOR_SIZE(x) gdrom_sector_size[x]
    37 typedef enum {
    38     GDROM_MODE1,
    39     GDROM_MODE2,
    40     GDROM_MODE2_XA1,
    41     GDROM_MODE2_XA2,
    42     GDROM_CDDA,
    43     GDROM_GD,
    44     GDROM_RAW
    45 } gdrom_track_mode_t;
    47 /* The disc register indicates the current contents of the drive. When open
    48  * contains 0x06.
    49  */
    50 #define IDE_DISC_AUDIO 0x00
    51 #define IDE_DISC_NONE  0x06
    52 #define IDE_DISC_CDROM 0x20
    53 #define IDE_DISC_GDROM 0x80
    54 #define IDE_DISC_READY 0x01 /* ored with above */
    55 #define IDE_DISC_IDLE  0x02 /* ie spun-down */
    57 #define TRACK_PRE_EMPHASIS   0x10
    58 #define TRACK_COPY_PERMITTED 0x20
    59 #define TRACK_DATA           0x40
    60 #define TRACK_FOUR_CHANNEL   0x80
    62 struct gdrom_track {
    63     gdrom_track_mode_t mode;
    64     uint8_t flags;        /* Track flags */
    65     int      session;     /* session # containing this track */
    66     uint32_t lba;         /* start sector address */
    67     uint32_t sector_size; /* For convenience, determined by mode */
    68     uint32_t sector_count;
    69     uint32_t offset; /* File offset of start of track - image files only */
    70 };
    73 typedef struct gdrom_disc {
    74     int disc_type;
    75     int track_count;
    76     struct gdrom_track track[99];
    77     gchar mcn[14]; /* Media catalogue number */
    78     const gchar *filename; /* Image filename */
    79     FILE *file; /* Stream, for image files */
    80     uint32_t (*read_sectors)( struct gdrom_disc *disc,
    81 			      uint32_t lba, uint32_t sector_count,
    82 			      int mode, char *buf, uint32_t *length );
    83     void (*close)( struct gdrom_disc *disc );
    84 } *gdrom_disc_t;
    86 /**
    87  * Construct a new image file using the default methods.
    88  */
    89 gdrom_disc_t gdrom_image_new( FILE *file );
    91 /**
    92  * Open an image file
    93  */
    94 gdrom_disc_t gdrom_image_open( const gchar *filename );
    95 gdrom_disc_t nrg_image_open( const gchar *filename );
    97 /**
    98  * Retrieve the disc table of contents, and write it into the buffer in the 
    99  * format expected by the DC.
   100  * @return 0 on success, error code on failure (eg no disc mounted)
   101  */
   102 gdrom_error_t gdrom_get_toc( char *buf );
   104 /**
   105  * Retrieve the short (6-byte) disc info, and write it into the buffer.
   106  * @return 0 on success, error code on failure.
   107  */
   108 gdrom_error_t gdrom_get_info( char *buf );
   110 /**
   111  * Shortcut to open and mount an image file
   112  */
   113 gdrom_disc_t gdrom_mount_image( const gchar *filename );
   115 void gdrom_mount_disc( gdrom_disc_t disc );
   117 void gdrom_unmount_disc( void );
   119 gboolean gdrom_is_mounted( void );
   121 uint32_t gdrom_read_sectors( uint32_t sector, uint32_t sector_count,
   122 			     int mode, char *buf, uint32_t *length );
   124 #endif
.