예제 #1
0
/*
 *  ======== Swi_restore ========
 */
Void Swi_restore(UInt swiKey)
{
    if (swiKey == FALSE) {

        if (Core_getId() != 0) {
            Swi_restoreSMP();
            return;
        }

        Core_hwiDisable();

        if (Swi_module->curSet) {
            Hwi_enable();
            Swi_schedule();     /* sets locked to FALSE */
        }
        else {
            Swi_module->locked = FALSE;

            if (BIOS_taskEnabled) {
                TASK_RESTORE(TASK_DISABLE()); /* required for Swi's posted from Tasks */
            }
            else {
                Hwi_enable();
            }
        }
    }
}
예제 #2
0
/*
 *  ======== Task_allBlockedFunction ========
 */
Void Task_allBlockedFunction()
{
    volatile UInt delay;

    if (Task_allBlockedFunc == Idle_run) {
        Hwi_enable();
        Idle_run();
        Hwi_disable();
    }
    else if (Task_allBlockedFunc == NULL) {
        Hwi_enable();
        /* Guarantee that interrupts are enabled briefly */
        for (delay = 0; delay < 1; delay++) {
           ;
        }
        Hwi_disable();
    }
    else {
        Task_allBlockedFunc();
        /*
         * disable ints just in case the
         * allBlockedFunc left them enabled
         */
        Hwi_disable();
    }
}
예제 #3
0
파일: Hwi.c 프로젝트: andreimironenko/bios
Void Hwi_handlerNONE(Hwi_Object *hwi, UInt intNum)
{
    Int32 nestingLevel;

    /* remember old nesting priority level */
    nestingLevel = Hwi_cpIntc.HINLR[1];

    /* forcibly unmask all channels/priorities */
    Hwi_cpIntc.HINLR[1] = 0x80000020;

    /* clear the interrupt status for this int */
    Hwi_cpIntc.SICR = intNum;

    /* re-enable IRQ */
    Hwi_cpIntc.HIEISR = 1;
    
    Hwi_enable();

    (hwi->fxn)(hwi->arg);

    Hwi_disable();

    /* disable IRQ */
    Hwi_cpIntc.HIDISR = 1;

    /* restore previous nesting level */
    Hwi_cpIntc.HINLR[1] = nestingLevel | 0x80000000;
 
    /* re-enable IRQ */
    Hwi_cpIntc.HIEISR = 1;
}
예제 #4
0
/*
 *  ======== Swi_restoreSMP ========
 *  Only called when coreId != 0
 */
Void Swi_restoreSMP()
{
    UInt tskKey;

    /* make Core 0 process the Swis */
    if (Swi_module->curSet) {
        Core_interruptCore(0);
    }

    if (BIOS_taskEnabled) {
        tskKey = TASK_DISABLE();    /* required for Swi's posted from Tasks */

        /* release our hold on the Swi scheduler */
        Swi_module->locked = FALSE;

        /* run task scheduler if its unlocked */
        TASK_RESTORE(tskKey);
    }
    else {
        /* release our hold on the Swi scheduler */
        Swi_module->locked = FALSE;

        /* release the Inter-core Gate */
        Hwi_enable();
    }
}
예제 #5
0
/*
 *  ======== Timer_periodicNestStub ========
 */
Void Timer_periodicNestStub(UArg arg)
{
    Timer_Object *obj;
    ti_catalog_msp430_peripherals_timers_TimerRegs *timer;

    obj = Timer_module->handles[(UInt)arg];

    timer = (ti_catalog_msp430_peripherals_timers_TimerRegs *)
        Timer_module->device[obj->id].baseAddr;

    /* save previous threshold value */
    obj->prevThreshold = timer->cc_compare_0;

    /* set compare threshold for next periodic interrupt */
    timer->cc_compare_0 += obj->period;

    /* allow nesting of other interrupts ... */
    timer->cctl_0 &= ~TIMER_COMPARE_INTR_ENABLE;
    Hwi_enable();

    /* call the tick function */
    obj->tickFxn(obj->arg);

    /* disable interrupts as unwind the ISR */
    Hwi_disable();
    timer->cctl_0 |= TIMER_COMPARE_INTR_ENABLE;
}
/**
 *  @b Description
 *  @n  
 *      The function is used to clean up a previously allocated data buffer 
 *      block. All data buffers are in the global address space
 *
 *  @param[in]  ptr
 *      Pointer to the data buffer block to be cleaned up
 *  @param[in]  size
 *      Size of the data buffer
 *
 *  @retval
 *      Not Applicable
 */
