Search
lxdream.org :: lxdream/test/testide.c
lxdream 0.9.1
released Jun 29
Download Now
filename test/testide.c
changeset 185:6755a04c447f
next248:f8022f2ef2a2
author nkeynes
date Tue Jul 11 01:35:27 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change First commit of system test framework. 3 initial test cases (incomplete):
testide, testmath, and testta
view annotate diff log raw
     1 #include <assert.h>
     2 #include <ctype.h>
     3 #include "ide.h"
     4 void debug_dump_buffer(char *buf, int length)
     5 {
     6     int i,j;
     7     for( i=0; i<length; i+=16 ) {
     8 	printf( "%08X: ", i );
     9         for( j=0; j<16 && i+j < length; j+=4 ) {
    10 	    unsigned int val = *((volatile unsigned int *)(buf+i+j));
    11 	    printf( "%02X %02X %02X %02X  ", val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF, (val>>24)&0xFF );
    12         }
    13 	for( j=0; j<16 && i+j < length; j++ ) {
    14 	    printf( "%c", isprint(buf[i+j]) ? buf[i+j] : '.' );
    15 	}
    16 	printf("\n");
    17     }
    18 }
    20 void debug_dump_int_buffer(volatile char *buf, int length)
    21 {
    22     int i,j;
    23     for( i=0; i<length; i+=16 ) {
    24 	printf( "%08X:", i );
    25         for( j=0; j<16 && i+j < length; j+=4 ) {
    26 	    printf( " %08X", *((volatile unsigned int *)(buf+i+j)) );
    27         }
    28 	printf( "\n" );
    29     }
    30 }
    33 char buf[2048*7 + 32];
    35 int test_ide_read_bootstrap()
    36 {
    37     struct gdrom_session session;
    38     int length;
    39     char *p;
    41     ide_init();
    43     if( ide_test_ready() != 0 ) {
    44 	printf( "ERROR - Test ready failed\n" );
    45 	return -1;
    46     }
    48     if( ide_spinup() != 0 ) {
    49 	printf( "ERROR - Spinup failed\n" );
    50 	return -1;
    51     }
    53     /*
    54     length = ide_unknown71( buf, sizeof(buf) );
    55     if( length == -1 ) {
    56 	printf( "ERROR - 0x71 failed\n" );
    57 	ide_print_sense_error();
    58 	return -1;
    59     }
    60     debug_dump_buffer(buf,length);
    61     */
    62     if( ide_get_session( 0, &session ) == -1 ) {
    63 	printf( "ERROR - Get session(0) failed\n" );
    64 	return -1;
    65     }
    66     if( ide_get_session( session.track, &session ) == -1 ) {
    67 	printf( "ERROR - Get session(%d) failed\n", session.track );
    68 	return -1;
    69     }
    71     p = (char *)((((unsigned int)buf) & 0xFFFFFFE0) + 0x20);
    72     printf( "--- DMA buffer: %08X\n",  p );
    73     length = ide_read_sector_dma( session.lba, 2, 0x28, p, 2048*2 );
    74     if( length != 2048*2 ) {
    75 	printf( "ERROR - Got incorrect read length, expected %d but was %d\n", 2048, length );
    76 	return -1;
    77     }
    78     debug_dump_buffer( p, 2048*2 );
    80     return 0;
    81 }
    84 int main( int argc, char *argv[] )
    85 {
    86     ide_dump_registers();
    87     ide_spinup();
    88     ide_read_something();
    89 //    test_ide_read_bootstrap();
    90 }
.