#include "ext_regist.h" | |
#include "NvParam_drv.h" | |
#include "libcpnv.h" | |
/**************************wdt******************** | |
*************************************************/ | |
#define ZOSS_ERROR 0xffffffff | |
#define ZOSS_SUCCESS 0x0 | |
/*wdt nv flag*/ | |
#define WDT_OFF (0x57445446) //ascii:WDTF | |
#define WDT_ON (0x5744544F) //ascii:WDTO | |
#define ZX_WDT_IOC_MAGIC 'W' | |
/*ioctl cmd usd by device*/ | |
#define ZX_WDT_SET_INTERNAL _IOW(ZX_WDT_IOC_MAGIC, 1, char *) | |
#define ZX_WDT_SET_WAKEUP _IOW(ZX_WDT_IOC_MAGIC, 2, char *) | |
#define ZX_WDT_FEED_DOG _IOW(ZX_WDT_IOC_MAGIC, 3, char *) | |
#define ZX_WDT_GET_HANDLE_TIMEOUT _IOWR(ZX_WDT_IOC_MAGIC, 4, char *) | |
#define ZX_WDT_GET_GLOBAL_CNT _IOWR(ZX_WDT_IOC_MAGIC, 5, char *) | |
#define ZX_WDT_GET_AP_TIMEOUT _IOWR(ZX_WDT_IOC_MAGIC, 6, char *) | |
#define ZX_WDT_SET_AP_SWITCH _IOWR(ZX_WDT_IOC_MAGIC, 7, char *) | |
#define ZX_WDT_SET_NV _IOWR(ZX_WDT_IOC_MAGIC, 8, char *) | |
#define ZX_WDT_GET_NV _IOWR(ZX_WDT_IOC_MAGIC, 9, char *) | |
#define ZX_WDT_SET_CHECK _IOWR(ZX_WDT_IOC_MAGIC, 10, char *) | |
#define ZX_SOFT_WDT_DEV "/dev/zx_soft_wdt" | |
extern int zx_wdt_set_nv(BOOL nv_flag); | |
extern BOOL zx_wdt_get_wdtnv_for_ctrm(void); | |
//static long int wdt_fd; | |
int wdt_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
char *at_str = NULL; | |
unsigned long retCode = ZOSS_ERROR; | |
int nv_value = 0; | |
unsigned int wdt_nvdata = 0; | |
assert(at_paras!=NULL); | |
at_str = at_paras; | |
get_at_cmd_param_int(at_str, &nv_value, &at_str); | |
at_print(AT_DEBUG,"wdt_act_func:nv_value == %d\n", nv_value); | |
if(0 == nv_value ) | |
{ | |
//ioctl(wdt_fd, ZX_WDT_SET_NV, FALSE); | |
wdt_nvdata=WDT_OFF; | |
retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(wdtSwitch), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtSwitch)); | |
if(ZOSS_SUCCESS == retCode ){ | |
retCode= cpnv_NvramFlush(); | |
} | |
} | |
else if(1 == nv_value ) | |
{ | |
//ioctl(wdt_fd, ZX_WDT_SET_NV, TRUE); | |
wdt_nvdata=WDT_ON; | |
retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(wdtSwitch), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtSwitch)); | |
if(ZOSS_SUCCESS == retCode ){ | |
retCode= cpnv_NvramFlush(); | |
} | |
} | |
else | |
{ | |
*res_msg = at_err_build(ATERR_PARAM_INVALID); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
if (retCode == ZOSS_SUCCESS) | |
{ | |
*res_msg = at_query_result_build("WDT=",at_str); | |
} | |
else | |
{ | |
*res_msg = at_err_build(ATERR_PROC_FAILED); | |
} | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
int wdt_get_nv_state(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
unsigned int wdt_nvdata = 0; | |
long retCode = CPNV_ERROR; | |
//ioctl(wdt_fd, ZX_WDT_GET_NV, &retCode); | |
retCode =cpnv_NvItemRead(DRV_SYS_NV_ITEM_ADDR(wdtSwitch), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtSwitch)); | |
if(CPNV_ERROR == retCode) softap_assert(""); | |
if (WDT_OFF == wdt_nvdata ) | |
{ | |
*res_msg = at_query_result_build("WDT","WDT OFF"); | |
} else if(WDT_ON== wdt_nvdata ) | |
{ | |
*res_msg = at_query_result_build("WDT","WDT ON"); | |
} | |
else | |
{ | |
*res_msg = at_err_build(ATERR_PROC_FAILED); | |
} | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
int wdt_set_nv_priority(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
char *at_str = NULL; | |
unsigned long retCode = ZOSS_ERROR; | |
int nv_value = 0; | |
char strCmd[AT_CMD_MAX] = {0}; | |
assert(at_paras!=NULL); | |
at_str = at_paras; | |
get_at_cmd_param_int(at_str, &nv_value, &at_str); | |
at_print(AT_DEBUG,"wdt_set_nv_priority:nv_value == %d\n", nv_value); | |
if((nv_value > 0)&&(nv_value <= 99))//priority | |
{ | |
retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(wdtPriority), (unsigned char *)(&nv_value), DRV_SYS_NV_ITEM_SIZE(wdtPriority)); | |
if(ZOSS_SUCCESS == retCode ){ | |
retCode= cpnv_NvramFlush(); | |
} | |
} | |
else | |
{ | |
*res_msg = at_err_build(ATERR_PARAM_INVALID); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
if (retCode == ZOSS_SUCCESS) | |
{ | |
sprintf(strCmd,"%d", nv_value); | |
*res_msg = at_query_result_build("WDTP=",strCmd); | |
} | |
else | |
{ | |
*res_msg = at_err_build(ATERR_PROC_FAILED); | |
} | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
int wdt_get_nv_priority(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
unsigned int wdt_nvdata = 0; | |
long retCode = CPNV_ERROR; | |
char strCmd[AT_CMD_MAX] = {0}; | |
retCode =cpnv_NvItemRead(DRV_SYS_NV_ITEM_ADDR(wdtPriority), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtPriority)); | |
if(CPNV_ERROR == retCode) softap_assert(""); | |
sprintf(strCmd,"%d", wdt_nvdata); | |
*res_msg = at_query_result_build("WDTP",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
/**************************pm******************** | |
*************************************************/ | |
#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"); | |
close(fd); | |
return AT_END; | |
} | |
ret=write(fd, &ctx, 4); | |
if(ret<0){ | |
at_print(AT_DEBUG,"cap add write FAIL\n"); | |
close(fd); | |
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"); | |
close(fd); | |
return AT_END; | |
} | |
ret=write(fd, &ctx, 4); | |
if(ret<0){ | |
at_print(AT_DEBUG,"cap add write FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
close(fd); | |
*res_msg = at_query_result_build("capdelete_lock",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
/**************************tsc******************** | |
*************************************************/ | |
#define THRESH_NUM 11 | |
#define ZX_TSC_DEV "/dev/zx_tsc" | |
#define ZX_TSC_IOC_MAGIC 'W' | |
/*ioctl cmd usd by device*/ | |
#define ZX_TSC_SET_THRESHOLD _IOW(ZX_TSC_IOC_MAGIC, 1, char *) | |
#define ZX_TSC_GET_THRESHOLD _IOW(ZX_TSC_IOC_MAGIC, 2, char *) | |
static int tsc_probe0_set_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
char strCmd[AT_CMD_MAX] = {0}; | |
char *at_str = NULL; | |
unsigned char ctx[12]={0,0}; | |
int fd, ret, i; | |
void *p[THRESH_NUM] = { | |
&ctx[1], &ctx[2], &ctx[3], &ctx[4], &ctx[5], | |
&ctx[6], &ctx[7], &ctx[8], &ctx[9], &ctx[10], | |
&ctx[11], | |
}; | |
if(at_paras==NULL) | |
{ | |
*res_msg = at_err_build(ATERR_PARAM_INVALID); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
at_str = at_paras; | |
parse_param("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", at_str, p); | |
at_print(AT_NORMAL,"probe is %d\n", ctx[0]); | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
fd =open(ZX_TSC_DEV, O_RDWR); | |
if(fd<0){ | |
at_print(AT_NORMAL,"ap tsc open FAIL\n"); | |
return -1; | |
} | |
ret=ioctl(fd, ZX_TSC_SET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc set ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
#if 0 | |
ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc get ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
#endif | |
close(fd); | |
*res_msg = at_query_result_build("tsc_test",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
static int tsc_probe0_get_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
char strCmd[AT_CMD_MAX] = {0}; | |
unsigned char ctx[12]={0,0}; | |
int fd, ret, i; | |
fd =open(ZX_TSC_DEV, O_RDWR); | |
if(fd<0){ | |
at_print(AT_NORMAL,"ap tsc open FAIL\n"); | |
return -1; | |
} | |
ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc add ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
at_print(AT_NORMAL,"probe is %d\n", ctx[0]); | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
close(fd); | |
*res_msg = at_query_result_build("tsc_test",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
static int tsc_probe1_set_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
char strCmd[AT_CMD_MAX] = {0}; | |
char *at_str = NULL; | |
unsigned char ctx[12]={1,0}; | |
int fd, ret, i; | |
void *p[THRESH_NUM] = { | |
&ctx[1], &ctx[2], &ctx[3], &ctx[4], &ctx[5], | |
&ctx[6], &ctx[7], &ctx[8], &ctx[9], &ctx[10], | |
&ctx[11], | |
}; | |
if(at_paras==NULL) | |
{ | |
*res_msg = at_err_build(ATERR_PARAM_INVALID); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
at_str = at_paras; | |
parse_param("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", at_str, p); | |
at_print(AT_NORMAL,"probe is %d\n", ctx[0]); | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
fd =open(ZX_TSC_DEV, O_RDWR); | |
if(fd<0){ | |
at_print(AT_NORMAL,"ap tsc open FAIL\n"); | |
return -1; | |
} | |
ret=ioctl(fd, ZX_TSC_SET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc set ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
#if 0 | |
ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc get ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
#endif | |
close(fd); | |
*res_msg = at_query_result_build("tsc_test",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
static int tsc_probe1_get_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
char strCmd[AT_CMD_MAX] = {0}; | |
unsigned char ctx[12]={1,0}; | |
int fd, ret, i; | |
fd =open(ZX_TSC_DEV, O_RDWR); | |
if(fd<0){ | |
at_print(AT_NORMAL,"ap tsc open FAIL\n"); | |
return -1; | |
} | |
ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc add ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
at_print(AT_NORMAL,"probe is %d\n", ctx[0]); | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
close(fd); | |
*res_msg = at_query_result_build("tsc_test",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
static int tsc_probe2_set_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
char strCmd[AT_CMD_MAX] = {0}; | |
char *at_str = NULL; | |
unsigned char ctx[12]={2,0}; | |
int fd, ret, i; | |
void *p[THRESH_NUM] = { | |
&ctx[1], &ctx[2], &ctx[3], &ctx[4], &ctx[5], | |
&ctx[6], &ctx[7], &ctx[8], &ctx[9], &ctx[10], | |
&ctx[11], | |
}; | |
if(at_paras==NULL) | |
{ | |
*res_msg = at_err_build(ATERR_PARAM_INVALID); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
at_str = at_paras; | |
parse_param("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", at_str, p); | |
at_print(AT_NORMAL,"probe is %d\n", ctx[0]); | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
fd =open(ZX_TSC_DEV, O_RDWR); | |
if(fd<0){ | |
at_print(AT_NORMAL,"ap tsc open FAIL\n"); | |
return -1; | |
} | |
ret=ioctl(fd, ZX_TSC_SET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc set ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
#if 0 | |
ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc get ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
#endif | |
close(fd); | |
*res_msg = at_query_result_build("tsc_test",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
static int tsc_probe2_get_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
char strCmd[AT_CMD_MAX] = {0}; | |
unsigned char ctx[12]={2,0}; | |
int fd, ret, i; | |
fd =open(ZX_TSC_DEV, O_RDWR); | |
if(fd<0){ | |
at_print(AT_NORMAL,"ap tsc open FAIL\n"); | |
return -1; | |
} | |
ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc add ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
at_print(AT_NORMAL,"probe is %d\n", ctx[0]); | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
close(fd); | |
*res_msg = at_query_result_build("tsc_test",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
static int tsc_probe3_set_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
char strCmd[AT_CMD_MAX] = {0}; | |
char *at_str = NULL; | |
unsigned char ctx[12]={3,0}; | |
int fd, ret, i; | |
void *p[THRESH_NUM] = { | |
&ctx[1], &ctx[2], &ctx[3], &ctx[4], &ctx[5], | |
&ctx[6], &ctx[7], &ctx[8], &ctx[9], &ctx[10], | |
&ctx[11], | |
}; | |
if(at_paras==NULL) | |
{ | |
*res_msg = at_err_build(ATERR_PARAM_INVALID); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
at_str = at_paras; | |
parse_param("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", at_str, p); | |
at_print(AT_NORMAL,"probe is %d\n", ctx[0]); | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
fd =open(ZX_TSC_DEV, O_RDWR); | |
if(fd<0){ | |
at_print(AT_NORMAL,"ap tsc open FAIL\n"); | |
return -1; | |
} | |
ret=ioctl(fd, ZX_TSC_SET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc set ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
#if 0 | |
ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc get ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
#endif | |
close(fd); | |
*res_msg = at_query_result_build("tsc_test",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
static int tsc_probe3_get_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
char strCmd[AT_CMD_MAX] = {0}; | |
unsigned char ctx[12]={3,0}; | |
int fd, ret, i; | |
fd =open(ZX_TSC_DEV, O_RDWR); | |
if(fd<0){ | |
at_print(AT_NORMAL,"ap tsc open FAIL\n"); | |
return -1; | |
} | |
ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx); | |
if(ret<0){ | |
at_print(AT_NORMAL,"tsc add ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
at_print(AT_NORMAL,"probe is %d\n", ctx[0]); | |
for(i=1; i<12; i++) | |
{ | |
at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]); | |
} | |
close(fd); | |
*res_msg = at_query_result_build("tsc_test",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
#define ZX_RESET_DEV "/dev/zx_reset" | |
#define ZX_RESET_IOC_MAGIC 'W' | |
/*ioctl cmd usd by device*/ | |
#define ZX_RESET_FAST_REBOOT _IOW(ZX_RESET_IOC_MAGIC, 1, char *) | |
static int fast_reboot(int at_fd,char * at_paras,void * *res_msg,int * res_msglen) | |
{ | |
int fd, ret; | |
char strCmd[AT_CMD_MAX] = {0}; | |
fd =open(ZX_RESET_DEV, O_RDWR); | |
if(fd<0){ | |
at_print(AT_NORMAL,"ap reset open FAIL\n"); | |
return -1; | |
} | |
ret=ioctl(fd, ZX_RESET_FAST_REBOOT, NULL); | |
if(ret<0){ | |
at_print(AT_NORMAL,"fast reboot add ioctl FAIL\n"); | |
close(fd); | |
return AT_END; | |
} | |
close(fd); | |
*res_msg = at_query_result_build("fast reboot",strCmd); | |
*res_msglen = strlen(*res_msg); | |
return AT_END; | |
} | |
/**************************init******************** | |
*************************************************/ | |
void ext_bsp_regist_init(void) | |
{ | |
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("WDTP=", 0, 0, 0, wdt_set_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); | |
register_serv_func2("probe0_set_thresh=", 0, 0, 0,tsc_probe0_set_thresh,NULL); | |
register_serv_func2("probe0_get_thresh", 0, 0, 0,tsc_probe0_get_thresh,NULL); | |
register_serv_func2("probe1_set_thresh=", 0, 0, 0,tsc_probe1_set_thresh,NULL); | |
register_serv_func2("probe1_get_thresh", 0, 0, 0,tsc_probe1_get_thresh,NULL); | |
register_serv_func2("probe2_set_thresh=", 0, 0, 0,tsc_probe2_set_thresh,NULL); | |
register_serv_func2("probe2_get_thresh", 0, 0, 0,tsc_probe2_get_thresh,NULL); | |
register_serv_func2("probe3_set_thresh=", 0, 0, 0,tsc_probe3_set_thresh,NULL); | |
register_serv_func2("probe3_get_thresh", 0, 0, 0,tsc_probe3_get_thresh,NULL); | |
register_serv_func2("fast_reboot", 0, 0, 0,fast_reboot, NULL); | |
} | |