Search
lxdream.org :: lxdream/test/ide.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/ide.c
changeset 251:3c5953d944e0
prev247:b356d391d02a
author nkeynes
date Thu Jan 31 09:35:01 2008 +0000 (16 years ago)
permissions -rw-r--r--
last change Update release notes for 0.8.3
file annotate diff log raw
1.1 --- a/test/ide.c Tue Dec 19 09:56:09 2006 +0000
1.2 +++ b/test/ide.c Thu Jan 31 09:35:01 2008 +0000
1.3 @@ -124,10 +124,10 @@
1.4 int i;
1.5 for( i=0; i<MAX_WAIT; i++ ) {
1.6 status = byte_read(IDE_ALTSTATUS);
1.7 - if( (status & 0x80) != 0x80 )
1.8 + if( (status & 0x80) == 0 )
1.9 return 0;
1.10 }
1.11 - printf( "Timeout waiting for IDE to become ready\n" );
1.12 + printf( "Timeout waiting for IDE to become ready (status = 0x%02X)\n", status );
1.13 ide_dump_registers();
1.14 return 1;
1.15 }
1.16 @@ -164,20 +164,14 @@
1.17 byte_write( IDE_DEVICE, 0 );
1.18 byte_write( IDE_COMMAND, IDE_CMD_PACKET );
1.19 status = byte_read(IDE_ALTSTATUS); /* delay 1 PIO cycle as per spec */
1.20 - printf( "After writing PACKET command byte:\n" );
1.21 - ide_dump_registers();
1.22 /* Wait until device is ready to accept command */
1.23 if( ide_wait_ready() )
1.24 return 1;
1.25 - printf( "Device ready to receive packet:\n" );
1.26 - ide_dump_registers();
1.27
1.28 /* Write the command */
1.29 for( i=0; i<6; i++ ) {
1.30 word_write( IDE_DATA, spkt[i] );
1.31 }
1.32 - printf( "After writing command packet:\n" );
1.33 - ide_dump_registers();
1.34 }
1.35
1.36 int ide_read_pio( char *buf, int buflen ) {
1.37 @@ -334,6 +328,17 @@
1.38 return ide_do_packet_command_pio( cmd, buf, 10 );
1.39 }
1.40
1.41 +int ide_get_sense_code()
1.42 +{
1.43 + char buf[10];
1.44 + int len = ide_sense_error( buf );
1.45 + if( len != 10 ) {
1.46 + printf( "ERROR: Sense request failed!\n" );
1.47 + return -1;
1.48 + }
1.49 + return ((int)buf[8] << 8) | buf[2];
1.50 +}
1.51 +
1.52 void ide_print_sense_error()
1.53 {
1.54 char buf[10];
1.55 @@ -428,10 +433,11 @@
1.56 return 0;
1.57 }
1.58
1.59 -int ide_read_status( char *buf, int length )
1.60 +int ide_read_status( char *buf, int length, int type )
1.61 {
1.62 char cmd[12] = { 0x40,0,0,0, 0xFF,0,0,0, 0,0,0,0 };
1.63
1.64 + cmd[1] = type;
1.65 return ide_do_packet_command_pio( cmd, buf, length );
1.66 }
1.67
.