ER
set_dft(int32_t drift)
{
	ER		ercd;

	LOG_SET_DFT_ENTER(drift);
	CHECK_UNL();								/*[NGKI3598]*/
	CHECK_PAR(TMIN_DRIFT <= drift && drift <= TMAX_DRIFT);
												/*[NGKI3599]*/
	lock_cpu();
	update_current_evttim();

	drift_rate = (uint32_t)(1000000U + drift);	/*[NGKI3601]*/

	evttim_step = (TSTEP_HRTCNT * drift_rate + 999999U) / 1000000U;
	evttim_step_frac = (TSTEP_HRTCNT * drift_rate + 999999U) % 1000000U;

	set_hrt_event();
	ercd = E_OK;
	unlock_cpu();

  error_exit:
	LOG_SET_DFT_LEAVE(ercd);
	return(ercd);
}
Esempio n. 2
0
ER
sta_alm(ID almid, RELTIM almtim)
{
    ALMCB	*p_almcb;
    ER		ercd;

    LOG_STA_ALM_ENTER(almid, almtim);
    CHECK_UNL();
    CHECK_ID(VALID_ALMID(almid));
    CHECK_PAR(VALID_RELTIM(almtim));
    p_almcb = get_almcb(almid);

    lock_cpu();
    if (p_almcb->almsta) {
        tmevtb_dequeue(&(p_almcb->tmevtb));
    }
    else {
        p_almcb->almsta = true;
    }
    tmevtb_enqueue(&(p_almcb->tmevtb), almtim);
    ercd = E_OK;
    unlock_cpu();

error_exit:
    LOG_STA_ALM_LEAVE(ercd);
    return(ercd);
}
Esempio n. 3
0
ER
psnd_pdq(ID pdqid, intptr_t data, PRI datapri)
{
	PDQCB	*p_pdqcb;
	ER		ercd;

	LOG_PSND_PDQ_ENTER(pdqid, data, datapri);
	CHECK_UNL();
	CHECK_ID(VALID_PDQID(pdqid));
	p_pdqcb = get_pdqcb(pdqid);
	CHECK_PAR(TMIN_DPRI <= datapri && datapri <= p_pdqcb->p_pdqinib->maxdpri);

	lock_cpu();
	if (send_pridata(p_pdqcb, data, datapri)) {
		if (p_runtsk != p_schedtsk) {
			if (!sense_context()) {
				dispatch();
			}
			else {
				request_dispatch();
			}
		}
		ercd = E_OK;
	}
	else {
		ercd = E_TMOUT;
	}
	unlock_cpu();

  error_exit:
	LOG_PSND_PDQ_LEAVE(ercd);
	return(ercd);
}
Esempio n. 4
0
ER
stp_alm(ID almid)
{
	ALMCB	*p_almcb;
	ER		ercd;

	LOG_STP_ALM_ENTER(almid);
	CHECK_UNL();
	CHECK_ID(VALID_ALMID(almid));
	p_almcb = get_almcb(almid);

	lock_cpu();
	if (p_almcb->p_alminib->almatr == TA_NOEXS) {
		ercd = E_NOEXS;
	}
	else {
		if (p_almcb->almsta) {
			p_almcb->almsta = false;
			tmevtb_dequeue(&(p_almcb->tmevtb));
		}
		ercd = E_OK;
	}
	unlock_cpu();

  error_exit:
	LOG_STP_ALM_LEAVE(ercd);
	return(ercd);
}
Esempio n. 5
0
ER
wup_tsk(ID tskid)
{
	TCB		*p_tcb;
	ER		ercd;

	LOG_WUP_TSK_ENTER(tskid);
	CHECK_UNL();
	if (tskid == TSK_SELF && !sense_context()) {
		p_tcb = p_runtsk;
	}
	else {
		CHECK_ID(VALID_TSKID(tskid));
		p_tcb = get_tcb(tskid);
	}

	lock_cpu();
	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
		ercd = E_NOEXS;
	}
	else if (TSTAT_DORMANT(p_tcb->tstat)) {
		ercd = E_OBJ;
	}
	else if (TSTAT_WAIT_SLP(p_tcb->tstat)) {
		wait_complete(p_tcb);
		if (p_runtsk != p_schedtsk) {
			if (!sense_context()) {
				dispatch();
			}
			else {
				request_dispatch();
			}
		}
		ercd = E_OK;
	}
	else if (!(p_tcb->wupque)) {
		p_tcb->wupque = true;
		ercd = E_OK;
	}
	else {
		ercd = E_QOVR;
	}
	unlock_cpu();

  error_exit:
	LOG_WUP_TSK_LEAVE(ercd);
	return(ercd);
}
Esempio n. 6
0
ER
act_tsk(ID tskid)
{
	TCB		*p_tcb;
	ER		ercd;

	LOG_ACT_TSK_ENTER(tskid);
	CHECK_UNL();								/*[NGKI1114]*/
	if (tskid == TSK_SELF && !sense_context()) {
		p_tcb = p_runtsk;						/*[NGKI1121]*/
	}
	else {
		CHECK_ID(VALID_TSKID(tskid));			/*[NGKI1115]*/
		p_tcb = get_tcb(tskid);
	}

	lock_cpu();
	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
		ercd = E_NOEXS;							/*[NGKI1116]*/
	}
	else if (TSTAT_DORMANT(p_tcb->tstat)) {
		make_active(p_tcb);						/*[NGKI1118]*/
		if (p_runtsk != p_schedtsk) {
			if (!sense_context()) {
				dispatch();
			}
			else {
				request_dispatch();
			}
		}
		ercd = E_OK;
	}
	else if ((p_tcb->p_tinib->tskatr & TA_NOACTQUE) != 0U || p_tcb->actque) {
		ercd = E_QOVR;			   				/*[NGKI3528]*/
	}
	else {
		p_tcb->actque = true;					/*[NGKI3527]*/
		ercd = E_OK;
	}
	unlock_cpu();

  error_exit:
	LOG_ACT_TSK_LEAVE(ercd);
	return(ercd);
}
Esempio n. 7
0
ER
sig_sem(ID semid)
{
	SEMCB	*p_semcb;
	TCB		*p_tcb;
	ER		ercd;
    
	LOG_SIG_SEM_ENTER(semid);
	CHECK_UNL();
	CHECK_ID(VALID_SEMID(semid));
	p_semcb = get_semcb(semid);

	lock_cpu();
	if (p_semcb->p_seminib->sematr == TA_NOEXS) {
		ercd = E_NOEXS;
	}
	else if (VIOLATE_ACPTN(p_semcb->p_seminib->acvct.acptn1)) {
		ercd = E_OACV;
	}
	else if (!queue_empty(&(p_semcb->wait_queue))) {
		p_tcb = (TCB *) queue_delete_next(&(p_semcb->wait_queue));
		wait_complete(p_tcb);
		if (p_runtsk != p_schedtsk) {
			if (!sense_context()) {
				dispatch();
			}
			else {
				request_dispatch_retint();
			}
		}
		ercd = E_OK;
	}
	else if (p_semcb->semcnt < p_semcb->p_seminib->maxsem) {
		p_semcb->semcnt += 1;
		ercd = E_OK;
	}
	else {
		ercd = E_QOVR;
	}
	unlock_cpu();

  error_exit:
	LOG_SIG_SEM_LEAVE(ercd);
	return(ercd);
}
Esempio n. 8
0
ER
rel_wai(ID tskid)
{
	TCB		*p_tcb;
	ER		ercd;

	LOG_REL_WAI_ENTER(tskid);
	CHECK_UNL();
	CHECK_ID(VALID_TSKID(tskid));
	p_tcb = get_tcb(tskid);

	lock_cpu();
	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
		ercd = E_NOEXS;
	}
	else if (!TSTAT_WAITING(p_tcb->tstat)) {
		ercd = E_OBJ;
	}
	else {
		wait_dequeue_wobj(p_tcb);
		wait_dequeue_tmevtb(p_tcb);
		p_tcb->p_winfo->wercd = E_RLWAI;
		make_non_wait(p_tcb);
		if (p_runtsk != p_schedtsk) {
			if (!sense_context()) {
				dispatch();
			}
			else {
				request_dispatch();
			}
		}
		ercd = E_OK;
	}
	unlock_cpu();

  error_exit:
	LOG_REL_WAI_LEAVE(ercd);
	return(ercd);
}
ER
adj_tim(int32_t adjtim)
{
	EVTTIM	previous_evttim;
	ER		ercd;

	LOG_ADJ_TIM_ENTER(adjtim);
	CHECK_UNL();								/*[NGKI3583]*/
	CHECK_PAR(TMIN_ADJTIM <= adjtim && adjtim <= TMAX_ADJTIM);
												/*[NGKI3584]*/
	lock_cpu();
	update_current_evttim();					/*[ASPD1051]*/
	if (check_adjtim(adjtim)) {					/*[ASPD1052]*/
		ercd = E_OBJ;
	}
	else {
		previous_evttim = current_evttim;
		current_evttim += adjtim;				/*[ASPD1053]*/
		boundary_evttim = current_evttim - BOUNDARY_MARGIN;	/*[ASPD1055]*/

		if (adjtim > 0
				&& monotonic_evttim - previous_evttim < (EVTTIM) adjtim) {
#ifdef UINT64_MAX
			if (current_evttim < monotonic_evttim) {
				systim_offset += 1LLU << 32;
			}
#endif /* UINT64_MAX */
			monotonic_evttim = current_evttim;	/*[ASPD1054]*/
		}

		set_hrt_event();						/*[ASPD1056]*/
		ercd = E_OK;
	}
	unlock_cpu();

  error_exit:
	LOG_ADJ_TIM_LEAVE(ercd);
	return(ercd);
}