Remove unused directories and files in video_in_hal
[staging/basesystem.git] / vehicleservice / positioning_base_library / library / src / _pbTimer.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file
19  *    _pbTimer.cpp
20  */
21 /*---------------------------------------------------------------------------------*
22  * Include Files                                                                   *
23  *---------------------------------------------------------------------------------*/
24 #include <native_service/frameworkunified_framework_if.h>
25
26 #include <native_service/ns_message_center_if.h>
27
28 #include <vehicle_service/positioning_base_library.h>
29 #include "TimerEntryDrv_If.h"
30 #include "DEV_TimerEntryDrv_if.h"
31
32 #include <native_service/ns_timer_if.h>
33 #include "WPF_STD_private.h"
34
35
36 /*---------------------------------------------------------------------------------*
37  * Define                                                                          *
38  *---------------------------------------------------------------------------------*/
39 #define MAX_CTRL_TIMER_NUM (8)
40
41 #define CID_TIMER_1    (0x1000)
42 #define CID_TIMER_2    (0x1001)
43 #define CID_TIMER_3    (0x1002)
44 #define CID_TIMER_4    (0x1003)
45 #define CID_TIMER_5    (0x1004)
46 #define CID_TIMER_6    (0x1005)
47 #define CID_TIMER_7    (0x1006)
48 #define CID_TIMER_8    (0x1007)
49
50 #define TIMER_MAKE_DEFAULT_MESSAGE(x) \
51     (x)->Header.signo = 0; \
52     (x)->Header.hdr.sndpno = 0; \
53     (x)->Header.hdr.respno = 0; \
54     (x)->Header.hdr.cid = CID_TIMER_TOUT; \
55     (x)->Header.hdr.msgbodysize = \
56         static_cast<uint16_t>(sizeof(TimerToutMsg) - sizeof(T_APIMSG_MSGBUF_HEADER)); \
57     (x)->Header.hdr.rid = 0; \
58     (x)->Header.hdr.reserve = 0; \
59     (x)->TimerSeq = 0;
60
61 /*---------------------------------------------------------------------------------*
62  * Structure                                                                       *
63  *---------------------------------------------------------------------------------*/
64 /*!
65    @brief    Timer control information
66 */
67 typedef struct {
68     CID            cid;        /**< Command ID              */
69     HANDLE         h_timer;    /**< Timer handle            */
70     TimerToutMsg   msg_buf;    /**< Message buffer        */
71     uint16_t       size;        /**< Message size        */
72     PNO            pno;        /**< Process number            */
73     uint16_t       seq_no;        /**< Timer Sequence Number    */
74     uint8_t        type;         /**< Timer type            */
75     uint32_t       time_out;    /**< Timeout       */
76 } TIMER_CTRL_INFO;
77
78 /*---------------------------------------------------------------------------------*
79  * Local Function Prototype                                                        *
80  *---------------------------------------------------------------------------------*/
81 /* Timer control table manipulation functions */
82 static void        TimerSetCidOfCtrlTbl(u_int32 idx, CID cid);               /* Set timer CID    */
83 static CID        TimerGetCidOfCtrlTbl(u_int32 idx);                           /* Get timer CID    */
84 static void        TimerSetPnoOfCtrlTbl(u_int32 idx, PNO pno);               /* Set PNO              */
85 static PNO        TimerGetPnoOfCtrlTbl(u_int32 idx);                           /* Get PNO             */
86 static void        TimerSetSizeOfCtrlTbl(u_int32 idx, u_int16 size);           /* Set message size         */
87 static TimerToutMsg* TimerGetMsgBufOfCtrlTbl(u_int32 idx);                        /* Get message buffer     */
88 static void        TimerSetTimerHandleOfCtrlTbl(u_int32 idx, HANDLE handle);      /* Set timer handle         */
89 static HANDLE    TimerGetTimerHandleOfCtrlTbl(u_int32 idx);                        /* Get timer handle         */
90 static void        TimerSetTypeOfCtrlTbl(u_int32 idx, u_int8 type);                /* Set timer type             */
91 static u_int8    TimerGetTypeOfCtrlTbl(u_int32 idx);                            /* Get timer type             */
92 static void        TimerSetSeqNoOfCtrlTbl(u_int32 idx, u_int16 seq_no);            /* Set timer Sequence Number     */
93 static u_int16    TimerGetSeqNoOfCtrlTbl(u_int32 idx);                            /* Get timer sequence number     */
94 static void        TimerSetTimeOutOfCtrlTbl(u_int32 idx, u_int32 time_out);        /* Set timeout         */
95 static u_int32  TimerGetTimeOutOfCtrlTbl(u_int32 idx);                         /* Get timeout         */
96 static u_int32    TimerSearchEmptyOfCtrlTbl(void);                                /* Search unused area             */
97 static u_int32    TimerSearchTimerOfCtrlTbl(PNO snd_pno, u_int16 timer_seq, u_int8 time_type); /* Search specified timer */
98 static void        TimerClearSettingOfCtrlTbl(u_int32 idx);                        /* Clear timer information             */
99
100 /* Mutex handling Functions for accessing Timer Control Table */
101 static void TimerCreateMutex(void);    /* Create Mutex */
102 static void TimerDeleteMutex(void);    /* Delete Mutex */
103 static void TimerLockMutex(void);        /* Get Mutex */
104 static void TimerUnlockMutex(void);    /* Release Mutex */
105
106 /* Callback function resources */
107 static EFrameworkunifiedStatus TimerCallback1(HANDLE h_app);
108 static EFrameworkunifiedStatus TimerCallback2(HANDLE h_app);
109 static EFrameworkunifiedStatus TimerCallback3(HANDLE h_app);
110 static EFrameworkunifiedStatus TimerCallback4(HANDLE h_app);
111 static EFrameworkunifiedStatus TimerCallback5(HANDLE h_app);
112 static EFrameworkunifiedStatus TimerCallback6(HANDLE h_app);
113 static EFrameworkunifiedStatus TimerCallback7(HANDLE h_app);
114 static EFrameworkunifiedStatus TimerCallback8(HANDLE h_app);
115
116 static void TimerCallbackComProc(const uint8_t id);
117
118 /*---------------------------------------------------------------------------------*
119  * Grobal Values                                                                   *
120  *---------------------------------------------------------------------------------*/
121 /**
122    Timer control table
123    Note : Access to this instance shall be made through the operation module.
124 */
125 static TIMER_CTRL_INFO g_timer_ctrl_tbl[MAX_CTRL_TIMER_NUM];    // NOLINT(readability/nolint) global class instance
126
127 /** Timer control table lock Mutex handle */
128 static HANDLE        g_h_mtx = NULL;
129
130 /** Timer event destination handle */
131 static HANDLE        g_h_service;
132
133
134 /** Dispatcher Registration Callback Table */
135 static const FrameworkunifiedProtocolCallbackHandler kTimerPcbhs[] = {
136     {CID_TIMER_1,    &TimerCallback1    },
137     {CID_TIMER_2,    &TimerCallback2    },
138     {CID_TIMER_3,    &TimerCallback3    },
139     {CID_TIMER_4,    &TimerCallback4    },
140     {CID_TIMER_5,    &TimerCallback5    },
141     {CID_TIMER_6,    &TimerCallback6    },
142     {CID_TIMER_7,    &TimerCallback7    },
143     {CID_TIMER_8,    &TimerCallback8    },
144 };  // LCOV_EXCL_BR_LINE 11:unexpected branch
145
146 /*---------------------------------------------------------------------------------*
147  * Function                                                                        *
148  *---------------------------------------------------------------------------------*/
149 /**
150  * @brief
151  *   Timer function initialization
152  *
153  * @return    RET_NORMAL    Normal completion
154  * @return    RET_ERROR    ABEND
155  */
156 RET_API TimerInit(HANDLE h_app) {
157     RET_API ret_api = RET_NORMAL;
158     u_int32    idx;
159     HANDLE        h_timer;
160     EFrameworkunifiedStatus    estatus;
161     NSTimerInfo    timer_info;
162     HANDLE* p_h_service = &g_h_service;
163
164     if (h_app == NULL) {  // LCOV_EXCL_BR_LINE 6: h_app cannot be Null
165         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR!! [h_app=%p]", h_app);
166         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
167         ret_api = RET_ERROR;  // LCOV_EXCL_LINE 6: h_app cannot be Null
168     } else {
169         memset(&timer_info, 0x00, sizeof(timer_info));
170
171         /* Create Mutex */
172         TimerCreateMutex();  // LCOV_EXCL_BR_LINE 200: no branch
173
174         /* Register callback function for timer control */
175         // LCOV_EXCL_BR_LINE 4: nsfw error
176         estatus = FrameworkunifiedAttachCallbacksToDispatcher(h_app, "NS_ANY_SRC", kTimerPcbhs, _countof(kTimerPcbhs));  // LCOV_EXCL_BR_LINE 4: nsfw error  // NOLINT(whitespace/line_length)
177         if (estatus != eFrameworkunifiedStatusOK) {  // LCOV_EXCL_BR_LINE 4: nsfw error
178             /* When registration fails */
179             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, \
180                 "FrameworkunifiedAttachCallbacksToDispatcher ERROR [status:%d]", estatus);
181             AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
182             ret_api = RET_ERROR;  // LCOV_EXCL_LINE 4: nsfw error
183         }
184
185         /* Initialization of timer control table */
186         for (idx = 0; idx < MAX_CTRL_TIMER_NUM; idx++) {
187             TimerSetCidOfCtrlTbl(idx, static_cast<CID>(kTimerPcbhs[idx].iCmd)); /* Set timer control CID */  // LCOV_EXCL_BR_LINE 200: no branch  // NOLINT(whitespace/line_length)
188
189             /* Initialize timeout */
190             TimerSetTimeOutOfCtrlTbl(idx, 0);  // LCOV_EXCL_BR_LINE 200: no branch
191
192             *p_h_service = McOpenSender("Positioning"); /* Be intended for use only in Positioning */  // LCOV_EXCL_BR_LINE 4: nsfw error  // NOLINT(whitespace/line_length)
193
194             /* Create Timer Resource */
195             timer_info.iCmd = TimerGetCidOfCtrlTbl(idx); /* Only CID needs to be set. */  // LCOV_EXCL_BR_LINE 200: no branch
196             h_timer = NS_TimerCreate(timer_info, CALLBACK_MESSAGE, (HANDLE)*p_h_service);  // LCOV_EXCL_BR_LINE 4: nsfw error  // NOLINT(whitespace/line_length)
197             if (h_timer == NULL) {  // LCOV_EXCL_BR_LINE 4: nsfw error
198                 // LCOV_EXCL_START 4: nsfw error
199                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
200                 /* When an error occurs */
201                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, \
202                     "NS_TimerCreate ERROR [h_timer:%p, hService:%p]", h_timer, *p_h_service);
203                 ret_api = RET_ERROR;
204                 // LCOV_EXCL_STOP
205             } else {
206                 /* If successful */
207                 /* Set Handle information */
208                 TimerSetTimerHandleOfCtrlTbl(idx, h_timer);  // LCOV_EXCL_BR_LINE 200: no branch
209             }
210         }
211     }
212
213     return ret_api;
214 }
215
216 /**
217  * @brief
218  *   Terminate timer function
219  *
220  * @return    Normal completion
221  */
222 RET_API TimerTerm(void) {  // LCOV_EXCL_START 8:dead code
223     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
224     RET_API ret_api = RET_NORMAL;
225     u_int32    idx;
226     HANDLE h_timer;
227     EFrameworkunifiedStatus estatus;
228     HANDLE* p_h_service = &g_h_service;
229
230     /* If a control Mutex has not been created, it is determined that the Timer function has not been initialized (non Positioning processes) and the process terminates with an error. */
231     if (g_h_mtx == NULL) {
232         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "g_h_mtx is NULL!!");
233         ret_api = RET_ERROR;
234     } else {
235         /* Delete timer control information */
236         for (idx = 0; idx < MAX_CTRL_TIMER_NUM; idx++) {
237             h_timer = TimerGetTimerHandleOfCtrlTbl(idx);
238             if (h_timer != NULL) {
239                 /* Delete timer */
240                 estatus = NS_TimerDelete(h_timer);
241                 if (estatus != eFrameworkunifiedStatusOK) {
242                     /* When an error occurs */
243                     FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, \
244                         "NS_TimerDelete ERROR [estatus:%d, h_timer:%p]", estatus, h_timer);
245                 }
246                 TimerSetTimerHandleOfCtrlTbl(idx, NULL);
247             }
248
249             TimerClearSettingOfCtrlTbl(idx);
250         }
251
252         /* Mutex deletion */
253         TimerDeleteMutex();
254     }
255
256     /* Delete transmission handle */
257     estatus = McClose(*p_h_service);
258     if (estatus != eFrameworkunifiedStatusOK) {
259         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "McClose ERROR [estatus:%d, hService:%p]", \
260             estatus, *p_h_service);
261     }
262
263     return ret_api;
264 }
265 // LCOV_EXCL_STOP
266
267 /**
268  * @brief
269  *   Fixed period/asynchronous timer start instruction
270  *
271  * @param[in]  snd_pno        Requesting process number
272  * @param[in]  timer_seq        Timer sequence number
273  * @param[in]  TimerType    Timer type
274  * @param[in]  time_out         Timeout value [10ms]
275  *
276  * @return    RET_NORMAL        Normal completion<br>
277  *            RET_ERROR        Message transmission error<br>
278  *            RET_ERRPARAM    Parameter error
279  */
280 RET_API _pb_ReqTimerStart(PNO snd_pno, u_int16 timer_seq,      // NOLINT(readability/nolint) WPF_SYSAPI.h API
281         u_int8 time_type, u_int32 time_out) {
282     RET_API        ret_api = RET_NORMAL; /* Return value of this module */
283     u_int32        idx;
284     TimerToutMsg *p_msg;
285     EFrameworkunifiedStatus  estatus;
286     HANDLE        h_timer;
287     NSTimerInfo    timer_info;
288
289     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "+");
290
291     /* If a control Mutex has not been created, it is determined that the Timer function has not been initialized (non Positioning processes) and the process terminates with an error. */
292     if (g_h_mtx == NULL) {  // LCOV_EXCL_BR_LINE 6: g_h_mtx cannot be null
293         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "g_h_mtx is NULL!!");
294         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
295         ret_api = RET_ERROR;  // LCOV_EXCL_LINE 6: g_h_mtx cannot be null
296     } else {
297         /* Parameter study */
298         if ((time_type != TIMER_TYPE_SYN) && (time_type != TIMER_TYPE_USN)) {
299             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [time_type:%d]", time_type);
300             ret_api = RET_ERRPARAM;    /* Timer type error */
301         }
302
303         if (time_out == 0) {
304             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [time_out:%d]", time_out);
305             ret_api =  RET_ERRPARAM; /* Timer setting value error */
306         }
307
308         /* When a timer of the same process number, sequence number, or type is already registered, creation of the timer is not allowed. */
309         idx = TimerSearchTimerOfCtrlTbl(snd_pno, timer_seq, time_type);
310         if (idx != MAX_CTRL_TIMER_NUM) {
311             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "TimerSearchTimerOfCtrlTbl ERROR!! " \
312                 "[snd_pno:%d, timer_seq:%d, TimeType:%d]", snd_pno, timer_seq, time_type);
313             ret_api =  RET_ERRPARAM; /* Invalid timer value */
314         }
315
316         /* Parameter normal */
317         if (ret_api == RET_NORMAL) {
318             TimerLockMutex(); /* Get Mutex */
319
320             /* Get free space in timer control table */
321             idx = TimerSearchEmptyOfCtrlTbl();  // LCOV_EXCL_BR_LINE 200: no branch
322             if (idx == MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 200: idx can not be MAX_CTRL_TIMER_NUM
323                 // LCOV_EXCL_START 200: idx can not be MAX_CTRL_TIMER_NUM
324                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
325                 /* When there is no free space */
326                 /* Be impossible by design */
327                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "TimerSearchEmptyCtrlTbl ERROR!! " \
328                     "[idx = %d]", idx);
329                 _pb_Exit();
330                 /* don't arrive here. */
331                 // LCOV_EXCL_STOP
332             }
333
334             /* Get message buffer address */
335             p_msg = TimerGetMsgBufOfCtrlTbl(idx);
336
337             TIMER_MAKE_DEFAULT_MESSAGE(p_msg); /* Set message data to be send */
338             p_msg->TimerSeq = timer_seq; /* Timer sequence number */
339
340             /* Set callback function information in timer control table */
341             TimerSetPnoOfCtrlTbl(idx, snd_pno);  // LCOV_EXCL_BR_LINE 200: no branch
342             TimerSetSizeOfCtrlTbl(idx, sizeof(TimerToutMsg));  // LCOV_EXCL_BR_LINE 200: no branch
343             TimerSetTypeOfCtrlTbl(idx, time_type);  // LCOV_EXCL_BR_LINE 200: no branch
344             TimerSetSeqNoOfCtrlTbl(idx, timer_seq);  // LCOV_EXCL_BR_LINE 200: no branch
345             TimerSetTimeOutOfCtrlTbl(idx, time_out);  // LCOV_EXCL_BR_LINE 200: no branch
346
347             /* Set timer value */
348             timer_info.t_sec = (uint32_t)((10 * time_out) / 1000);
349             /* Coverity CID: 21979 compliant */
350             timer_info.t_nsec = ((10 * (uint64_t)time_out) - ((uint64_t)(timer_info.t_sec) * 1000)) * 1000 * 1000;
351             timer_info.iCmd = TimerGetCidOfCtrlTbl(idx);
352             timer_info.rpt_sec = 0;
353             timer_info.rpt_nsec = 0;
354             if (time_type == TIMER_TYPE_SYN) {
355                 timer_info.rpt_sec  = timer_info.t_sec;
356                 timer_info.rpt_nsec = timer_info.t_nsec;
357             }
358
359             h_timer = TimerGetTimerHandleOfCtrlTbl(idx);
360
361             /* Start timer */
362             estatus = NS_TimerSetTime(h_timer, timer_info);  // LCOV_EXCL_BR_LINE 4: nsfw error
363             if ((h_timer == NULL) || (estatus != eFrameworkunifiedStatusOK)) {  // LCOV_EXCL_BR_LINE 4: nsfw error
364                 // LCOV_EXCL_START 4: nsfw error
365                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
366                 /* When an error occurs */
367                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "NS_TimerSetTime ERROR " \
368                     "[estatus:%d, h_timer:%p]", estatus, h_timer);
369
370                 TimerClearSettingOfCtrlTbl(idx); /* Clear timer information */
371                 ret_api = RET_ERROR;
372                 // LCOV_EXCL_STOP
373             } else {
374                 /* If successful */
375                 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "### TIMER TABLE INFORMATION # " \
376                     "(++) idx:%d cid:%d h_timer:%p pno:%d seq_no:%d type:%d time_out:%d", \
377                     idx, g_timer_ctrl_tbl[idx].cid, g_timer_ctrl_tbl[idx].h_timer, g_timer_ctrl_tbl[idx].pno, \
378                     g_timer_ctrl_tbl[idx].seq_no, g_timer_ctrl_tbl[idx].type, g_timer_ctrl_tbl[idx].time_out);
379             }
380
381             TimerUnlockMutex(); /* Release Mutex */  // LCOV_EXCL_BR_LINE 200: no branch
382         }
383     }
384
385     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "-");
386
387     return ret_api;
388 }
389
390 /**
391  * @brief
392  *   Timer stop instruction
393  *
394  * @param[in]    snd_pno    Requesting process number
395  * @param[in]    timer_seq    Timer sequence number
396  * @param[in]    time_r_type    Timer type<br>
397  *                TIMER_TYPE_SYN Fixed-period timer<br>
398  *                TIMER_TYPE_USN Asynchronous timer<br>
399  *                TIMER_TYPE_ALM Alerm with specified time <br>
400  *
401  * @return    RET_NORMAL        Normal completion<br>
402  *            RET_ERROR        Message transmission error<br>
403  *            RET_ERRPARAM    Parameter error
404  */
405 RET_API _pb_TimerStop(PNO snd_pno, u_int16 timer_seq,     // NOLINT(readability/nolint) WPF_SYSAPI.h API
406             u_int8 time_type) {
407     RET_API    ret_api = RET_NORMAL; /* Return value of this module */
408     u_int32    idx;
409     EFrameworkunifiedStatus estatus;
410     HANDLE     h_timer;
411     const NSTimerInfo timer_info = {0};
412
413     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "+");
414
415     /* If a control Mutex has not been created, it is determined that the Timer function has not been initialized (non Positioning processes) and the process terminates with an error. */
416     if (g_h_mtx == NULL) {  // LCOV_EXCL_BR_LINE 6: g_h_mtx cannot be NULL
417         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "g_h_mtx is NULL!!");
418         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
419         ret_api = RET_ERROR;  // LCOV_EXCL_LINE 6: g_h_mtx cannot be NULL
420     } else {
421         TimerLockMutex(); /* Get Mutex */  // LCOV_EXCL_BR_LINE 200: no branch
422
423         idx = TimerSearchTimerOfCtrlTbl(snd_pno, timer_seq, time_type);
424         if (idx == MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 200: idx can not be MAX_CTRL_TIMER_NUM
425             /* When the specified timer is not set */
426             /* nop */
427         } else {
428             h_timer = TimerGetTimerHandleOfCtrlTbl(idx);
429
430             /* Stop timer */
431             estatus = NS_TimerSetTime(h_timer, timer_info);  // LCOV_EXCL_BR_LINE 4: nsfw error
432             if (estatus != eFrameworkunifiedStatusOK) {  // LCOV_EXCL_BR_LINE 4: nsfw error
433                 // LCOV_EXCL_START 4: nsfw error
434                 AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
435                 /* When deletion fails */
436                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "NS_TimerSetTime ERROR " \
437                     "[estatus:%d, h_timer:%p]", estatus, h_timer);
438                 ret_api = RET_ERROR;
439                 // LCOV_EXCL_STOP
440             } else {
441                 /* If successful */
442                 /* Clear timer information */
443                 TimerClearSettingOfCtrlTbl(idx);  // LCOV_EXCL_BR_LINE 200: no branch
444
445                 FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "### TIMER TABLE INFORMATION # " \
446                     "(--) idx:%d cid:%d h_timer:%p pno:%d seq_no:%d type:%d time_out:%d", \
447                     idx, g_timer_ctrl_tbl[idx].cid, g_timer_ctrl_tbl[idx].h_timer, g_timer_ctrl_tbl[idx].pno, \
448                     g_timer_ctrl_tbl[idx].seq_no, g_timer_ctrl_tbl[idx].type, g_timer_ctrl_tbl[idx].time_out);
449             }
450         }
451
452         TimerUnlockMutex(); /* Release Mutex */  // LCOV_EXCL_BR_LINE 200: no branch
453     }
454
455     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "-");
456
457     return ret_api;
458 }
459
460 /*---------------------------------------------------------------------------------*
461  * Local Function                                                                  *
462  *---------------------------------------------------------------------------------*/
463 /**
464  * @brief
465  *   Timer CID setting (Timer control table)
466  *
467  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
468  *
469  * @param[in]  idx    Control table accessor
470  * @param[in]  cid    Command ID
471  */
472 static void TimerSetCidOfCtrlTbl(u_int32 idx, CID cid) {
473     /* check index */
474     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
475         /* forbidden */
476         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR [idx:%d]", idx);
477         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
478         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
479         /* don't arrive here. */
480     } else {
481         g_timer_ctrl_tbl[idx].cid = cid;
482     }
483
484     return;
485 }
486
487 /**
488  * @brief
489  *   Timer CID acquisition (Timer control table)
490  *
491  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
492  *
493  * @param[in]    idx    Timer control table accessor
494  *
495  * @return Command ID
496  */
497 static CID TimerGetCidOfCtrlTbl(u_int32 idx) {
498     /* check index */
499     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
500         /* forbidden */
501         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR [idx:%d]", idx);
502         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
503         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
504         /* don't arrive here. */
505     }
506
507     return g_timer_ctrl_tbl[idx].cid;
508 }
509
510 /**
511  * @brief
512  *   PNO setting (Timer control table)
513  *
514  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
515  *
516  * @param[in]  idx    Timer control table accessor
517  * @param[in]  pno    Process number
518  */
519 static void TimerSetPnoOfCtrlTbl(u_int32 idx, PNO pno) {
520     /* check index */
521     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
522         /* forbidden */
523         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR " \
524             "[idx:%d, pno:%d]", idx, pno);
525         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
526         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
527         /* don't arrive here. */
528     } else {
529         g_timer_ctrl_tbl[idx].pno = pno;
530     }
531
532     return;
533 }
534
535 /**
536  * @brief
537  *   PNO acquisition (Timer control table)
538  *
539  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
540  *
541  * @param[in]  idx    Timer control table accessor
542  *
543  * @return Process number
544  */
545 static PNO TimerGetPnoOfCtrlTbl(u_int32 idx) {
546     /* check index */
547     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
548         /* forbidden */
549         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR [idx:%d]", idx);
550         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
551         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
552         /* don't arrive here. */
553     }
554
555     return g_timer_ctrl_tbl[idx].pno;
556 }
557
558 /**
559  * @brief
560  *   Message size setting (Timer control table)
561  *
562  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
563  *
564  * @param[in]  idx        Timer control table accessor
565  * @param[in]  size    Message size
566  */
567 static void TimerSetSizeOfCtrlTbl(u_int32 idx, u_int16 size) {
568     /* check index */
569     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
570         /* forbidden */
571         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR " \
572             "[idx:%d, size:%d]", idx, size);
573         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
574         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
575         /* don't arrive here. */
576     } else {
577         g_timer_ctrl_tbl[idx].size = size;
578     }
579
580     return;
581 }
582
583 /**
584  * @brief
585  *   Message buffer acquisition (Timer control table)
586  *
587  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
588  *
589  * @param[in]  idx    Timer control table accessor
590  *
591  * @return Pointer to message storage area
592  */
593 static TimerToutMsg* TimerGetMsgBufOfCtrlTbl(u_int32 idx) {
594     /* check index */
595     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
596         /* forbidden */
597         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR [idx:%d]", idx);
598         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
599         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
600         /* don't arrive here. */
601     }
602
603     return &(g_timer_ctrl_tbl[idx].msg_buf);
604 }
605
606 /**
607  * @brief
608  *   Timer handle setting (Timer control table)
609  *
610  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
611  *
612  * @param[in]  idx        Timer control table accessor
613  * @param[in]   handle    Timer handle
614  */
615 static void TimerSetTimerHandleOfCtrlTbl(u_int32 idx, HANDLE handle) {
616     /* check index */
617     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
618         /* forbidden */
619         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR " \
620             "[idx:%d, handle:%p]", idx, handle);
621         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
622         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
623         /* don't arrive here. */
624     } else {
625         g_timer_ctrl_tbl[idx].h_timer = handle;
626     }
627
628     return;
629 }
630
631 /**
632  * @brief
633  *   Timer handle acquisition (Timer control table)
634  *
635  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
636  *
637  * @param[in]  idx    Timer control table accessor
638  *
639  * @return    Timer handle
640  */
641 static HANDLE TimerGetTimerHandleOfCtrlTbl(u_int32 idx) {
642     /* check index */
643     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
644         /* forbidden */
645         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR [idx:%d]", idx);
646         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
647         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
648         /* don't arrive here. */
649     }
650
651     return g_timer_ctrl_tbl[idx].h_timer;
652 }
653
654 /**
655  * @brief
656  *   Timer type setting (Timer control table)
657  *
658  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
659  *
660  * @param[in]  idx        Timer control table accessor
661  * @param[in]  type    Timer type
662  */
663 static void TimerSetTypeOfCtrlTbl(u_int32 idx, u_int8 type) {
664     /* check index */
665     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
666         /* forbidden */
667         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR " \
668             "[idx:%d, type:%d]", idx, type);
669         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
670         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
671         /* don't arrive here. */
672     } else {
673         g_timer_ctrl_tbl[idx].type = type;
674     }
675
676     return;
677 }
678
679 /**
680  * @brief
681  *   Timer type acquisition (Timer control table)
682  *
683  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
684  *
685  * @param[in]  idx    Timer control table accessor
686  *
687  * @return Timer handle
688  */
689 static u_int8 TimerGetTypeOfCtrlTbl(u_int32 idx) {
690     /* check index */
691     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
692         /* forbidden */
693         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR [idx:%d]", idx);
694         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
695         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
696         /* don't arrive here. */
697     }
698
699     return g_timer_ctrl_tbl[idx].type;
700 }
701
702 /**
703  * @brief
704  *   Timer sequence number setting (Timer control table)
705  *
706  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
707  *
708  * @param[in]  idx        Timer control table accessor
709  * @param[in]  seq_no    Timer Sequence Number
710  */
711 static void TimerSetSeqNoOfCtrlTbl(u_int32 idx, u_int16 seq_no) {
712     /* check index */
713     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
714         /* forbidden */
715         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR " \
716             "[idx:%d, seq_no:%d]", idx, seq_no);
717         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
718         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
719         /* don't arrive here. */
720     } else {
721         g_timer_ctrl_tbl[idx].seq_no = seq_no;
722     }
723
724     return;
725 }
726
727 /**
728  * @brief
729  *   Timer sequence number acquisition (Timer control table)
730  *
731  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
732  *
733  * @param[in]  idx        Timer control table accessor
734  */
735 static u_int16 TimerGetSeqNoOfCtrlTbl(u_int32 idx) {
736     /* check index */
737     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
738         /* forbidden */
739         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR [idx:%d]", idx);
740         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
741         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
742         /* don't arrive here. */
743     }
744
745     return g_timer_ctrl_tbl[idx].seq_no;
746 }
747
748 /**
749  * @brief
750  *   Timeout setting (Timer control table)
751  *
752  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
753  *
754  * @param[in]  idx            Timer control table access Index
755  * @param[in]  time_out    Timeout
756  */
757 static void TimerSetTimeOutOfCtrlTbl(u_int32 idx, u_int32 time_out) {
758     /* check index */
759     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
760         /* forbidden */
761         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR [idx:%d, " \
762             "time_out:%d]", idx, time_out);
763         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
764         _pb_Exit();  // LCOV_EXCL_LINE 6: idx cannot greater
765         /* don't arrive here. */
766     } else {
767         g_timer_ctrl_tbl[idx].time_out = time_out;
768     }
769
770     return;
771 }
772
773 /**
774  * @brief
775  *   Timeout acquisition (Timer control table)
776  *
777  *   If an invalid value is specified for an argument, the system assumes that it is a design problem and calls _pb_Exit().
778  *
779  * @param[in]  idx            Timer control table access Index
780  *
781  * @return Timeout value
782  */
783 static u_int32 TimerGetTimeOutOfCtrlTbl(u_int32 idx) {
784     /* check index */
785     if (idx >= MAX_CTRL_TIMER_NUM) {  // LCOV_EXCL_BR_LINE 6: idx cannot greater
786         /* forbidden */
787         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argment ERROR [idx:%d]", idx);
788         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
789         _pb_Exit();  // LCOV_EXCL_LINE 6:idx cannot greater
790         /* don't arrive here. */
791     }
792
793     return g_timer_ctrl_tbl[idx].time_out;
794 }
795
796 /**
797  * @brief
798  *   Retreaval of unused area in the timer control table (Timer control table)
799  *
800  *   Return the lowest-numbered index for accessing unused space in the Timer control table.
801  *   If the mutex is not registered, the maximum timer management value (MAX_CTRL_MUTEX_NUM)
802  *   is returned.
803  *
804  * @return Table accessor
805  */
806 static u_int32 TimerSearchEmptyOfCtrlTbl(void) {
807     u_int32    idx;
808     u_int32 time_out;
809
810     for (idx = 0; idx < MAX_CTRL_TIMER_NUM; idx++) {
811         time_out = TimerGetTimeOutOfCtrlTbl(idx);
812
813         /* For unused space */
814         if (time_out == 0) {
815             break;
816         }
817     }
818
819     return idx;
820 }
821
822 /**
823  * @brief
824  *   Retrieval of specified timer for in the timer control table (Timer control table)
825  *
826  *   Retrieve whether the specified timer is already registered in the timer control table.
827  *   If it is registered, the access index is returned. If it is not registered,
828  *   Return the maximum value of timer management (MAX_CTRL_TIMER_NUM).
829  *
830  * @param[in]  snd_pno        Process number
831  * @param[in]  TimerSeq    Timer sequence number
832  * @param[in]  TimeType    Timer type
833  *
834  * @return Index for access(If it is registered)<br>
835  *              Maximum mutex management value (Not registered)
836  */
837 static u_int32 TimerSearchTimerOfCtrlTbl(PNO snd_pno, u_int16 TimerSeq, u_int8 TimeType) {
838     u_int32    idx;
839     PNO        pno;
840     u_int16    seq_no;
841     u_int8        type;
842
843     for (idx = 0; idx < MAX_CTRL_TIMER_NUM; idx++) {
844         pno   = TimerGetPnoOfCtrlTbl(idx);
845         seq_no = TimerGetSeqNoOfCtrlTbl(idx);
846         type  = TimerGetTypeOfCtrlTbl(idx);
847
848         /* If there is a match */
849         if ((pno == snd_pno) && (seq_no == TimerSeq) && (type == TimeType)) {
850             break;
851         }
852     }
853
854     return idx;
855 }
856
857 /**
858  * @brief
859  *   Clear timer setting information
860  *
861  * @param[in]  idx    Timer control table accessor
862  */
863 static void TimerClearSettingOfCtrlTbl(u_int32 idx) {
864     void *p_msg;
865
866     /* Delete timer information */
867     TimerSetPnoOfCtrlTbl(idx, 0);
868     TimerSetSizeOfCtrlTbl(idx, 0);
869     TimerSetTypeOfCtrlTbl(idx, 0);
870     TimerSetSeqNoOfCtrlTbl(idx, 0);
871     TimerSetTimeOutOfCtrlTbl(idx, 0);
872     p_msg = TimerGetMsgBufOfCtrlTbl(idx);
873     memset(p_msg, 0x00, sizeof(TimerToutMsg));
874
875     return;
876 }
877
878 /**
879  * @brief
880  *   Create Mutex for accessing the timer control table
881  */
882 static void TimerCreateMutex(void) {
883     g_h_mtx = _pb_CreateMutex(NULL, 0, "Timer_Mutex");
884     if (g_h_mtx == NULL) {
885         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "_pb_CreateMutex ERROR " \
886             "[g_h_mtx:%p]", g_h_mtx);
887         _pb_Exit();
888         /* don't arrive here. */
889     }
890
891     return;
892 }
893
894 /**
895  * @brief
896  *   Delete Mutex for accessing timer control table
897  */
898 static void TimerDeleteMutex(void) {  // LCOV_EXCL_START 8:dead code
899     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
900     DWORD    ret;
901
902     ret = PbDeleteMutex(g_h_mtx);
903     if (ret != WAIT_OBJECT_0) {
904         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PbDeleteMutex ERROR " \
905             "[ret:%lu, g_h_mtx:%p]", ret, g_h_mtx);
906         _pb_Exit();
907         /* don't arrive here. */
908     }
909
910     return;
911 }
912 // LCOV_EXCL_STOP
913
914 /**
915  * @brief
916  *   Get Mutex for accessing timer control table
917  */
918 static void TimerLockMutex(void) {
919     DWORD    ret;
920
921     ret = PbMutexLock(g_h_mtx, INFINITE);  // LCOV_EXCL_BR_LINE 200: lock will not failed
922     if (ret != WAIT_OBJECT_0) {  // LCOV_EXCL_BR_LINE 200: lock will not failed
923         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PbMutexLock ERROR " \
924             "[ret:%lu, g_h_mtx:%p]", ret, g_h_mtx);
925         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
926         _pb_Exit();  // LCOV_EXCL_LINE 200: lock will not failed
927         /* don't arrive here. */
928     }
929
930     return;
931 }
932
933 /**
934  * @brief
935  *   Release Mutex for accessing timer control table
936  */
937 static void TimerUnlockMutex(void) {
938     BOOL    ret;
939
940     ret = PbMutexUnlock(g_h_mtx);  // LCOV_EXCL_BR_LINE 200: unlock will not failed
941     if (ret != TRUE) {  // LCOV_EXCL_BR_LINE 200: unlock will not failed
942         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PbMutexUnlock ERROR " \
943             "[ret:%d, g_h_mtx:%p]", ret, g_h_mtx);
944         AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
945         _pb_Exit();  // LCOV_EXCL_LINE 200: unlock will not failed
946         /* don't arrive here. */
947     }
948
949     return;
950 }
951
952 /**
953  * @brief
954  *   Timer Expiration Callback Functions
955  *
956  *   For setting the timer creation function (NS_TimerCreate)<br>
957  *   TimerCallback1 ... TimerCallback8
958  *
959  * @param[in]  h_app Application handle
960  *
961  * @return eFrameworkunifiedStatusOK    Normal completion
962  */
963 static EFrameworkunifiedStatus TimerCallback1(HANDLE h_app) {
964     static const u_int8 ID = 0;
965
966     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "+");
967
968     TimerCallbackComProc(ID);
969
970     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "-");
971
972     return eFrameworkunifiedStatusOK;
973 }
974
975 static EFrameworkunifiedStatus TimerCallback2(HANDLE h_app) {
976     static const u_int8 ID = 1;
977
978     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "+");
979
980     TimerCallbackComProc(ID);
981
982     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "-");
983
984     return eFrameworkunifiedStatusOK;
985 }
986
987 static EFrameworkunifiedStatus TimerCallback3(HANDLE h_app) {
988     static const u_int8 ID = 2;
989
990     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "+");
991
992     TimerCallbackComProc(ID);
993
994     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "-");
995
996     return eFrameworkunifiedStatusOK;
997 }
998
999 static EFrameworkunifiedStatus TimerCallback4(HANDLE h_app) {
1000     static const u_int8 ID = 3;
1001
1002     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "+");
1003
1004     TimerCallbackComProc(ID);
1005
1006     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "-");
1007
1008     return eFrameworkunifiedStatusOK;
1009 }
1010
1011 static EFrameworkunifiedStatus TimerCallback5(HANDLE h_app) {
1012     static const u_int8 ID = 4;
1013
1014     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "+");
1015
1016     TimerCallbackComProc(ID);
1017
1018     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "-");
1019
1020     return eFrameworkunifiedStatusOK;
1021 }
1022
1023 static EFrameworkunifiedStatus TimerCallback6(HANDLE h_app) {
1024     static const u_int8 ID = 5;
1025
1026     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "+");
1027
1028     TimerCallbackComProc(ID);
1029
1030     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "-");
1031
1032     return eFrameworkunifiedStatusOK;
1033 }
1034
1035 static EFrameworkunifiedStatus TimerCallback7(HANDLE h_app) {
1036     static const u_int8 ID = 6;
1037
1038     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "+");
1039
1040     TimerCallbackComProc(ID);
1041
1042     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "-");
1043
1044     return eFrameworkunifiedStatusOK;
1045 }
1046
1047 static EFrameworkunifiedStatus TimerCallback8(HANDLE h_app) {
1048     static const u_int8 ID = 7;
1049
1050     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "+");
1051
1052     TimerCallbackComProc(ID);
1053
1054     FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "-");
1055
1056     return eFrameworkunifiedStatusOK;
1057 }
1058
1059 static void TimerCallbackComProc(const uint8_t id) {
1060     uint8_t type;
1061
1062     TimerLockMutex(); /* Get Mutex */
1063
1064     /* Message is sent to the thread specified when the timer is created. */
1065     (void)_pb_SndMsg(g_timer_ctrl_tbl[id].pno, g_timer_ctrl_tbl[id].size, &(g_timer_ctrl_tbl[id].msg_buf), 0);
1066
1067     type = TimerGetTypeOfCtrlTbl(id);
1068     if (type == TIMER_TYPE_USN) {
1069         /* One-shot timer */
1070         /* Clear timer information */
1071         TimerClearSettingOfCtrlTbl(id);
1072
1073         FRAMEWORKUNIFIEDLOG(ZONE_20, __FUNCTION__, "### TIMER TABLE INFORMATION # " \
1074             "(--) idx:%d cid:%d h_timer:%p pno:%d seq_no:%d type:%d time_out:%d", \
1075             id, g_timer_ctrl_tbl[id].cid, g_timer_ctrl_tbl[id].h_timer, g_timer_ctrl_tbl[id].pno, \
1076             g_timer_ctrl_tbl[id].seq_no, g_timer_ctrl_tbl[id].type, g_timer_ctrl_tbl[id].time_out);
1077     }
1078
1079     TimerUnlockMutex(); /* Release Mutex */
1080
1081     return;
1082 }
1083
1084 /**
1085  * @brief
1086  *   Get dump information
1087  *
1088  * @param[out] p_buf      Dump info
1089  */
1090 void _pb_GetDebugTimerMngTbl(void* p_buf) {
1091     static uint8_t  buf[DEBUG_DUMP_MAX_SIZE];
1092     static uint8_t  buf_tmp[256];
1093     uint32_t         i;
1094
1095     if (p_buf != NULL) {
1096         memset(&buf, 0x00, sizeof(buf));
1097         snprintf(reinterpret_cast<char *>(&(buf)), sizeof(buf), "Timer");
1098         for (i = 0; i < MAX_CTRL_TIMER_NUM; i++) {
1099             memset(&buf_tmp[0], 0x00, sizeof(buf_tmp));
1100             snprintf(reinterpret_cast<char *>(&buf_tmp[0]), sizeof(buf_tmp),
1101                     "\n [%d] cid:%05d, hTim:%10p, sz:%05d, pno:0x%04x, seq:0x%04x, typ:%03d, tOut:%10d",
1102                     i,
1103                     g_timer_ctrl_tbl[i].cid,
1104                     g_timer_ctrl_tbl[i].h_timer,
1105                     g_timer_ctrl_tbl[i].size,
1106                     g_timer_ctrl_tbl[i].pno,
1107                     g_timer_ctrl_tbl[i].seq_no,
1108                     g_timer_ctrl_tbl[i].type,
1109                     g_timer_ctrl_tbl[i].time_out);
1110             strncat(reinterpret_cast<char *>(&buf[0]), reinterpret_cast<char *>(&buf_tmp[0]), \
1111                 strlen(reinterpret_cast<char *>(&buf_tmp[0])));
1112         }
1113         memcpy(p_buf, &buf[0], sizeof(buf));
1114     }
1115 }  // LCOV_EXCL_BR_LINE 10:The final line