void Osal_srioDataBufferFree(void* ptr, uint32_t numBytes)
{
    uint32_t    index;

    /* Increment the free counter. */
    free_counter++;	

    /* Lock out interrupts */
    Hwi_disable();

    /* Cycle through and clean up */
    for (index = 0; index < MAX_MEM_MGR_ENTRIES; index++)
    {
        /* Check if the entry is free or not? */
        if (gDataBufferMemMgr[index].ptrMemory == (uint8_t*)ptr) 
        {
            /* Mark the entry as free. */
            gDataBufferMemMgr[index].isFree = 1;

            /* We have found a match. */
            break;
        }
    }

    /* Unlock interrupts. */
    Hwi_enable();
    return;
}
예제 #7
0
파일: Hwi.c 프로젝트: andreimironenko/bios
Void Hwi_handlerLOWER(Hwi_Object *hwi, UInt intNum)
{
    Int32 nestingLevel;

    /* remember old nesting priority level */
    nestingLevel = Hwi_cpIntc.HINLR[1];

    /* internally set the current nesting level */
    Hwi_cpIntc.HINLR[1] = 0;

    /* clear the interrupt status for this int */
    Hwi_cpIntc.SICR = intNum;

    /* re-enable IRQs */
    Hwi_cpIntc.HIEISR = 1;
    
    Hwi_enable();

    (hwi->fxn)(hwi->arg);

    Hwi_disable();

    /* disable IRQs */
    Hwi_cpIntc.HIDISR = 1;

    /* restore previous nesting level */
    Hwi_cpIntc.HINLR[1] = nestingLevel | 0x80000000;
 
    /* re-enable IRQ */
    Hwi_cpIntc.HIEISR = 1;
}
예제 #8
0
/*
 *  ======== Task_enter ========
 *  Here on task's first invocation.
 *
 *  Unlock the Task Scheduler to enter task as though we
 *  returned through Task_restore()
 */
Void Task_enter()
{
    if (Task_module->workFlag) {
        Task_schedule();
    }
    Task_module->locked = FALSE;
    Hwi_enable();
}
예제 #9
0
/*
 *  ======== Swi_run ========
 *  Set up and run Swi.
 *  Enter with Hwi's disabled
 *  Calls Swi function with interrupts enabled
 *  Exits with Hwi's enabled
 *  When no Swis are running, curQ is NULL
 */
Void Swi_run(Swi_Object *swi)
{
    UInt saved_curTrigger = Swi_module->curTrigger;
    Swi_Object *saved_curSwi = Swi_module->curSwi;
    Queue_Handle saved_curQ = Swi_module->curQ;
    BIOS_ThreadType prevThreadType;
#ifndef ti_sysbios_knl_Swi_DISABLE_ALL_HOOKS
    Int i;
#endif

    Swi_module->curQ = swi->readyQ;
    Swi_module->curSwi = swi;
    Swi_module->curTrigger = swi->trigger;

    swi->trigger = swi->initTrigger;
    swi->posted = FALSE;

    Swi_module->locked = FALSE; /* unlock the scheduler while */
                                /* Swi is running  */

    /* set thread type to Swi */
    prevThreadType = BIOS_setThreadType(BIOS_ThreadType_Swi);

    Hwi_enable();

#ifndef ti_sysbios_knl_Swi_DISABLE_ALL_HOOKS
    for (i = 0; i < Swi_hooks.length; i++) {
        if (Swi_hooks.elem[i].beginFxn != NULL) {
            Swi_hooks.elem[i].beginFxn(swi);
        }
    }
#endif

    Log_write3(Swi_LM_begin, (UArg)swi, (UArg)swi->fxn, (UArg)prevThreadType);

    (swi->fxn)(swi->arg0, swi->arg1);

    Log_write1(Swi_LD_end, (UArg)swi);

#ifndef ti_sysbios_knl_Swi_DISABLE_ALL_HOOKS
    for (i = 0; i < Swi_hooks.length; i++) {
        if (Swi_hooks.elem[i].endFxn != NULL) {
            Swi_hooks.elem[i].endFxn(swi);
        }
    }
#endif

    Hwi_disable();

    /* restore thread type */
    BIOS_setThreadType(prevThreadType);

    Swi_module->locked = TRUE;       /* relock the scheduler */

    Swi_module->curQ = saved_curQ;
    Swi_module->curSwi = saved_curSwi;
    Swi_module->curTrigger = saved_curTrigger;
}
예제 #10
0
파일: Task.c 프로젝트: andreimironenko/bios
/*
 *  ======== Task_startup ========
 */
