Search
lxdream.org :: lxdream/test/testide.c :: diff
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
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/testide.c Tue Jul 11 01:35:27 2006 +0000
1.3 @@ -0,0 +1,90 @@
1.4 +#include <assert.h>
1.5 +#include <ctype.h>
1.6 +#include "ide.h"
1.7 +void debug_dump_buffer(char *buf, int length)
1.8 +{
1.9 + int i,j;
1.10 + for( i=0; i<length; i+=16 ) {
1.11 + printf( "%08X: ", i );
1.12 + for( j=0; j<16 && i+j < length; j+=4 ) {
1.13 + unsigned int val = *((volatile unsigned int *)(buf+i+j));
1.14 + printf( "%02X %02X %02X %02X ", val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF, (val>>24)&0xFF );
1.15 + }
1.16 + for( j=0; j<16 && i+j < length; j++ ) {
1.17 + printf( "%c", isprint(buf[i+j]) ? buf[i+j] : '.' );
1.18 + }
1.19 + printf("\n");
1.20 + }
1.21 +}
1.22 +
1.23 +void debug_dump_int_buffer(volatile char *buf, int length)
1.24 +{
1.25 + int i,j;
1.26 + for( i=0; i<length; i+=16 ) {
1.27 + printf( "%08X:", i );
1.28 + for( j=0; j<16 && i+j < length; j+=4 ) {
1.29 + printf( " %08X", *((volatile unsigned int *)(buf+i+j)) );
1.30 + }
1.31 + printf( "\n" );
1.32 + }
1.33 +}
1.34 +
1.35 +
1.36 +char buf[2048*7 + 32];
1.37 +
1.38 +int test_ide_read_bootstrap()
1.39 +{
1.40 + struct gdrom_session session;
1.41 + int length;
1.42 + char *p;
1.43 +
1.44 + ide_init();
1.45 +
1.46 + if( ide_test_ready() != 0 ) {
1.47 + printf( "ERROR - Test ready failed\n" );
1.48 + return -1;
1.49 + }
1.50 +
1.51 + if( ide_spinup() != 0 ) {
1.52 + printf( "ERROR - Spinup failed\n" );
1.53 + return -1;
1.54 + }
1.55 +
1.56 + /*
1.57 + length = ide_unknown71( buf, sizeof(buf) );
1.58 + if( length == -1 ) {
1.59 + printf( "ERROR - 0x71 failed\n" );
1.60 + ide_print_sense_error();
1.61 + return -1;
1.62 + }
1.63 + debug_dump_buffer(buf,length);
1.64 + */
1.65 + if( ide_get_session( 0, &session ) == -1 ) {
1.66 + printf( "ERROR - Get session(0) failed\n" );
1.67 + return -1;
1.68 + }
1.69 + if( ide_get_session( session.track, &session ) == -1 ) {
1.70 + printf( "ERROR - Get session(%d) failed\n", session.track );
1.71 + return -1;
1.72 + }
1.73 +
1.74 + p = (char *)((((unsigned int)buf) & 0xFFFFFFE0) + 0x20);
1.75 + printf( "--- DMA buffer: %08X\n", p );
1.76 + length = ide_read_sector_dma( session.lba, 2, 0x28, p, 2048*2 );
1.77 + if( length != 2048*2 ) {
1.78 + printf( "ERROR - Got incorrect read length, expected %d but was %d\n", 2048, length );
1.79 + return -1;
1.80 + }
1.81 + debug_dump_buffer( p, 2048*2 );
1.82 +
1.83 + return 0;
1.84 +}
1.85 +
1.86 +
1.87 +int main( int argc, char *argv[] )
1.88 +{
1.89 + ide_dump_registers();
1.90 + ide_spinup();
1.91 + ide_read_something();
1.92 +// test_ide_read_bootstrap();
1.93 +}
.