/**************************************************************************** *-Copyright (c) 2004 DST Technologies Inc. All Rights Reserved. * * Module: dsthaldebug.c * * Description: DST HAL Debug Routines * * * notes: 20040609hwatk * ***************************************************************************/ #include #include #include "dsthalcommon.h" #include #ifdef DMALLOC #include #endif #define DELAY(x) usleep((x)*1000) /**************************************************************************** gDbgLevel 0 : Print-out level 0. 1 : Print-out level 1 & level 0 2 : Print-out all debug messaged. gDbgMsgLevel 0 : Print-out only messages. 1 : Print-out function name and messages. 2 : Print-out component name and function name and messages. bmDbg DHLDBG_AV : Enable AV debugging. DHLDBG_FE : Enable FE debugging. DHLDBG_DEV : Enable DEV debugging. DHLDBG_COMM : Enable COMM debugging. DHLDBG_ALL : Enable all DHL component debugging. ***************************************************************************/ DS_U32 gDbgLevel = 3; DS_U32 gDbgMsgLevel = 2; DS_U32 bmDbg = DHLDBG_ALL; /**************************************************************************** DHL_DbgPrintf - Summary : Debug printf for DHL - Arguments print-out only if ( Level < gDbgLevel ). ***************************************************************************/ void DHL_DBGPRINTF(const char *Function, DS_U32 Level, DS_U32 bmDbgComponent, char *Format, ...) { va_list va; DS_S8 MsgBuf[256]; if ( gDbgLevel <= Level ) return; if ( (bmDbgComponent & bmDbg) == 0 ) return; //jfet_20051026 |add for debug switch ( gDbgMsgLevel ) { case 3: printf("%ld ", OS_GetTickCount()); case 2: { switch( bmDbgComponent ) { case DHLDBG_SYS: printf("dhl_sy|"); break; case DHLDBG_DMX: printf("dhl_dx|"); break; case DHLDBG_DTV: printf("dhldtv|"); break; case DHLDBG_FE: printf("dhl_fe|"); break; case DHLDBG_DEV: printf("dhl_dv|"); break; case DHLDBG_COMM: printf("dhl_cm|"); break; case DHLDBG_CAP: printf("dhlcap|"); break; case DHLDBG_CA: printf("dhl_ca|"); break; case DHLDBG_IR: printf("dhl_ir|"); break; case DHLDBG_MVS: printf("dhl_mv|"); break; case DDDBG_SYS: printf("dd_sys|"); break; case DDDBG_DMX: printf("dd_dmx|"); break; case DDDBG_V: printf("dd_vid|"); break; case DDDBG_A: printf("dd_aud|"); break; case DDDBG_CAP: printf("dd_cap|"); break; case DDDBG_CC: printf("dd__cc|"); break; case DDDBG_G: printf("dd_grp|"); break; case DDDBG_IR: printf("dd__ir|"); break; case DHLDBG_AUD: printf("dhlaud|"); break; case DDDBG_MVS: printf("dd_mvs|"); break; case DHLDBG_GFX: printf("dhl_gf|"); break; case DDDBG_GFX: printf("dd_gfx|"); break; case DHLDBG_PSI: printf("dhlpsi|"); break; case DDDBG_COMM: printf("dd_com|"); break; case DDDBG_FE: printf("dd_fe |"); break; case DDDBG_PSI: printf("dd_psi|"); break; case DHLDBG_EXT: printf("extdev|"); break; } } case 1: { printf(" %s| ",Function); } break; } va_start (va, Format); vsprintf ((DS_S8 *)MsgBuf, Format, va); va_end (va); printf( MsgBuf ); } void DHL_SetDbgLevel( DS_U32 Level ) { if ( Level > 3 ) return; gDbgLevel = Level; } void DHL_SetDbgMsgLevel( DS_U32 MsgLevel ) { if ( MsgLevel > 3 ) return; gDbgMsgLevel = MsgLevel; } void DHL_SetDbgComponent( DS_U32 bmDbgComponent ) { bmDbg |= bmDbgComponent; } void DHL_ClrDbgComponent( DS_U32 bmDbgComponent ) { bmDbg &= ~bmDbgComponent; } void DHL_DbgStatus(void) { printf("Current Debug Level = %lx.\n", gDbgLevel); printf("Current Debug Message Level = %lx\n.", gDbgMsgLevel); printf("Current Enabled Component\n"); if ( bmDbg & DHLDBG_DTV ) printf("\tDHL_AV Enabled\n"); if ( bmDbg & DHLDBG_FE ) printf("\tDHL_FE Enabled\n"); if ( bmDbg & DHLDBG_DEV ) printf("\tDHL_DEV Enabled\n"); if ( bmDbg & DHLDBG_COMM ) printf("\tDHL_COMM Enabled\n"); } static int *MemoryTestPtr; DHL_RESULT MemoryTest(DS_U32 Size) { int i; printf("*** Memory Test - Size = 0x%08lX\n", Size); for (i=0; i<(Size/sizeof(DS_U32)); i++) { if ( MemoryTestPtr[i] != 0x5A5A5A5A ) printf("Invalid data! ptr[%d] = 0x%08lX\n", i, (DS_U32)MemoryTestPtr[i]); } return DHL_OK; } void InvalidateMemory(DS_U32 addr, int pattern) { DS_U32 *ptr; ptr = (DS_U32 *)addr; printf("*** MemoryTestPtr[0x%08lX] = %08lX\n", addr, (DS_U32)pattern); *ptr = (DS_U32)pattern; } void DumpMemory(DS_U32 addr) { int i; DS_U32 *ptr; ptr = (DS_U32 *)addr; printf("0x%08lX: ", addr); for (i=0; i<8; i++) { printf("0x%08lX ", ptr[i]); } printf("\n"); }