Void Task_startup()
{
    Queue_Handle maxQ;
    Task_Object *prevTask;
    Task_Struct dummyTask;
    Int i;

    Hwi_disable();      /* re-enabled in Task_enter of first task */

    /* Use dummyTask as initial task to swap from */
    prevTask = Task_handle(&dummyTask);

    /* stall until a task is ready */
    while (Task_module->curSet == 0) {
        Task_allBlockedFunc();
    }

    /* Determine current max ready Task priority */
    maxQ = (Queue_Handle)((UInt8 *)(Task_module->readyQ) + 
                (UInt)(Intrinsics_maxbit(Task_module->curSet)*(2*sizeof(Ptr))));

    Task_module->curQ = maxQ;
    Task_module->curTask = Queue_head(maxQ);

    /* we've done the scheduler's work */
    Task_module->workFlag = 0;

    /* Signal that we are entering task thread mode */
    BIOS_setThreadType(BIOS_ThreadType_Task);
        
    /* should be safe to enable intrs here */
    Hwi_enable();

#ifndef ti_sysbios_knl_Task_DISABLE_ALL_HOOKS
    /* Run switch hooks for first real Task */
    for (i = 0; i < Task_hooks.length; i++) {
        if (Task_hooks.elem[i].switchFxn != NULL) {
            Task_hooks.elem[i].switchFxn(NULL, Task_module->curTask);
        }
    }
#endif

    Log_write4(Task_LM_switch, (UArg)0, (UArg)0, 
               (UArg)Task_module->curTask, 
               (UArg)Task_module->curTask->fxn);

    /* must leave this function with ints disabled */
    Hwi_disable();

    /* inform dispatcher that we're running on task stack */
    Hwi_switchFromBootStack();  

    /* start first task by way of enter() */
    Task_SupportProxy_swap((Ptr)&prevTask->context,
                (Ptr)&Task_module->curTask->context);
}
예제 #11
0
/*
 *  ======== Task_schedule ========
 *  Find highest priority task and invoke it.
 *
 *  Must be called with interrupts disabled.
 */
Void Task_schedule()
{
    Queue_Handle maxQ;
    Task_Object *prevTask;
    Task_Object *curTask;
#ifndef ti_sysbios_knl_Task_DISABLE_ALL_HOOKS
    Int i;
#endif

    do {
        Task_module->workFlag = 0;

        /* stall until a task is ready */
        while (Task_module->curSet == 0) {
            Task_allBlockedFunction();
        }

        /* Determine current max ready Task priority */
        maxQ = (Queue_Handle)((UInt8 *)(Task_module->readyQ) +
                (UInt)(Intrinsics_maxbit(Task_module->curSet)*(2*sizeof(Ptr))));

        /* if a higher priority task is ready - switch to it */
        if (maxQ > Task_module->curQ) {
            prevTask = Task_module->curTask;
            Task_module->curQ = maxQ;
            Task_module->curTask = Queue_head(maxQ);
            curTask = Task_module->curTask;

            if (Task_checkStackFlag) {
                Task_checkStacks(prevTask, curTask);
            }
	
#if !defined(ti_sysbios_knl_Task_DISABLE_ALL_HOOKS) \
    || (xdc_runtime_Log_DISABLE_ALL == 0)
            /* It's safe to enable intrs here */
            Hwi_enable();

#ifndef ti_sysbios_knl_Task_DISABLE_ALL_HOOKS
            for (i = 0; i < Task_hooks.length; i++) {
                if (Task_hooks.elem[i].switchFxn != NULL) {
                    Task_hooks.elem[i].switchFxn(prevTask, curTask);
                }
            }
#endif

            Log_write4(Task_LM_switch, (UArg)prevTask, (UArg)prevTask->fxn,
                       (UArg)curTask, (UArg)curTask->fxn);

            /* Hard-disable intrs - this fxn is called with them disabled */
            Hwi_disable();
#endif
            Task_SupportProxy_swap((Ptr)&prevTask->context,
                            (Ptr)&curTask->context);
        }
    } while (Task_module->workFlag);
}
예제 #12
0
/*
 *  ======== Task_restore ========
 */
