Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2151528
  • 博文数量: 438
  • 博客积分: 3871
  • 博客等级: 中校
  • 技术积分: 6075
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-10 00:11
个人简介

邮箱: wangcong02345@163.com

文章分类

全部博文(438)

文章存档

2017年(15)

2016年(119)

2015年(91)

2014年(62)

2013年(56)

2012年(79)

2011年(16)

分类: Android平台

2015-04-17 12:12:15

92的modem打印很不方便:
a. __FILE__打印的路径太长看起来不方便
b. 需要万能的dbmsg
如下所示一共修改了两个文件:
  1. cong@msi:/work/mtk/modem$ git status
  2.     modified: driver/storage/sim/inc/sim_drv_SW_API.h
  3.     modified: driver/storage/sim/src/icc_sim_common_mtk.c
1.driver/storage/sim/inc/sim_drv_SW_API.h中
添加__FNAME__宏及dbmsg的定义,在DRV_ICC_print之上添加即可
  1. diff --git a/driver/storage/sim/inc/sim_drv_SW_API.h b/driver/storage/sim/inc/sim_drv_SW_API.h
  2. index d02bb9b..356ab1f 100644
  3. --- a/driver/storage/sim/inc/sim_drv_SW_API.h
  4. +++ b/driver/storage/sim/inc/sim_drv_SW_API.h
  5. @@ -58,6 +58,50 @@ extern void L1sim_Enable_Enhanced_Speed(kal_bool enable, sim_HW_cb *hw_cb);
  6.  #endif
  7.  extern void USIM_SET_EVENT_Multiple(usim_dcb_struct *usim_dcb);
  8.  extern void SIM_SetTOUT(kal_uint32 TOUT, sim_HW_cb *hw_cb);
  9. +#define _STRRCHR_IMPL_COMMON(str, ch, offset) (str)[sizeof((str)) - 1 - (offset)] == (ch)? (str) + sizeof((str)) - (offset): sizeof((str)) <= (offset) + 1? (str)
  10. +#define _STRRCHR_IMPL_31(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 31): (str))
  11. +#define _STRRCHR_IMPL_30(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 30): _STRRCHR_IMPL_31(str, ch))
  12. +#define _STRRCHR_IMPL_29(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 29): _STRRCHR_IMPL_30(str, ch))
  13. +#define _STRRCHR_IMPL_28(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 28): _STRRCHR_IMPL_29(str, ch))
  14. +#define _STRRCHR_IMPL_27(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 27): _STRRCHR_IMPL_28(str, ch))
  15. +#define _STRRCHR_IMPL_26(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 26): _STRRCHR_IMPL_27(str, ch))
  16. +#define _STRRCHR_IMPL_25(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 25): _STRRCHR_IMPL_26(str, ch))
  17. +#define _STRRCHR_IMPL_24(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 24): _STRRCHR_IMPL_25(str, ch))
  18. +#define _STRRCHR_IMPL_23(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 23): _STRRCHR_IMPL_24(str, ch))
  19. +#define _STRRCHR_IMPL_22(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 22): _STRRCHR_IMPL_23(str, ch))
  20. +#define _STRRCHR_IMPL_21(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 21): _STRRCHR_IMPL_22(str, ch))
  21. +#define _STRRCHR_IMPL_20(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 20): _STRRCHR_IMPL_21(str, ch))
  22. +#define _STRRCHR_IMPL_19(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 19): _STRRCHR_IMPL_20(str, ch))
  23. +#define _STRRCHR_IMPL_18(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 18): _STRRCHR_IMPL_19(str, ch))
  24. +#define _STRRCHR_IMPL_17(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 17): _STRRCHR_IMPL_18(str, ch))
  25. +#define _STRRCHR_IMPL_16(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 16): _STRRCHR_IMPL_17(str, ch))
  26. +#define _STRRCHR_IMPL_15(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 15): _STRRCHR_IMPL_16(str, ch))
  27. +#define _STRRCHR_IMPL_14(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 14): _STRRCHR_IMPL_15(str, ch))
  28. +#define _STRRCHR_IMPL_13(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 13): _STRRCHR_IMPL_14(str, ch))
  29. +#define _STRRCHR_IMPL_12(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 12): _STRRCHR_IMPL_13(str, ch))
  30. +#define _STRRCHR_IMPL_11(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 11): _STRRCHR_IMPL_12(str, ch))
  31. +#define _STRRCHR_IMPL_10(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 10): _STRRCHR_IMPL_11(str, ch))
  32. +#define _STRRCHR_IMPL_9(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 9): _STRRCHR_IMPL_10(str, ch))
  33. +#define _STRRCHR_IMPL_8(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 8): _STRRCHR_IMPL_9(str, ch))
  34. +#define _STRRCHR_IMPL_7(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 7): _STRRCHR_IMPL_8(str, ch))
  35. +#define _STRRCHR_IMPL_6(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 6): _STRRCHR_IMPL_7(str, ch))
  36. +#define _STRRCHR_IMPL_5(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 5): _STRRCHR_IMPL_6(str, ch))
  37. +#define _STRRCHR_IMPL_4(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 4): _STRRCHR_IMPL_5(str, ch))
  38. +#define _STRRCHR_IMPL_3(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 3): _STRRCHR_IMPL_4(str, ch))
  39. +#define _STRRCHR_IMPL_2(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 2): _STRRCHR_IMPL_3(str, ch))
  40. +#define _STRRCHR_IMPL_1(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 1): _STRRCHR_IMPL_2(str, ch))
  41. +#define _STRRCHR_IMPL_0(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 0): _STRRCHR_IMPL_1(str, ch))
  42. +
  43. +// a macro version of strrchr().
  44. +// it has several limitations:
  45. +// - str must be a literal string, e.g. "a string".
  46. +// - if ch cannot be found in last 32 characters, it will return the whole string.
  47. +// this limit can be increased by adding more _STRRCHR_IMPL_* macros.
  48. +#define _STRRCHR(str, ch) (sizeof((str)) <= 1? (str): _STRRCHR_IMPL_0(str, ch))
  49. +
  50. +#define __FNAME__ _STRRCHR(__FILE__, '/')
  51. +extern void myprintf(char *fmt,...);
  52. +#define dbmsg(fmt, args ...) myprintf("%s:%s[%d]: "fmt"\n", __FNAME__,__FUNCTION__, __LINE__,##args)
  53.  extern void DRV_ICC_print(sim_printEnum messageType, kal_uint32 value1, kal_uint32 value2, kal_uint32 value3, kal_uint32 value4, kal_uint32 value5);
