コード例 #1
0
ファイル: hashLib.c プロジェクト: andy345/vxworks5
STATUS hashTblInit
    (
    HASH_TBL    *pHashTbl,      /* pointer to hash table to initialize */
    SL_LIST     *pTblMem,       /* pointer to memory of sizeLog2 SL_LISTs */
    int         sizeLog2,       /* number of elements in hash table log 2 */
    FUNCPTR     keyCmpRtn,      /* function to test keys for equivalence */
    FUNCPTR     keyRtn,         /* hashing function to generate hash from key */
    int         keyArg          /* argument to hashing function */
    )
    {
    FAST int ix;

    pHashTbl->elements	= 1 << sizeLog2;	/* store number of elements */
    pHashTbl->keyCmpRtn	= keyCmpRtn;		/* store comparator routine */
    pHashTbl->keyRtn	= keyRtn;		/* store hashing function */
    pHashTbl->keyArg	= keyArg;		/* store hashing function arg */
    pHashTbl->pHashTbl	= pTblMem;

    /* initialize all of the linked list heads in the table */

    for (ix = 0; ix < pHashTbl->elements; ix++)
	sllInit (&pHashTbl->pHashTbl [ix]);

    objCoreInit (&pHashTbl->objCore, hashClassId);	/* initialize core */

    return (OK);
    }
コード例 #2
0
ファイル: vmLib.c プロジェクト: phoboz/vmx
STATUS vmContextInit(
    VM_CONTEXT_ID context
    )
{
    STATUS status;

    if (vmLibInstalled != TRUE)
    {
        errnoSet(S_vmLib_NOT_INSTALLED);
        status = ERROR;
    }
    else
    {
        context->mmuTransTable = MMU_TRANS_TABLE_CREATE();
        if (context->mmuTransTable == NULL)
        {
            status = ERROR;
        }
        else
        {
            semMInit(&context->sem, vmMutexOptions);
            objCoreInit(&context->objCore, vmContextClassId);
            status = OK;
        }
    }

    return status;
}
コード例 #3
0
ファイル: wdLib.c プロジェクト: andy345/vxworks5
STATUS wdInit
(
    WDOG *pWdog         /* pointer to watchdog to initialize */
)
{
    if ((!wdLibInstalled) && (wdLibInit () != OK))
        return (ERROR);				/* package init problem */

    pWdog->status        = WDOG_OUT_OF_Q;	/* initially out of q */
    pWdog->deferStartCnt = 0;			/* no pending starts */

#ifdef WV_INSTRUMENTATION
    /* windview - connect instrumented class for level 1 event logging */
    if (wvObjIsEnabled)
        objCoreInit (&pWdog->objCore, wdInstClassId);
    else
#endif
        objCoreInit (&pWdog->objCore, wdClassId);	/* initialize core */

    return (OK);
}
コード例 #4
0
STATUS semQueueInit
    (
    SEMAPHORE * pSemaphore,             /* pointer to semaphore to init */
    int         options,                /* semaphore options */
    int         initialCount            /* initial count */
    )
    {
    if ((options & ~(SEM_CNT_OPTIONS_MASK)) != 0)
	{
	/* coverity[NULL_RETURNS] */
	errno = S_semLib_INVALID_OPTION;
	return (ERROR);
	}

    if (initialCount < 0)
	{
	/* coverity[NULL_RETURNS] */
	errno = S_semLib_INVALID_INITIAL_COUNT;
	return (ERROR);
	}

    if (semQInit (pSemaphore, options) != OK)		/* initialize queue */
	return (ERROR);

    pSemaphore->semCount = (unsigned int)initialCount;		/* initialize count */
    pSemaphore->recurse  = 0;				/* no recursive takes */
    pSemaphore->options  = options;			/* stow away options *//*lint !e734*/
    pSemaphore->semType  = SEM_TYPE_COUNTING;		/* type is counting */

    /* initialize the events structure */

    pSemaphore->events.taskId     = (int)NULL;
    pSemaphore->events.registered = 0x0;
    pSemaphore->events.options    = 0x0;

#ifdef _WRS_CONFIG_OBJECT_LIB
    /* initialize the semaphore object core information */

    objCoreInit (&pSemaphore->objCore, semClassId);
#else
    /*
     * Make the pObjClass point to a unique class structure. The class
     * structure itself is uninitialized without objLib being present.
     * By having a unique value, it is ensured that all semaphores have
     * the same unique pObjClass value.
     */

    pSemaphore->objCore.pObjClass = semClassId;
#endif	/* _WRS_CONFIG_OBJECT_LIB */

    return (OK);
    }	
