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