Void Task_restore(UInt tskKey)
{
    if (tskKey == FALSE) {
        Hwi_disable();
        if (Task_module->workFlag
            && (!BIOS_swiEnabled || (BIOS_swiEnabled && Swi_enabled()))) {
            Task_schedule();
        }
        Task_module->locked = FALSE;
        Hwi_enable();
    }
}
예제 #13
0
파일: Task.c 프로젝트: andreimironenko/bios
/*
 *  ======== Task_allBlockedFunction ========
 */
Void Task_allBlockedFunction()
{
    volatile UInt delay;

    Hwi_enable();

    /* Guarantee that interrupts are enabled briefly */
    for (delay = 0; delay < 1; delay++) {
        ;
    }

    Hwi_disable();
}
예제 #14
0
/*
 *  ======== Timer_oneShotNestStub ========
 */
Void Timer_oneShotNestStub(UArg arg)
{
    Timer_Object *obj;
    obj = Timer_module->handles[(UInt)arg];

    /* stop the timer (and disable this interrupt source) */
    Timer_stop(obj);

    /* enable interrupts to allow nesting */ 
    Hwi_enable();            

    /* call the tick function */
    obj->tickFxn(obj->arg);

    /* disable interrupts as unwind the ISR */
    Hwi_disable();           
}
/**
 *  @b Description
 *  @n  
 *      The function is called to end the critical section access of shared resources
 *      from single cores.
 *
 *  @param[in]  drvHandle
 *      Driver Handle which needed critical section to protect its resources.
 *  @param[in]  critSectHandle
 *      Opaque handle retreived when the Single Core Protection Enter API was called
 *
 *  @retval
 *      Not Applicable.
 */
Void Osal_srioExitSingleCoreCriticalSection(Void* critSectHandle)
{
    /* In the Test code; we have 2 driver instances 
     *  - Driver Managed 
     *      This configuration uses interrupts and calls the SRIO Driver API's
     *      from 2 contexts (Thread and ISR)
     *  - Application Managed 
     *      This configuration uses polled mode only and thus there is only 
     *      one context from which the SRIO Driver API's are called from */
    if (critSectHandle == hDrvManagedSrioDrv)
    {
        /* Driver Managed Configuration: We need to enable interrupts. */
        Hwi_enable();
    }
    else
    {
        /* Application Managed Configuration: This is a NOP. */
        return; 
    }
}
/**
 *  @b Description
 *  @n  
 *      The function is used to allocate a data buffer of the specified
 *      size. Data buffers should always be allocated from the global
 *      address space.
 *
 *  @param[in]  numBytes
 *      Number of bytes to be allocated.
 *
 *  @retval
 *      Allocated block address
 */
Void* Osal_srioDataBufferMalloc(UInt32 numBytes)
{
    uint32_t    index;
    void*       ptrMemory = NULL;

    /* Basic Validation: Ensure that the memory size requested is within range. */
    if (numBytes > gDataBufferMemMgrMaxSize)
        return NULL;

    /* Increment the allocation counter. */
    malloc_counter++;

    /* Lock out interrupts */
    Hwi_disable();

    /* Cycle through for a free entry. */
    for (index = 0; index < MAX_MEM_MGR_ENTRIES; index++)
    {
        /* Check if the entry is free or not? */
        if (gDataBufferMemMgr[index].isFree == 1) 
        {
            /* Entry was free. We can use it. */
            ptrMemory = gDataBufferMemMgr[index].ptrMemory;

            /* Mark the entry as used. */
            gDataBufferMemMgr[index].isFree = 0;

            /* We have found a match. */
            break;
        }
    }

    /* Unlock interrupts. */
    Hwi_enable();

    /* Return the allocated memory. */
    return ptrMemory;	
}
예제 #17
0
파일: Hwi.c 프로젝트: andreimironenko/bios
/*
 *  ======== Hwi_dispatchIRQC ========
 *  Configurable IRQ interrupt dispatcher.
 */