コード例 #5
0
void memPartInit(PART_ID partId, char* pPool, unsigned poolSize)
{
	memset((void*)partId, 0, sizeof(*partId));

	partId->options = memPartDefaultOption;
	partId->minBlockWords = sizeof (FREE_BLOCK) >> 1;	/* word not byte */

	(* memPartSemInitRtn) (partId);
	
	dllInit(&partId->freeList);
	
	objCoreInit(&partId->objCore, memPartClassId);
	
	memPartAddToPool(partId, pPool, poolSize);
}
コード例 #6
0
ファイル: memPartLib.c プロジェクト: andy345/vxworks5
void memPartInit 
    (
    FAST PART_ID partId,        /* partition to initialize */
    char *pPool,                /* pointer to memory block */
    unsigned poolSize           /* block size in bytes */
    )
    {
    /* initialize partition descriptor */

    bfill ((char *) partId, sizeof (*partId), 0);

    partId->options	  = memPartOptionsDefault;
    partId->minBlockWords = sizeof (FREE_BLOCK) >> 1;

    /* initialize partition semaphore with a virtual function so semaphore
     * type is selectable.  By default memPartLibInit() will utilize binary
     * semaphores while memInit() will utilize mutual exclusion semaphores
     * with the options stored in _mutexOptionsMemLib.
     */

    (* memPartSemInitRtn) (partId);

    dllInit (&partId->freeList);			/* init. free list */

#ifdef WV_INSTRUMENTATION
    if (wvObjIsEnabled)
    {
    /* windview - connect object class event logging routine */
    objCoreInit (&partId->objCore, memPartInstClassId); 
    }
    else
#endif
    objCoreInit (&partId->objCore, memPartClassId);	/* initialize core */

    (void) memPartAddToPool (partId, pPool, poolSize);
    }
