Search
lxdream.org :: lxdream/src/gdrom/ide.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/ide.c
changeset 143:9446fb6df0c5
prev142:2f631c3a3946
next149:d88dd2e9a190
author nkeynes
date Wed May 03 12:52:38 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Add (track) mode parameter to read sectors call
Fix missing interrupt on end-of-packet read.
file annotate diff log raw
1.1 --- a/src/gdrom/ide.c Tue May 02 14:09:11 2006 +0000
1.2 +++ b/src/gdrom/ide.c Wed May 03 12:52:38 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: ide.c,v 1.11 2006-05-02 14:09:11 nkeynes Exp $
1.6 + * $Id: ide.c,v 1.12 2006-05-03 12:52:38 nkeynes Exp $
1.7 *
1.8 * IDE interface implementation
1.9 *
1.10 @@ -72,7 +72,7 @@
1.11 idereg.feature = 0; /* Indeterminate really */
1.12 idereg.status = 0x00;
1.13 idereg.device = 0x00;
1.14 - idereg.disc = gdrom_is_mounted() ? IDE_DISC_NONE : (IDE_DISC_CDROM|IDE_DISC_READY);
1.15 + idereg.disc = gdrom_is_mounted() ? (IDE_DISC_CDROM|IDE_DISC_READY) : IDE_DISC_NONE;
1.16 }
1.17
1.18 static void ide_save_state( FILE *f )
1.19 @@ -147,6 +147,7 @@
1.20 if( idereg.datalen <=0 ) {
1.21 idereg.readptr = NULL;
1.22 idereg.status &= ~IDE_ST_DATA;
1.23 + ide_raise_interrupt();
1.24 } else if( idereg.blockleft <= 0 ) {
1.25 ide_raise_interrupt();
1.26 idereg.blockleft = idereg.blocksize;
1.27 @@ -223,8 +224,8 @@
1.28 void ide_set_packet_error( uint16_t error )
1.29 {
1.30 idereg.gdrom_error = error;
1.31 + idereg.error = (error & 0x0F) << 4;
1.32 if( error != 0 ) {
1.33 - idereg.error = (error & 0x0F) << 4;
1.34 idereg.status = 0x51;
1.35 }
1.36 }
1.37 @@ -237,7 +238,8 @@
1.38 void ide_packet_command( unsigned char *cmd )
1.39 {
1.40 uint32_t length, datalen;
1.41 - uint32_t lba;
1.42 + uint32_t lba, status;
1.43 + int mode;
1.44 int blocksize = idereg.lba1 + (idereg.lba2<<8);
1.45
1.46 ide_raise_interrupt( );
1.47 @@ -295,14 +297,22 @@
1.48 data_buffer = realloc( data_buffer, data_buffer_len );
1.49 }
1.50
1.51 - if( !gdrom_is_mounted() ) {
1.52 - ide_set_packet_error( PKT_ERR_NODISC );
1.53 + switch( cmd[1] ) {
1.54 + case 0x20: mode = GDROM_MODE1; break;
1.55 + case 0x24: mode = GDROM_GD; break;
1.56 + case 0x28: mode = GDROM_MODE1; break; /* ??? */
1.57 + case 0x30: mode = GDROM_RAW; break;
1.58 + default:
1.59 + ERROR( "Unrecognized read mode '%02X' in GD-Rom read request", cmd[1] );
1.60 + ide_set_packet_error( PKT_ERR_BADFIELD );
1.61 return;
1.62 }
1.63
1.64 - datalen = gdrom_read_sectors( lba, length, data_buffer );
1.65 - if( datalen == 0 ) {
1.66 - ide_set_packet_error( 0x05 );
1.67 + status = gdrom_read_sectors( lba, length, mode, data_buffer, &data_buffer_len );
1.68 + if( status != 0 ) {
1.69 + ide_set_packet_error( status );
1.70 + data_buffer[6] = (lba >> 8) & 0xFF;
1.71 + data_buffer[7] = lba & 0xFF;
1.72 return;
1.73 }
1.74 ide_set_read_buffer( data_buffer, datalen, blocksize );
.