2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <sys/eventfd.h>
23 #include <native_service/frameworkunified_dispatcher.h>
24 #include <system_service/ss_system_if.h>
26 #include "tskm_debug.h"
27 #include "tskm_comm.h"
28 #include "tskm_port_pf.h"
29 #include "tskm_port_subsys.h"
30 #include "tskm_util.h"
34 #define PRI_PROC_NAME_MAX 32
40 TSKM_SVCID_t svcId; // Set valid value by REQ_WAKEUP
41 char procName[PRI_PROC_NAME_MAX];
44 T_SS_SM_START_DataStructType bootInfo;
45 T_SS_SM_START_ExtDataStructType extBootInfo; TSKM_BOOL_t isDynamic;
46 uint32_t wakeupStepDone; // Executed local step
48 uint32_t downStepDone; // Executed local step
49 TSKM_BOOL_t isExitStart;
51 #define PRI_MONITOR_DEFAULT_TIMEOUT 50
52 uint32_t timeout; // Service monitoring timeout period (valid only for the INI_Main type service)
55 int connFd; // TSKM communication socket
56 int nsFd; // NSFW socket
57 int pipeFd[2]; // for exitDone
58 HANDLE hApp; // appHandle
61 static PRI_CTX_t g_pri;
63 /*********************************************
64 * Create shared memory
65 *********************************************/
66 TSKM_STATIC void shmMake(PRI_CTX_t* p_ctx) {
67 const PRIM_SHAREDATA_TBL* shmEntry;
68 for (shmEntry = p_ctx->prm.shmTbl; shmEntry->shmName[0] != '\0'; shmEntry++) {
70 ret = tskm_pf_shmCreate(shmEntry->shmName, shmEntry->size, NULL);
71 if (ret != 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
72 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
73 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
76 // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
79 p_ctx->shmDone = TSKM_TRUE;
82 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
84 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
89 /*********************************************
90 * Call backup check CB
91 *********************************************/
92 TSKM_STATIC uint32_t wakeupExFuncCallback(PRI_CTX_t* p_ctx,
93 TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
94 const PRIM_EXFUNC_TBL* funcEntry;
97 for (funcEntry = p_ctx->prm.wakeupExFuncTbl; funcEntry->localStep != 0;
99 if (funcEntry->localStep == p_prm->localStep) {
100 funcEntry->func(funcEntry->prm);
102 maxStep = TSKM_MAX(maxStep, funcEntry->localStep);
107 /*********************************************
108 * Gradual startup request
109 *********************************************/
110 TSKM_STATIC void wakeupRequest(PRI_CTX_t* p_ctx,
111 TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
112 TSKM_EV_PRI_REQ_WAKEUP_PRM_t prm = *p_prm;
115 // Execute step by step
116 for (prm.localStep = p_ctx->wakeupStepDone + 1;
117 (prm.localStep <= p_prm->localStep && prm.localStep < PRIM_STEPFORK_MAX);
119 max = wakeupExFuncCallback(p_ctx, &prm);
122 if (max <= p_prm->localStep) {
123 // Completed gradual startup
124 p_ctx->wakeupStepDone = PRIM_STEPFORK_MAX;
126 p_ctx->wakeupStepDone = p_prm->localStep;
130 /*********************************************
131 * All startup requests
132 *********************************************/
133 TSKM_STATIC void allWakeup(PRI_CTX_t* p_ctx,
134 TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
135 if (!p_ctx->shmDone) {
139 if (p_ctx->wakeupStepDone < PRIM_STEPFORK_MAX) {
140 wakeupRequest(p_ctx, p_prm);
144 /*********************************************
145 * Startup request handles
146 *********************************************/
147 TSKM_STATIC void wakeupRequestHandle(PRI_CTX_t* p_ctx,
148 TSKM_EV_PRI_REQ_WAKEUP_PRM_t* p_prm) {
149 TSKM_EVENT_INFO_t ev;
152 bzero(&ev, sizeof(ev));
154 p_ctx->svcId = p_prm->svcId;
155 memcpy(&p_ctx->bootInfo, &p_prm->bootInfo, sizeof(p_ctx->bootInfo));
156 memcpy(&p_ctx->extBootInfo, &p_prm->extBootInfo, sizeof(p_ctx->extBootInfo));
157 p_ctx->isDynamic = p_prm->isDynamic;
159 if (p_prm->localStep == TSKM_LSTEP_ALL) {
160 allWakeup(p_ctx, p_prm);
161 } else if (p_prm->localStep == TSKM_LSTEP_LAST) {
162 wakeupRequest(p_ctx, p_prm);
163 } else if (p_prm->localStep == TSKM_LSTEP_SHM) {
166 wakeupRequest(p_ctx, p_prm);
169 ev.prm.resWakeup.isShmDone = p_ctx->shmDone;
170 ev.prm.resWakeup.isStepDone =
171 (p_ctx->wakeupStepDone >= PRIM_STEPFORK_MAX) ?
175 // LCOV_EXCL_BR_START 6: Because it depends on the test order
176 if (ev.prm.resWakeup.isShmDone && ev.prm.resWakeup.isStepDone) {
178 ev.prm.resWakeup.isLast = TSKM_TRUE;
181 ev.event = TSKM_EV_PRI_RES_WAKEUP;
182 ev.errCode = TSKM_E_OK;
183 ret = tskm_sockSend(p_ctx->connFd, &ev);
184 if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
185 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
186 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
189 // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
193 /*********************************************
194 * Gradual termination callback
195 *********************************************/
196 TSKM_STATIC uint32_t downExFuncCallback(PRI_CTX_t* p_ctx,
197 TSKM_EV_PRI_REQ_DOWN_PRM_t* p_prm) {
198 const PRIM_EXFUNC_TBL* funcEntry;
199 uint32_t maxStep = 0;
201 for (funcEntry = p_ctx->prm.downExFuncTbl; funcEntry->localStep != 0;
203 if (funcEntry->localStep == p_prm->localStep) {
204 funcEntry->func(funcEntry->prm);
206 maxStep = TSKM_MAX(maxStep, funcEntry->localStep);
211 /*********************************************
212 * Gradual termination requests
213 *********************************************/
214 TSKM_STATIC void downRequest(PRI_CTX_t* p_ctx,
215 TSKM_EV_PRI_REQ_DOWN_PRM_t* p_prm) {
216 TSKM_EV_PRI_REQ_DOWN_PRM_t prm = *p_prm;
219 // Execute step by step
220 for (prm.localStep = p_ctx->downStepDone + 1;
221 (prm.localStep <= p_prm->localStep && prm.localStep < PRIM_ACCOFF_MAX);
223 max = downExFuncCallback(p_ctx, &prm);
226 if (max <= p_prm->localStep) {
227 p_ctx->downStepDone = PRIM_ACCOFF_MAX; // Completed all steps
229 p_ctx->downStepDone = p_prm->localStep;
233 TSKM_STATIC void downRequestHandle(PRI_CTX_t* p_ctx,
234 TSKM_EV_PRI_REQ_DOWN_PRM_t* p_prm) {
235 TSKM_EVENT_INFO_t ev;
238 bzero(&ev, sizeof(ev));
240 if (p_prm->localStep == TSKM_LSTEP_ALL || p_prm->localStep == TSKM_LSTEP_LAST) {
241 downRequest(p_ctx, p_prm);
242 } else if (p_prm->localStep == TSKM_LSTEP_SHM) {
244 } else if (p_prm->localStep == TSKM_LSTEP_BUPCHK) {
247 downRequest(p_ctx, p_prm);
250 if (p_ctx->downStepDone >= PRIM_ACCOFF_MAX) {
251 /* It is not notified when the last function is executed, and it is left to the exitDone.
252 TSKM_PRINTF(TSKM_LOG_DEBUG,"ACCOFF DONE");
253 ev.prm.resDown.isLast = TSKM_TRUE;
254 p_ctx->isExec = TSKM_FALSE;
255 ret = tskm_sockSend(p_ctx->connFd,&ev);
262 ev.event = TSKM_EV_PRI_RES_DOWN;
263 ev.errCode = TSKM_E_OK;
264 ret = tskm_sockSend(p_ctx->connFd, &ev);
265 if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
266 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
267 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
270 // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
275 /*********************************************
276 * Termination completion notification to the TSKM
277 *********************************************/
278 TSKM_STATIC void sendLastDoneRes(PRI_CTX_t* p_ctx) {
280 TSKM_EVENT_INFO_t ev;
282 bzero(&ev, sizeof(ev));
284 ev.event = TSKM_EV_PRI_RES_DOWN;
285 ev.errCode = TSKM_E_OK;
286 ev.prm.resDown.isLast = TSKM_TRUE;
287 ret = tskm_sockSend(p_ctx->connFd, &ev);
288 if (ret <= 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
289 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
290 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
293 // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
297 /*********************************************
299 *********************************************/
300 TSKM_STATIC void touchService(PRI_CTX_t* p_ctx) {
303 if (p_ctx->isExitStart) {
304 // If termination has already begun, the system just processes as timeout for retrying not respond Touch
308 p_ctx->prm.onTouch(p_ctx->hApp);
310 tskm_pf_mkTouchFileName(getpid(), touchName);
312 if ((access(touchName, F_OK) == 0)) {
313 // Synchronize by deleting files.
314 TSKM_PRINTF(TSKM_LOG_STATE, "del:%s", touchName);
317 TSKM_ASSERT_PRINT(0, "%s", touchName);
321 /*********************************************
323 *********************************************/
324 TSKM_STATIC void callDebugDump(PRI_CTX_t* p_ctx) {
325 if (!p_ctx->prm.onDebugDump) { // LCOV_EXCL_BR_LINE 6: As NULL checked by INI_Init
326 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
327 TSKM_ASSERT(0); // LCOV_EXCL_LINE 6: As NULL checked by INI_Init
329 p_ctx->prm.onDebugDump(p_ctx->hApp);
333 /*********************************************
334 * Call LowMemory detection
335 *********************************************/
336 TSKM_STATIC void callLowMem(PRI_CTX_t* p_ctx) {
337 if (!p_ctx->prm.onLowMem) {
339 } else if (!p_ctx->isExitStart) {
340 // Notify LowMemory only before starting terminating process
341 p_ctx->prm.onLowMem(p_ctx->hApp);
345 /*********************************************
347 *********************************************/
348 TSKM_STATIC void eventHandle(PRI_CTX_t* p_ctx, TSKM_EVENT_INFO_t* p_ev) {
349 //Processing according to the request
350 switch (p_ev->event) {
351 case TSKM_EV_PRI_REQ_WAKEUP:
352 wakeupRequestHandle(p_ctx, &p_ev->prm.reqWakeup);
354 case TSKM_EV_PRI_REQ_DOWN:
355 downRequestHandle(p_ctx, &p_ev->prm.reqDown);
357 case TSKM_EV_PRI_REQ_TOUCH:
360 case TSKM_EV_PRI_REQ_DEBUGDUMP:
361 callDebugDump(p_ctx);
363 case TSKM_EV_PRI_REP_LOWMEM:
372 /*********************************************
374 *********************************************/
375 TSKM_STATIC void initCtx(T_PRIM_PRM* p_prm, PRI_CTX_t* p_ctx, int argc,
377 FrameworkunifiedDefaultCallbackHandler cbFuncs;
381 cbFuncs.onInitilization = p_ctx->prm.onInit;
382 cbFuncs.onDestroy = p_ctx->prm.onDestory;
383 cbFuncs.onDebugDump = p_ctx->prm.onDebugDump;
384 cbFuncs.onStart = FrameworkunifiedOnStart;
385 cbFuncs.onStop = FrameworkunifiedOnStop;
386 cbFuncs.createStateMachine = FrameworkunifiedCreateStateMachine;
387 cbFuncs.ssFrameworkInterface = FrameworkunifiedSSFrameworkInterface;
389 EFrameworkunifiedStatus taskmanagerRet;
390 taskmanagerRet = FrameworkunifiedCreateDispatcherWithoutLoop(p_ctx->prm.name, p_ctx->hApp, argc,
391 argv, &cbFuncs, FALSE);
392 if (eFrameworkunifiedStatusOK != taskmanagerRet) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
393 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
394 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
395 TSKM_ASSERT_PRINT(0, "%d", taskmanagerRet);
397 // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
400 taskmanagerRet = FrameworkunifiedGetDispatcherFD(p_ctx->hApp, &p_ctx->nsFd);
401 if (taskmanagerRet != eFrameworkunifiedStatusOK) {
402 TSKM_ASSERT_PRINT(0, "%d", taskmanagerRet);
405 p_ctx->connFd = tskm_cliSockConnect(TSKM_SOCKET_NAME);
406 if (p_ctx->connFd < 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
407 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
408 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
411 // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
413 if (pipe(p_ctx->pipeFd) != 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
414 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
415 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
416 TSKM_ASSERT_ERRNO(0);
418 // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
423 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
425 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
430 /*********************************************
432 *********************************************/
433 TSKM_STATIC void termCtx(PRI_CTX_t* p_ctx) {
434 if (p_ctx->shmDone) { // LCOV_EXCL_BR_LINE 6: Since it has been set to True by INI_Handler and cannot be changed
435 const PRIM_SHAREDATA_TBL* shmEntry = p_ctx->prm.shmTbl;
436 for (shmEntry = p_ctx->prm.shmTbl; shmEntry->shmName[0] != '\0';
438 TSKM_ASSERT(0 == tskm_pf_shmDelete(shmEntry->shmName)); // LCOV_EXCL_BR_LINE 8: For processing in which only return value 0 is set
442 if (p_ctx->connFd > 0) { // LCOV_EXCL_BR_LINE 6: For processing in which only return value 0 is set
443 tskm_sockDestory(p_ctx->connFd);
446 EFrameworkunifiedStatus taskmanagerRet;
447 taskmanagerRet = FrameworkunifiedDestroyDispatcherWithoutLoop(p_ctx->hApp);
448 TSKM_ASSERT(taskmanagerRet == eFrameworkunifiedStatusOK);
450 if (p_ctx->isDynamic) {
451 TSKM_PRINTF(TSKM_LOG_STATE, "EXIT %s", p_ctx->procName);
453 // Hung up running services to prevent adversely affecting to system termination processing during process termination processing
454 sleep(TSKM_CFG_WAIT_SHUTDOWN);
458 /*******************************************************************
459 * Initialize PRI context
460 *******************************************************************/
461 void pri_init(T_PRIM_PRM* p_prm, int argc, char* argv[], int *fdNum,
462 int fdlist[INI_FD_MAX]) {
464 PRI_CTX_t* p_ctx = &g_pri;
466 strncpy(p_ctx->procName, basename(argv[0]), sizeof(p_ctx->procName) - 1);
468 ret = tskm_pf_procInit();
469 if (ret != 0) { // LCOV_EXCL_BR_LINE 6: Return value of 0 only
470 // LCOV_EXCL_START 6: Return value of 0 only
471 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
474 // LCOV_EXCL_STOP 6: Return value of 0 only
477 ret = tskm_comm_procInit();
478 if (ret != 0) { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
479 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
482 // LCOV_EXCL_STOP 5: Checked in Death testing, but it is not reflected in the coverage and excluded
485 initCtx(p_prm, p_ctx, argc, argv);
488 fdlist[0] = p_ctx->connFd;
489 fdlist[1] = p_ctx->pipeFd[0];
490 fdlist[2] = p_ctx->nsFd;
492 p_ctx->svcId = TSKM_SVCID_NONE;
493 p_ctx->isExec = TSKM_TRUE;
495 p_ctx->bootInfo.startupReason = epswfINVALID;
496 p_ctx->bootInfo.isUserModeOn = FALSE;
497 p_ctx->bootInfo.dataResetMode = e_SS_SM_DATA_RESET_MODE_NONE;
498 p_ctx->bootInfo.securityStatus = epsssINVALID;
499 p_ctx->bootInfo.wakeupType = epsstINVALID;
500 p_ctx->bootInfo.dramBackupStatus = e_SS_SM_DRAM_BACKUP_UNSET;
501 p_ctx->bootInfo.resetStatus = e_SS_SM_RESET_STATUS_UNSET;
503 memset(&p_ctx->extBootInfo, 0, sizeof(p_ctx->extBootInfo));
505 p_ctx->timeout = PRI_MONITOR_DEFAULT_TIMEOUT;
508 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
510 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
511 tskm_pf_abort(); // ABORT
515 /*******************************************************************
516 * Primary library handler
517 *******************************************************************/
518 BOOL pri_handler(fd_set* p_fds) {
519 PRI_CTX_t* p_ctx = &g_pri;
521 if (FD_ISSET(p_ctx->connFd, p_fds)) {
523 TSKM_EVENT_INFO_t ev;
524 ret = tskm_sockRcv(p_ctx->connFd, &ev);
525 // LCOV_EXCL_BR_START 5: True condition is checked in Death tests, but not reflected in coverage and excluded
528 eventHandle(p_ctx, &ev);
529 } else { // LCOV_EXCL_BR_LINE 5: Checked in Death testing, but it is not reflected in the coverage and excluded
530 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
531 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
538 if (FD_ISSET(p_ctx->pipeFd[0], p_fds)) {
541 TSKM_ASSERT(sizeof(tmp) == read(p_ctx->pipeFd[0], &tmp, sizeof(tmp)));
542 TSKM_ASSERT(p_ctx->downStepDone == PRIM_ACCOFF_MAX); // Check if all exit functions are complete
543 if (p_ctx->isDynamic) {
544 // A nonresident service completes its termination processing by terminating the process (because the SIGNAL will overtake the sockets)
546 // The resident service completes termination processing with a termination notice (Do not terminate processes to reduce the impact on system termination)
547 sendLastDoneRes(p_ctx);
549 p_ctx->isExec = TSKM_FALSE;
552 if (FD_ISSET(p_ctx->nsFd, p_fds)) {
553 FrameworkunifiedDispatchProcessWithoutLoop(p_ctx->hApp);
555 return p_ctx->isExec;
557 // LCOV_EXCL_START 5: Checked in Death testing, but it is not reflected in the coverage and excluded
559 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
560 tskm_pf_abort(); // ABORT
565 /*******************************************************************
566 * Process termination
567 *******************************************************************/
568 void pri_term(void) {
569 PRI_CTX_t* p_ctx = &g_pri;
573 /*******************************************************************
574 * Service Monitoring Status Setting
575 *******************************************************************/
576 int pri_setMonitorState(BOOL bIsRun, uint32_t timeout) {
577 PRI_CTX_t* p_ctx = &g_pri;
578 int ret = INI_SUCCESS;
580 if (TSKM_SVCID_NONE == p_ctx->svcId) {
581 // Ignore requests until svcId is acquired
582 } else if ((TRUE == bIsRun) && (0 == timeout)) {
583 // When RUN is specified with timeout = 0, monitoring is disabled
585 ret = tskm_comm_setSvcWatchState(p_ctx->svcId, bIsRun, timeout);
586 if (INI_SUCCESS != ret) {
594 /*******************************************************************
596 *******************************************************************/
597 int pri_main(T_PRIM_PRM* p_prm, int argc, char* argv[]) {
599 int fdlist[INI_FD_MAX];
604 pri_init(p_prm, argc, argv, &fdNum, fdlist);
607 PRI_CTX_t* p_ctx = &g_pri;
614 for (ii = 0; ii < fdNum; ii++) {
615 FD_SET(fdlist[ii], &fds);
616 maxFd = TSKM_MAX(fdlist[ii], maxFd);
619 TSKM_ASSERT(INI_SUCCESS == pri_setMonitorState(FALSE, 0));
620 ret = select(maxFd + 1, &fds, NULL, NULL, NULL);
621 TSKM_ASSERT(INI_SUCCESS == pri_setMonitorState(TRUE, p_ctx->timeout));
623 if (errno != EINTR) {
629 isExec = pri_handler(&fds);
638 /*******************************************************************
639 * Termination request
640 *******************************************************************/
641 void pri_exitStart(void *rsv) {
643 PRI_CTX_t* p_ctx = &g_pri;
644 TSKM_EVENT_INFO_t ev;
646 bzero(&ev, sizeof(ev));
647 p_ctx->isExitStart = TRUE;
648 ev.event = TSKM_EV_PRI_REQ_EXIT;
649 ev.errCode = TSKM_E_OK;
651 ret = tskm_sockSend(p_ctx->connFd, &ev);
652 if (ret <= 0) { // LCOV_EXCL_BR_LINE 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
657 // LCOV_EXCL_START 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
659 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
664 void pri_exitDone(int status) {
665 PRI_CTX_t* p_ctx = &g_pri;
666 uint32_t l_status = (uint32_t) status;
668 // LCOV_EXCL_BR_START 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
669 if (p_ctx->pipeFd[1] > 0) {
671 // LCOV_EXCL_START 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
672 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
674 write(p_ctx->pipeFd[1], &l_status, sizeof(l_status))
675 == sizeof(l_status));
678 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
679 TSKM_ASSERT(0); // LCOV_EXCL_LINE 6: The caller's external API does not execute the second or subsequent processing and cannot be checked
683 /*******************************************************************
684 * Event completion notification at startup
685 *******************************************************************/
686 int32_t pri_stepForkComp(uint64_t id) {
688 PRI_CTX_t* p_ctx = &g_pri;
689 TSKM_EVENT_INFO_t ev;
691 bzero(&ev, sizeof(ev));
692 ev.event = TSKM_EV_PRI_REP_WAKEUP_COMP;
693 ev.errCode = TSKM_E_OK;
694 ev.prm.repWakeupComp.compId = id;
695 ret = tskm_sockSend(p_ctx->connFd, &ev);
701 ERROR: return INI_FALSE;
704 /*******************************************************************
705 * Event completion notification at termination
706 *******************************************************************/
707 int32_t pri_accOffComp(uint64_t id) {
709 PRI_CTX_t* p_ctx = &g_pri;
710 TSKM_EVENT_INFO_t ev;
712 bzero(&ev, sizeof(ev));
714 ev.event = TSKM_EV_PRI_REP_DOWN_COMP;
715 ev.errCode = TSKM_E_OK;
716 ev.prm.repDownComp.compId = id;
717 ret = tskm_sockSend(p_ctx->connFd, &ev);
723 ERROR: return INI_FALSE;
726 /*******************************************************************
728 *******************************************************************/
731 PRI_CTX_t* p_ctx = &g_pri;
732 return p_ctx->prm.priv;
735 /*******************************************************************
737 *******************************************************************/
738 HANDLE pri_getHandle() {
739 PRI_CTX_t* p_ctx = &g_pri;
743 /*******************************************************************
744 * Service monitoring status setting timeout setting
745 *******************************************************************/
746 int32_t pri_setMonitorTimeout(uint32_t timeout) {
747 PRI_CTX_t* p_ctx = &g_pri;
748 p_ctx->timeout = timeout;
752 /*******************************************************************
754 *******************************************************************/
755 int32_t pri_getBootInfo(T_SS_SM_START_DataStructType *info) {
756 PRI_CTX_t* p_ctx = &g_pri;
758 if (p_ctx->bootInfo.startupReason == epswfINVALID) {
763 *info = p_ctx->bootInfo;
768 /*******************************************************************
769 * Get extended boot info
770 *******************************************************************/
771 int32_t pri_getExtBootInfo(T_SS_SM_START_ExtDataStructType *info) {
772 PRI_CTX_t* p_ctx = &g_pri;
774 if (p_ctx->bootInfo.startupReason == epswfINVALID) {
779 *info = p_ctx->extBootInfo;
784 /*******************************************************************
786 *******************************************************************/
787 void pri_sendDebugDumpRes(const char *buf) { // LCOV_EXCL_START 7: Debugging code
788 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
790 PRI_CTX_t* p_ctx = &g_pri;
791 TSKM_EVENT_INFO_t ev;
792 TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t *p_prm;
794 ev.event = TSKM_EV_PRI_RES_DEBUGDUMP;
795 ev.errCode = TSKM_E_OK;
796 ev.hasExtend = TSKM_TRUE;
798 ev.extendPrm = malloc(sizeof(TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t));
804 ev.extendSize = sizeof(TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t);
806 p_prm = (TSKM_EV_PRI_EX_RES_DEBUGDUMP_PRM_t *) ev.extendPrm; // NOLINT (readability/casting)
807 snprintf(p_prm->dumpMsg, TSKM_EV_DEBUGDUMP_SIZE, "%s", buf);
809 ret = tskm_sockSend(p_ctx->connFd, &ev);
817 /*************************************************
818 * Empty functions implemented for building software
819 **************************************************/
820 EFrameworkunifiedStatus FrameworkunifiedOnStart(HANDLE hApp) {
821 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
822 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
823 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
826 EFrameworkunifiedStatus FrameworkunifiedOnStop(HANDLE hApp) {
827 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
828 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
829 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
833 EFrameworkunifiedStatus FrameworkunifiedCreateStateMachine(HANDLE hApp) { // LCOV_EXCL_START 6: Because the condition cannot be set
834 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
835 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
836 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
837 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");