[Feature][task-view-306]merge P56U08(patch6) version
Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: I8e809511ac30c97228dd110c304b4a08f4af36d7
diff --git a/ap/app/zte_comm/nvserver/nvserver_rpc.c b/ap/app/zte_comm/nvserver/nvserver_rpc.c
index 7e4d012..d12bb0d 100755
--- a/ap/app/zte_comm/nvserver/nvserver_rpc.c
+++ b/ap/app/zte_comm/nvserver/nvserver_rpc.c
@@ -31,6 +31,9 @@
#include "nv_typedef.h"
#include <message.h>
#include "sc_rpc.h"
+#include "soft_timer.h"
+#include "zxicbasic_api.h"
+#include "pub_debug_info.h"
#ifdef __cplusplus
extern "C"
@@ -45,6 +48,9 @@
* ºê¶¨Òå *
*******************************************************************************/
#define RPC_RPMSG_DEV "/dev/rpmsg8"
+#define NVSERVER_LOG_START_TIME (120) /* 2 minutes */
+#define MODULE_ID_AP_SERVER "ap_nvserver"
+#define NVSERVER_LOG_TIMER_ID (0x1984)
/*******************************************************************************
* Êý¾ÝÀàÐͶ¨Òå *
@@ -66,6 +72,7 @@
static unsigned int g_msgRcvErrCnt = 0;
static unsigned int g_msgSndCnt = 0;
static unsigned int g_msgSndErrCnt = 0;
+static int g_debug_info_flag = 0; /* not log debug info */
/*******************************************************************************
* ¾Ö²¿º¯ÊýʵÏÖ *
@@ -152,6 +159,83 @@
return 0;
}
+static void log_timer_callback(void *argc)
+{
+ g_debug_info_flag = 1;
+ //logmsg("log_timer_callback\n");
+}
+
+// return -1 error; 1 active; 0 sleep
+int cap_is_active(void)
+{
+ char buf[4];
+ int ret = -1;
+
+ memset(buf, 0, sizeof(buf));
+ ret = open_read_close("/sys/zte_pm/cap_state", buf, sizeof(buf));
+ if (ret < 0)
+ return -1;
+ //logmsg("cap_is_active:%s\n", buf);
+ if (buf[0] == '1')
+ {
+ //logmsg("cap_is_active:active\n");
+ return 1;
+ }
+ else
+ {
+ if (buf[0] == '0')
+ {
+ //logmsg("cap_is_active:sleeping\n");
+ return 0;
+ }
+ else
+ {
+ //logmsg("cap_is_active:error\n");
+ return -1;
+ }
+ }
+}
+
+static void log_nv_info(T_NV_MSG_INFO *msg)
+{
+ //logmsg("log_nv_info\n");
+ switch(msg->nvType)
+ {
+ case MSG_GET:
+ //printf("[nvrpc] cfg_get key:%s\n", msg->key);
+ sc_debug_info_record(MODULE_ID_AP_SERVER, "cfg_get key:%s\n", msg->key);
+ break;
+ case MSG_SET:
+ //printf("[nvrpc] cfg_set key:%s value:%s\n", msg->key, msg->value);
+ sc_debug_info_record(MODULE_ID_AP_SERVER, "cfg_set key:%s value:%s\n", msg->key, msg->value);
+ break;
+ case MSG_UNSET:
+ //printf("[nvrpc] cfg_unset key:%s\n", msg->key);
+ sc_debug_info_record(MODULE_ID_AP_SERVER, "cfg_unset key:%s\n", msg->key);
+ break;
+ case MSG_CLEAR:
+ //printf("[nvrpc] cfg_clear\n");
+ sc_debug_info_record(MODULE_ID_AP_SERVER, "cfg_clear\n");
+ break;
+ case MSG_RESET:
+ //printf("[nvrpc] cfg_reset\n");
+ sc_debug_info_record(MODULE_ID_AP_SERVER, "cfg_reset\n");
+ break;
+ case MSG_SHOW:
+ //printf("[nvrpc] cfg_show\n");
+ sc_debug_info_record(MODULE_ID_AP_SERVER, "cfg_show\n");
+ break;
+ case MSG_COMMIT:
+ //printf("[nvrpc] cfg_save\n");
+ sc_debug_info_record(MODULE_ID_AP_SERVER, "cfg_save\n");
+ break;
+ default:
+ //printf("[nvrpc] cfg other action\n");
+ sc_debug_info_record(MODULE_ID_AP_SERVER, "error cfg other action\n");
+ break;
+ }
+}
+
/*******************************************************************************
* È«¾Öº¯ÊýʵÏÖ *
*******************************************************************************/
@@ -178,6 +262,11 @@
memset(&msgInfo, 0, sizeof(msgInfo));
+ if (0 != sc_timer_create(NVSERVER_LOG_TIMER_ID, TIMER_FLAG_ONCE, NVSERVER_LOG_START_TIME*1000, log_timer_callback, NULL))
+ {
+ abort(); // create timer error
+ }
+
g_rpc_fd = sc_rpc_open(RPC_RPMSG_DEV);
msgId = msgget(MODULE_ID_NV, IPC_CREAT | 0600);
@@ -237,6 +326,10 @@
pid_backup = rcvBuf.pid;
g_msgRcvCnt++; /* msgrcv success count */
+ if (g_debug_info_flag && (cap_is_active() == 0))
+ { //start log and cap is sleeping
+ log_nv_info(&rcvBuf);
+ }
analyMsg(&rcvBuf, &sndBuf, rpc_data, rpc_data2);
//printf("apnv nvserver_rpc msgsnd pid:%d, backup:%d\n", sndBuf.msgType, pid_backup);