📄 testdma.c
字号:
printf( "Status of last async transfer: %0d\n", sysVmeDmaGetLastAsyncStatus() ); /* * Remove the interrupt vector to prevent problems when we want to test * the sync (blocking) version. */ sysVmeDmaConnect( (FUNCPTR) NULL ); printf( "Async DMA interrupt handler removed (replaced with NULL).\n" );}/****************************************************************/void testLockAsync( UINT32 tenths_of_seconds ){ BOOL timeout = FALSE, waiting_flag = FALSE; int i = 0; STATUS ret_val; BOOL originalDebugState; printf( "testLockAsync: Delay %0d0 mseconds, lock DMA, do async transfer, unlock DMA\n", tenths_of_seconds ); /* Get original state of debug value and set state of debug value * to TRUE to get display out of this function. */ originalDebugState = sysVmeDmaGetDebugState ();#ifdef CHANGE_DEBUG_STATE sysVmeDmaSetDebugState( DEFAULT_DEBUG_STATE );#endif fprintf(stdout, "Async delaying %0d tenths_of_seconds before attempting to take lock\n", tenths_of_seconds ); TimeDelay( tenths_of_seconds ); fprintf(stdout, "Async attempting to take the lock (%0d)\n", tenths_of_seconds ); while( ((ret_val = sysVmeDmaLock()) != OK) && !timeout ) { if( !waiting_flag ) { fprintf(stdout, "Async waiting for the lock (%0d)\n", tenths_of_seconds ); waiting_flag = TRUE; } TimeDelay( 1 ); i++; if( i > LOCK_TIMEOUT ) timeout = TRUE; } if( timeout ) { fprintf(stdout, "Async timeout occured waiting for the lock (%0d)\n", tenths_of_seconds ); return; } fprintf(stdout, "Async got the lock (%0d)\n", tenths_of_seconds ); testAsync();#if 1 ret_val = sysVmeDmaUnlock ( DO_NOT_FORCE_UNLOCK );#else ret_val = sysVmeDmaUnlock ( FORCE_UNLOCK );#endif fprintf(stdout, "Async released the lock (sec = %0d, ret = %0d)\n", tenths_of_seconds, ret_val ); /* Restore original state of debug value. */ sysVmeDmaSetDebugState( originalDebugState );}/****************************************************************/void testLockSync( UINT32 tenths_of_seconds ){ BOOL timeout = FALSE, waiting_flag = FALSE; int i = 0; STATUS ret_val; BOOL originalDebugState; printf( "testLockSync: Delay %0d0 mseconds, lock DMA, do sync transfer, unlock DMA\n", tenths_of_seconds ); /* Get original state of debug value and set state of debug value * to TRUE to get display out of this function. */ originalDebugState = sysVmeDmaGetDebugState ();#ifdef CHANGE_DEBUG_STATE sysVmeDmaSetDebugState( DEFAULT_DEBUG_STATE );#endif fprintf(stdout, "Sync delaying %0d tenths_of_seconds before attempting to take lock\n", tenths_of_seconds ); TimeDelay( tenths_of_seconds ); fprintf(stdout, "Sync attempting to take the lock (%0d)\n", tenths_of_seconds ); while( ((ret_val = sysVmeDmaLock()) != OK) && !timeout ) { if( !waiting_flag ) { fprintf(stdout, "Sync waiting for the lock (%0d)\n", tenths_of_seconds ); waiting_flag = TRUE; } TimeDelay( 1 ); i++; if( i > LOCK_TIMEOUT ) timeout = TRUE; } if( timeout ) { fprintf(stdout, "Sync timeout occured waiting for the lock (%0d)\n", tenths_of_seconds ); return; } fprintf(stdout, "Sync got the lock (%0d)\n", tenths_of_seconds ); testSync();#if 1 ret_val = sysVmeDmaUnlock ( DO_NOT_FORCE_UNLOCK );#else ret_val = sysVmeDmaUnlock ( FORCE_UNLOCK );#endif fprintf(stdout, "Sync released the lock (sec = %0d, ret = %0d)\n", tenths_of_seconds, ret_val ); /* Restore original state of debug value. */ sysVmeDmaSetDebugState( originalDebugState );}/****************************************************************/void testLockAsync2( UINT32 tenths_of_seconds ){ BOOL timeout = FALSE, waiting_flag = FALSE; int i = 0; STATUS ret_val; BOOL originalDebugState; printf( "testLockAsync2: Delay %0d0 mseconds, lock DMA, do async transfer, unlock DMA\n", tenths_of_seconds ); /* Get original state of debug value and set state of debug value * to TRUE to get display out of this function. */ originalDebugState = sysVmeDmaGetDebugState ();#ifdef CHANGE_DEBUG_STATE sysVmeDmaSetDebugState( DEFAULT_DEBUG_STATE );#endif fprintf(stdout, "Async delaying %0d tenths_of_seconds before attempting to take lock\n", tenths_of_seconds ); TimeDelay( tenths_of_seconds ); fprintf(stdout, "Async attempting to take the lock (%0d)\n", tenths_of_seconds ); while( ((ret_val = sysVmeDmaLock()) != OK) && !timeout ) { if( !waiting_flag ) { fprintf(stdout, "Async waiting for the lock (%0d)\n", tenths_of_seconds ); waiting_flag = TRUE; } TimeDelay( 1 ); i++; if( i > LOCK_TIMEOUT ) timeout = TRUE; } if( timeout ) { fprintf(stdout, "Async timeout occured waiting for the lock (%0d)\n", tenths_of_seconds ); return; } fprintf(stdout, "Async got the lock (%0d)\n", tenths_of_seconds ); testAsync2();#if 1 ret_val = sysVmeDmaUnlock ( DO_NOT_FORCE_UNLOCK );#else ret_val = sysVmeDmaUnlock ( FORCE_UNLOCK );#endif fprintf(stdout, "Async released the lock (sec = %0d, ret = %0d)\n", tenths_of_seconds, ret_val ); /* Restore original state of debug value. */ sysVmeDmaSetDebugState( originalDebugState );}/****************************************************************/void testAsync2( void ){ /* * Install our interrupt handler. */ sysVmeDmaConnect( (FUNCPTR) async_sysVmeDmaExampleISR ); printf( "Example async DMA interrupt handler installed.\n" ); testAsyncDmaCopy( my_local_addr+my_size, my_vme_addr+my_size, my_size, (my_to_vme ? 0 : 1), my_pattern_type+1, my_do_verify ); printf( "Status of last async transfer: %0d\n", sysVmeDmaGetLastAsyncStatus() ); /* * Remove the interrupt vector to prevent problems when we want to test * the sync (blocking) version. */ sysVmeDmaConnect( (FUNCPTR) NULL ); printf( "Example async DMA interrupt handler removed (replaced with NULL).\n" );}/****************************************************************/void testTargetRam( char * addr, UINT32 size ){ UINT32 i; fprintf( stdout, "Clearing target RAM at address 0x%08X\n", (UINT32)addr ); for( i = 0; i < size; i++ ) { *(addr+i) = 0; } fprintf( stdout, "Reading target RAM at address 0x%08X\n", (UINT32)addr ); for( i = 0; i < size; i++ ) { if( *(addr+i) != 0) fprintf( stdout, "Error reading target RAM at address 0x%08X\n", (UINT32)(addr+i) ); } fprintf( stdout, "setting target RAM at address 0x%08X\n", (UINT32)addr ); for( i = 0; i < size; i++ ) { *(addr+i) = 1; } fprintf( stdout, "Reading target RAM at address 0x%08X\n", (UINT32)addr ); for( i = 0; i < size; i++ ) { if( *(addr+i) != 1) fprintf( stdout, "Error reading target RAM at address 0x%08X\n", (UINT32)(addr+i) ); }}/****************************************************************/void readTargetRam( char * addr, UINT32 size ){ UINT32 i; fprintf( stdout, "Reading target RAM at address 0x%08X\n", (UINT32)addr ); for( i = 0; i < size; i++ ) { fprintf( stdout, "Data in target RAM at address 0x%08X 0x%08X\n", (UINT32)(addr+i), (UINT32)(*(addr+i)) ); }}/****************************************************************/void writeTargetRam( char * addr, UINT32 size, UINT32 data ){ UINT32 i; fprintf( stdout, "writting target RAM at address 0x%08X\n", (UINT32)addr ); for( i = 0; i < size; i++ ) { *(addr+i) = data; }}/****************************************************************/void testDriver(void)/****************************************************************//* *//* This test is a copy of script test "TEST.SCR" and *//* "SPAWN5.GO". *//* *//****************************************************************/{ printf("-----------------------------------------------\n");printf("Results of:\n");printf("testDriver\n");printf("-----------------------------------------------\n");printf("\n");sysVmeDmaSet(12,1) ;printf(" DCTL 23..22 00 \n");printfDctlDgcs();sysVmeDmaSet(12,2) ;printf(" DCTL 23..22 01 \n");printfDctlDgcs();sysVmeDmaSet(12,3) ;printf(" DCTL 23..22 10 \n");printfDctlDgcs();sysVmeDmaSet(12,4) ;printf(" DCTL 23..22 10 \n");printfDctlDgcs();sysVmeDmaSet(12,4) ;printf(" DCTL 23..22 11 \n");printfDctlDgcs();sysVmeDmaSet(12,6) ;printf(" DCTL 23..22 11 \n");printfDctlDgcs();sysVmeDmaSet(12,7) ;sysVmeDmaClr();sysVmeDmaSet(11,1) ;printf(" DCTL 18..16 000 \n");printfDctlDgcs();sysVmeDmaSet(11,2) ;printf(" DCTL 18..16 001 \n");printfDctlDgcs(); sysVmeDmaSet(11,3) ;printf(" DCTL 18..16 010 \n");printfDctlDgcs(); sysVmeDmaSet(11,4) ;sysVmeDmaClr();sysVmeDmaSet(15,0);printf(" DCTL 13..12 00 \n");printfDctlDgcs();sysVmeDmaSet(15,1);printf(" DCTL 13..12 01 \n");printfDctlDgcs();sysVmeDmaSet(15,3) ;sysVmeDmaClr(); sysVmeDmaSet(16,0);printf(" DCTL 15..14 00 \n");printfDctlDgcs();sysVmeDmaSet(16,1);printf(" DCTL 15..14 01 \n");printfDctlDgcs();sysVmeDmaSet(16,3); sysVmeDmaClr(); sysVmeDmaSet(13,0);printf(" DGCS 22..20 000 \n");printfDctlDgcs();sysVmeDmaSet(13,1);printf(" DGCS 22..20 001 \n");printfDctlDgcs();sysVmeDmaSet(13,2);printf(" DGCS 22..20 010 \n");printfDctlDgcs();sysVmeDmaSet(13,3);printf(" DGCS 22..20 011 \n");printfDctlDgcs();sysVmeDmaSet(13,4);printf(" DGCS 22..20 100 \n");printfDctlDgcs();sysVmeDmaSet(13,5);printf(" DGCS 22..20 101 \n");printfDctlDgcs();sysVmeDmaSet(13,6);printf(" DGCS 22..20 110 \n");printfDctlDgcs();sysVmeDmaSet(13,7);printf(" DGCS 22..20 111 \n");printfDctlDgcs();sysVmeDmaSet(13,8); sysVmeDmaClr(); sysVmeDmaSet(14,0);printf(" DGCS 19..16 000 \n");printfDctlDgcs();sysVmeDmaSet(14,1);printf(" DGCS 19..16 001 \n");printfDctlDgcs();sysVmeDmaSet(14,2);printf(" DGCS 19..16 010 \n");printfDctlDgcs();sysVmeDmaSet(14,3);printf(" DGCS 19..16 011 \n");printfDctlDgcs();sysVmeDmaSet(14,4);printf(" DGCS 19..16 100 \n");printfDctlDgcs();sysVmeDmaSet(14,5);printf(" DGCS 19..16 101 \n");printfDctlDgcs();sysVmeDmaSet(14,6);printf(" DGCS 19..16 110 \n");printfDctlDgcs();sysVmeDmaSet(14,7);printf(" DGCS 19..16 111 \n");printfDctlDgcs();sysVmeDmaSet(14,8); sysVmeDmaClr();testSync();my_to_vme = 0;testSync();printf("-----------------------------------------------\n");printf("Spawn two locked processes.\n");printf(" - Async spawned 1st but delays longer (runs 3rd)\n");printf(" - to VME\n");printf(" - Sync spawned 2nd but delays shorter (runs 2nd)\n");printf(" - from VME\n");printf(" - Async spawned 3rd but delays shorter (runs 1st)\n");printf(" - from VME\n");printf("-----------------------------------------------\n");sysVmeDmaClr();my_to_vme = 1;testLockAsync(14);testLockSync(12);testLockAsync2(10);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -