Search
lxdream.org :: lxdream/src/gdrom/gdrom.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdrom.h
changeset 1023:264e2fd90be8
prev837:4eae2ddccf9c
next1097:d4807997e450
author nkeynes
date Mon Jun 22 01:13:16 2009 +0000 (14 years ago)
permissions -rw-r--r--
last change Fix disc type breakage introduced in last refactor
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * This file defines the public structures and functions exported by the 
     5  * GD-Rom subsystem
     6  *
     7  * Copyright (c) 2005 Nathan Keynes.
     8  *
     9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  */
    20 #ifndef lxdream_gdrom_H
    21 #define lxdream_gdrom_H 1
    23 #include "lxdream.h"
    24 #include "hook.h"
    25 #include <glib/glist.h>
    27 #ifdef __cplusplus
    28 extern "C" {
    29 #endif
    31 #define GDROM_TOC_SIZE (102*4) /* Size of GDROM TOC structure */
    32 #define GDROM_SESSION_INFO_SIZE 6 /* Size of GDROM session info structure */
    33 #define GDROM_SHORT_STATUS_SIZE 14 /* Size of GDROM short status structure */
    35 typedef uint16_t gdrom_error_t;
    38 struct gdrom_device {
    39     char *name;  // internal name
    40     char *device_name; // Human-readable device name
    41 };
    43 typedef struct gdrom_device *gdrom_device_t;
    45 typedef struct gdrom_disc *gdrom_disc_t;
    47 typedef gboolean (*gdrom_disc_change_hook_t)( gdrom_disc_t new_disc, const gchar *new_disc_name, void *user_data );
    48 DECLARE_HOOK(gdrom_disc_change_hook, gdrom_disc_change_hook_t);
    50 typedef gboolean (*gdrom_drive_list_change_hook_t)( GList *drive_list, void *user_data );
    51 DECLARE_HOOK(gdrom_drive_list_change_hook, gdrom_drive_list_change_hook_t);
    53 /**
    54  * Open an image file
    55  */
    56 gdrom_disc_t gdrom_image_open( const gchar *filename );
    58 /**
    59  * Read image bootstrap info
    60  */
    61 gboolean gdrom_image_read_info( gdrom_disc_t d );
    64 /**
    65  * Shortcut to open and mount an image file
    66  * @return true on success
    67  */
    68 gboolean gdrom_mount_image( const gchar *filename );
    70 void gdrom_mount_disc( gdrom_disc_t disc );
    72 void gdrom_unmount_disc( void );
    74 gboolean gdrom_is_mounted( void );
    76 gdrom_disc_t gdrom_get_current_disc();
    78 const gchar *gdrom_get_current_disc_name();
    80 const gchar *gdrom_get_current_disc_title();
    83 /**
    84  * Find the track (numbered from 1) containing the sector specified by LBA.
    85  * Note: this function does not check for media change.
    86  * @return The track number, or -1 if no track contains the sector.
    87  */
    88 int gdrom_disc_get_track_by_lba( gdrom_disc_t disc, uint32_t lba );
    90 /** 
    91  * Check if the disc contains valid media.
    92  * @return PKT_ERR_OK if disc is present, otherwise PKT_ERR_NODISC
    93  */
    94 gdrom_error_t gdrom_disc_check_media( gdrom_disc_t disc ); 
    96 /**
    97  * Retrieve the disc table of contents, and write it into the buffer in the 
    98  * format expected by the DC.
    99  * @param disc The disc to read
   100  * @param buf Buffer to receive the TOC data, which must be at least
   101  * GDROM_TOC_SIZE bytes long.
   102  * @return 0 on success, error code on failure (eg no disc)
   103  */
   104 gdrom_error_t gdrom_disc_get_toc( gdrom_disc_t disc, unsigned char *buf );
   106 /**
   107  * Retrieve the short (6-byte) session info, and write it into the buffer.
   108  * @param disc The disc to read
   109  * @param session The session to read (numbered from 1), or 0 
   110  * @param buf Buffer to receive the session data, which must be at least
   111  * GDROM_SESSION_INFO_SIZE bytes long.
   112  * @return 0 on success, error code on failure.
   113  */
   114 gdrom_error_t gdrom_disc_get_session_info( gdrom_disc_t disc, int session, unsigned char *buf );
   116 /**
   117  * Generate the position data as returned from a STATUS(1) packet. 
   118  * @param disc The disc to read
   119  * @param lba The current head position
   120  * @param buf The buffer to receive the position data, which must be at least
   121  * GDROM_SHORT_STATUS_SIZE bytes long.
   122  * @return 0 on success, error code on failure.
   123  */
   124 gdrom_error_t gdrom_disc_get_short_status( gdrom_disc_t disc, uint32_t lba, unsigned char *buf );
   126 /**
   127  * Return the 1-byte status code for the disc (combination of IDE_DISC_* flags)
   128  */
   129 int gdrom_disc_get_drive_status( gdrom_disc_t disc );
   131 /**
   132  * Native CD-ROM API - provided by drivers/cd_*.c
   133  *
   134  * A device name is either a system special file (most unixes) or a url of the
   135  * form dvd://<identifier> or cd://<identifier>, where <identifier> is a system
   136  * defined string that uniquely identifies a particular device.
   137  */
   139 /**
   140  * Return a list of gdrom_device_t defining all CD/DVD drives in the host system.
   141  */
   142 GList *cdrom_get_native_devices();
   144 /**
   145  * Open a native device given a device name and url method. Eg, for the url dvd://1
   146  * this function will be invoked with method = "dvd" and name = "1"
   147  * 
   148  * @return NULL on failure, otherwise a valid gdrom_disc_t that can be mounted.
   149  */
   150 gdrom_disc_t cdrom_open_device( const gchar *method, const gchar *name );
   152 #ifdef __cplusplus
   153 }
   154 #endif
   156 #endif /* !lxdream_gdrom_H */
.