Search
lxdream.org :: lxdream/src/gdrom/gdrom.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdrom.h
changeset 1296:30ecee61f811
prev1109:700c5ab26a63
author nkeynes
date Fri May 29 18:47:05 2015 +1000 (8 years ago)
permissions -rw-r--r--
last change Fix test case
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 "drivers/cdrom/defs.h"
    26 #include <glib.h>
    28 #ifdef __cplusplus
    29 extern "C" {
    30 #endif
    32 struct gdrom_toc {
    33     uint32_t track[99];
    34     uint32_t first, last, leadout;
    35 };
    37 #define GDROM_TOC_SIZE (102*4) /* Size of GDROM TOC structure */
    38 #define GDROM_SESSION_INFO_SIZE 6 /* Size of GDROM session info structure */
    39 #define GDROM_SHORT_STATUS_SIZE 14 /* Size of GDROM short status structure */
    41 typedef gboolean (*gdrom_disc_change_hook_t)( cdrom_disc_t new_disc, const gchar *new_disc_name, void *user_data );
    42 DECLARE_HOOK(gdrom_disc_change_hook, gdrom_disc_change_hook_t);
    44 typedef gboolean (*gdrom_drive_list_change_hook_t)( GList *drive_list, void *user_data );
    45 DECLARE_HOOK(gdrom_drive_list_change_hook, gdrom_drive_list_change_hook_t);
    47 /**
    48  * Open an image file
    49  */
    50 cdrom_disc_t gdrom_image_open( const gchar *filename );
    52 /**
    53  * Shortcut to open and mount an image file
    54  * @return true on success
    55  */
    56 gboolean gdrom_mount_image( const gchar *filename, ERROR *err );
    58 void gdrom_mount_disc( cdrom_disc_t disc );
    60 void gdrom_unmount_disc( void );
    62 gboolean gdrom_is_mounted( void );
    64 cdrom_disc_t gdrom_get_current_disc();
    66 const gchar *gdrom_get_current_disc_name();
    68 const gchar *gdrom_get_current_disc_title();
    70 /**
    71  * Find the track which should be checked for the
    72  * dreamcast bootstrap - this is the first data track on the last
    73  * session (where there are at least 2 sessions). If a boot track
    74  * cannot be found, returns NULL.
    75  */
    76 cdrom_track_t gdrom_disc_get_boot_track( cdrom_disc_t disc );
    78 /** 
    79  * Check if the disc contains valid media.
    80  * @return CDROM_ERROR_OK if disc is present, otherwise CDROM_ERROR_NODISC
    81  */
    82 cdrom_error_t gdrom_check_media( );
    84 /**
    85  * Retrieve the disc table of contents, and write it into the buffer in the 
    86  * format expected by the DC.
    87  * @param buf Buffer to receive the TOC data, which must be at least
    88  * GDROM_TOC_SIZE bytes long.
    89  * @return 0 on success, error code on failure (eg no disc)
    90  */
    91 cdrom_error_t gdrom_read_toc( unsigned char *buf );
    93 /**
    94  * Retrieve the short (6-byte) session info, and write it into the buffer.
    95  * @param session The session to read (numbered from 1), or 0 
    96  * @param buf Buffer to receive the session data, which must be at least
    97  * GDROM_SESSION_INFO_SIZE bytes long.
    98  * @return 0 on success, error code on failure.
    99  */
   100 cdrom_error_t gdrom_read_session( int session, unsigned char *buf );
   102 /**
   103  * Generate the position data as returned from a STATUS(1) packet. 
   104  * @param disc The disc to read
   105  * @param lba The current head position
   106  * @param buf The buffer to receive the position data, which must be at least
   107  * GDROM_SHORT_STATUS_SIZE bytes long.
   108  * @return 0 on success, error code on failure.
   109  */
   110 cdrom_error_t gdrom_read_short_status( uint32_t lba, unsigned char *buf );
   112 /**
   113  * Read sectors from the current disc.
   114  * @param lba Address of first sector to read
   115  * @param count Number of sectors to read
   116  * @param read_mode GDROM format read-mode
   117  * @param buf Buffer to receive read sectors
   118  * @param length If not null, will be written with the number of bytes read.
   119  * @return 0 on success, otherwise error code.
   120  */
   121 cdrom_error_t gdrom_read_cd( cdrom_lba_t lba, cdrom_count_t count,
   122                              unsigned read_mode, unsigned char *buf, size_t *length );
   124 cdrom_error_t gdrom_play_audio( cdrom_lba_t lba, cdrom_count_t count );
   126 /**
   127  * Return the 1-byte status code for the disc (combination of IDE_DISC_* flags)
   128  */
   129 int gdrom_get_drive_status( );
   131 /**
   132  * Run GDROM time slice (if any)
   133  */
   134 void gdrom_run_slice( uint32_t nanosecs );
   136 #ifdef __cplusplus
   137 }
   138 #endif
   140 #endif /* !lxdream_gdrom_H */
.