/** @file DHL_DBG.c @brief DHL Debug Module Copyright 2006~2010 Digital STREAM Technology, Inc. All Rights Reserved */ #include "DHL_OSAL.h" #include "DHL_DBG.h" #include "DHL_DBG_Priv.h" //#include ////#include //#include /* DHL µð¹ö±× ¸ðµâ À̸§ Á¤ÀÇ ·ê Âü°í: DHL ¸ðµâµéÀº ¸ðµÎ * ·Î ½ÃÀÛ. API´Â ´ë¹®ÀÚ, Platform ¹× ±âŸ´Â ¼Ò¹®ÀÚ »ç¿ë. µðÆúÆ® ·¹º§Àº 0À¸·Î ¼³Á¤ÇÑ´Ù. (0: ¿¡·¯ ¸Þ½ÃÁö¸¸ Ãâ·Â) */ //DHL_MODULE("*DBG", 0); #if COMMENT ____Config____(){} #endif /* ÀÌ ¸ðµâ ³»ºÎ¿¡¼­ »ç¿ëµÇ´Â °¢Á¾ configuration Á¤ÀÇ. */ /* #define SUPPORT_FAST_SWITCHING_OPTIMIZATION 1 */ /* #define FUNC_MONITOR_TIMER_ID TIMER_ID_FUNC_MONITOR */ #define max(a,b) (((a) > (b)) ? (a) : (b)) #define min(a,b) (((a) < (b)) ? (a) : (b)) #if COMMENT ____Types____(){} #endif /* ÀÌ ¸ðµâ ³»ºÎ¿¡¼­ »ç¿ëµÇ´Â structure ¹× enumerations. */ #if COMMENT ____Variables____(){} #endif /* global·Î Àû¿ëµÇ´Â variable Á¤ÀÇ. °¢ function º°·Î Ư¼öÇÑ ¿ëµµÀÇ variableÀº °¢ functionX block ¿¡¼­ Á¤ÀÇ °¡´É. */ #if COMMENT ____Group1____(){} #endif /* */ void DHL_DBG_GenerateAssert(BOOL cond, const char *msg, const char *file, unsigned line) { if (!cond) { int bForceExit = FALSE; DHL_OS_Printf("\n!! ASSERT failed on %s:%d\n", file, line); DHL_OS_Printf("%s\n", msg); while(!bForceExit); } } #if COMMENT ____Group2____(){} #endif #if COMMENT ____Debug____(){} #endif #if COMMENT ____MemDump____(){} #endif #define isprint(c) (((c) >= 32) && ((c) < 127)) void DHL_DBG_MemDump3(void *buf0, int size, char *msg, UINT32 off, UINT32 flag) { int i, k, skip, n; unsigned char *p; char line[100]; UINT8 *buf = buf0; if ((flag & MEMDUMP_NOHDR) == 0) DHL_OS_Printf(" Dump '%s' %d(0x%x) bytes:\n", msg ? msg : "", size, size); if (size <= 0) return; if (flag & MEMDUMP_ALIGN) // align print position by its address. skip = (UINT32) buf % 16; else skip = 0; // do not align. p = (unsigned char *)buf - skip; size += skip; for (i=0; i='0'&&(c)<='9') ? (c)-'0' : \ ((c)>='a'&&(c)<='f') ? (c)-'a'+10 : \ ((c)>='A'&&(c)<='F') ? (c)-'A'+10 : \ -1) static UINT32 read_hex(char *p) { int i; UINT32 data = 0; // skip spaces while (*p == ' ' || *p == '\t') p++; for (i=0; *p && i<8; i++, p++) { int d = h2d(*p); if (d < 0) break; data = (data << 4) | d; } return data; } /* µð¹ö±ë Áß¿¡ ¸Þ¸ð¸®(·¹Áö½ºÅÍ)ÀÇ Æ¯Á¤ ¿µ¿ªÀ» ¼öÁ¤ÇϰíÀÚ ÇÏ´Â °æ¿ì¿¡ »ç¿ëµÉ ¼ö ÀÖ´Â À¯Æ¿¸®Æ¼. Shell »ó¿¡¼­ ±×³É memedit ¶ó°í ÀÔ·ÂÇÏ¸é µÈ´Ù. À߸ø µÈ ¹øÁö¸¦ Àаųª ±â·ÏÇÒ °æ¿ì exceptionÀÌ ¹ß»ýÇÒ ¼ö ÀÖ´Ù. */ void memedit(UINT32 addr) { char buf[80]; int align = 1; // one of 1, 2, 4 #define print DHL_OS_Printf if (addr == 0) addr = (UINT32)&buf; // ¾Æ¹« ÀÇ¹Ì ¾øÀ½. 0¹øÁö´Â »ç¿ëÀÚ°¡ À߸ø ÀÔ·ÂÇÑ °ÍÀ¸·Î ÃßÁ¤. // print usage print("memedit usage\n"); print(" > w 12345678 : write data of cur addr to 0x12345678\n"); print(" > m b0001000 : modify (goto) address b0001000\n"); print(" > [ENTER_KEY] : go to next addr without modifying\n"); print(" > a 2 : address align (1:byte, 2:16bit, 4:32bit)\n"); print(" > x : exit\n"); print("\n"); while(1) { if(align == 4) { addr &= ~3; print("%08x:%08x > ", addr, *(UINT32 *)addr); } else if(align == 2) { addr &= ~1; print("%08x:%04x > ", addr, *(UINT16 *)addr); } else { print("%08x:%02x > ", addr, *(UINT8 *)addr); } // get user input. dhl_os_get_line(buf, sizeof(buf), eDHL_OS_GLF_NORMAL); if(buf[0] == 0) { addr += align; } else if (buf[1] != ' ' && buf[1] != 0) { continue; // invalid command. all cmd has one character. } else if (buf[0] == 'm') { UINT32 new_addr = read_hex(&buf[1]); if (new_addr == 0) print("wrong addr\n"); else addr = new_addr; } else if (buf[0] == 'w') { UINT32 data = read_hex(&buf[1]); print("write 0x%x..\n", data); if (align == 4) *(UINT32 *)addr = (UINT32)data; else if (align == 2) *(UINT16 *)addr = (UINT16)data; else *(UINT8 *)addr = (UINT8)data; } else if (buf[0] == 'a') { align = read_hex(&buf[1]); if (align != 4 && align != 2) align = 1; print("acces unit: %d\n", align); } else if(buf[0] == 'x') { break; } } } #if COMMENT ____Symbol____(){} #endif #if DHL_REGISTER_DEUBG_SYMBOLS static DHL_SymbolTable _symbols[] = { //DHL_FNC_SYM_ENTRY2("symlkup", dhl_dbg_lookup_symbols), //DHL_FNC_SYM_ENTRY2("which", dhl_dbg_lookup_symbols), //DHL_FNC_SYM_ENTRY2("i", OS_ShowInfo), DHL_FNC_SYM_ENTRY2("sml", (void *)DHL_DBG_SetModuleLevel), DHL_FNC_SYM_ENTRY2("pml", (void *)DHL_DBG_PrintModuleLevel), //DHL_FNC_SYM_ENTRY2("sdt", DHL_DBG_SetDbgKey), //DHL_FNC_SYM_ENTRY2("pdt", DHL_DBG_PrintDbgKey), //----- //DHL_VAR_SYM_ENTRY(dmc_bRequestVideoWidthReduction), }; #endif // DHL_REGISTER_DEUBG_SYMBOLS #if COMMENT ____Init____(){} #endif void DHL_DBG_Init(void) { //DHL_DBG_InitVendor(); #if DHL_USING_DEBUG_SHELL_SYMBOLS dhl_dbg_init_symtab(); //dhl_dbg_init(); //BKNOTE: disable first boot. DHL_DBG_StartDbgShell(); //DHL_DBG_InitHeapDebug(); #endif #if DHL_REGISTER_DEUBG_SYMBOLS DHL_DBG_RegisterSymbols(_symbols, DHL_NUMSYMBOLS(_symbols)); #endif } /* end of file */