Search
lxdream.org :: lxdream :: r258:8864fae65928
lxdream 0.9.1
released Jun 29
Download Now
changeset258:8864fae65928
parent257:62fa1cabc46c
child259:7c6881790cc2
authornkeynes
dateFri Dec 29 00:23:16 2006 +0000 (13 years ago)
Fix byte-count handling in accordance with the actual DC chip
src/gdrom/ide.c
test/testide.c
1.1 --- a/src/gdrom/ide.c Fri Dec 29 00:21:46 2006 +0000
1.2 +++ b/src/gdrom/ide.c Fri Dec 29 00:23:16 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: ide.c,v 1.21 2006-12-21 11:13:10 nkeynes Exp $
1.6 + * $Id: ide.c,v 1.22 2006-12-29 00:23:13 nkeynes Exp $
1.7 *
1.8 * IDE interface implementation
1.9 *
1.10 @@ -223,10 +223,8 @@
1.11 } else {
1.12 idereg.state = IDE_STATE_PIO_READ;
1.13 idereg.status = 0x58;
1.14 - idereg.lba1 = length & 0xFF;
1.15 - idereg.lba2 = (length >> 8) & 0xFF;
1.16 - // idereg.lba1 = blocksize & 0xFF;
1.17 - // idereg.lba2 = blocksize >> 8;
1.18 + idereg.lba1 = blocksize & 0xFF;
1.19 + idereg.lba2 = blocksize >> 8;
1.20 idereg.block_length = blocksize;
1.21 idereg.block_left = blocksize;
1.22 ide_raise_interrupt( );
1.23 @@ -449,7 +447,7 @@
1.24 if( lba+length > sizeof(gdrom_ident) )
1.25 length = sizeof(gdrom_ident) - lba;
1.26 memcpy( data_buffer, gdrom_ident + lba, length );
1.27 - ide_start_packet_read( length, blocksize );
1.28 + ide_start_packet_read( length, length );
1.29 }
1.30 break;
1.31 case PKT_CMD_SENSE:
1.32 @@ -457,7 +455,7 @@
1.33 if( length > 10 )
1.34 length = 10;
1.35 memcpy( data_buffer, idereg.gdrom_sense, length );
1.36 - ide_start_packet_read( length, blocksize );
1.37 + ide_start_packet_read( length, length );
1.38 break;
1.39 case PKT_CMD_READ_TOC:
1.40 length = (cmd[3]<<8) | cmd[4];
1.41 @@ -468,7 +466,7 @@
1.42 if( status != PKT_ERR_OK ) {
1.43 ide_set_packet_result( status );
1.44 } else {
1.45 - ide_start_packet_read( length, blocksize );
1.46 + ide_start_packet_read( length, length );
1.47 }
1.48 break;
1.49 case PKT_CMD_SESSION_INFO:
1.50 @@ -479,7 +477,7 @@
1.51 if( status != PKT_ERR_OK ) {
1.52 ide_set_packet_result( status );
1.53 } else {
1.54 - ide_start_packet_read( length, blocksize );
1.55 + ide_start_packet_read( length, length );
1.56 }
1.57 break;
1.58 case PKT_CMD_PLAY_CD:
1.59 @@ -515,10 +513,11 @@
1.60 idereg.gdrom_sense[5] = (lba >> 16) & 0xFF;
1.61 idereg.gdrom_sense[6] = (lba >> 8) & 0xFF;
1.62 idereg.gdrom_sense[7] = lba & 0xFF;
1.63 + WARN( " => Read CD returned sense key %02X, %02X", status & 0xFF, status >> 8 );
1.64 } else {
1.65 idereg.last_read_lba = lba + length;
1.66 idereg.last_read_track = gdrom_get_track_no_by_lba( idereg.last_read_lba );
1.67 - ide_start_packet_read( datalen, blocksize );
1.68 + ide_start_packet_read( datalen, 0x0800 );
1.69 }
1.70 break;
1.71 case PKT_CMD_SPIN_UP:
1.72 @@ -537,7 +536,7 @@
1.73 length = sizeof(gdrom_status);
1.74 }
1.75 memcpy( data_buffer, gdrom_status, length );
1.76 - ide_start_packet_read( length, blocksize );
1.77 + ide_start_packet_read( length, length );
1.78 break;
1.79 case 1:
1.80 if( length > 14 ) {
1.81 @@ -559,7 +558,7 @@
1.82 data_buffer[11] = (idereg.last_read_lba >> 16) & 0xFF;
1.83 data_buffer[12] = (idereg.last_read_lba >> 8) & 0xFF;
1.84 data_buffer[13] = idereg.last_read_lba & 0xFF;
1.85 - ide_start_packet_read( length, blocksize );
1.86 + ide_start_packet_read( length, length );
1.87 break;
1.88 }
1.89 }
1.90 @@ -570,7 +569,7 @@
1.91 * For sake of something to do, it returns the results from a test dump
1.92 */
1.93 memcpy( data_buffer, gdrom_71, sizeof(gdrom_71) );
1.94 - ide_start_packet_read( sizeof(gdrom_71), blocksize );
1.95 + ide_start_packet_read( sizeof(gdrom_71), sizeof(gdrom_71) );
1.96 break;
1.97 default:
1.98 ide_set_packet_result( PKT_ERR_BADCMD ); /* Invalid command */
2.1 --- a/test/testide.c Fri Dec 29 00:21:46 2006 +0000
2.2 +++ b/test/testide.c Fri Dec 29 00:23:16 2006 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: testide.c,v 1.4 2006-12-21 10:14:24 nkeynes Exp $
2.6 + * $Id: testide.c,v 1.5 2006-12-29 00:23:16 nkeynes Exp $
2.7 *
2.8 * IDE interface test cases. Covers all (known) IDE registers in the
2.9 * 5F7000 - 5F74FF range including DMA, but does not cover any GD-Rom
2.10 @@ -377,7 +377,6 @@
2.11 byte_write( IDE_COUNT, 0x0B );
2.12 byte_write( IDE_COMMAND, 0xEF );
2.13 EXPECT_READY();
2.14 - CHECK_INTRQ_CLEAR();
2.15 CHECK_REGS( post_set_feature_regs );
2.16
2.17 /** Set Multi-word DMA mode 2 */
2.18 @@ -450,6 +449,8 @@
2.19 return 0;
2.20 }
2.21
2.22 +
2.23 +
2.24 /**
2.25 * Test DMA transfer (using the Inquiry packet comand)
2.26 */
2.27 @@ -477,6 +478,41 @@
2.28 return 0;
2.29 }
2.30
2.31 +int test_read_pio()
2.32 +{
2.33 + int i,j;
2.34 + char cmd[12] = {0x30, 0x28, 0, 0x2E, 0x4C, 0, 0, 0, 0, 0, 7, 0 };
2.35 + uint32_t read_pio_ready_regs[] =
2.36 + { IDE_ALTSTATUS, 0x58,
2.37 + IDE_ERROR, 0x00,
2.38 + IDE_COUNT, 0x02,
2.39 + IDE_LBA1, 0x00,
2.40 + IDE_LBA2, 0x08,
2.41 + IDE_DEVICE, 0,
2.42 + IDE_STATUS, 0x58, 0, 0 };
2.43 +
2.44 + if( send_packet_command(cmd) != 0 ) {
2.45 + return -1;
2.46 + }
2.47 +
2.48 + for( j=0; j<7; j++ ) {
2.49 + CHECK_REGS(read_pio_ready_regs);
2.50 + CHECK_INTRQ_CLEAR();
2.51 + for( i=0; i<0x0800; i+=2 ) {
2.52 + word_read(IDE_DATA); // throw away for now.
2.53 + }
2.54 +
2.55 + EXPECT_INTRQ();
2.56 + EXPECT_READY();
2.57 + }
2.58 +
2.59 + read_pio_ready_regs[1] = 0x50;
2.60 + read_pio_ready_regs[5] = 0x03;
2.61 + read_pio_ready_regs[13] = 0x50;
2.62 + CHECK_REGS( read_pio_ready_regs );
2.63 + return 0;
2.64 +}
2.65 +
2.66 /**
2.67 * Test interaction of Read CD (0x30) with Status (0x40,1)
2.68 */
2.69 @@ -519,7 +555,7 @@
2.70 typedef int (*test_func_t)();
2.71
2.72 test_func_t test_fns[] = { test_enable, test_reset, test_packet,
2.73 - test_dma, test_dma_abort,
2.74 + test_dma, test_dma_abort, test_read_pio,
2.75 test_read_toc,
2.76 test_status1, NULL };
2.77
.