Void Hwi_dispatchIRQC(Hwi_Irp irp)
{
    /*
     * Enough room is reserved above the isr stack to handle
     * as many as 16 32-bit stack resident local variables.
     * If the dispatcher requires more than this, you must
     * handle this in Hwi_Module_startup().
     */

    Hwi_Object *hwi;
    BIOS_ThreadType prevThreadType;
    UInt intNum;
    Char *oldTaskSP;
    UInt32 oldREQENASET0, oldREQENASET1;
    Int tskKey;
    Int swiKey;
    Int i;

    /* save irp somewhere that survives the stack switch */
    Hwi_module->irp = irp;

    if (Hwi_dispatcherTaskSupport) {
        tskKey = TASK_DISABLE();
        /* 
         * If this is a non-nested interrupt,
         * tskkey is saved on the task stack.
         * It must not be referenced again until
         * switching back to the task stack!!!!
         * All other local variables will be
         * on the isr stack.
         */
    }

    /* 
     * Switch to Hwi stack if not already on it.
     * This step, and the corresponding switch back to the task
     * stack are performed outside the "if (Hwi_dispatcherTaskSupport)"
     * conditionals because sometimes the generated code placed a copy
     * of Hwi_dispatcherTaskSupport on the task stack for use below.
     */
    oldTaskSP = Hwi_switchToIsrStack();

    /* 
     * all references to local variables beyond this point
     * will be on the isr stack
     */

    intNum = Hwi_vim.IRQINDEX - 1;

    /* ack this interrupt */
    Hwi_clearInterrupt(intNum);

    hwi = Hwi_module->dispatchTable[intNum];

    hwi->irp = Hwi_module->irp;

    if (Hwi_dispatcherSwiSupport) {
        swiKey = SWI_DISABLE();
    }

    /* set thread type to Hwi */
    prevThreadType = BIOS_setThreadType(BIOS_ThreadType_Hwi);

#ifndef ti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS
    /* call the begin hooks */
    for (i = 0; i < Hwi_hooks.length; i++) {
        if (Hwi_hooks.elem[i].beginFxn != NULL) {
            Hwi_hooks.elem[i].beginFxn((IHwi_Handle)hwi);
        }
    }
#endif

    Log_write5(Hwi_LM_begin, (IArg)hwi, (IArg)hwi->fxn, 
               (IArg)prevThreadType, (IArg)intNum, hwi->irp);

    /* call the user's isr */
    if (Hwi_dispatcherAutoNestingSupport) {
        oldREQENASET0 = Hwi_vim.REQENASET[0];
        Hwi_vim.REQENACLR[0] = hwi->disableMask0;
        oldREQENASET1 = Hwi_vim.REQENASET[1];
        Hwi_vim.REQENACLR[1] = hwi->disableMask1;
        Hwi_enable();

        (hwi->fxn)(hwi->arg);

        Hwi_disable();
        Hwi_vim.REQENASET[0] = (hwi->restoreMask0 & oldREQENASET0);
        Hwi_vim.REQENASET[1] = (hwi->restoreMask1 & oldREQENASET1);
    }
    else {
        (hwi->fxn)(hwi->arg);
    }

    Log_write1(Hwi_LD_end, (IArg)hwi);

#ifndef ti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS
    /* call the end hooks */
    for (i = 0; i < Hwi_hooks.length; i++) {
        if (Hwi_hooks.elem[i].endFxn != NULL) {
            Hwi_hooks.elem[i].endFxn((IHwi_Handle)hwi);
        }
    }
#endif

    /* Run Swi scheduler */
    if (Hwi_dispatcherSwiSupport) {
        SWI_RESTORE(swiKey);
    }

    /* restore thread type */
    BIOS_setThreadType(prevThreadType);

    /* 
     * Switch back to Task stack if at bottom of Hwi stack
     * While it seems that this step should be placed in the
     * "if (Hwi_dispatcherTaskSupport)" conditional below,
     * some code generators placed a copy of the Hwi_dispatcherTaskSupport
     * constant on the task stack (see above comment), which would
     * make the test below bogus as it would be being performed on
     * on the ISR stack...
     */
    Hwi_switchToTaskStack(oldTaskSP);

    /* Run Task scheduler */
    if (Hwi_dispatcherTaskSupport) {
        /* tskKey fetched from task stack if this is a non-nested interrupt */
        TASK_RESTORE(tskKey);   /* returns with ints disabled */
    }
}
예제 #18
0
파일: Hwi.c 프로젝트: andreimironenko/bios
/*
 *  ======== Hwi_startup ========
 */
Void Hwi_startup()
{
    Hwi_enable();
}
예제 #19
0
/*
 *  ======== Power_blockedTaskFunction ========
 */
