static STK_T _module_ustack_BALANCE_CONTROL_TASK[COUNT_STK_T(STACK_SIZE)]; ID _module_id_LINE_TRACE_TASK __attribute__((section (".module.text"))); static STK_T _module_ustack_LINE_TRACE_TASK[COUNT_STK_T(STACK_SIZE)]; ID _module_id_TAIL_CONTROL_TASK __attribute__((section (".module.text"))); static STK_T _module_ustack_TAIL_CONTROL_TASK[COUNT_STK_T(STACK_SIZE)]; ID _module_id_SELECTED_TASK __attribute__((section (".module.text"))); static STK_T _module_ustack_SELECTED_TASK[COUNT_STK_T(STACK_SIZE)]; ID _module_id_MAIN_TASK __attribute__((section (".module.text"))); static STK_T _module_ustack_MAIN_TASK[COUNT_STK_T(STACK_SIZE)]; static const T_CTSK _module_ctsk_tab[6] = { { TA_ACT, 0, _app_init_task, TPRI_APP_INIT_TASK, ROUND_STK_T(STACK_SIZE), _module_ustack_APP_INIT_TASK, DEFAULT_SSTKSZ, NULL }, { TA_NULL, 0, balance_control_task_run, TMIN_APP_TPRI + 1, ROUND_STK_T(STACK_SIZE), _module_ustack_BALANCE_CONTROL_TASK, DEFAULT_SSTKSZ, NULL }, { TA_NULL, 0, line_trace_task_run, TMIN_APP_TPRI + 1, ROUND_STK_T(STACK_SIZE), _module_ustack_LINE_TRACE_TASK, DEFAULT_SSTKSZ, NULL }, { TA_NULL, 0, tail_control_task_run, TMIN_APP_TPRI + 1, ROUND_STK_T(STACK_SIZE), _module_ustack_TAIL_CONTROL_TASK, DEFAULT_SSTKSZ, NULL }, { TA_NULL, 0, selected_task_run, TMIN_APP_TPRI + 3, ROUND_STK_T(STACK_SIZE), _module_ustack_SELECTED_TASK, DEFAULT_SSTKSZ, NULL }, { TA_ACT, 0, main_task_run, TMIN_APP_TPRI + 7, ROUND_STK_T(STACK_SIZE), _module_ustack_MAIN_TASK, DEFAULT_SSTKSZ, NULL }, }; static const T_CSEM _module_csem_tab[0] = { }; static const T_CFLG _module_cflg_tab[0] = { }; const SIZE _module_cfg_entry_num = 6;
#ifndef LOG_ISR_LEAVE #define LOG_ISR_LEAVE(intno) #endif /* LOG_ISR_LEAVE */ /* * Task Management Functions */ const ID _kernel_tmax_tskid = (TMIN_TSKID + TNUM_TSKID - 1); static STK_T _kernel_stack_INIT_TASK[COUNT_STK_T(STACK_SIZE)]; static STK_T _kernel_stack_FUNC1_TASK[COUNT_STK_T(STACK_SIZE)]; const TINIB _kernel_tinib_table[TNUM_TSKID] = { { (TA_ACT), (intptr_t)(0), (main), INT_PRIORITY(IDLE_PRIORITY), ROUND_STK_T(STACK_SIZE), (_kernel_stack_INIT_TASK), (TA_NULL), (NULL) }, { (TA_NULL), (intptr_t)(0), (func1_task), INT_PRIORITY(MID_PRIORITY), ROUND_STK_T(STACK_SIZE), (_kernel_stack_FUNC1_TASK), (TA_NULL), (NULL) } }; TCB _kernel_tcb_table[TNUM_TSKID]; const ID _kernel_torder_table[TNUM_TSKID] = { INIT_TASK, FUNC1_TASK }; /* * Semaphore Functions */ const ID _kernel_tmax_semid = (TMIN_SEMID + TNUM_SEMID - 1);
#include "target_serial_dbsio.h" #include "syssvc/serial.h" #include "syssvc/logtask.h" #include "api.cfg.h" #include "app.h" ID _module_id_APP_INIT_TASK __attribute__((section (".module.text"))); static STK_T _module_ustack_APP_INIT_TASK[COUNT_STK_T(STACK_SIZE)]; ID _module_id_MAIN_TASK __attribute__((section (".module.text"))); static STK_T _module_ustack_MAIN_TASK[COUNT_STK_T(STACK_SIZE)]; ID _module_id_TRACER_TASK __attribute__((section (".module.text"))); static STK_T _module_ustack_TRACER_TASK[COUNT_STK_T(STACK_SIZE)]; static const T_CTSK _module_ctsk_tab[3] = { { TA_ACT, 0, _app_init_task, TPRI_APP_INIT_TASK, ROUND_STK_T(STACK_SIZE), _module_ustack_APP_INIT_TASK, DEFAULT_SSTKSZ, NULL }, { TA_ACT, 0, main_task, MAIN_PRIORITY, ROUND_STK_T(STACK_SIZE), _module_ustack_MAIN_TASK, DEFAULT_SSTKSZ, NULL }, { TA_NULL, 0, tracer_task, TRACER_PRIORITY, ROUND_STK_T(STACK_SIZE), _module_ustack_TRACER_TASK, DEFAULT_SSTKSZ, NULL }, }; const SIZE _module_cfg_entry_num = 3; const MOD_CFG_ENTRY _module_cfg_tab[3] = { { TSFN_CRE_TSK, &_module_ctsk_tab[0], &_module_id_APP_INIT_TASK }, { TSFN_CRE_TSK, &_module_ctsk_tab[1], &_module_id_MAIN_TASK }, { TSFN_CRE_TSK, &_module_ctsk_tab[2], &_module_id_TRACER_TASK }, }; const uint32_t _module_pil_version = PIL_VERSION;
ER_UINT acre_tsk(const T_CTSK *pk_ctsk) { ID domid; const DOMINIB *p_dominib; TCB *p_tcb; TINIB *p_tinib; ATR tskatr; SIZE sstksz, ustksz; void *sstk, *ustk; ACPTN acptn; ER ercd; LOG_ACRE_TSK_ENTER(pk_ctsk); CHECK_TSKCTX_UNL(); CHECK_MACV_READ(pk_ctsk, T_CTSK); CHECK_RSATR(pk_ctsk->tskatr, TA_ACT|TARGET_TSKATR|TA_DOMMASK); domid = get_atrdomid(pk_ctsk->tskatr); CHECK_ATRDOMID_ACTIVE(domid); CHECK_ALIGN_FUNC(pk_ctsk->task); CHECK_NONNULL_FUNC(pk_ctsk->task); CHECK_TPRI(pk_ctsk->itskpri); p_dominib = (domid == TDOM_SELF) ? p_runtsk->p_tinib->p_dominib : (domid == TDOM_KERNEL) ? &dominib_kernel : get_dominib(domid); if (p_dominib == &dominib_kernel) { /* * システムタスクの場合 */ ustksz = 0U; ustk = NULL; CHECK_PAR(pk_ctsk->sstk == NULL); CHECK_PAR(pk_ctsk->stksz > 0U); sstksz = pk_ctsk->stksz; sstk = pk_ctsk->stk; if (sstk != NULL) { CHECK_PAR(pk_ctsk->sstksz == 0U); } else { sstksz += pk_ctsk->sstksz; } } else { /* * ユーザタスクの場合 */ ustksz = pk_ctsk->stksz; ustk = pk_ctsk->stk; CHECK_PAR(ustksz >= TARGET_MIN_USTKSZ); CHECK_NOSPT(ustk != NULL); CHECK_TARGET_USTACK(ustksz, ustk, p_dominib); sstksz = pk_ctsk->sstksz; sstk = pk_ctsk->sstk; } CHECK_PAR(sstksz >= TARGET_MIN_SSTKSZ); if (sstk != NULL) { CHECK_ALIGN_STKSZ(sstksz); CHECK_ALIGN_STACK(sstk); } CHECK_ACPTN(sysstat_acvct.acptn3); tskatr = pk_ctsk->tskatr; t_lock_cpu(); if (queue_empty(&free_tcb)) { ercd = E_NOID; } else { if (sstk == NULL) { sstk = kernel_malloc(ROUND_STK_T(sstksz)); tskatr |= TA_MEMALLOC; } if (sstk == NULL) { ercd = E_NOMEM; } else { p_tcb = ((TCB *) queue_delete_next(&free_tcb)); p_tinib = (TINIB *)(p_tcb->p_tinib); p_tinib->p_dominib = p_dominib; p_tinib->tskatr = tskatr; p_tinib->exinf = pk_ctsk->exinf; p_tinib->task = pk_ctsk->task; p_tinib->ipriority = INT_PRIORITY(pk_ctsk->itskpri); #ifdef USE_TSKINICTXB init_tskinictxb(&(p_tinib->tskinictxb), p_dominib, sstksz, sstk, utsksz, ustk, pk_ctsk); #else /* USE_TSKINICTXB */ p_tinib->sstksz = sstksz; p_tinib->sstk = sstk; p_tinib->ustksz = ustksz; p_tinib->ustk = ustk; #endif /* USE_TSKINICTXB */ p_tinib->texatr = TA_NULL; p_tinib->texrtn = NULL; acptn = default_acptn(domid); p_tinib->acvct.acptn1 = acptn; p_tinib->acvct.acptn2 = acptn; p_tinib->acvct.acptn3 = acptn | rundom; p_tinib->acvct.acptn4 = acptn; p_tcb->actque = false; make_dormant(p_tcb); queue_initialize(&(p_tcb->mutex_queue)); if ((p_tcb->p_tinib->tskatr & TA_ACT) != 0U) { make_active(p_tcb); } ercd = TSKID(p_tcb); } } t_unlock_cpu(); error_exit: LOG_ACRE_TSK_LEAVE(ercd); return(ercd); }
ER_UINT acre_tsk(const T_CTSK *pk_ctsk) { TCB *p_tcb; TINIB *p_tinib; ATR tskatr; TASK task; PRI itskpri; size_t stksz; STK_T *stk; ER ercd; LOG_ACRE_TSK_ENTER(pk_ctsk); CHECK_TSKCTX_UNL(); tskatr = pk_ctsk->tskatr; task = pk_ctsk->task; itskpri = pk_ctsk->itskpri; stksz = pk_ctsk->stksz; stk = pk_ctsk->stk; CHECK_RSATR(tskatr, TA_ACT|TA_NOACTQUE|TARGET_TSKATR); CHECK_PAR(FUNC_ALIGN(task)); CHECK_PAR(FUNC_NONNULL(task)); CHECK_PAR(VALID_TPRI(itskpri)); CHECK_PAR(stksz >= TARGET_MIN_STKSZ); if (stk != NULL) { CHECK_PAR(STKSZ_ALIGN(stksz)); CHECK_PAR(STACK_ALIGN(stk)); } lock_cpu(); if (queue_empty(&free_tcb)) { ercd = E_NOID; } else { if (stk == NULL) { stk = kernel_malloc(ROUND_STK_T(stksz)); tskatr |= TA_MEMALLOC; } if (stk == NULL) { ercd = E_NOMEM; } else { p_tcb = ((TCB *) queue_delete_next(&free_tcb)); p_tinib = (TINIB *)(p_tcb->p_tinib); p_tinib->tskatr = tskatr; p_tinib->exinf = pk_ctsk->exinf; p_tinib->task = task; p_tinib->ipriority = INT_PRIORITY(itskpri); #ifdef USE_TSKINICTXB init_tskinictxb(&(p_tinib->tskinictxb), stksz, stk); #else /* USE_TSKINICTXB */ p_tinib->stksz = stksz; p_tinib->stk = stk; #endif /* USE_TSKINICTXB */ p_tcb->actque = false; make_dormant(p_tcb); if ((p_tcb->p_tinib->tskatr & TA_ACT) != 0U) { make_active(p_tcb); } ercd = TSKID(p_tcb); } } unlock_cpu(); error_exit: LOG_ACRE_TSK_LEAVE(ercd); return(ercd); }
&_kernel_prc1_pcb, &_kernel_prc2_pcb }; /* * Task Management Functions */ const ID _kernel_tmax_tskid = (TMIN_TSKID + TNUM_TSKID - 1); static STK_T _kernel_stack_LOGTASK1[COUNT_STK_T(LOGTASK_STACK_SIZE)] __attribute__((section(".bss._kernel_prc1s_tstack"),nocommon)); static STK_T _kernel_stack_LOGTASK2[COUNT_STK_T(LOGTASK_STACK_SIZE)] __attribute__((section(".bss._kernel_prc2s_tstack"),nocommon)); static STK_T _kernel_stack_TASK2[COUNT_STK_T(STACK_SIZE)] __attribute__((section(".bss._kernel_prc2s_tstack"),nocommon)); const TINIB _kernel_tinib_table[TNUM_TSKID] = { { (TA_ACT), (intptr_t)(LOGTASK_PORTID_PRC1), (logtask_main), INT_PRIORITY(LOGTASK_PRIORITY), ROUND_STK_T(LOGTASK_STACK_SIZE), _kernel_stack_LOGTASK1, (TA_NULL), (NULL), 1, (uint_t)(0x0000000f) }, { (TA_ACT), (intptr_t)(LOGTASK_PORTID_PRC2), (logtask_main), INT_PRIORITY(LOGTASK_PRIORITY), ROUND_STK_T(LOGTASK_STACK_SIZE), _kernel_stack_LOGTASK2, (TA_NULL), (NULL), 2, (uint_t)(0x0000000f) }, { (TA_ACT), (intptr_t)(2), (task), INT_PRIORITY(MID_PRIORITY), ROUND_STK_T(STACK_SIZE), _kernel_stack_TASK2, (TA_NULL), (NULL), 2, (uint_t)(0x0000000f) } }; TCB _kernel_tcb_LOGTASK1 __attribute__((section(".bss._kernel_prc1s_tskcb"),nocommon)); TCB _kernel_tcb_LOGTASK2 __attribute__((section(".bss._kernel_prc2s_tskcb"),nocommon)); TCB _kernel_tcb_TASK2 __attribute__((section(".bss._kernel_prc2s_tskcb"),nocommon)); TCB* const _kernel_p_tcb_table[TNUM_TSKID] ={ &_kernel_tcb_LOGTASK1, &_kernel_tcb_LOGTASK2, &_kernel_tcb_TASK2 };