コード例 #7
0
STATUS msgQInit(FAST MSG_Q* pMsgQ, int maxMsgs, int maxMsgLength, int options, void* pMsgPool)
{
	FAST int nodeSize = MSG_NODE_SIZE(maxMsgLength);
	FAST int ix;
	FAST QUEUE_ID msgQType;

	if ((!msgQLibInstalled) && (msgQLibInit () != OK))
	{
		return (ERROR); 			/* package init problem */
	}

	memset((char*)pMsgQ, 0, sizeof(*pMsgQ));

	switch(options & MSG_Q_TYPE_MASK)
	{
	case MSG_Q_FIFO:
		msgQType = Q_FIFO;
		break;
	case MSG_Q_PRIORITY:
		msgQType = Q_PRI_LIST;
		break;
	default:
		msgQType = Q_FIFO;
		break;
	}

	if((qInit(&pMsgQ->msgQ, qJobClassId, msgQType, 2,3,4,5) != OK) ||
		(qInit(&pMsgQ->freeQ, qJobClassId, msgQType, 2,3,4,5) != OK))
	{
		return (ERROR);
	}

	for(ix = 0; ix < maxMsgs; ix++)
	{
		qJobPut(pMsgQ, &pMsgQ->freeQ, (Q_JOB_NODE*)pMsgPool, Q_JOB_PRI_DONT_CARE);
		pMsgPool = (void*)((char*)pMsgPool + nodeSize);
	}

	/*printf("pMsgQ->freeQ.first:0x%x\n", pMsgQ->freeQ.first);*/

	pMsgQ->options = options;
	pMsgQ->maxMsgs = maxMsgs;
	pMsgQ->maxMsgLength = maxMsgLength;

	objCoreInit(&pMsgQ->objCore, msgQClassId);

	return (OK);
}
コード例 #8
0
ファイル: semBLib.c プロジェクト: phoboz/vmx
LOCAL STATUS semBCoreInit(
    SEM_ID      semId,
    int         options,
    SEM_B_STATE state
    )
{
    STATUS status;

    if (options & SEM_DELETE_SAFE)
    {
        errnoSet(S_semLib_INVALID_OPTION);
        status = ERROR;
    }
    else
    {
        /* Setup state */
        switch(state)
        {
            case SEM_EMPTY:
                SEM_OWNER_SET(semId, taskIdCurrent);
                status = OK;
                break;

            case SEM_FULL:
                SEM_OWNER_SET(semId, NULL);
                status = OK;
                break;

            default: 
                errnoSet(S_semLib_INVALID_OPTION);
                status = ERROR;
        }

        if (status == OK)
        {
            /* Initialize variables */
            semId->recurse = 0;
            semId->options = options;
            semId->semType = SEM_TYPE_BINARY;

            /* Initialize object core */
            objCoreInit(&semId->objCore, semClassId);
        }
    }

    return status;
}
コード例 #9
0
ファイル: wdLib.c プロジェクト: phoboz/vmx
STATUS wdInit(
    WDOG_ID wdId
    )
{
    STATUS status;

    if (wdLibInstalled != TRUE)
    {
        status = ERROR;
    }
    else
    {
        wdId->status        = WDOG_OUT_OF_Q;
        wdId->dfrStartCount = 0;

        objCoreInit(&wdId->objCore, wdClassId);
        status = OK;
    }

    return status;
}
コード例 #10
0
static STATUS semBCoreInit(SEMAPHORE* pSemaphore, int options, SEM_B_STATE initialState)
{
	switch(initialState)
	{
	case SEM_EMPTY:
		pSemaphore->semOwner = taskCurrent;
		break;
	case SEM_FULL:
		pSemaphore->semOwner = NULL;
		break;
	default:
		return (ERROR);
	}

	pSemaphore->recurse = 0;
	pSemaphore->options = options;
	pSemaphore->semType = SEM_TYPE_BINARY;

	objCoreInit(&pSemaphore->objCore, semClassId);

	return (OK);
}
コード例 #11
0
ファイル: taskLib.c プロジェクト: phoboz/vmx
STATUS taskInit(
    TCB_ID      tcbId,
    const char *name,
    unsigned    priority,
    int         options,
    char       *pStackBase,
    unsigned    stackSize,
    FUNCPTR     func,
    ARG         arg0,
    ARG         arg1,
    ARG         arg2,
    ARG         arg3,
    ARG         arg4,
    ARG         arg5,
    ARG         arg6,
    ARG         arg7,
    ARG         arg8,
    ARG         arg9
    )
{
    static unsigned new_id;

    STATUS status;
    int    i;
    int    len;
    char  *taskName;
    ARG    args[MAX_TASK_ARGS];

    if (INT_RESTRICT() != OK)
    {
        errnoSet(S_intLib_NOT_ISR_CALLABLE);
        status = ERROR;
    }
    else
    {
        /* Check if task lib is installed */
        if (taskLibInstalled != TRUE)
        {
            errnoSet(S_taskLib_NOT_INSTALLED);
            status = ERROR;
        }
        else
        {
            /* Copy args to array */
            args[0] = arg0;
            args[1] = arg1;
            args[2] = arg2;
            args[3] = arg3;
            args[4] = arg4;
            args[5] = arg5;
            args[6] = arg6;
            args[7] = arg7;
            args[8] = arg8;
            args[9] = arg9;

            /* Task entry point */
            tcbId->entry = func;

            /* Setup errno */
            tcbId->errno = 0;

            /* Set unique id */
            tcbId->id = new_id++;

            /* Set initial status as suspended */
            tcbId->status    = TASK_SUSPEND;
            tcbId->lockCount = 0;

            /* Zero swap mask */
            tcbId->swapInMask  = 0;
            tcbId->swapOutMask = 0;

            /* Name and options */
            tcbId->priority = priority;
            tcbId->options  = options;

            /* Round robin time slice */
            tcbId->timeSlice   = 0;

            /* Pending queue, used by semaphores */
            tcbId->pPendQ = NULL;

            /* Zero unpend callback */
            tcbId->objUnpendHandler = NULL;
            tcbId->pObj             = NULL;
            tcbId->objInfo          = 0;

            /* Initialize safety */
            tcbId->safeCount = 0;
            qInit(
                &tcbId->safetyQ,
                qPrioClassId,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0,
                (ARG) 0);

            /* Setup error status and exit code */
            tcbId->errorStatus = OK;
            tcbId->exitCode    = 0;

            /* Task variables */
            tcbId->pTaskVar = NULL;

            /* Exception info */
            tcbId->pExcRegSet    = NULL;
            tcbId->excInfo.valid = 0;

            /* Setup stack */
            tcbId->pStackBase  = pStackBase;
            tcbId->pStackLimit = tcbId->pStackBase + stackSize * _STACK_DIR;
            tcbId->pStackEnd   = tcbId->pStackLimit;

            if ((options & TASK_OPTIONS_NO_STACK_FILL) == 0)
            {
#if (_STACK_DIR == _STACK_GROWS_DOWN)
                memset(tcbId->pStackLimit, 0xee, stackSize);
#else /* _STACK_GROWS_UP */
                memset(tcbId->stackBase, 0xee, stackSize);
#endif /* _STACK_DIR */
            }

            /* Initialize standard file desriptors */
            for (i = 0; i < 3; i++)
            {
                tcbId->taskStd[i]   = i;
                tcbId->taskStdFp[i] = NULL;
            }

            /* Initialize posix related fields */
            tcbId->pSignalInfo     = NULL;
            tcbId->selectContextId = NULL;

            /* Environment */
            tcbId->ppEnviron = NULL;

            /* Initialize architecutre depedent stuff */
            taskRegsInit(tcbId, pStackBase);

            /* Push args on task stack */
            taskArgSet(tcbId, pStackBase, args);

            /* Object core */
            objCoreInit(&tcbId->objCore, taskClassId);

            /* Copy name if not unnamed */
            if (name != NULL)
            {
                len = strlen(name) + 1;

                taskName = (char *) taskStackAllot((int) tcbId, len);
                if (taskName != NULL)
                {
                    strcpy(taskName, name);
                }

                tcbId->name = taskName;
            }
            else
            {
                tcbId->name = NULL;
            }

            /* Run create hooks */
            for (i = 0; i < MAX_TASK_CREATE_HOOKS; i++)
            {
                if (taskCreateHooks[i] != NULL)
                {
                    (*taskCreateHooks[i])(tcbId);
                }
            }

            /* Set task as active */
            vmxSpawn(tcbId);
            status = OK;
        }
    }

    return status;
}