Void Power_blockedTaskFunction()
{
    Hwi_enable();
    Power_idleCPU();
    Hwi_disable();
}
예제 #20
0
파일: Hwi.c 프로젝트: andreimironenko/bios
/*
 *  ======== Hwi_dispatchIRQC ========
 *  Configurable IRQ interrupt dispatcher.
 */
Void Hwi_dispatchIRQC(Hwi_Irp irp)
{
    /*
     * Enough room is reserved above the isr stack to handle
     * as many as 16 32-bit stack resident local variables.
     * If the dispatcher requires more than this, you must
     * handle this in Hwi_Module_startup().
     */

    Hwi_Object *hwi;
    BIOS_ThreadType prevThreadType;
    UInt intNum;
    Char *oldTaskSP;
    Int tskKey;
    Int swiKey;
    Int i;

    /* save irp somewhere that survives the stack switch */
    Hwi_module->irp = irp;

    if (Hwi_dispatcherTaskSupport) {
        tskKey = TASK_DISABLE();
        /* 
         * If this is a non-nested interrupt,
         * tskkey is saved on the task stack.
         * It must not be referenced again until
         * switching back to the task stack!!!!
         * All other local variables will be
         * on the isr stack.
         */
    }

    /* 
     * Switch to Hwi stack if not already on it.
     * This step, and the corresponding switch back to the task
     * stack are performed outside the "if (Hwi_dispatcherTaskSupport)"
     * conditionals because sometimes the generated code placed a copy
     * of Hwi_dispatcherTaskSupport on the task stack for use below.
     */
    oldTaskSP = Hwi_switchToIsrStack();

    /* 
     * all references to local variables beyond this point
     * will be on the isr stack
     */

    if (Hwi_dispatcherSwiSupport) {
        swiKey = SWI_DISABLE();
    }

    /* set thread type to Hwi */
    prevThreadType = BIOS_setThreadType(BIOS_ThreadType_Hwi);

    /* Porcess ALL pending and enabled interrupts */
    do {
        intNum = Hwi_l1Intc.SIR_IRQ;        /* get current L1 int num */

        if (intNum == 0) {                  /* is from L2? */
            intNum = Hwi_l2Intc.SIR_IRQ;    /* get current L2 int num */
            intNum += 32;                   /* force to linear index */
        }

        hwi = Hwi_module->dispatchTable[intNum];

        hwi->irp = Hwi_module->irp;

#ifndef ti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS
        /* call the begin hooks */
        for (i = 0; i < Hwi_hooks.length; i++) {
            if (Hwi_hooks.elem[i].beginFxn != NULL) {
                Hwi_hooks.elem[i].beginFxn((IHwi_Handle)hwi);
            }
        }
#endif

        Log_write5(Hwi_LM_begin, (IArg)hwi, (IArg)hwi->fxn, 
                   (IArg)prevThreadType, (IArg)intNum, hwi->irp);

        Hwi_enable();

        /* call user's ISR func */
        (hwi->fxn)(hwi->arg);

        Hwi_disable();

        Log_write1(Hwi_LD_end, (IArg)hwi);

#ifndef ti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS
        /* call the end hooks */
        for (i = 0; i < Hwi_hooks.length; i++) {
            if (Hwi_hooks.elem[i].endFxn != NULL) {
                Hwi_hooks.elem[i].endFxn((IHwi_Handle)hwi);
            }
        }
#endif

        if (intNum > 31) {                      /* is from L2? */
            Hwi_l2Intc.CONTROL = L2_NEW_IRQ_AGR;/* force NEW_IRQ_AGR */
        }
        Hwi_l1Intc.CONTROL = L1_NEW_IRQ_AGR;    /* force NEW_IRQ_AGR */

    }   /* loop thru all active and enabled IRQ ints */
    while (Hwi_l1Intc.ITR & ~Hwi_l1Intc.MIR & Hwi_module->irq0Mask);

    /* Run Swi scheduler */
    if (Hwi_dispatcherSwiSupport) {
        SWI_RESTORE(swiKey);
    }

    /* restore thread type */
    BIOS_setThreadType(prevThreadType);

    /* 
     * Switch back to Task stack if at bottom of Hwi stack
     * While it seems that this step should be placed in the
     * "if (Hwi_dispatcherTaskSupport)" conditional below,
     * some code generators placed a copy of the Hwi_dispatcherTaskSupport
     * constant on the task stack (see above comment), which would
     * make the test below bogus as it would be being performed on
     * on the ISR stack...
     */
    Hwi_switchToTaskStack(oldTaskSP);

    /* Run Task scheduler */
    if (Hwi_dispatcherTaskSupport) {
        /* tskKey fetched from task stack if this is a non-nested interrupt */
        TASK_RESTORE(tskKey);   /* returns with ints disabled */
    }
}
BOOL Intr_Init(Intr *pThis, IntrItem eIntrItem, Intr_Handler pfnIntr_Handler, VOID *pIntrHandlerArg) //(*pIntr_Handler)(void *),\
						 
