| 66 | ****************************************************************************/ |
| 67 | |
| 68 | void nxtask_start(void) |
| 69 | { |
| 70 | FAR struct tcb_s *tcb = this_task(); |
| 71 | uint8_t ttype = tcb->flags & TCB_FLAG_TTYPE_MASK; |
| 72 | int exitcode = EXIT_FAILURE; |
| 73 | FAR char **argv; |
| 74 | int argc; |
| 75 | |
| 76 | DEBUGASSERT(ttype != TCB_FLAG_TTYPE_PTHREAD); |
| 77 | |
| 78 | #ifdef CONFIG_SIG_DEFAULT |
| 79 | if (ttype != TCB_FLAG_TTYPE_KERNEL) |
| 80 | { |
| 81 | /* Set up default signal actions for NON-kernel thread */ |
| 82 | |
| 83 | nxsig_default_initialize(tcb); |
| 84 | } |
| 85 | #endif |
| 86 | |
| 87 | /* Take args from stack, as group is shared for kthreads */ |
| 88 | |
| 89 | argv = nxsched_get_stackargs(tcb); |
| 90 | for (argc = 0; argv && argv[argc]; argc++); |
| 91 | |
| 92 | /* Call the 'main' entry point passing argc and argv. In the kernel build |
| 93 | * this has to be handled differently if we are starting a user-space task; |
| 94 | * we have to switch to user-mode before calling the task. |
| 95 | */ |
| 96 | |
| 97 | if (ttype == TCB_FLAG_TTYPE_KERNEL) |
| 98 | { |
| 99 | exitcode = tcb->entry.main(argc, argv); |
| 100 | } |
| 101 | else |
| 102 | { |
| 103 | #ifdef CONFIG_BUILD_FLAT |
| 104 | nxtask_startup(tcb->entry.main, argc, argv); |
| 105 | #else |
| 106 | up_task_start(tcb->entry.main, argc, argv); |
| 107 | #endif |
| 108 | } |
| 109 | |
| 110 | /* Call _exit() if/when the task returns */ |
| 111 | |
| 112 | _exit(exitcode); |
| 113 | } |
nothing calls this directly
no test coverage detected