quec_boot_log.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _QUEC_BOOT_LOG_H_
  13. #define _QUEC_BOOT_LOG_H_
  14. #include "osi_compiler.h"
  15. #include <stdio.h>
  16. #include "quec_proj_config.h"
  17. //剪裁boot中QUEC_BOOT_LOG打印,只添加打印函数地址,不添加函数名和行号
  18. //如果调试需要打印函数名和行号可以将此宏设为0
  19. #define QUEC_BOOT_LOG_CUT_ 1
  20. #ifndef _RET_IP_
  21. //0表示当前函数的返回地址,1表示当前函数的调用者的返回地址
  22. #define _RET_IP_ (unsigned long)__builtin_return_address(0)
  23. #endif
  24. #ifndef _THIS_IP_
  25. //获取当前函数的地址
  26. #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
  27. #endif
  28. #define QUEC_BOOT_LEVEL OSI_LOG_LEVEL_INFO
  29. #define QUEC_BOOT_LOG_TAG OSI_MAKE_LOG_TAG('Q', 'B', 'O', 'T')
  30. #define QUEC_BOOT_PRINTF(level, fmt, ...) \
  31. do \
  32. { \
  33. if (QUEC_BOOT_LEVEL >= level) \
  34. osiTracePrintf((level << 28) | (QUEC_BOOT_LOG_TAG), fmt, ##__VA_ARGS__); \
  35. } while (0)
  36. //CSDK compilation will generate CONFIG_QL_CCSDK_BUILD_ON,otherwise only CONFIG_QL_CCSDK_BUILD_ will be generated
  37. #ifdef CONFIG_QL_CCSDK_BUILD_ON
  38. //csdk build use this
  39. //打印中添加函数名和行号
  40. #define custom_boot_log(user_str, msg, ...) QUEC_BOOT_PRINTF(QUEC_BOOT_LEVEL, "%s %d "msg"", __FUNCTION__, __LINE__, ##__VA_ARGS__)
  41. #else
  42. //local or kernel build use this
  43. #if QUEC_BOOT_LOG_CUT_
  44. //打印中只添加函数地址
  45. //#define custom_boot_log(user_str, msg, ...) QUEC_BOOT_PRINTF(QUEC_BOOT_LEVEL, "%p "msg"", _THIS_IP_, ##__VA_ARGS__)
  46. //打印中添加函数地址和行号
  47. #define custom_boot_log(user_str, msg, ...) QUEC_BOOT_PRINTF(QUEC_BOOT_LEVEL, "%p %d "msg"", _THIS_IP_, __LINE__, ##__VA_ARGS__)
  48. #else
  49. //打印中添加函数名和行号
  50. #define custom_boot_log(user_str, msg, ...) QUEC_BOOT_PRINTF(QUEC_BOOT_LEVEL, "%s %d "msg"", __FUNCTION__, __LINE__, ##__VA_ARGS__)
  51. #endif/* QUEC_BOOT_LOG_CUT_ */
  52. #endif/* CONFIG_QL_CCSDK_BUILD */
  53. #define QUEC_BOOT_LOG(msg, ...) custom_boot_log("Qboot", msg, ##__VA_ARGS__)
  54. #endif /* _QUEC_BOOT_LOG_H_ */