Search
lxdream.org :: lxdream/src/gdrom/ide.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/ide.c
changeset 245:a1d0655a88d3
prev240:9ae4bd697292
next250:84e056e12a19
author nkeynes
date Tue Dec 19 09:52:56 2006 +0000 (13 years ago)
permissions -rw-r--r--
last change Work in progress: 0x40,1 (read status)
file annotate diff log raw
1.1 --- a/src/gdrom/ide.c Fri Dec 15 10:18:39 2006 +0000
1.2 +++ b/src/gdrom/ide.c Tue Dec 19 09:52:56 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: ide.c,v 1.17 2006-12-15 10:18:39 nkeynes Exp $
1.6 + * $Id: ide.c,v 1.18 2006-12-19 09:52:56 nkeynes Exp $
1.7 *
1.8 * IDE interface implementation
1.9 *
1.10 @@ -134,6 +134,9 @@
1.11 memset( idereg.gdrom_sense, '\0', 10 );
1.12 idereg.data_offset = -1;
1.13 idereg.data_length = -1;
1.14 + idereg.last_read_track = 1;
1.15 + idereg.last_read_lba = 150;
1.16 + idereg.last_read_count = 0;
1.17 }
1.18
1.19 static void ide_save_state( FILE *f )
1.20 @@ -454,9 +457,9 @@
1.21 lba = cmd[2] << 16 | cmd[3] << 8 | cmd[4];
1.22 length = cmd[8] << 16 | cmd[9] << 8 | cmd[10]; /* blocks */
1.23 switch( cmd[1] ) {
1.24 - case 0x20: mode = GDROM_MODE1; break;
1.25 + case 0x20: mode = GDROM_MODE1; break; /* TODO - might be unchecked? */
1.26 case 0x24: mode = GDROM_GD; break;
1.27 - case 0x28: mode = GDROM_MODE1; break; /* ??? */
1.28 + case 0x28: mode = GDROM_MODE2_XA1; break; /* ??? */
1.29 case 0x30: mode = GDROM_RAW; break;
1.30 default:
1.31 ERROR( "Unrecognized read mode '%02X' in GD-Rom read request", cmd[1] );
1.32 @@ -479,6 +482,9 @@
1.33 idereg.gdrom_sense[6] = (lba >> 8) & 0xFF;
1.34 idereg.gdrom_sense[7] = lba & 0xFF;
1.35 } else {
1.36 + idereg.last_read_count += length;
1.37 + idereg.last_read_lba = lba + length;
1.38 + idereg.last_read_track = gdrom_get_track_no_by_lba( idereg.last_read_lba );
1.39 ide_start_packet_read( datalen, blocksize );
1.40 }
1.41 break;
1.42 @@ -487,6 +493,39 @@
1.43 ide_set_packet_result( PKT_ERR_OK );
1.44 ide_raise_interrupt();
1.45 break;
1.46 + case PKT_CMD_STATUS:
1.47 + length = cmd[4];
1.48 + if( !gdrom_is_mounted() ) {
1.49 + ide_set_packet_result( PKT_ERR_NODISC );
1.50 + } else {
1.51 + switch( cmd[1] ) {
1.52 + case 0:
1.53 + break;
1.54 + case 1:
1.55 + if( length > 16 ) {
1.56 + length = 16;
1.57 + }
1.58 + data_buffer[0] = 0x00;
1.59 + data_buffer[1] = 0x15; /* ??? */
1.60 + data_buffer[2] = 0x00;
1.61 + data_buffer[3] = 0x0E;
1.62 + data_buffer[4] = gdrom_get_track(idereg.last_read_track)->flags;
1.63 + data_buffer[5] = idereg.last_read_track;
1.64 + data_buffer[6] = 0x01; /* ?? */
1.65 + data_buffer[7] = (idereg.last_read_count >> 16) & 0xFF;
1.66 + data_buffer[8] = (idereg.last_read_count >> 8) & 0xFF;
1.67 + data_buffer[9] = idereg.last_read_count & 0xFF;
1.68 + data_buffer[10] = (idereg.last_read_lba >> 24) & 0xFF;
1.69 + data_buffer[11] = (idereg.last_read_lba >> 16) & 0xFF;
1.70 + data_buffer[12] = (idereg.last_read_lba >> 8) & 0xFF;
1.71 + data_buffer[13] = idereg.last_read_lba & 0xFF;
1.72 + data_buffer[14] = 0x00;
1.73 + data_buffer[15] = 0x00;
1.74 + ide_start_packet_read( length, blocksize );
1.75 + break;
1.76 + }
1.77 + }
1.78 + break;
1.79 case PKT_CMD_71:
1.80 /* This is a weird one. As far as I can tell it returns random garbage
1.81 * (and not even the same length each time, never mind the same data).
.