[Feature][ZXW-33]merge ZXW 0428 version

Change-Id: I11f167edfea428d9fab198ff00ff1364932d1b0b
diff --git a/ap/lib/libatext/ext_wdt_func.c b/ap/lib/libatext/ext_wdt_func.c
index e289b5f..db6806d 100644
--- a/ap/lib/libatext/ext_wdt_func.c
+++ b/ap/lib/libatext/ext_wdt_func.c
@@ -167,14 +167,145 @@
 	return AT_END;

 }

 

+

+/*****************

+*

+*

+*/

+

+#define RPMSG_IOC_MAGIC     'R'

+

+/*ioctl cmd usd by device*/

+#define RPMSG_CREATE_CHANNEL          _IOW(RPMSG_IOC_MAGIC, 1, char *)

+#define RPMSG_GET_DATASIZE       _IOWR(RPMSG_IOC_MAGIC, 2, char *)

+#define RPMSG_SET_INT            _IOW(RPMSG_IOC_MAGIC, 3, char *)

+#define RPMSG_SET_INT_FLAG        _IOW(RPMSG_IOC_MAGIC, 4, char *)

+#define RPMSG_CLEAR_INT_FLAG      _IOW(RPMSG_IOC_MAGIC, 5, char *)

+#define RPMSG_SET_POLL_FLAG       _IOW(RPMSG_IOC_MAGIC, 6, char *)

+#define RPMSG_CLEAR_POLL_FLAG     _IOW(RPMSG_IOC_MAGIC, 7, char *)

+#define AT_CAP_DEV    "/dev/rpmsg2"

+

+ static void write_lockfile(char *filepath, char *setbuf)

+ {	

+ 	int f, len = 0;	

+	f = open(filepath, O_RDWR);	

+	if (f == -1) {

+	 	at_print(AT_DEBUG,"write_lockfile OPEN FAIL\n");

+		return;	

+	}	

+	len = strlen(setbuf);	

+	if (write(f, setbuf, len) != len) 

+	{	} 

+	else 

+	{	}

+	

+	close(f);

+}

+

+static int pm_apadd_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)

+{

+	char strCmd[AT_CMD_MAX] = {0};

+

+	write_lockfile("/sys/power/wake_lock", "test_wakelock");

+

+	*res_msg = at_query_result_build("delete_lock",strCmd);	

+	*res_msglen = strlen(*res_msg);	

+	return AT_END;

+}

+

+static int pm_apdelete_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)

+{

+	char strCmd[AT_CMD_MAX] = {0};

+

+	write_lockfile("/sys/power/wake_unlock", "test_wakelock");

+

+	*res_msg = at_query_result_build("delete_lock",strCmd);	

+	*res_msglen = strlen(*res_msg);

+	

+	return AT_END;

+}

+

+

+static int pm_capadd_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)

+{

+	char strCmd[AT_CMD_MAX] = {0};

+	unsigned int ctx=0x5a5a;

+	int fd, ret;

+	

+	 at_print(AT_DEBUG,"pm_capadd_wakelock\n");

+

+

+	fd =open(AT_CAP_DEV, O_RDWR);

+	if(fd<0){

+	 	at_print(AT_DEBUG,"cap add  open FAIL\n");

+		return -1;	

+	}

+

+	ret=ioctl(fd, RPMSG_SET_INT_FLAG, NULL);

+	if(ret<0){

+	 	at_print(AT_DEBUG,"cap add  ioctl FAIL\n");

+		return AT_END;	

+	}		

+	ret=write(fd, &ctx, 4);

+	if(ret<0){

+	 	at_print(AT_DEBUG,"cap add  write FAIL\n");

+		return AT_END;	

+	}

+	

+	*res_msg = at_query_result_build("capadd_lock",strCmd);	

+	*res_msglen = strlen(*res_msg);

+	

+	close(fd);

+	

+	return AT_END;

+}

+

+static int pm_capdelete_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)

+{

+	char strCmd[AT_CMD_MAX] = {0};

+

+	unsigned int ctx=0x5a5b;

+	int fd, ret;

+	

+	 at_print(AT_DEBUG,"pm_capdelete_wakelock\n");

+

+	fd =open(AT_CAP_DEV, O_RDWR);

+	if(fd<0){

+	 	at_print(AT_DEBUG,"cap add  open FAIL\n");

+		return -1;	

+	}

+

+	ret=ioctl(fd, RPMSG_SET_INT_FLAG, NULL);

+	if(ret<0){

+	 	at_print(AT_DEBUG,"cap add  ioctl FAIL\n");

+		return AT_END;	

+	}		

+	ret=write(fd, &ctx, 4);

+	if(ret<0){

+	 	at_print(AT_DEBUG,"cap add  write FAIL\n");

+		return AT_END;	

+	}

+

+	close(fd);

+	

+	*res_msg = at_query_result_build("capdelete_lock",strCmd);	

+	*res_msglen = strlen(*res_msg);

+	

+	return AT_END;

+}

 void ext_wdt_regist_init(void)

 {

 	//wdt_fd = open(ZX_SOFT_WDT_DEV, O_RDWR);

 	//ioctl(wdt_fd, ZX_WDT_SET_CHECK, FALSE);

 

 	register_serv_func2("WDT=", 0, 0, 0, wdt_act_func, NULL);

-    register_serv_func2("WDT?", 0, 0, 0,wdt_get_nv_state,NULL);

+	register_serv_func2("WDT?", 0, 0, 0,wdt_get_nv_state,NULL);

 	register_serv_func2("WDTP=", 0, 0, 0, wdt_set_nv_priority, NULL);

-    register_serv_func2("WDTP?", 0, 0, 0,wdt_get_nv_priority,NULL);

+	register_serv_func2("WDTP?", 0, 0, 0,wdt_get_nv_priority,NULL);

+

+	register_serv_func2("apadd_lock", 0, 0, 0,pm_apadd_wakelock,NULL);

+	register_serv_func2("apdel_lock", 0, 0, 0,pm_apdelete_wakelock,NULL);

+	register_serv_func2("capadd_lock", 0, 0, 0,pm_capadd_wakelock,NULL);

+	register_serv_func2("capdel_lock", 0, 0, 0,pm_capdelete_wakelock,NULL);		

 }