nkeynes@125: /** nkeynes@561: * $Id$ nkeynes@125: * nkeynes@678: * This file defines the public structures and functions exported by the nkeynes@678: * GD-Rom subsystem nkeynes@125: * nkeynes@125: * Copyright (c) 2005 Nathan Keynes. nkeynes@125: * nkeynes@125: * This program is free software; you can redistribute it and/or modify nkeynes@125: * it under the terms of the GNU General Public License as published by nkeynes@125: * the Free Software Foundation; either version 2 of the License, or nkeynes@125: * (at your option) any later version. nkeynes@125: * nkeynes@125: * This program is distributed in the hope that it will be useful, nkeynes@125: * but WITHOUT ANY WARRANTY; without even the implied warranty of nkeynes@125: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nkeynes@125: * GNU General Public License for more details. nkeynes@125: */ nkeynes@125: nkeynes@678: #ifndef lxdream_gdrom_H nkeynes@678: #define lxdream_gdrom_H 1 nkeynes@125: nkeynes@678: #include "lxdream.h" nkeynes@678: #include "hook.h" nkeynes@1097: #include "drivers/cdrom/defs.h" nkeynes@678: #include nkeynes@342: nkeynes@736: #ifdef __cplusplus nkeynes@736: extern "C" { nkeynes@736: #endif nkeynes@736: nkeynes@1101: struct gdrom_toc { nkeynes@1101: uint32_t track[99]; nkeynes@1101: uint32_t first, last, leadout; nkeynes@1101: }; nkeynes@1101: nkeynes@1023: #define GDROM_TOC_SIZE (102*4) /* Size of GDROM TOC structure */ nkeynes@1023: #define GDROM_SESSION_INFO_SIZE 6 /* Size of GDROM session info structure */ nkeynes@1023: #define GDROM_SHORT_STATUS_SIZE 14 /* Size of GDROM short status structure */ nkeynes@1023: nkeynes@1097: typedef gboolean (*gdrom_disc_change_hook_t)( cdrom_disc_t new_disc, const gchar *new_disc_name, void *user_data ); nkeynes@720: DECLARE_HOOK(gdrom_disc_change_hook, gdrom_disc_change_hook_t); nkeynes@138: nkeynes@720: typedef gboolean (*gdrom_drive_list_change_hook_t)( GList *drive_list, void *user_data ); nkeynes@720: DECLARE_HOOK(gdrom_drive_list_change_hook, gdrom_drive_list_change_hook_t); nkeynes@125: nkeynes@138: /** nkeynes@138: * Open an image file nkeynes@138: */ nkeynes@1097: cdrom_disc_t gdrom_image_open( const gchar *filename ); nkeynes@245: nkeynes@138: /** nkeynes@138: * Shortcut to open and mount an image file nkeynes@433: * @return true on success nkeynes@138: */ nkeynes@433: gboolean gdrom_mount_image( const gchar *filename ); nkeynes@138: nkeynes@1097: void gdrom_mount_disc( cdrom_disc_t disc ); nkeynes@138: nkeynes@138: void gdrom_unmount_disc( void ); nkeynes@138: nkeynes@138: gboolean gdrom_is_mounted( void ); nkeynes@138: nkeynes@1097: cdrom_disc_t gdrom_get_current_disc(); nkeynes@464: nkeynes@678: const gchar *gdrom_get_current_disc_name(); nkeynes@678: nkeynes@837: const gchar *gdrom_get_current_disc_title(); nkeynes@837: nkeynes@1023: /** nkeynes@1097: * Find the track which should be checked for the nkeynes@1097: * dreamcast bootstrap - this is the first data track on the last nkeynes@1097: * session (where there are at least 2 sessions). If a boot track nkeynes@1097: * cannot be found, returns NULL. nkeynes@1023: */ nkeynes@1097: cdrom_track_t gdrom_disc_get_boot_track( cdrom_disc_t disc ); nkeynes@1023: nkeynes@1023: /** nkeynes@1023: * Check if the disc contains valid media. nkeynes@1097: * @return CDROM_ERROR_OK if disc is present, otherwise CDROM_ERROR_NODISC nkeynes@1023: */ nkeynes@1097: cdrom_error_t gdrom_check_media( ); nkeynes@678: nkeynes@613: /** nkeynes@678: * Retrieve the disc table of contents, and write it into the buffer in the nkeynes@678: * format expected by the DC. nkeynes@1023: * @param buf Buffer to receive the TOC data, which must be at least nkeynes@1023: * GDROM_TOC_SIZE bytes long. nkeynes@1023: * @return 0 on success, error code on failure (eg no disc) nkeynes@613: */ nkeynes@1097: cdrom_error_t gdrom_read_toc( unsigned char *buf ); nkeynes@678: nkeynes@678: /** nkeynes@678: * Retrieve the short (6-byte) session info, and write it into the buffer. nkeynes@1023: * @param session The session to read (numbered from 1), or 0 nkeynes@1023: * @param buf Buffer to receive the session data, which must be at least nkeynes@1023: * GDROM_SESSION_INFO_SIZE bytes long. nkeynes@678: * @return 0 on success, error code on failure. nkeynes@678: */ nkeynes@1097: cdrom_error_t gdrom_read_session( int session, unsigned char *buf ); nkeynes@1023: nkeynes@1023: /** nkeynes@1023: * Generate the position data as returned from a STATUS(1) packet. nkeynes@1023: * @param disc The disc to read nkeynes@1023: * @param lba The current head position nkeynes@1023: * @param buf The buffer to receive the position data, which must be at least nkeynes@1023: * GDROM_SHORT_STATUS_SIZE bytes long. nkeynes@1023: * @return 0 on success, error code on failure. nkeynes@1023: */ nkeynes@1097: cdrom_error_t gdrom_read_short_status( uint32_t lba, unsigned char *buf ); nkeynes@1097: nkeynes@1097: /** nkeynes@1097: * Read sectors from the current disc. nkeynes@1097: * @param lba Address of first sector to read nkeynes@1097: * @param count Number of sectors to read nkeynes@1097: * @param read_mode GDROM format read-mode nkeynes@1097: * @param buf Buffer to receive read sectors nkeynes@1097: * @param length If not null, will be written with the number of bytes read. nkeynes@1097: * @return 0 on success, otherwise error code. nkeynes@1097: */ nkeynes@1097: cdrom_error_t gdrom_read_cd( cdrom_lba_t lba, cdrom_count_t count, nkeynes@1097: unsigned read_mode, unsigned char *buf, size_t *length ); nkeynes@1097: nkeynes@1097: cdrom_error_t gdrom_play_audio( cdrom_lba_t lba, cdrom_count_t count ); nkeynes@1023: nkeynes@1023: /** nkeynes@1023: * Return the 1-byte status code for the disc (combination of IDE_DISC_* flags) nkeynes@1023: */ nkeynes@1097: int gdrom_get_drive_status( ); nkeynes@678: nkeynes@709: /** nkeynes@1097: * Run GDROM time slice (if any) nkeynes@709: */ nkeynes@1097: void gdrom_run_slice( uint32_t nanosecs ); nkeynes@709: nkeynes@736: #ifdef __cplusplus nkeynes@736: } nkeynes@125: #endif nkeynes@736: nkeynes@736: #endif /* !lxdream_gdrom_H */