Beispiel #1
0
ER
sac_mtx(ID mtxid, const ACVCT *p_acvct)
{
	MTXCB	*p_mtxcb;
	MTXINIB	*p_mtxinib;
	ER		ercd;

	LOG_SAC_MTX_ENTER(mtxid, p_acvct);
	CHECK_TSKCTX_UNL();
	CHECK_ID(VALID_MTXID(mtxid));
	CHECK_MACV_READ(p_acvct, ACVCT);
	p_mtxcb = get_mtxcb(mtxid);

	lock_cpu();
	if (p_mtxcb->p_mtxinib->mtxatr == TA_NOEXS) {
		ercd = E_NOEXS;
	}
	else if (VIOLATE_ACPTN(p_mtxcb->p_mtxinib->acvct.acptn3)) {
		ercd = E_OACV;
	}
	else if (MTXID(p_mtxcb) <= tmax_smtxid) {
		ercd = E_OBJ;
	}
	else {
		p_mtxinib = (MTXINIB *)(p_mtxcb->p_mtxinib);
		p_mtxinib->acvct = *p_acvct;
		ercd = E_OK;
	}
	unlock_cpu();

  error_exit:
	LOG_SAC_MTX_LEAVE(ercd);
	return(ercd);
}
Beispiel #2
0
ER
sac_isr(ID isrid, const ACVCT *p_acvct)
{
	ISRCB	*p_isrcb;
	ISRINIB	*p_isrinib;
	ER		ercd;

	LOG_SAC_ISR_ENTER(isrid, p_acvct);
	CHECK_TSKCTX_UNL();
	CHECK_ISRID(isrid);
	CHECK_MACV_READ(p_acvct, ACVCT);
	p_isrcb = get_isrcb(isrid);

	t_lock_cpu();
	if (p_isrcb->p_isrinib->isratr == TA_NOEXS) {
		ercd = E_NOEXS;
	}
	else if (VIOLATE_ACPTN(p_isrcb->p_isrinib->acvct.acptn3)) {
		ercd = E_OACV;
	}
	else {
		p_isrinib = (ISRINIB *)(p_isrcb->p_isrinib);
		p_isrinib->acvct = *p_acvct;
		ercd = E_OK;
	}
	t_unlock_cpu();

  error_exit:
	LOG_SAC_ISR_LEAVE(ercd);
	return(ercd);
}
Beispiel #3
0
ER
sac_sem(ID semid, const ACVCT *p_acvct)
{
    SEMCB	*p_semcb;
    SEMINIB	*p_seminib;
    ER		ercd;

    LOG_SAC_SEM_ENTER(semid, p_acvct);
    CHECK_TSKCTX_UNL();
    CHECK_SEMID(semid);
    CHECK_MACV_READ(p_acvct, ACVCT);
    p_semcb = get_semcb(semid);

    t_lock_cpu();
    if (p_semcb->p_seminib->sematr == TA_NOEXS) {
        ercd = E_NOEXS;
    }
    else if (VIOLATE_ACPTN(p_semcb->p_seminib->acvct.acptn3)) {
        ercd = E_OACV;
    }
    else if (SEMID(p_semcb) > tmax_ssemid) {
        p_seminib = (SEMINIB *)(p_semcb->p_seminib);
        p_seminib->acvct = *p_acvct;
        ercd = E_OK;
    }
    else {
        ercd = E_OBJ;
    }
    t_unlock_cpu();

error_exit:
    LOG_SAC_SEM_LEAVE(ercd);
    return(ercd);
}
Beispiel #4
0
ER
sac_flg(ID flgid, const ACVCT *p_acvct)
{
    FLGCB	*p_flgcb;
    FLGINIB	*p_flginib;
    ER		ercd;

    LOG_SAC_FLG_ENTER(flgid, p_acvct);
    CHECK_TSKCTX_UNL();
    CHECK_FLGID(flgid);
    CHECK_MACV_READ(p_acvct, ACVCT);
    p_flgcb = get_flgcb(flgid);

    t_lock_cpu();
    if (p_flgcb->p_flginib->flgatr == TA_NOEXS) {
        ercd = E_NOEXS;
    }
    else if (VIOLATE_ACPTN(p_flgcb->p_flginib->acvct.acptn3)) {
        ercd = E_OACV;
    }
    else if (FLGID(p_flgcb) > tmax_sflgid) {
        p_flginib = (FLGINIB *)(p_flgcb->p_flginib);
        p_flginib->acvct = *p_acvct;
        ercd = E_OK;
    }
    else {
        ercd = E_OBJ;
    }
    t_unlock_cpu();

error_exit:
    LOG_SAC_FLG_LEAVE(ercd);
    return(ercd);
}
Beispiel #5
0
ER
sac_tsk(ID tskid, const ACVCT *p_acvct)
{
	TCB		*p_tcb;
	TINIB	*p_tinib;
	ER		ercd;

	LOG_SAC_TSK_ENTER(tskid, p_acvct);
	CHECK_TSKCTX_UNL();
	CHECK_TSKID(tskid);
	CHECK_MACV_READ(p_acvct, ACVCT);
	p_tcb = get_tcb(tskid);

	t_lock_cpu();
	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
		ercd = E_NOEXS;
	}
	else if (VIOLATE_ACPTN(p_tcb->p_tinib->acvct.acptn3)) {
		ercd = E_OACV;
	}
	else if (TSKID(p_tcb) > tmax_stskid) {
		p_tinib = (TINIB *)(p_tcb->p_tinib);
		p_tinib->acvct = *p_acvct;
		ercd = E_OK;
	}
	else {
		ercd = E_OBJ;
	}
	t_unlock_cpu();

  error_exit:
	LOG_SAC_TSK_LEAVE(ercd);
	return(ercd);
}
Beispiel #6
0
ER
sac_pdq(ID pdqid, const ACVCT *p_acvct)
{
	PDQCB	*p_pdqcb;
	PDQINIB	*p_pdqinib;
	ER		ercd;

	LOG_SAC_PDQ_ENTER(pdqid, p_acvct);
	CHECK_TSKCTX_UNL();
	CHECK_PDQID(pdqid);
	CHECK_MACV_READ(p_acvct, ACVCT);
	p_pdqcb = get_pdqcb(pdqid);

	t_lock_cpu();
	if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) {
		ercd = E_NOEXS;
	}
	else if (VIOLATE_ACPTN(p_pdqcb->p_pdqinib->acvct.acptn3)) {
		ercd = E_OACV;
	}
	else if (PDQID(p_pdqcb) > tmax_spdqid) {
		p_pdqinib = (PDQINIB *)(p_pdqcb->p_pdqinib);
		p_pdqinib->acvct = *p_acvct;
		ercd = E_OK;
	}
	else {
		ercd = E_OBJ;
	}
	t_unlock_cpu();

  error_exit:
	LOG_SAC_PDQ_LEAVE(ercd);
	return(ercd);
}
Beispiel #7
0
ER_UINT
acre_isr(const T_CISR *pk_cisr)
{
	ISRCB	*p_isrcb;
	ISRINIB	*p_isrinib;
	QUEUE	*p_isr_queue;
	ER		ercd;

	LOG_ACRE_ISR_ENTER(pk_cisr);
	CHECK_TSKCTX_UNL();
	CHECK_MACV_READ(pk_cisr, T_CISR);
	CHECK_RSATR(pk_cisr->isratr, TARGET_ISRATR|TA_DOMMASK);
	CHECK_ATRDOMID_KERNEL(get_atrdomid(pk_cisr->isratr));
	CHECK_INTNO_CREISR(pk_cisr->intno);
	CHECK_ALIGN_FUNC(pk_cisr->isr);
	CHECK_NONNULL_FUNC(pk_cisr->isr);
	CHECK_ISRPRI(pk_cisr->isrpri);
	CHECK_ACPTN(sysstat_acvct.acptn3);

	p_isr_queue = search_isr_queue(pk_cisr->intno);
	CHECK_OBJ(p_isr_queue != NULL);

	t_lock_cpu();
	if (tnum_isr == 0 || queue_empty(&free_isrcb)) {
		ercd = E_NOID;
	}
	else {
		p_isrcb = ((ISRCB *) queue_delete_next(&free_isrcb));
		p_isrinib = (ISRINIB *)(p_isrcb->p_isrinib);
		p_isrinib->isratr = pk_cisr->isratr;
		p_isrinib->exinf = pk_cisr->exinf;
		p_isrinib->intno = pk_cisr->intno;
		p_isrinib->p_isr_queue = p_isr_queue;
		p_isrinib->isr = pk_cisr->isr;
		p_isrinib->isrpri = pk_cisr->isrpri;

		p_isrinib->acvct.acptn1 = TACP_KERNEL;
		p_isrinib->acvct.acptn2 = TACP_KERNEL;
		p_isrinib->acvct.acptn3 = TACP_KERNEL | rundom;
		p_isrinib->acvct.acptn4 = TACP_KERNEL;

		enqueue_isr(p_isr_queue, p_isrcb);
		ercd = ISRID(p_isrcb);
	}
	t_unlock_cpu();

  error_exit:
	LOG_ACRE_ISR_LEAVE(ercd);
	return(ercd);
}
Beispiel #8
0
ER_UINT
acre_sem(const T_CSEM *pk_csem)
{
    ID		domid;
    SEMCB	*p_semcb;
    SEMINIB	*p_seminib;
    ACPTN	acptn;
    ER		ercd;

    LOG_ACRE_SEM_ENTER(pk_csem);
    CHECK_TSKCTX_UNL();
    CHECK_MACV_READ(pk_csem, T_CSEM);
    CHECK_RSATR(pk_csem->sematr, TA_TPRI|TA_DOMMASK);
    domid = get_atrdomid(pk_csem->sematr);
    CHECK_ATRDOMID_INACTIVE(domid);
    CHECK_PAR(0 <= pk_csem->isemcnt && pk_csem->isemcnt <= pk_csem->maxsem);
    CHECK_PAR(1 <= pk_csem->maxsem && pk_csem->maxsem <= TMAX_MAXSEM);
    CHECK_ACPTN(sysstat_acvct.acptn3);

    t_lock_cpu();
    if (tnum_sem == 0 || queue_empty(&free_semcb)) {
        ercd = E_NOID;
    }
    else {
        p_semcb = ((SEMCB *) queue_delete_next(&free_semcb));
        p_seminib = (SEMINIB *)(p_semcb->p_seminib);
        p_seminib->sematr = pk_csem->sematr;
        p_seminib->isemcnt = pk_csem->isemcnt;
        p_seminib->maxsem = pk_csem->maxsem;

        acptn = default_acptn(domid);
        p_seminib->acvct.acptn1 = acptn;
        p_seminib->acvct.acptn2 = acptn;
        p_seminib->acvct.acptn3 = acptn | rundom;
        p_seminib->acvct.acptn4 = acptn;

        queue_initialize(&(p_semcb->wait_queue));
        p_semcb->semcnt = p_semcb->p_seminib->isemcnt;
        ercd = SEMID(p_semcb);
    }
    t_unlock_cpu();

error_exit:
    LOG_ACRE_SEM_LEAVE(ercd);
    return(ercd);
}
Beispiel #9
0
ER_UINT
acre_flg(const T_CFLG *pk_cflg)
{
    ID		domid;
    FLGCB	*p_flgcb;
    FLGINIB	*p_flginib;
    ACPTN	acptn;
    ER		ercd;

    LOG_ACRE_FLG_ENTER(pk_cflg);
    CHECK_TSKCTX_UNL();
    CHECK_MACV_READ(pk_cflg, T_CFLG);
    CHECK_RSATR(pk_cflg->flgatr, TA_TPRI|TA_WMUL|TA_CLR|TA_DOMMASK);
    domid = get_atrdomid(pk_cflg->flgatr);
    CHECK_ATRDOMID_INACTIVE(domid);
    CHECK_ACPTN(sysstat_acvct.acptn3);

    t_lock_cpu();
    if (tnum_flg == 0 || queue_empty(&free_flgcb)) {
        ercd = E_NOID;
    }
    else {
        p_flgcb = ((FLGCB *) queue_delete_next(&free_flgcb));
        p_flginib = (FLGINIB *)(p_flgcb->p_flginib);
        p_flginib->flgatr = pk_cflg->flgatr;
        p_flginib->iflgptn = pk_cflg->iflgptn;

        acptn = default_acptn(domid);
        p_flginib->acvct.acptn1 = acptn;
        p_flginib->acvct.acptn2 = acptn;
        p_flginib->acvct.acptn3 = acptn | rundom;
        p_flginib->acvct.acptn4 = acptn;

        queue_initialize(&(p_flgcb->wait_queue));
        p_flgcb->flgptn = p_flgcb->p_flginib->iflgptn;
        ercd = FLGID(p_flgcb);
    }
    t_unlock_cpu();

error_exit:
    LOG_ACRE_FLG_LEAVE(ercd);
    return(ercd);
}
Beispiel #10
0
ER_UINT
acre_mtx(const T_CMTX *pk_cmtx)
{
	MTXCB			*p_mtxcb;
	MTXINIB			*p_mtxinib;
	ATR				mtxatr;
	PRI				ceilpri;
	ID				domid;
	const DOMINIB	*p_dominib;
	ACPTN			acptn;
	ER				ercd;

	LOG_ACRE_MTX_ENTER(pk_cmtx);
	CHECK_TSKCTX_UNL();
	CHECK_MACV_READ(pk_cmtx, T_CMTX);

	mtxatr = pk_cmtx->mtxatr;
	ceilpri = pk_cmtx->ceilpri;

	if ((mtxatr & MTXPROTO_MASK) == TA_CEILING) {
		CHECK_VALIDATR(mtxatr, TA_CEILING|TA_DOMMASK);
		CHECK_PAR(VALID_TPRI(ceilpri));
	}
	else {
		CHECK_VALIDATR(pk_cmtx->mtxatr, TA_TPRI|TA_DOMMASK);
	}
	domid = get_atrdomid(mtxatr);
	if (domid == TDOM_SELF) {
		if (rundom == TACP_KERNEL) {
			domid = TDOM_KERNEL;
		}
		else {
			domid = p_runtsk->p_tinib->domid;
		}
		mtxatr = set_atrdomid(mtxatr, domid);
	}
	switch (domid) {
	case TDOM_KERNEL:
		p_dominib = &dominib_kernel;
		break;
	case TDOM_NONE:
		p_dominib = &dominib_none;
		break;
	default:
		CHECK_RSATR(VALID_DOMID(domid));
		p_dominib = get_dominib(domid);
		break;
	}
	CHECK_ACPTN(p_dominib->acvct.acptn1);

	lock_cpu();
	if (tnum_mtx == 0 || queue_empty(&(p_dominib->p_domcb->free_mtxcb))) {
		ercd = E_NOID;
	}
	else {
		p_mtxcb = (MTXCB *)
					queue_delete_next(&(p_dominib->p_domcb->free_mtxcb));
		p_mtxinib = (MTXINIB *)(p_mtxcb->p_mtxinib);
		p_mtxinib->mtxatr = mtxatr;
		p_mtxinib->ceilpri = INT_PRIORITY(ceilpri);

		acptn = default_acptn(domid);
		p_mtxinib->acvct.acptn1 = acptn;
		p_mtxinib->acvct.acptn2 = acptn;
		p_mtxinib->acvct.acptn3 = p_dominib->acvct.acptn1;
		p_mtxinib->acvct.acptn4 = acptn;

		queue_initialize(&(p_mtxcb->wait_queue));
		p_mtxcb->p_loctsk = NULL;
		ercd = MTXID(p_mtxcb);
	}
	unlock_cpu();

  error_exit:
	LOG_ACRE_MTX_LEAVE(ercd);
	return(ercd);
}
Beispiel #11
0
ER_UINT
acre_mbf(const T_CMBF *pk_cmbf)
{
	MBFCB			*p_mbfcb;
	MBFINIB			*p_mbfinib;
	ATR				mbfatr;
	uint_t			maxmsz;
	size_t			mbfsz;
	void			*mbfmb;
	ID				domid;
	const DOMINIB	*p_dominib;
	ACPTN			acptn;
	ER				ercd;

	LOG_ACRE_MBF_ENTER(pk_cmbf);
	CHECK_TSKCTX_UNL();
	CHECK_MACV_READ(pk_cmbf, T_CMBF);

	mbfatr = pk_cmbf->mbfatr;
	maxmsz = pk_cmbf->maxmsz;
	mbfsz = pk_cmbf->mbfsz;
	mbfmb = pk_cmbf->mbfmb;

	CHECK_VALIDATR(mbfatr, TA_TPRI|TA_DOMMASK);
	if (mbfmb != NULL) {
		CHECK_PAR(MB_ALIGN(mbfmb));
		CHECK_OBJ(valid_memobj_kernel(mbfmb, mbfsz));
	}
	domid = get_atrdomid(mbfatr);
	if (domid == TDOM_SELF) {
		if (rundom == TACP_KERNEL) {
			domid = TDOM_KERNEL;
		}
		else {
			domid = p_runtsk->p_tinib->domid;
		}
		mbfatr = set_atrdomid(mbfatr, domid);
	}
	switch (domid) {
	case TDOM_KERNEL:
		p_dominib = &dominib_kernel;
		break;
	case TDOM_NONE:
		p_dominib = &dominib_none;
		break;
	default:
		CHECK_RSATR(VALID_DOMID(domid));
		p_dominib = get_dominib(domid);
		break;
	}
	CHECK_ACPTN(p_dominib->acvct.acptn1);

	lock_cpu();
	if (tnum_mbf == 0 || queue_empty(&(p_dominib->p_domcb->free_mbfcb))) {
		ercd = E_NOID;
	}
	else {
		if (mbfsz != 0 && mbfmb == NULL) {
			mbfmb = malloc_mpk(mbfsz, p_dominib);
			mbfatr |= TA_MBALLOC;
		}
		if (mbfsz != 0 && mbfmb == NULL) {
			ercd = E_NOMEM;
		}
		else {
			p_mbfcb = (MBFCB *)
						queue_delete_next(&(p_dominib->p_domcb->free_mbfcb));
			p_mbfinib = (MBFINIB *)(p_mbfcb->p_mbfinib);
			p_mbfinib->mbfatr = mbfatr;
			p_mbfinib->maxmsz = maxmsz;
			p_mbfinib->mbfsz = mbfsz;
			p_mbfinib->mbfmb = mbfmb;

			acptn = default_acptn(domid);
			p_mbfinib->acvct.acptn1 = acptn;
			p_mbfinib->acvct.acptn2 = acptn;
			p_mbfinib->acvct.acptn3 = p_dominib->acvct.acptn1;
			p_mbfinib->acvct.acptn4 = acptn;

			queue_initialize(&(p_mbfcb->swait_queue));
			queue_initialize(&(p_mbfcb->rwait_queue));
			p_mbfcb->fmbfsz = mbfsz;
			p_mbfcb->head = 0U;
			p_mbfcb->tail = 0U;
			p_mbfcb->smbfcnt = 0U;
			ercd = MBFID(p_mbfcb);
		}
	}
	unlock_cpu();

  error_exit:
	LOG_ACRE_MBF_LEAVE(ercd);
	return(ercd);
}
Beispiel #12
0
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);
}
Beispiel #13
0
ER_UINT
acre_pdq(const T_CPDQ *pk_cpdq)
{
	ID		domid;
	PDQCB	*p_pdqcb;
	PDQINIB	*p_pdqinib;
	ATR		pdqatr;
	PDQMB	*p_pdqmb;
	ACPTN	acptn;
	ER		ercd;

	LOG_ACRE_PDQ_ENTER(pk_cpdq);
	CHECK_TSKCTX_UNL();
	CHECK_MACV_READ(pk_cpdq, T_CPDQ);
	CHECK_RSATR(pk_cpdq->pdqatr, TA_TPRI|TA_DOMMASK);
	domid = get_atrdomid(pk_cpdq->pdqatr);
	CHECK_ATRDOMID_INACTIVE(domid);
	CHECK_DPRI(pk_cpdq->maxdpri);
	if (pk_cpdq->pdqmb != NULL) {
		CHECK_ALIGN_MB(pk_cpdq->pdqmb);
		CHECK_OBJ(valid_memobj_kernel(pk_cpdq->pdqmb,
									sizeof(PDQMB) * pk_cpdq->pdqcnt));
	}
	CHECK_ACPTN(sysstat_acvct.acptn3);
	pdqatr = pk_cpdq->pdqatr;
	p_pdqmb = pk_cpdq->pdqmb;

	t_lock_cpu();
	if (tnum_pdq == 0 || queue_empty(&free_pdqcb)) {
		ercd = E_NOID;
	}
	else {
		if (pk_cpdq->pdqcnt != 0 && p_pdqmb == NULL) {
			p_pdqmb = kernel_malloc(sizeof(PDQMB) * pk_cpdq->pdqcnt);
			pdqatr |= TA_MBALLOC;
		}
		if (pk_cpdq->pdqcnt != 0 && p_pdqmb == NULL) {
			ercd = E_NOMEM;
		}
		else {
			p_pdqcb = ((PDQCB *) queue_delete_next(&free_pdqcb));
			p_pdqinib = (PDQINIB *)(p_pdqcb->p_pdqinib);
			p_pdqinib->pdqatr = pdqatr;
			p_pdqinib->pdqcnt = pk_cpdq->pdqcnt;
			p_pdqinib->maxdpri = pk_cpdq->maxdpri;
			p_pdqinib->p_pdqmb = p_pdqmb;

			acptn = default_acptn(domid);
			p_pdqinib->acvct.acptn1 = acptn;
			p_pdqinib->acvct.acptn2 = acptn;
			p_pdqinib->acvct.acptn3 = acptn | rundom;
			p_pdqinib->acvct.acptn4 = acptn;

			queue_initialize(&(p_pdqcb->swait_queue));
			queue_initialize(&(p_pdqcb->rwait_queue));
			p_pdqcb->count = 0U;
			p_pdqcb->p_head = NULL;
			p_pdqcb->unused = 0U;
			p_pdqcb->p_freelist = NULL;
			ercd = PDQID(p_pdqcb);
		}
	}
	t_unlock_cpu();

  error_exit:
	LOG_ACRE_PDQ_LEAVE(ercd);
	return(ercd);
}
Beispiel #14
0
ER_UINT
acre_sem(const T_CSEM *pk_csem)
{
	SEMCB			*p_semcb;
	SEMINIB			*p_seminib;
	ATR				sematr;
	uint_t			isemcnt, maxsem;
	ID				domid;
	const DOMINIB	*p_dominib;
	ACPTN			acptn;
	ER				ercd;

	LOG_ACRE_SEM_ENTER(pk_csem);
	CHECK_TSKCTX_UNL();
	CHECK_MACV_READ(pk_csem, T_CSEM);

	sematr = pk_csem->sematr;
	isemcnt = pk_csem->isemcnt;
	maxsem = pk_csem->maxsem;

	CHECK_VALIDATR(sematr, TA_TPRI|TA_DOMMASK);
	CHECK_PAR(0 <= isemcnt && isemcnt <= maxsem);
	CHECK_PAR(1 <= maxsem && maxsem <= TMAX_MAXSEM);
	domid = get_atrdomid(sematr);
	if (domid == TDOM_SELF) {
		if (rundom == TACP_KERNEL) {
			domid = TDOM_KERNEL;
		}
		else {
			domid = p_runtsk->p_tinib->domid;
		}
		sematr = set_atrdomid(sematr, domid);
	}
	switch (domid) {
	case TDOM_KERNEL:
		p_dominib = &dominib_kernel;
		break;
	case TDOM_NONE:
		p_dominib = &dominib_none;
		break;
	default:
		CHECK_RSATR(VALID_DOMID(domid));
		p_dominib = get_dominib(domid);
		break;
	}
	CHECK_ACPTN(p_dominib->acvct.acptn1);

	lock_cpu();
	if (tnum_sem == 0 || queue_empty(&(p_dominib->p_domcb->free_semcb))) {
		ercd = E_NOID;
	}
	else {
		p_semcb = (SEMCB *)
					queue_delete_next(&(p_dominib->p_domcb->free_semcb));
		p_seminib = (SEMINIB *)(p_semcb->p_seminib);
		p_seminib->sematr = sematr;
		p_seminib->isemcnt = isemcnt;
		p_seminib->maxsem = maxsem;

		acptn = default_acptn(domid);
		p_seminib->acvct.acptn1 = acptn;
		p_seminib->acvct.acptn2 = acptn;
		p_seminib->acvct.acptn3 = p_dominib->acvct.acptn1;
		p_seminib->acvct.acptn4 = acptn;

		queue_initialize(&(p_semcb->wait_queue));
		p_semcb->semcnt = isemcnt;
		ercd = SEMID(p_semcb);
	}
	unlock_cpu();

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