92的modem打印很不方便:
a. __FILE__打印的路径太长看起来不方便
b. 需要万能的dbmsg
如下所示一共修改了两个文件:
-
cong@msi:/work/mtk/modem$ git status
-
modified: driver/storage/sim/inc/sim_drv_SW_API.h
-
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之上添加即可
-
diff --git a/driver/storage/sim/inc/sim_drv_SW_API.h b/driver/storage/sim/inc/sim_drv_SW_API.h
-
index d02bb9b..356ab1f 100644
-
--- a/driver/storage/sim/inc/sim_drv_SW_API.h
-
+++ b/driver/storage/sim/inc/sim_drv_SW_API.h
-
@@ -58,6 +58,50 @@ extern void L1sim_Enable_Enhanced_Speed(kal_bool enable, sim_HW_cb *hw_cb);
-
#endif
-
extern void USIM_SET_EVENT_Multiple(usim_dcb_struct *usim_dcb);
-
extern void SIM_SetTOUT(kal_uint32 TOUT, sim_HW_cb *hw_cb);
-
+#define _STRRCHR_IMPL_COMMON(str, ch, offset) (str)[sizeof((str)) - 1 - (offset)] == (ch)? (str) + sizeof((str)) - (offset): sizeof((str)) <= (offset) + 1? (str)
-
+#define _STRRCHR_IMPL_31(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 31): (str))
-
+#define _STRRCHR_IMPL_30(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 30): _STRRCHR_IMPL_31(str, ch))
-
+#define _STRRCHR_IMPL_29(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 29): _STRRCHR_IMPL_30(str, ch))
-
+#define _STRRCHR_IMPL_28(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 28): _STRRCHR_IMPL_29(str, ch))
-
+#define _STRRCHR_IMPL_27(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 27): _STRRCHR_IMPL_28(str, ch))
-
+#define _STRRCHR_IMPL_26(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 26): _STRRCHR_IMPL_27(str, ch))
-
+#define _STRRCHR_IMPL_25(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 25): _STRRCHR_IMPL_26(str, ch))
-
+#define _STRRCHR_IMPL_24(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 24): _STRRCHR_IMPL_25(str, ch))
-
+#define _STRRCHR_IMPL_23(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 23): _STRRCHR_IMPL_24(str, ch))
-
+#define _STRRCHR_IMPL_22(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 22): _STRRCHR_IMPL_23(str, ch))
-
+#define _STRRCHR_IMPL_21(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 21): _STRRCHR_IMPL_22(str, ch))
-
+#define _STRRCHR_IMPL_20(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 20): _STRRCHR_IMPL_21(str, ch))
-
+#define _STRRCHR_IMPL_19(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 19): _STRRCHR_IMPL_20(str, ch))
-
+#define _STRRCHR_IMPL_18(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 18): _STRRCHR_IMPL_19(str, ch))
-
+#define _STRRCHR_IMPL_17(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 17): _STRRCHR_IMPL_18(str, ch))
-
+#define _STRRCHR_IMPL_16(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 16): _STRRCHR_IMPL_17(str, ch))
-
+#define _STRRCHR_IMPL_15(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 15): _STRRCHR_IMPL_16(str, ch))
-
+#define _STRRCHR_IMPL_14(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 14): _STRRCHR_IMPL_15(str, ch))
-
+#define _STRRCHR_IMPL_13(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 13): _STRRCHR_IMPL_14(str, ch))
-
+#define _STRRCHR_IMPL_12(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 12): _STRRCHR_IMPL_13(str, ch))
-
+#define _STRRCHR_IMPL_11(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 11): _STRRCHR_IMPL_12(str, ch))
-
+#define _STRRCHR_IMPL_10(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 10): _STRRCHR_IMPL_11(str, ch))
-
+#define _STRRCHR_IMPL_9(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 9): _STRRCHR_IMPL_10(str, ch))
-
+#define _STRRCHR_IMPL_8(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 8): _STRRCHR_IMPL_9(str, ch))
-
+#define _STRRCHR_IMPL_7(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 7): _STRRCHR_IMPL_8(str, ch))
-
+#define _STRRCHR_IMPL_6(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 6): _STRRCHR_IMPL_7(str, ch))
-
+#define _STRRCHR_IMPL_5(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 5): _STRRCHR_IMPL_6(str, ch))
-
+#define _STRRCHR_IMPL_4(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 4): _STRRCHR_IMPL_5(str, ch))
-
+#define _STRRCHR_IMPL_3(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 3): _STRRCHR_IMPL_4(str, ch))
-
+#define _STRRCHR_IMPL_2(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 2): _STRRCHR_IMPL_3(str, ch))
-
+#define _STRRCHR_IMPL_1(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 1): _STRRCHR_IMPL_2(str, ch))
-
+#define _STRRCHR_IMPL_0(str, ch) (_STRRCHR_IMPL_COMMON(str, ch, 0): _STRRCHR_IMPL_1(str, ch))
-
+
-
+// a macro version of strrchr().
-
+// it has several limitations:
-
+// - str must be a literal string, e.g. "a string".
-
+// - if ch cannot be found in last 32 characters, it will return the whole string.
-
+// this limit can be increased by adding more _STRRCHR_IMPL_* macros.
-
+#define _STRRCHR(str, ch) (sizeof((str)) <= 1? (str): _STRRCHR_IMPL_0(str, ch))
-
+
-
+#define __FNAME__ _STRRCHR(__FILE__, '/')
-
+extern void myprintf(char *fmt,...);
-
+#define dbmsg(fmt, args ...) myprintf("%s:%s[%d]: "fmt"\n", __FNAME__,__FUNCTION__, __LINE__,##args)
-
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的实现
-
--- a/driver/storage/sim/src/icc_sim_common_mtk.c
-
+++ b/driver/storage/sim/src/icc_sim_common_mtk.c
-
+static void itoa(char **buf, int i, int base)
-
+{
-
+ char *s;
-
+#define LEN 20
-
+ int rem;
-
+ static char rev[LEN+1];
-
+
-
+ rev[LEN] = 0;
-
+ if (i == 0)
-
+ {
-
+ (*buf)[0] = '0';
-
+ ++(*buf);
-
+ return;
-
+ }
-
+ s = &rev[LEN];
-
+ while (i)
-
+ {
-
+ rem = i % base;
-
+ if (rem < 10)
-
+ *--s = rem + '0';
-
+ else if (base == 16)
-
+ *--s = "abcdef"[rem - 10];
-
+ i /= base;
-
+ }
-
+ while (*s)
-
+ {
-
+ (*buf)[0] = *s++;
-
+ ++(*buf);
-
+ }
-
+}
-
+char print_buf[1024];
-
+void myprintf(char *fmt,...)
-
+{
-
+ va_list ap;
-
+ double dval;
-
+ int ival;
-
+ char *p, *sval;
-
+ char *bp, cval;
-
+ int fract;
-
+ unsigned short len;
-
+ bp= print_buf;
-
+ *bp= 0;
-
+
-
+ va_start (ap, fmt);
-
+ for (p= fmt; *p; p++)
-
+ {
-
+ if (*p != '%')
-
+ {
-
+ *bp++= *p;
-
+ continue;
-
+ }
-
+ switch (*++p) {
-
+ case 'd':
-
+ ival= va_arg(ap, int);
-
+ if (ival < 0){
-
+ *bp++= '-';
-
+ ival= -ival;
-
+ }
-
+ itoa (&bp, ival, 10);
-
+ break;
-
+
-
+ case 'o':
-
+ ival= va_arg(ap, int);
-
+ if (ival < 0){
-
+ *bp++= '-';
-
+ ival= -ival;
-
+ }
-
+ *bp++= '0';
-
+ itoa (&bp, ival, 8);
-
+ break;
-
+
-
+ case 'x':
-
+ ival= va_arg(ap, int);
-
+ if (ival < 0){
-
+ *bp++= '-';
-
+ ival= -ival;
-
+ }
-
+ *bp++= '0';
-
+ *bp++= 'x';
-
+ itoa (&bp, ival, 16);
-
+ break;
-
+
-
+ case 'c':
-
+ cval= va_arg(ap, int);
-
+ *bp++= cval;
-
+ break;
-
+
-
+ case 's':
-
+ for (sval = va_arg(ap, char *) ; *sval ; sval++ )
-
+ *bp++= *sval;
-
+ break;
-
+ }
-
+ }
-
+ *bp= 0;
-
+ tst_sys_trace(print_buf);
-
+ va_end (ap);
-
+}
-
-
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) |