{
	//CSL_Status          intStat;


	//guru:may be not required for C6678
	#if 1
	//Initialize Global interrupts
	//Intr_EnableGlobalInterrupts();
	Hwi_enable();
	#endif
	//Initialize Global interrupts
	//CSL_intcGlobalEnable(NULL);
	//Get the values from Interrupt Table DataBase
	IntrDB_GetIntrTableParam(&pThis->oIntrTableParam, eIntrItem);
	Hwi_Params_init(&pThis->oHwi);
	Error_init(&pThis->eb);


	//Check whether the Interrupt source uses CIC Module
	if(pThis->oIntrTableParam.bCicRequired == TRUE)
	{
		
		/* Map the System Interrupt i.e. the Interrupt Destination 0 interrupt to the DIO ISR Handler. */
		CpIntc_dispatchPlug(pThis->oIntrTableParam.SysInt,(ti_sysbios_family_c66_tci66xx_CpIntc_FuncPtr) pfnIntr_Handler, (xdc_UArg)pIntrHandlerArg, FALSE);

		/* The configuration is for CPINTC0. We map system interrupt 112 to Host Interrupt 8. */
		CpIntc_mapSysIntToHostInt(0,pThis->oIntrTableParam.SysInt,pThis->oIntrTableParam.HostInt );
		/* Get the event id associated with the host interrupt. */
		pThis->oHwi.eventId = CpIntc_getEventId(pThis->oIntrTableParam.HostInt);
		pThis->oHwi.arg = pThis->oIntrTableParam.HostInt;
		pThis->oHwi.maskSetting = Hwi_MaskingOption_NONE;
		//pThis->oHwi.priority = 3;
		pThis->oHwiHandle =	Hwi_create((Int)pThis->oIntrTableParam.eIntcVectorId, (Hwi_FuncPtr)CpIntc_dispatch, &pThis->oHwi, &pThis->eb);// SYSBIOS API
		if(pThis->oHwiHandle==NULL)
							{
								#ifdef DEBUG
								LOG_TRACE0("INTR: Hwi not created  ... Failed.\n");
								#endif
							}
	}
	else
	{
		pThis->oHwi.eventId=pThis->oIntrTableParam.nIntcEventId;
		pThis->oHwi.maskSetting = Hwi_MaskingOption_NONE;
		//pThis->oHwi.priority = 3;
		//register the argument to be passed with the ISR
		pThis->oHwi.arg = (UArg)pIntrHandlerArg;
		pThis->oHwiHandle =	Hwi_create((Int)pThis->oIntrTableParam.eIntcVectorId, (Hwi_FuncPtr)pfnIntr_Handler, &pThis->oHwi, &pThis->eb);// SYSBIOS API
		if(pThis->oHwiHandle==NULL)
							{
								#ifdef DEBUG
								LOG_TRACE0("INTR: Hwi not created  ... Failed.\n");
								#endif
							}
	}
	#ifdef _STE_APP
	//Initialize the oHwi object




	#endif
	#ifdef _STE_BOOT
	//Csl APIs or Hooking the Interrupt Event
	pThis->oIntcHandle = CSL_intcOpen (&pThis->oIntcObj, pThis->oIntrTableParam.nIntcEventId, 
									&pThis->oIntrTableParam.eIntcVectorId, NULL);
    if ((pThis->oIntcHandle == NULL)) 
    {
    	#ifdef DEBUG
    	printf ("INTR: Open... Failed.\n");
        printf ("hIntc = 0x%x]\n", pThis->oIntcHandle);
		#endif
            
    }
    else
	{
		#ifdef DEBUG
        printf ("INTR: Open... Passed.\n");
		#endif
	}

	pThis->oEventRecord.handler = (CSL_IntcEventHandler)pfnIntr_Handler;
    pThis->oEventRecord.arg = pIntrHandlerArg;

    CSL_intcPlugEventHandler(pThis->oIntcHandle, &pThis->oEventRecord);
	#endif

	return TRUE;
}