Search
lxdream.org :: lxdream/src/gdrom/gdrom.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdrom.c
changeset 167:71c0cc416a64
prev158:a0a82246b44e
next168:203a72138e16
author nkeynes
date Mon Jun 19 11:00:42 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change Add config value retrieval for pathnames
Implement default path for disc + save state loaders
Dump disc ID when mounting a CD
file annotate diff log raw
1.1 --- a/src/gdrom/gdrom.c Thu Jun 15 10:32:42 2006 +0000
1.2 +++ b/src/gdrom/gdrom.c Mon Jun 19 11:00:42 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: gdrom.c,v 1.7 2006-06-15 10:32:42 nkeynes Exp $
1.6 + * $Id: gdrom.c,v 1.8 2006-06-19 11:00:42 nkeynes Exp $
1.7 *
1.8 * GD-Rom access functions.
1.9 *
1.10 @@ -124,15 +124,35 @@
1.11 }
1.12
1.13
1.14 -void gdrom_dump_disc( gdrom_disc_t disc ) {
1.15 +void gdrom_dump_disc_info( gdrom_disc_t disc ) {
1.16 int i;
1.17 + int last_session = disc->track[disc->track_count-1].session;
1.18 + gboolean is_bootable = FALSE;
1.19 +
1.20 INFO( "Disc ID: %s, %d tracks in %d sessions", disc->mcn, disc->track_count,
1.21 disc->track[disc->track_count-1].session + 1 );
1.22 - for( i=0; i<disc->track_count; i++ ) {
1.23 - INFO( "Sess %d Trk %d: Start %06X Length %06X, %s",
1.24 - disc->track[i].session+1, i+1, disc->track[i].lba,
1.25 - disc->track[i].sector_count, gdrom_mode_names[disc->track[i].mode] );
1.26 + if( last_session > 0 ) {
1.27 + /* Boot track is the first data track of the last session, provided that it
1.28 + * cannot be a single-session disc.
1.29 + */
1.30 + int boot_track = -1;
1.31 + for( i=disc->track_count-1; i>=0 && disc->track[i].session == last_session; i-- ) {
1.32 + if( disc->track[i].flags & TRACK_DATA ) {
1.33 + boot_track = i;
1.34 + }
1.35 + }
1.36 + if( boot_track != -1 ) {
1.37 + char boot_sector[2048];
1.38 + uint32_t length = sizeof(boot_sector);
1.39 + if( disc->read_sectors( disc, disc->track[boot_track].lba, 1, GDROM_MODE1,
1.40 + boot_sector, &length ) == PKT_ERR_OK ) {
1.41 + bootstrap_dump(boot_sector, FALSE);
1.42 + is_bootable = TRUE;
1.43 + }
1.44 + }
1.45 }
1.46 + if( !is_bootable )
1.47 + WARN( "Disc does not appear to be bootable" );
1.48 }
1.49
1.50 gdrom_error_t gdrom_get_toc( char *buf )
1.51 @@ -192,7 +212,7 @@
1.52 gdrom_unmount_disc();
1.53 gdrom_disc = disc;
1.54 idereg.disc = disc->disc_type | IDE_DISC_READY;
1.55 - gdrom_dump_disc( disc );
1.56 + gdrom_dump_disc_info( disc );
1.57 }
1.58
1.59 gdrom_disc_t gdrom_mount_image( const gchar *filename )
.