blob: ab2a2263f823bfd93a6f0378682798af9f1243d9 [file] [log] [blame]
xf.lie31de8b2023-12-26 23:38:58 -08001#include "ext_regist.h"
2#include "NvParam_drv.h"
3#include "libcpnv.h"
4
5
6/**************************wdt********************
7
8*************************************************/
9
10#define ZOSS_ERROR 0xffffffff
11#define ZOSS_SUCCESS 0x0
12
13/*wdt nv flag*/
14#define WDT_OFF (0x57445446) //ascii:WDTF
15#define WDT_ON (0x5744544F) //ascii:WDTO
16
17#define ZX_WDT_IOC_MAGIC 'W'
18
19/*ioctl cmd usd by device*/
20#define ZX_WDT_SET_INTERNAL _IOW(ZX_WDT_IOC_MAGIC, 1, char *)
21#define ZX_WDT_SET_WAKEUP _IOW(ZX_WDT_IOC_MAGIC, 2, char *)
22#define ZX_WDT_FEED_DOG _IOW(ZX_WDT_IOC_MAGIC, 3, char *)
23#define ZX_WDT_GET_HANDLE_TIMEOUT _IOWR(ZX_WDT_IOC_MAGIC, 4, char *)
24#define ZX_WDT_GET_GLOBAL_CNT _IOWR(ZX_WDT_IOC_MAGIC, 5, char *)
25#define ZX_WDT_GET_AP_TIMEOUT _IOWR(ZX_WDT_IOC_MAGIC, 6, char *)
26#define ZX_WDT_SET_AP_SWITCH _IOWR(ZX_WDT_IOC_MAGIC, 7, char *)
27#define ZX_WDT_SET_NV _IOWR(ZX_WDT_IOC_MAGIC, 8, char *)
28#define ZX_WDT_GET_NV _IOWR(ZX_WDT_IOC_MAGIC, 9, char *)
29#define ZX_WDT_SET_CHECK _IOWR(ZX_WDT_IOC_MAGIC, 10, char *)
30
31#define ZX_SOFT_WDT_DEV "/dev/zx_soft_wdt"
32
33
34extern int zx_wdt_set_nv(BOOL nv_flag);
35extern BOOL zx_wdt_get_wdtnv_for_ctrm(void);
36//static long int wdt_fd;
37
38int wdt_act_func(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
39{
40 char *at_str = NULL;
41 unsigned long retCode = ZOSS_ERROR;
42 int nv_value = 0;
43 unsigned int wdt_nvdata = 0;
44
45 assert(at_paras!=NULL);
46 at_str = at_paras;
47
48 get_at_cmd_param_int(at_str, &nv_value, &at_str);
49 at_print(AT_DEBUG,"wdt_act_func:nv_value == %d\n", nv_value);
50
51 if(0 == nv_value )
52 {
53
54 //ioctl(wdt_fd, ZX_WDT_SET_NV, FALSE);
55 wdt_nvdata=WDT_OFF;
56 retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(wdtSwitch), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtSwitch));
57 if(ZOSS_SUCCESS == retCode ){
58 retCode= cpnv_NvramFlush();
59 }
60
61 }
62 else if(1 == nv_value )
63 {
64 //ioctl(wdt_fd, ZX_WDT_SET_NV, TRUE);
65 wdt_nvdata=WDT_ON;
66 retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(wdtSwitch), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtSwitch));
67 if(ZOSS_SUCCESS == retCode ){
68 retCode= cpnv_NvramFlush();
69 }
70 }
71 else
72 {
73 *res_msg = at_err_build(ATERR_PARAM_INVALID);
74 *res_msglen = strlen(*res_msg);
75 return AT_END;
76 }
77
78 if (retCode == ZOSS_SUCCESS)
79 {
80 *res_msg = at_query_result_build("WDT=",at_str);
81 }
82 else
83 {
84 *res_msg = at_err_build(ATERR_PROC_FAILED);
85 }
86
87 *res_msglen = strlen(*res_msg);
88 return AT_END;
89}
90
91int wdt_get_nv_state(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
92{
93
94 unsigned int wdt_nvdata = 0;
95 long retCode = CPNV_ERROR;
96
97 //ioctl(wdt_fd, ZX_WDT_GET_NV, &retCode);
98
99 retCode =cpnv_NvItemRead(DRV_SYS_NV_ITEM_ADDR(wdtSwitch), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtSwitch));
100 if(CPNV_ERROR == retCode) softap_assert("");
101 if (WDT_OFF == wdt_nvdata )
102 {
103 *res_msg = at_query_result_build("WDT","WDT OFF");
104
105 } else if(WDT_ON== wdt_nvdata )
106 {
107 *res_msg = at_query_result_build("WDT","WDT ON");
108 }
109 else
110 {
111 *res_msg = at_err_build(ATERR_PROC_FAILED);
112 }
113
114 *res_msglen = strlen(*res_msg);
115 return AT_END;
116}
117
118int wdt_set_nv_priority(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
119{
120 char *at_str = NULL;
121 unsigned long retCode = ZOSS_ERROR;
122 int nv_value = 0;
123 char strCmd[AT_CMD_MAX] = {0};
124
125 assert(at_paras!=NULL);
126 at_str = at_paras;
127
128 get_at_cmd_param_int(at_str, &nv_value, &at_str);
129 at_print(AT_DEBUG,"wdt_set_nv_priority:nv_value == %d\n", nv_value);
130
131 if((nv_value > 0)&&(nv_value <= 99))//priority
132 {
133 retCode = cpnv_NvItemWrite(DRV_SYS_NV_ITEM_ADDR(wdtPriority), (unsigned char *)(&nv_value), DRV_SYS_NV_ITEM_SIZE(wdtPriority));
134 if(ZOSS_SUCCESS == retCode ){
135 retCode= cpnv_NvramFlush();
136 }
137 }
138 else
139 {
140 *res_msg = at_err_build(ATERR_PARAM_INVALID);
141 *res_msglen = strlen(*res_msg);
142 return AT_END;
143 }
144
145 if (retCode == ZOSS_SUCCESS)
146 {
147 sprintf(strCmd,"%d", nv_value);
148 *res_msg = at_query_result_build("WDTP=",strCmd);
149 }
150 else
151 {
152 *res_msg = at_err_build(ATERR_PROC_FAILED);
153 }
154
155 *res_msglen = strlen(*res_msg);
156 return AT_END;
157}
158
159int wdt_get_nv_priority(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
160{
161 unsigned int wdt_nvdata = 0;
162 long retCode = CPNV_ERROR;
163 char strCmd[AT_CMD_MAX] = {0};
164
165 retCode =cpnv_NvItemRead(DRV_SYS_NV_ITEM_ADDR(wdtPriority), (unsigned char *)(&wdt_nvdata), DRV_SYS_NV_ITEM_SIZE(wdtPriority));
166 if(CPNV_ERROR == retCode) softap_assert("");
167
168 sprintf(strCmd,"%d", wdt_nvdata);
169
170 *res_msg = at_query_result_build("WDTP",strCmd);
171 *res_msglen = strlen(*res_msg);
172 return AT_END;
173}
174
175
176
177/**************************pm********************
178
179*************************************************/
180
181#define RPMSG_IOC_MAGIC 'R'
182
183/*ioctl cmd usd by device*/
184#define RPMSG_CREATE_CHANNEL _IOW(RPMSG_IOC_MAGIC, 1, char *)
185#define RPMSG_GET_DATASIZE _IOWR(RPMSG_IOC_MAGIC, 2, char *)
186#define RPMSG_SET_INT _IOW(RPMSG_IOC_MAGIC, 3, char *)
187#define RPMSG_SET_INT_FLAG _IOW(RPMSG_IOC_MAGIC, 4, char *)
188#define RPMSG_CLEAR_INT_FLAG _IOW(RPMSG_IOC_MAGIC, 5, char *)
189#define RPMSG_SET_POLL_FLAG _IOW(RPMSG_IOC_MAGIC, 6, char *)
190#define RPMSG_CLEAR_POLL_FLAG _IOW(RPMSG_IOC_MAGIC, 7, char *)
191#define AT_CAP_DEV "/dev/rpmsg2"
192
193 static void write_lockfile(char *filepath, char *setbuf)
194 {
195 int f, len = 0;
196 f = open(filepath, O_RDWR);
197 if (f == -1) {
198 at_print(AT_DEBUG,"write_lockfile OPEN FAIL\n");
199 return;
200 }
201 len = strlen(setbuf);
202 if (write(f, setbuf, len) != len)
203 { }
204 else
205 { }
206
207 close(f);
208}
209
210static int pm_apadd_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
211{
212 char strCmd[AT_CMD_MAX] = {0};
213
214 write_lockfile("/sys/power/wake_lock", "test_wakelock");
215
216 *res_msg = at_query_result_build("delete_lock",strCmd);
217 *res_msglen = strlen(*res_msg);
218 return AT_END;
219}
220
221static int pm_apdelete_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
222{
223 char strCmd[AT_CMD_MAX] = {0};
224
225 write_lockfile("/sys/power/wake_unlock", "test_wakelock");
226
227 *res_msg = at_query_result_build("delete_lock",strCmd);
228 *res_msglen = strlen(*res_msg);
229
230 return AT_END;
231}
232
233
234static int pm_capadd_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
235{
236 char strCmd[AT_CMD_MAX] = {0};
237 unsigned int ctx=0x5a5a;
238 int fd, ret;
239
240 at_print(AT_DEBUG,"pm_capadd_wakelock\n");
241
242
243 fd =open(AT_CAP_DEV, O_RDWR);
244 if(fd<0){
245 at_print(AT_DEBUG,"cap add open FAIL\n");
246 return -1;
247 }
248
249 ret=ioctl(fd, RPMSG_SET_INT_FLAG, NULL);
250 if(ret<0){
251 at_print(AT_DEBUG,"cap add ioctl FAIL\n");
252 close(fd);
253 return AT_END;
254 }
255 ret=write(fd, &ctx, 4);
256 if(ret<0){
257 at_print(AT_DEBUG,"cap add write FAIL\n");
258 close(fd);
259 return AT_END;
260 }
261
262 *res_msg = at_query_result_build("capadd_lock",strCmd);
263 *res_msglen = strlen(*res_msg);
264
265 close(fd);
266
267 return AT_END;
268}
269
270static int pm_capdelete_wakelock(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
271{
272 char strCmd[AT_CMD_MAX] = {0};
273
274 unsigned int ctx=0x5a5b;
275 int fd, ret;
276
277 at_print(AT_DEBUG,"pm_capdelete_wakelock\n");
278
279 fd =open(AT_CAP_DEV, O_RDWR);
280 if(fd<0){
281 at_print(AT_DEBUG,"cap add open FAIL\n");
282 return -1;
283 }
284
285 ret=ioctl(fd, RPMSG_SET_INT_FLAG, NULL);
286 if(ret<0){
287 at_print(AT_DEBUG,"cap add ioctl FAIL\n");
288 close(fd);
289 return AT_END;
290 }
291 ret=write(fd, &ctx, 4);
292 if(ret<0){
293 at_print(AT_DEBUG,"cap add write FAIL\n");
294 close(fd);
295 return AT_END;
296 }
297
298 close(fd);
299
300 *res_msg = at_query_result_build("capdelete_lock",strCmd);
301 *res_msglen = strlen(*res_msg);
302
303 return AT_END;
304}
305
306
307/**************************tsc********************
308
309*************************************************/
310
311#define THRESH_NUM 11
312
313#define ZX_TSC_DEV "/dev/zx_tsc"
314
315#define ZX_TSC_IOC_MAGIC 'W'
316/*ioctl cmd usd by device*/
317#define ZX_TSC_SET_THRESHOLD _IOW(ZX_TSC_IOC_MAGIC, 1, char *)
318#define ZX_TSC_GET_THRESHOLD _IOW(ZX_TSC_IOC_MAGIC, 2, char *)
319
320static int tsc_probe0_set_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
321{
322 char strCmd[AT_CMD_MAX] = {0};
323 char *at_str = NULL;
324 unsigned char ctx[12]={0,0};
325 int fd, ret, i;
326
327 void *p[THRESH_NUM] = {
328 &ctx[1], &ctx[2], &ctx[3], &ctx[4], &ctx[5],
329 &ctx[6], &ctx[7], &ctx[8], &ctx[9], &ctx[10],
330 &ctx[11],
331 };
332
333 if(at_paras==NULL)
334 {
335 *res_msg = at_err_build(ATERR_PARAM_INVALID);
336 *res_msglen = strlen(*res_msg);
337 return AT_END;
338 }
339
340 at_str = at_paras;
341
342 parse_param("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", at_str, p);
343 at_print(AT_NORMAL,"probe is %d\n", ctx[0]);
344 for(i=1; i<12; i++)
345 {
346 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
347 }
348
349 fd =open(ZX_TSC_DEV, O_RDWR);
350 if(fd<0){
351 at_print(AT_NORMAL,"ap tsc open FAIL\n");
352 return -1;
353 }
354 ret=ioctl(fd, ZX_TSC_SET_THRESHOLD, (unsigned long)&ctx);
355 if(ret<0){
356 at_print(AT_NORMAL,"tsc set ioctl FAIL\n");
357 close(fd);
358 return AT_END;
359 }
360 #if 0
361 ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx);
362 if(ret<0){
363 at_print(AT_NORMAL,"tsc get ioctl FAIL\n");
364 close(fd);
365 return AT_END;
366 }
367 for(i=1; i<12; i++)
368 {
369 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
370 }
371 #endif
372 close(fd);
373
374 *res_msg = at_query_result_build("tsc_test",strCmd);
375 *res_msglen = strlen(*res_msg);
376
377 return AT_END;
378}
379
380
381
382static int tsc_probe0_get_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
383{
384 char strCmd[AT_CMD_MAX] = {0};
385
386 unsigned char ctx[12]={0,0};
387 int fd, ret, i;
388
389 fd =open(ZX_TSC_DEV, O_RDWR);
390 if(fd<0){
391 at_print(AT_NORMAL,"ap tsc open FAIL\n");
392 return -1;
393 }
394
395 ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx);
396 if(ret<0){
397 at_print(AT_NORMAL,"tsc add ioctl FAIL\n");
398 close(fd);
399 return AT_END;
400 }
401
402 at_print(AT_NORMAL,"probe is %d\n", ctx[0]);
403 for(i=1; i<12; i++)
404 {
405 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
406 }
407
408 close(fd);
409
410 *res_msg = at_query_result_build("tsc_test",strCmd);
411 *res_msglen = strlen(*res_msg);
412
413 return AT_END;
414}
415
416static int tsc_probe1_set_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
417{
418 char strCmd[AT_CMD_MAX] = {0};
419 char *at_str = NULL;
420 unsigned char ctx[12]={1,0};
421 int fd, ret, i;
422
423 void *p[THRESH_NUM] = {
424 &ctx[1], &ctx[2], &ctx[3], &ctx[4], &ctx[5],
425 &ctx[6], &ctx[7], &ctx[8], &ctx[9], &ctx[10],
426 &ctx[11],
427 };
428
429 if(at_paras==NULL)
430 {
431 *res_msg = at_err_build(ATERR_PARAM_INVALID);
432 *res_msglen = strlen(*res_msg);
433 return AT_END;
434 }
435
436 at_str = at_paras;
437
438 parse_param("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", at_str, p);
439 at_print(AT_NORMAL,"probe is %d\n", ctx[0]);
440 for(i=1; i<12; i++)
441 {
442 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
443 }
444
445 fd =open(ZX_TSC_DEV, O_RDWR);
446 if(fd<0){
447 at_print(AT_NORMAL,"ap tsc open FAIL\n");
448 return -1;
449 }
450 ret=ioctl(fd, ZX_TSC_SET_THRESHOLD, (unsigned long)&ctx);
451 if(ret<0){
452 at_print(AT_NORMAL,"tsc set ioctl FAIL\n");
453 close(fd);
454 return AT_END;
455 }
456 #if 0
457 ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx);
458 if(ret<0){
459 at_print(AT_NORMAL,"tsc get ioctl FAIL\n");
460 close(fd);
461 return AT_END;
462 }
463 for(i=1; i<12; i++)
464 {
465 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
466 }
467 #endif
468 close(fd);
469
470 *res_msg = at_query_result_build("tsc_test",strCmd);
471 *res_msglen = strlen(*res_msg);
472
473 return AT_END;
474}
475
476
477
478static int tsc_probe1_get_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
479{
480 char strCmd[AT_CMD_MAX] = {0};
481
482 unsigned char ctx[12]={1,0};
483 int fd, ret, i;
484
485 fd =open(ZX_TSC_DEV, O_RDWR);
486 if(fd<0){
487 at_print(AT_NORMAL,"ap tsc open FAIL\n");
488 return -1;
489 }
490
491 ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx);
492 if(ret<0){
493 at_print(AT_NORMAL,"tsc add ioctl FAIL\n");
494 close(fd);
495 return AT_END;
496 }
497
498 at_print(AT_NORMAL,"probe is %d\n", ctx[0]);
499 for(i=1; i<12; i++)
500 {
501 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
502 }
503
504 close(fd);
505
506 *res_msg = at_query_result_build("tsc_test",strCmd);
507 *res_msglen = strlen(*res_msg);
508
509 return AT_END;
510}
511
512static int tsc_probe2_set_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
513{
514 char strCmd[AT_CMD_MAX] = {0};
515 char *at_str = NULL;
516 unsigned char ctx[12]={2,0};
517 int fd, ret, i;
518
519 void *p[THRESH_NUM] = {
520 &ctx[1], &ctx[2], &ctx[3], &ctx[4], &ctx[5],
521 &ctx[6], &ctx[7], &ctx[8], &ctx[9], &ctx[10],
522 &ctx[11],
523 };
524
525 if(at_paras==NULL)
526 {
527 *res_msg = at_err_build(ATERR_PARAM_INVALID);
528 *res_msglen = strlen(*res_msg);
529 return AT_END;
530 }
531
532 at_str = at_paras;
533
534 parse_param("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", at_str, p);
535 at_print(AT_NORMAL,"probe is %d\n", ctx[0]);
536 for(i=1; i<12; i++)
537 {
538 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
539 }
540
541 fd =open(ZX_TSC_DEV, O_RDWR);
542 if(fd<0){
543 at_print(AT_NORMAL,"ap tsc open FAIL\n");
544 return -1;
545 }
546 ret=ioctl(fd, ZX_TSC_SET_THRESHOLD, (unsigned long)&ctx);
547 if(ret<0){
548 at_print(AT_NORMAL,"tsc set ioctl FAIL\n");
549 close(fd);
550 return AT_END;
551 }
552 #if 0
553 ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx);
554 if(ret<0){
555 at_print(AT_NORMAL,"tsc get ioctl FAIL\n");
556 close(fd);
557 return AT_END;
558 }
559 for(i=1; i<12; i++)
560 {
561 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
562 }
563 #endif
564 close(fd);
565
566 *res_msg = at_query_result_build("tsc_test",strCmd);
567 *res_msglen = strlen(*res_msg);
568
569 return AT_END;
570}
571
572
573
574static int tsc_probe2_get_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
575{
576 char strCmd[AT_CMD_MAX] = {0};
577
578 unsigned char ctx[12]={2,0};
579 int fd, ret, i;
580
581 fd =open(ZX_TSC_DEV, O_RDWR);
582 if(fd<0){
583 at_print(AT_NORMAL,"ap tsc open FAIL\n");
584 return -1;
585 }
586
587 ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx);
588 if(ret<0){
589 at_print(AT_NORMAL,"tsc add ioctl FAIL\n");
590 close(fd);
591 return AT_END;
592 }
593
594 at_print(AT_NORMAL,"probe is %d\n", ctx[0]);
595 for(i=1; i<12; i++)
596 {
597 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
598 }
599
600 close(fd);
601
602 *res_msg = at_query_result_build("tsc_test",strCmd);
603 *res_msglen = strlen(*res_msg);
604
605 return AT_END;
606}
607
608
609static int tsc_probe3_set_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
610{
611 char strCmd[AT_CMD_MAX] = {0};
612 char *at_str = NULL;
613 unsigned char ctx[12]={3,0};
614 int fd, ret, i;
615
616 void *p[THRESH_NUM] = {
617 &ctx[1], &ctx[2], &ctx[3], &ctx[4], &ctx[5],
618 &ctx[6], &ctx[7], &ctx[8], &ctx[9], &ctx[10],
619 &ctx[11],
620 };
621
622 if(at_paras==NULL)
623 {
624 *res_msg = at_err_build(ATERR_PARAM_INVALID);
625 *res_msglen = strlen(*res_msg);
626 return AT_END;
627 }
628
629 at_str = at_paras;
630
631 parse_param("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", at_str, p);
632 at_print(AT_NORMAL,"probe is %d\n", ctx[0]);
633 for(i=1; i<12; i++)
634 {
635 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
636 }
637
638 fd =open(ZX_TSC_DEV, O_RDWR);
639 if(fd<0){
640 at_print(AT_NORMAL,"ap tsc open FAIL\n");
641 return -1;
642 }
643 ret=ioctl(fd, ZX_TSC_SET_THRESHOLD, (unsigned long)&ctx);
644 if(ret<0){
645 at_print(AT_NORMAL,"tsc set ioctl FAIL\n");
646 close(fd);
647 return AT_END;
648 }
649 #if 0
650 ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx);
651 if(ret<0){
652 at_print(AT_NORMAL,"tsc get ioctl FAIL\n");
653 close(fd);
654 return AT_END;
655 }
656 for(i=1; i<12; i++)
657 {
658 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
659 }
660 #endif
661 close(fd);
662
663 *res_msg = at_query_result_build("tsc_test",strCmd);
664 *res_msglen = strlen(*res_msg);
665
666 return AT_END;
667}
668
669
670
671static int tsc_probe3_get_thresh(int at_fd,char * at_paras,void * *res_msg,int * res_msglen)
672{
673 char strCmd[AT_CMD_MAX] = {0};
674
675 unsigned char ctx[12]={3,0};
676 int fd, ret, i;
677
678 fd =open(ZX_TSC_DEV, O_RDWR);
679 if(fd<0){
680 at_print(AT_NORMAL,"ap tsc open FAIL\n");
681 return -1;
682 }
683
684 ret=ioctl(fd, ZX_TSC_GET_THRESHOLD, (unsigned long)&ctx);
685 if(ret<0){
686 at_print(AT_NORMAL,"tsc add ioctl FAIL\n");
687 close(fd);
688 return AT_END;
689 }
690
691 at_print(AT_NORMAL,"probe is %d\n", ctx[0]);
692 for(i=1; i<12; i++)
693 {
694 at_print(AT_NORMAL,"threshold[%d] is %d\n", i-1, ctx[i]);
695 }
696
697 close(fd);
698
699 *res_msg = at_query_result_build("tsc_test",strCmd);
700 *res_msglen = strlen(*res_msg);
701
702 return AT_END;
703}
704
705
706
707/**************************init********************
708
709*************************************************/
710void ext_bsp_regist_init(void)
711{
712
713 register_serv_func2("WDT=", 0, 0, 0, wdt_act_func, NULL);
714 register_serv_func2("WDT?", 0, 0, 0,wdt_get_nv_state,NULL);
715 register_serv_func2("WDTP=", 0, 0, 0, wdt_set_nv_priority, NULL);
716 register_serv_func2("WDTP?", 0, 0, 0,wdt_get_nv_priority,NULL);
717
718 register_serv_func2("apadd_lock", 0, 0, 0,pm_apadd_wakelock,NULL);
719 register_serv_func2("apdel_lock", 0, 0, 0,pm_apdelete_wakelock,NULL);
720 register_serv_func2("capadd_lock", 0, 0, 0,pm_capadd_wakelock,NULL);
721 register_serv_func2("capdel_lock", 0, 0, 0,pm_capdelete_wakelock,NULL);
722
723 register_serv_func2("probe0_set_thresh=", 0, 0, 0,tsc_probe0_set_thresh,NULL);
724 register_serv_func2("probe0_get_thresh", 0, 0, 0,tsc_probe0_get_thresh,NULL);
725 register_serv_func2("probe1_set_thresh=", 0, 0, 0,tsc_probe1_set_thresh,NULL);
726 register_serv_func2("probe1_get_thresh", 0, 0, 0,tsc_probe1_get_thresh,NULL);
727 register_serv_func2("probe2_set_thresh=", 0, 0, 0,tsc_probe2_set_thresh,NULL);
728 register_serv_func2("probe2_get_thresh", 0, 0, 0,tsc_probe2_get_thresh,NULL);
729 register_serv_func2("probe3_set_thresh=", 0, 0, 0,tsc_probe3_set_thresh,NULL);
730 register_serv_func2("probe3_get_thresh", 0, 0, 0,tsc_probe3_get_thresh,NULL);
731
732
733}
734