2.driver/storage/sim/src/icc_sim_common_mtk.c中
添加dbmsg中最重要的函数myprintf的实现
  1. --- a/driver/storage/sim/src/icc_sim_common_mtk.c
  2. +++ b/driver/storage/sim/src/icc_sim_common_mtk.c
  3. +static void itoa(char **buf, int i, int base)
  4. +{
  5. + char *s;
  6. +#define LEN 20
  7. + int rem;
  8. + static char rev[LEN+1];
  9. +
  10. + rev[LEN] = 0;
  11. + if (i == 0)
  12. + {
  13. + (*buf)[0] = '0';
  14. + ++(*buf);
  15. + return;
  16. + }
  17. + s = &rev[LEN];
  18. + while (i)
  19. + {
  20. + rem = i % base;
  21. + if (rem < 10)
  22. + *--s = rem + '0';
  23. + else if (base == 16)
  24. + *--s = "abcdef"[rem - 10];
  25. + i /= base;
  26. + }
  27. + while (*s)
  28. + {
  29. + (*buf)[0] = *s++;
  30. + ++(*buf);
  31. + }
  32. +}
  33. +char print_buf[1024];
  34. +void myprintf(char *fmt,...)
  35. +{
  36. + va_list ap;
  37. + double dval;
  38. + int ival;
  39. + char *p, *sval;
  40. + char *bp, cval;
  41. + int fract;
  42. + unsigned short len;
  43. + bp= print_buf;
  44. + *bp= 0;
  45. +
  46. + va_start (ap, fmt);
  47. + for (p= fmt; *p; p++)
  48. + {
  49. + if (*p != '%')
  50. + {
  51. + *bp++= *p;
  52. + continue;
  53. + }
  54. + switch (*++p) {
  55. + case 'd':
  56. + ival= va_arg(ap, int);
  57. + if (ival < 0){
  58. + *bp++= '-';
  59. + ival= -ival;
  60. + }
  61. + itoa (&bp, ival, 10);
  62. + break;
  63. +
  64. + case 'o':
  65. + ival= va_arg(ap, int);
  66. + if (ival < 0){
  67. + *bp++= '-';
  68. + ival= -ival;
  69. + }
  70. + *bp++= '0';
  71. + itoa (&bp, ival, 8);
  72. + break;
  73. +
  74. + case 'x':
  75. + ival= va_arg(ap, int);
  76. + if (ival < 0){
  77. + *bp++= '-';
  78. + ival= -ival;
  79. + }
  80. + *bp++= '0';
  81. + *bp++= 'x';
  82. + itoa (&bp, ival, 16);
  83. + break;
  84. +
  85. + case 'c':
  86. + cval= va_arg(ap, int);
  87. + *bp++= cval;
  88. + break;
  89. +
  90. + case 's':
  91. + for (sval = va_arg(ap, char *) ; *sval ; sval++ )
  92. + *bp++= *sval;
  93. + break;
  94. + }
  95. + }
  96. + *bp= 0;
  97. + tst_sys_trace(print_buf);
  98. + va_end (ap);
  99. +}
  100.  
  101.  void DRV_ICC_print(sim_printEnum messageType, kal_uint32 value1, kal_uint32 value2, kal_uint32 value3, kal_uint32 value4, kal_uint32 value5)

3.这样在打印的地方直接dbmsg就可以了

阅读(1687) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~