/*---------------------------------------------------------------------------* Project: TwlSDK - MI - demos - exDma-1 File: main.c Copyright 2007 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Log: $ $NoKeywords: $ *---------------------------------------------------------------------------*/ #include #define MY_DMA_MMEM ((t_TestBuf *)HW_MAIN_MEM_SUB) #define MY_TEST_LOOPS (sizeof(copyfillArg)/sizeof(t_CommonArg)) #define ONE_BUF_SIZE 0x2004 typedef struct { u32 prePad __attribute__ ((aligned (32))); u16 src[4][ONE_BUF_SIZE/2] __attribute__ ((aligned (32))); u16 dest[4][ONE_BUF_SIZE/2] __attribute__ ((aligned (32))); u32 PostPad __attribute__ ((aligned (32))); } t_TestBuf; typedef struct { u16 (*src)[ONE_BUF_SIZE/2]; u16 (*dest)[ONE_BUF_SIZE/2]; char *copyStr; char *fillStr; } t_CommonArg; t_TestBuf testBuf __attribute__ ((aligned (32))); t_CommonArg copyfillArg[] = { { testBuf.src, testBuf.dest, "DmaCopy success on WRAM -> WRAM.\n", NULL, }, { MY_DMA_MMEM->src, testBuf.dest, "DmaCopy success on MAIN_MEM -> WRAM.\n", "DmaFill success on WRAM.\n", }, { testBuf.src, MY_DMA_MMEM->dest, "DmaCopy success on WRAM -> MAIN_MEM.\n", NULL, }, { MY_DMA_MMEM->src, MY_DMA_MMEM->dest, "DmaCopy success on MAIN_MEM -> MAIN_MEM.\n", "DmaFill success on MAIN_MEM.\n", }, }; t_CommonArg stopArg[] = { { testBuf.src, testBuf.dest, "Stopping DmaCopy success on WRAM -> WRAM.\n", NULL, }, { MY_DMA_MMEM->src, testBuf.dest, "Stopping DmaCopy success on MAIN_MEM -> WRAM.\n", "Stopping DmaFill success on WRAM.\n", }, { testBuf.src, MY_DMA_MMEM->dest, "Stopping DmaCopy success on WRAM -> MAIN_MEM.\n", NULL, }, { MY_DMA_MMEM->src, MY_DMA_MMEM->dest, "Stopping DmaCopy success on MAIN_MEM -> MAIN_MEM.\n", "Stopping DmaFill success on MAIN_MEM.\n", }, }; t_CommonArg copyfillAsyncArg[] = { { testBuf.src, testBuf.dest, "DmaCopyAsync success on WRAM -> WRAM.\n", NULL, }, { MY_DMA_MMEM->src, testBuf.dest, "DmaCopyAsync success on MAIN_MEM -> WRAM.\n", "DmaFillAsync success on WRAM.\n", }, { testBuf.src, MY_DMA_MMEM->dest, "DmaCopyAsync success on WRAM -> MAIN_MEM.\n", NULL, }, { MY_DMA_MMEM->src, MY_DMA_MMEM->dest, "DmaCopyAsync success on MAIN_MEM -> MAIN_MEM.\n", "DmaFillAsync success on MAIN_MEM.\n", }, }; u32 exDmaIntrCount[MI_EXDMA_CH_NUM]; void InitExDmaIntr(void); void ClearIntrCount(void); void PrintIntrCount(void); void ExDma4Intr(void); void ExDma5Intr(void); void ExDma6Intr(void); void ExDma7Intr(void); static BOOL CheckDmaCopy( u32 dmaNo, void *src, void *dest, const char *str ) { BOOL ercd = TRUE; u8 *s = src; u8 *d = dest; int i; for (i=0; isrc; u16 (*dest)[ONE_BUF_SIZE/2] = arg->dest; char *copyStr = arg->copyStr; char *fillStr = arg->fillStr; BOOL c_ercd = TRUE, f_ercd = TRUE; u32 i, ii; for (i=0; i<4; i++) { for (ii=0; iisrc; u16 (*dest)[ONE_BUF_SIZE/2] = arg->dest; char *copyStr = arg->copyStr; char *fillStr = arg->fillStr; BOOL c_ercd = TRUE, f_ercd = TRUE; u32 i, ii; for (i=0; i<4; i++) { for (ii=0; iisrc; u16 (*dest)[ONE_BUF_SIZE/2] = arg->dest; char *copyStr = arg->copyStr; char *fillStr = arg->fillStr; BOOL c_ercd = TRUE, f_ercd = TRUE; u32 i; if ( copyStr ) { for (i=0; i<4; i++) { u32 ch = i + MI_EXDMA_CH_MIN; u16 *s = src[i]; u16 *d = dest[i]; MIi_ExDmaCopyAsync( ch, s, d, ONE_BUF_SIZE ); if ( MIi_IsExDmaBusy( ch ) == FALSE ) { OS_TPrintf( "warning: DmaCopyAsync isn't busy dmaNo = %d.\n", ch ); } MIi_StopExDma( ch ); if ( MIi_IsExDmaBusy( ch ) == TRUE ) { OS_TPrintf( "error: Stopping DmaCopy failed dmaNo = %d.\n", ch ); c_ercd = FALSE; // break; } } if ( c_ercd == TRUE ) { OS_TPrintf( copyStr ); } } if ( fillStr ) { for (i=0; i<4; i++) { u32 ch = i + MI_EXDMA_CH_MIN; u16 *d = dest[i]; MIi_ExDmaFillAsync( ch, d, i, ONE_BUF_SIZE ); if ( MIi_IsExDmaBusy( ch ) == FALSE ) { OS_TPrintf( "warning: DmaFillAsync isn't busy dmaNo = %d.\n", ch ); } MIi_StopExDma( ch ); if ( MIi_IsExDmaBusy( ch ) == TRUE ) { OS_TPrintf( "error: Stopping DmaFill failed dmaNo = %d.\n", ch ); f_ercd = FALSE; // break; } } if ( f_ercd == TRUE ) { OS_TPrintf( fillStr ); } } return c_ercd | f_ercd; } static void TestDmaFuncs( void ) { u32 i; ClearIntrCount(); // sync copy and fill test OS_TPrintf( "\nChecking DmaCopy and DmaFill ....\n" ); for (i=0; i