⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nsmdebug.h

📁 NATIONAL公司DP83816芯片Linux下驱动
💻 H
字号:
//******************************************************************************
//
//  NSMDEBUG.H
//
//  Copyright (c) 2005 National Semiconductor Corporation.
//  All Rights Reserved
//
//  Linux NSM debug
//
//*****************************************************************************

#ifndef _NSM_DEBUG_H_
#define _NSM_DEBUG_H_

extern unsigned int NsmDbgSettings;

// Change this to suit your OS
#define dbgprint printk
//#define dbgprint

#define hexdump  DBG_PrintBuf

// Debug zones
// More zones ? add to the list after decrease of the bit position by one
#define DBG_FUNC          (1 << 31)
#define DBG_ERR           (1 << 30)
#define DBG_INFO          (1 << 29) 
#define DBG_TMP           (1 << 28) 

extern void DBG_PrintBuf(unsigned char *dataPtr, int dataLen);

// Debug printf
#define NSM_DBG(flag,format) (((flag) & NsmDbgSettings )? dbgprint format:0)

// Debug HexDump
#define NSM_HD(flag,parms) (((flag) & NsmDbgSettings )? hexdump parms:0)

#define ISPRINT(ch) (((ch) >= ' ') && ((ch) <= '~'))
#define PRINTCHAR(ch) (unsigned char)(ISPRINT(ch) ? (ch) : '.')

#define DBG_PrintBuf(bufptr, buflen) \
{ \
    int i, linei; \
    dbgprint("\r\n         %d bytes @%x:", buflen, bufptr); \
    for (i = 0; i+8 <= buflen; i += 8) { \
       unsigned char ch0 = bufptr[i+0], \
              ch1 = bufptr[i+1], ch2 = bufptr[i+2], \
              ch3 = bufptr[i+3], ch4 = bufptr[i+4], \
              ch5 = bufptr[i+5], ch6 = bufptr[i+6], \
              ch7 = bufptr[i+7]; \
        dbgprint("\r\n         %02x %02x %02x %02x %02x %02x %02x %02x" "   %c %c %c %c %c %c %c %c", ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7, PRINTCHAR(ch0), PRINTCHAR(ch1), PRINTCHAR(ch2), PRINTCHAR(ch3), PRINTCHAR(ch4), PRINTCHAR(ch5), PRINTCHAR(ch6), PRINTCHAR(ch7)); \
    } \
        dbgprint("\r\n        "); \
        for (linei = 0; (linei < 8) && (i < buflen); i++, linei++){ dbgprint(" %02x", (int)(bufptr[i])); } \
        dbgprint("  "); \
        i -= linei; \
        while (linei++ < 8) dbgprint("   "); \
        for (linei = 0; (linei < 8) && (i < buflen); i++, linei++){ \
        unsigned char ch = bufptr[i]; \
        dbgprint(" %c", PRINTCHAR(ch)); } \
        dbgprint("\t\t<>\r\n"); \
}

// Local helful debug macros
#define NI(fn) NSM_DBG(DBG_FUNC, (">>> Enter " #fn"()\n"))
#define NO(fn) NSM_DBG(DBG_FUNC, (" <<< Exit  " #fn"() Line : %d \n", __LINE__))
#define NOInt(v) NSM_DBG(DBG_TMP, (" "#v": %x \n", v))
#define NP(fmt) NSM_DBG(DBG_TMP, fmt)

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -