Search
lxdream.org :: lxdream/src/gdrom/ide.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/ide.c
changeset 1023:264e2fd90be8
prev888:9892c970b95a
next1075:1a21750d300c
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
1.1 --- a/src/gdrom/ide.c Mon Oct 20 06:15:58 2008 +0000
1.2 +++ b/src/gdrom/ide.c Mon Jun 08 04:12:21 2009 +0000
1.3 @@ -174,8 +174,10 @@
1.4
1.5 static int ide_load_state( FILE *f )
1.6 {
1.7 - fread( &idereg, sizeof(idereg), 1, f );
1.8 - fread( data_buffer, MAX_SECTOR_SIZE, 1, f );
1.9 + if( fread( &idereg, sizeof(idereg), 1, f ) != 1 ||
1.10 + fread( data_buffer, MAX_SECTOR_SIZE, 1, f ) != 1 ) {
1.11 + return -1;
1.12 + }
1.13 return 0;
1.14 }
1.15
1.16 @@ -441,14 +443,10 @@
1.17
1.18 uint8_t ide_get_drive_status( void )
1.19 {
1.20 - if( gdrom_disc == NULL ) {
1.21 - return IDE_DISC_NONE;
1.22 - } else {
1.23 - return gdrom_disc->drive_status(gdrom_disc);
1.24 - }
1.25 + return gdrom_disc_get_drive_status(gdrom_disc);
1.26 }
1.27
1.28 -#define REQUIRE_DISC() if( gdrom_disc == NULL ) { ide_set_packet_result( PKT_ERR_NODISC ); return; }
1.29 +#define REQUIRE_DISC() if( gdrom_disc == NULL || gdrom_disc->disc_type == IDE_DISC_NONE ) { ide_set_packet_result( PKT_ERR_NODISC ); return; }
1.30
1.31 /**
1.32 * Read the next sector from the active read, if any
1.33 @@ -509,7 +507,7 @@
1.34 uint8_t status = ide_get_drive_status();
1.35 /* FIXME: Refactor read_position to avoid this kind of crud */
1.36 unsigned char tmp[16];
1.37 - gdrom_disc->read_position( gdrom_disc, idereg.current_lba, tmp );
1.38 + gdrom_disc_get_short_status( gdrom_disc, idereg.current_lba, tmp );
1.39
1.40 length = cmd[4];
1.41 if( lba+length > GDROM_DRIVE_STATUS_LENGTH )
1.42 @@ -563,10 +561,10 @@
1.43 case PKT_CMD_READ_TOC:
1.44 REQUIRE_DISC();
1.45 length = (cmd[3]<<8) | cmd[4];
1.46 - if( length > sizeof(struct gdrom_toc) )
1.47 - length = sizeof(struct gdrom_toc);
1.48 + if( length > GDROM_TOC_SIZE )
1.49 + length = GDROM_TOC_SIZE;
1.50
1.51 - status = gdrom_disc->read_toc( gdrom_disc, data_buffer );
1.52 + status = gdrom_disc_get_toc( gdrom_disc, data_buffer );
1.53 if( status != PKT_ERR_OK ) {
1.54 ide_set_packet_result( status );
1.55 } else {
1.56 @@ -578,7 +576,7 @@
1.57 length = cmd[4];
1.58 if( length > 6 )
1.59 length = 6;
1.60 - status = gdrom_disc->read_session( gdrom_disc, cmd[2], data_buffer );
1.61 + status = gdrom_disc_get_session_info( gdrom_disc, cmd[2], data_buffer );
1.62 if( status != PKT_ERR_OK ) {
1.63 ide_set_packet_result( status );
1.64 } else {
1.65 @@ -619,11 +617,7 @@
1.66 if( length > 14 ) {
1.67 length = 14;
1.68 }
1.69 - gdrom_disc->read_position( gdrom_disc, idereg.current_lba, data_buffer );
1.70 - data_buffer[0] = 0x00;
1.71 - data_buffer[1] = 0x15; /* audio status ? */
1.72 - data_buffer[2] = 0x00;
1.73 - data_buffer[3] = 0x0E;
1.74 + gdrom_disc_get_short_status( gdrom_disc, idereg.current_lba, data_buffer );
1.75 ide_start_packet_read( length, 0 );
1.76 break;
1.77 }
.