/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2012-2019. All rights reserved. * Description: API of debug module * Author: Hisilicon * Create: 2012-03-12 */ #ifndef SUBTITLE_DEBUG_H #define SUBTITLE_DEBUG_H #ifndef unused #define unused(x) ((void)(x)) #endif #define FMEA_SUBT_EVENT_ID_NO_DATA 955280002 #define FMEA_SUBT_EVENT_ID_PARSE_ERR 955280003 #define PNAME_SUBT_MAX_LEN 64 #define FMEA_SUBT_EVENT_REPORT_COUNT 10 #include "soc_log.h" #ifdef __MICROSYS__ extern void *ext_malloc(SOC_MOD_ID_E modId, td_u32 boundary, td_u32 size, td_bool nocache); extern void ext_free(SOC_MOD_ID_E modId, void *ptr, td_bool nocache); #define EXT_MEMSUBT_MALLOC(size) (ext_malloc(SOC_ID_SUBT, 0, (size), TD_FALSE)) #define EXT_MEMSUBT_FREE(memAddr) (ext_free(SOC_ID_SUBT, (memAddr), TD_FALSE)) #ifdef EXT_FATAL_PRINT #define EXT_FATAL_SUBT(fmt...) EXT_FATAL_PRINT(SOC_ID_SUBT, fmt) #else #define EXT_FATAL_SUBT(fmt...) SOC_TRACE(SOC_LOG_LEVEL_FATAL, SOC_DEBUG_ID_SUBT, fmt) #endif #ifdef EXT_ERR_PRINT #define EXT_ERR_SUBT(fmt...) EXT_ERR_PRINT(SOC_ID_SUBT, fmt) #else #define EXT_ERR_SUBT(fmt...) SOC_TRACE(SOC_LOG_LEVEL_ERROR, SOC_DEBUG_ID_SUBT, fmt) #endif #ifdef EXT_WARN_PRINT #define EXT_WARN_SUBT(fmt...) EXT_WARN_PRINT(SOC_ID_SUBT, fmt) #else #define EXT_WARN_SUBT(fmt...) SOC_TRACE(SOC_LOG_LEVEL_WARNING, SOC_DEBUG_ID_SUBT, fmt) #endif #ifdef EXT_INFO_PRINT #define EXT_INFO_SUBT(fmt...) EXT_INFO_PRINT(SOC_ID_SUBT, fmt) #else #define EXT_INFO_SUBT(fmt...) SOC_TRACE(SOC_LOG_LEVEL_INFO, SOC_DEBUG_ID_SUBT, fmt) #endif #else #include "uapi_version.h" #define EXT_MEMSUBT_MALLOC(size) (malloc(size)) #define EXT_MEMSUBT_FREE(memAddr) (free(memAddr)) #if (UAPI_VERSION_CODE >= UAPI_VERSION(1, 0)) #ifdef LOG_MODULE_ID #undef LOG_MODULE_ID #define LOG_MODULE_ID SOC_ID_SUBT #endif #define EXT_FATAL_SUBT(fmt...) soc_log_fatal(fmt) #define EXT_ERR_SUBT(fmt...) soc_log_err(fmt) #define EXT_WARN_SUBT(fmt...) soc_log_warn(fmt) #define EXT_INFO_SUBT(fmt...) soc_log_info(fmt) #else #ifdef EXT_FATAL_PRINT #define EXT_FATAL_SUBT(fmt...) EXT_FATAL_PRINT(SOC_ID_SUBT, fmt) #else #define EXT_FATAL_SUBT(fmt...) SOC_TRACE(SOC_LOG_LEVEL_FATAL, SOC_DEBUG_ID_SUBT, fmt) #endif #ifdef EXT_ERR_PRINT #define EXT_ERR_SUBT(fmt...) EXT_ERR_PRINT(SOC_ID_SUBT, fmt) #else #define EXT_ERR_SUBT(fmt...) SOC_TRACE(SOC_LOG_LEVEL_ERROR, SOC_DEBUG_ID_SUBT, fmt) #endif #ifdef EXT_WARN_PRINT #define EXT_WARN_SUBT(fmt...) EXT_WARN_PRINT(SOC_ID_SUBT, fmt) #else #define EXT_WARN_SUBT(fmt...) SOC_TRACE(SOC_LOG_LEVEL_WARNING, SOC_DEBUG_ID_SUBT, fmt) #endif #ifdef EXT_INFO_PRINT #define EXT_INFO_SUBT(fmt...) EXT_INFO_PRINT(SOC_ID_SUBT, fmt) #else #define EXT_INFO_SUBT(fmt...) SOC_TRACE(SOC_LOG_LEVEL_INFO, SOC_DEBUG_ID_SUBT, fmt) #endif #endif // (UAPI_VERSION_CODE >= UAPI_VERSION(1, 0)) #endif // __MICROSYS__ #define SUBT_CHECK_RETURN_RET(val, ret) \ do { \ if (val) \ return ret; \ } while (0) #define SUBT_CHECK_RETURN_LOG(val, ret, str) \ do { \ if (val) { \ EXT_WARN_SUBT("%s \n", (str)); \ return ret; \ } \ } while (0) #define SUBT_CHECK_LOG(val, str) \ do { \ if (val) { \ EXT_WARN_SUBT("%s \n", (str)); \ } \ } while (0) #define SUBT_CHECK_RETURN(val) \ do { \ if (val) \ return; \ } while (0) #ifdef DTV_SECUREC_SUPPORT #define SUBT_CHK_FUN_RET_ERR(func) do { \ td_s32 secFunRet = func; \ if (secFunRet != EOK) { \ EXT_ERR_SUBT("Call %s return %d[0x%08X]", #func, secFunRet, secFunRet); \ return TD_FAILURE; \ } \ } while (0) #define SUBT_CHK_FUN_RET_VOID(func) do { \ td_s32 secFunRet = func; \ if (secFunRet != EOK) { \ EXT_ERR_SUBT("Call %s return %d[0x%08X]", #func, secFunRet, secFunRet); \ return; \ } \ } while (0) #define SUBT_CHECK_FUN_PRINT_ERR(func) do { \ td_s32 secFunRet = func; \ if (secFunRet != EOK) { \ EXT_ERR_SUBT("Call %s return %d[0x%08X]", #func, secFunRet, secFunRet); \ } \ } while (0) #else #define SUBT_CHK_FUN_RET_ERR(func) do { \ func; \ } while (0) #define SUBT_CHK_FUN_RET_VOID(func) do { \ func; \ } while (0) #define SUBT_CHECK_FUN_PRINT_ERR(func) do { \ func; \ } while (0) #endif #endif // SUBTITLE_DEBUG_H