コード例 #1
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;
}
コード例 #2
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);
}
コード例 #3
0
ファイル: BIOS.c プロジェクト: CheredHerry/ti-bios
/*
 *  ======== BIOS_exit ========
 */
Void BIOS_exit(Int stat)
{
    /* remove the RTS lock */
    BIOS_removeRTSLock();

    /* force thread type to 'Main' */
    BIOS_setThreadType(BIOS_ThreadType_Main);

    System_exit(stat);
}
コード例 #4
0
ファイル: BIOS.c プロジェクト: CheredHerry/ti-bios
/*
 *  ======== BIOS_errorRaiseHook ========
 */
Void BIOS_errorRaiseHook(Error_Block *eb)
{
    /* 
     * If this is an Assert thread, defang Gate threadtype check 
     */
    if (eb->id == xdc_runtime_Assert_E_assertFailed) {
        /* remove the RTS lock */
        BIOS_removeRTSLock();

        /* force thread type to 'Main' */
        BIOS_setThreadType(BIOS_ThreadType_Main);
    }

    /* Call the default/user's Error.raiseHook */
    BIOS_installedErrorHook(eb);
}
コード例 #5
0
ファイル: Exception.c プロジェクト: mobiaqua/ti-sysbios-c64t
/*
 *  ======== Exception_excHandler ========
 */
Void Exception_excHandler(UInt *excStack, UInt pc)
{
    Exception_ExcContext excContext, *excContextp;
    SizeT stackSize = 0;
    UInt8 *stack = NULL;
    UInt coreId = 0;

#if (ti_sysbios_BIOS_smpEnabled__D)
    coreId = Core_getId();
#endif

#if defined(ti_sysbios_family_arm_a8_intcps_Hwi_enableAsidTagging__D) && \
    (ti_sysbios_family_arm_a8_intcps_Hwi_enableAsidTagging__D)
    Mmu_switchContext(0, Mmu_getMmuTableAddr());
#elif defined(ti_sysbios_family_arm_gic_Hwi_enableAsidTagging__D) && \
    (ti_sysbios_family_arm_gic_Hwi_enableAsidTagging__D)
    Mmu_switchContext(0, Mmu_getFirstLevelTableAddr());
#endif

    Exception_module->excActive[coreId] = TRUE;

    if (Exception_module->excContext[coreId] == NULL) {
        Exception_module->excContext[coreId] = &excContext;
        excContextp = &excContext;
    }
    else {
        excContextp = Exception_module->excContext[coreId];
    }

    /* copy registers from stack to excContext */
    excContextp->r0  = (Ptr)excStack[8];        /* r0 */
    excContextp->r1  = (Ptr)excStack[9];        /* r1 */
    excContextp->r2  = (Ptr)excStack[10];       /* r2 */
    excContextp->r3  = (Ptr)excStack[11];       /* r3 */
    excContextp->r4  = (Ptr)excStack[12];       /* r4 */
    excContextp->r5  = (Ptr)excStack[13];       /* r5 */
    excContextp->r6  = (Ptr)excStack[14];       /* r6 */
    excContextp->r7  = (Ptr)excStack[15];       /* r7 */
    excContextp->r8  = (Ptr)excStack[16];       /* r8 */
    excContextp->r9  = (Ptr)excStack[17];       /* r9 */
    excContextp->r10 = (Ptr)excStack[18];       /* r10 */
    excContextp->r11 = (Ptr)excStack[19];       /* r11 */
    excContextp->r12 = (Ptr)excStack[20];       /* r12 */
    excContextp->ifar = (Ptr)excStack[4];       /* IFAR */
    excContextp->dfar = (Ptr)excStack[5];       /* DFAR */
    excContextp->ifsr = (Ptr)excStack[6];       /* IFSR */
    excContextp->dfsr = (Ptr)excStack[7];       /* DFSR */
    excContextp->sp  = (Ptr)excStack[1];        /* sp */
    excContextp->lr  = (Ptr)excStack[2];        /* lr */
    excContextp->pc  = (Ptr)pc;                 /* pc */
    excContextp->psr = (Ptr)excStack[0];        /* psr */

    excContextp->type = (Exception_Type)(excStack[3] &0x1f);    /* psr */

    excContextp->threadType = BIOS_getThreadType();

    switch (excContextp->threadType) {
        case BIOS_ThreadType_Task: {
            if (BIOS_taskEnabled == TRUE) {
                excContextp->threadHandle = (Ptr)Task_self();
                stack = (UInt8 *)(Task_self())->stack;
                stackSize = (Task_self())->stackSize;
            }
            break;
        }
        case BIOS_ThreadType_Swi: {
            if (BIOS_swiEnabled == TRUE) {
                excContextp->threadHandle = (Ptr)Swi_self();
                stack = STACK_BASE;
                stackSize = (SizeT)(&__STACK_SIZE);
            }
            break;
        }
        case BIOS_ThreadType_Hwi: {
                excContextp->threadHandle = NULL;
                stack = STACK_BASE;
                stackSize = (SizeT)(&__STACK_SIZE);
            break;
        }
        case BIOS_ThreadType_Main: {
                excContextp->threadHandle = NULL;
                stack = STACK_BASE;
                stackSize = (SizeT)(&__STACK_SIZE);
            break;
        }
    }

    excContextp->threadStackSize = stackSize;
    excContextp->threadStack = (Ptr)stack;

    /* copy thread's stack contents if user has provided a buffer */
    if (Exception_module->excStackBuffers[coreId] != NULL) {
        UInt8 *from, *to;
        from = stack;
        to = (UInt8 *)Exception_module->excStackBuffers[coreId];
        while (stackSize--) {
            *to++ = *from++;
        }
    }

    /* Force MAIN threadtype So we can safely call System_printf */

    BIOS_setThreadType(BIOS_ThreadType_Main);

    if (Exception_enableDecode == TRUE) {
        Exception_excDumpContext(pc);
    }

    /* Call user's exception hook */
    if (Exception_excHookFuncs[coreId] != NULL) {
        Exception_excHookFuncs[coreId](excContextp);
    }

    /* raise a corresponding Error */
    switch(excContextp->type) {

        case Exception_Type_Supervisor:
            Error_raise(0, Exception_E_swi, pc, excStack[2]);
            break;

        case Exception_Type_PreAbort:
            Error_raise(0, Exception_E_prefetchAbort, pc, excStack[2]);
            break;

        case Exception_Type_DataAbort:
            Error_raise(0, Exception_E_dataAbort, pc, excStack[2]);
            break;

        case Exception_Type_UndefInst:
            Error_raise(0, Exception_E_undefinedInstruction, pc, excStack[2]);
            break;
    }
}
コード例 #6
0
/*
 *  ======== Exception_excHandler ========
 */
Void Exception_excHandler(UInt *excStack, UInt pc)
{
    Exception_ExcContext excContext, *excContextp;
    SizeT stackSize = 0;
    UInt8 *stack = NULL;

    Exception_module->excActive = TRUE;

    if (Exception_module->excContext == NULL) {
        Exception_module->excContext = &excContext;
        excContextp = &excContext;
    }
    else {
        excContextp = Exception_module->excContext;
    }

    /* copy registers from stack to excContext */
    excContextp->r0  = (Ptr)excStack[4];        /* r0 */
    excContextp->r1  = (Ptr)excStack[5];        /* r1 */
    excContextp->r2  = (Ptr)excStack[6];        /* r2 */
    excContextp->r3  = (Ptr)excStack[7];        /* r3 */
    excContextp->r4  = (Ptr)excStack[8];        /* r4 */
    excContextp->r5  = (Ptr)excStack[9];        /* r5 */
    excContextp->r6  = (Ptr)excStack[10];       /* r6 */
    excContextp->r7  = (Ptr)excStack[11];       /* r7 */
    excContextp->r8  = (Ptr)excStack[12];       /* r8 */
    excContextp->r9  = (Ptr)excStack[13];       /* r9 */
    excContextp->r10 = (Ptr)excStack[14];       /* r10 */
    excContextp->r11 = (Ptr)excStack[15];       /* r11 */
    excContextp->r12 = (Ptr)excStack[16];       /* r12 */
    excContextp->sp  = (Ptr)excStack[1];        /* sp */
    excContextp->lr  = (Ptr)excStack[2];        /* lr */
    excContextp->pc  = (Ptr)pc;         /* pc */
    excContextp->psr = (Ptr)excStack[0];        /* psr */

    excContextp->type = (Exception_Type)(excStack[3] &0x1f);    /* psr */

    excContextp->threadType = BIOS_getThreadType();

    switch (excContextp->threadType) {
    case BIOS_ThreadType_Task: {
        if (BIOS_taskEnabled == TRUE) {
            excContextp->threadHandle = (Ptr)Task_self();
            stack = (UInt8 *)(Task_self())->stack;
            stackSize = (Task_self())->stackSize;
        }
        break;
    }
    case BIOS_ThreadType_Swi: {
        if (BIOS_swiEnabled == TRUE) {
            excContextp->threadHandle = (Ptr)Swi_self();
            stack = STACK_BASE;
            stackSize = (SizeT)(&__STACK_SIZE);
        }
        break;
    }
    case BIOS_ThreadType_Hwi: {
        excContextp->threadHandle = NULL;
        stack = STACK_BASE;
        stackSize = (SizeT)(&__STACK_SIZE);
        break;
    }
    case BIOS_ThreadType_Main: {
        excContextp->threadHandle = NULL;
        stack = STACK_BASE;
        stackSize = (SizeT)(&__STACK_SIZE);
        break;
    }
    }

    excContextp->threadStackSize = stackSize;
    excContextp->threadStack = (Ptr)stack;

    /* copy thread's stack contents if user has provided a buffer */
    if (Exception_module->excStackBuffer != NULL) {
        UInt8 *from, *to;
        from = stack;
        to = (UInt8 *)Exception_module->excStackBuffer;
        while (stackSize--) {
            *to++ = *from++;
        }
    }

    /* Force MAIN threadtype So we can safely call System_printf */

    BIOS_setThreadType(BIOS_ThreadType_Main);

    if (Exception_enableDecode == TRUE) {
        Exception_excDumpContext(pc);
    }

    /* Call user's exception hook */
    if (Exception_excHookFunc != NULL) {
        Exception_excHookFunc(excContextp);
    }

    /* raise a corresponding Error */
    switch(excContextp->type) {

    case Exception_Type_Supervisor:
        Error_raise(0, Exception_E_swi, pc, excStack[2]);
        break;

    case Exception_Type_PreAbort:
        Error_raise(0, Exception_E_prefetchAbort, pc, excStack[2]);
        break;

    case Exception_Type_DataAbort:
        Error_raise(0, Exception_E_dataAbort, pc, excStack[2]);
        break;

    case Exception_Type_UndefInst:
        Error_raise(0, Exception_E_undefinedInstruction, pc, excStack[2]);
        break;
    }
}
コード例 #7
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->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 */
    }
}
コード例 #8
0
ファイル: Hwi.c プロジェクト: andreimironenko/bios
/*
 *  ======== Hwi_dispatchIRQC ========
 *  Configurable IRQ interrupt dispatcher.
 */
Void Hwi_dispatchIRQC()
{
    /*
     * 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;
    Int intNum;
    Char *oldTaskSP;
    Int tskKey;
    Int swiKey;
    Int i;

    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);

    /* read interrupt index */
    intNum = Hwi_cpIntc.HIPIR[1];

    /* disable host interrupt 1 (IRQ) */
    Hwi_cpIntc.HIDISR = 1;

    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);

    /* call the user's isr */
    if (Hwi_dispatcherAutoNestingSupport) {
        (hwi->handler)(hwi, intNum);
    }
    else {
        /* clear the interrupt status for this int */
        Hwi_cpIntc.SICR = intNum;

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

        /* re-enable IRQ */
        Hwi_cpIntc.HIEISR = 1;
    }

    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 */
    }
}
コード例 #9
0
ファイル: Hwi.c プロジェクト: alexeicolin/sysbios
/*
 *  ======== 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.
     * This space is reserved for the Swi scheduler.
     *
     * If the swi scheduler requires more than this, you must
     * handle this in Hwi_Module_startup().
     */

    Hwi_Object *hwi;
    BIOS_ThreadType prevThreadType;
    UInt intNum;
    Int swiKey;
    Int i;

    /* save irp for ROV call stack view */
    Hwi_module->irp = irp;

    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->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);
}
コード例 #10
0
ファイル: Hwi.c プロジェクト: mobiaqua/ti-sysbios-c64t
/*
 *  ======== Hwi_dispatchCore ========
 *  Configurable dispatcher.
 */
Void Hwi_dispatchCore(Int intNum)
{
    /*
     * 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;
    UInt16 oldIER, disableMask, restoreMask;
    Int swiKey;
    Int i;
    Hwi_FuncPtr fxn;
    UArg arg;

    /* save away intNum in module state because it might be saved on stack */
    Hwi_module->intNum = intNum;

    /*
     * pre-read local copies of the variables used
     * within to eliminate memory fetch nops
     */
    hwi = Hwi_module->dispatchTable[intNum];
    fxn = hwi->fxn;
    arg = hwi->arg;

    if (Hwi_dispatcherIrpTrackingSupport) {
        hwi->irp = IRP;
    }

    if (Hwi_dispatcherAutoNestingSupport) {
        disableMask = hwi->disableMask;
        restoreMask = hwi->restoreMask;
    }

    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) {
        oldIER = IER;
        IER &= ~disableMask;
        _enable_interrupts();

        (fxn)(arg);

        _disable_interrupts();
        IER |= (restoreMask & oldIER);
    }
    else {
        (fxn)(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);
}
コード例 #11
0
ファイル: Exception.c プロジェクト: mobiaqua/ti-sysbios-c64t
/*
 *  ======== Exception_handler ========
 *  This handler is called by the dispatch function.  It calls the various
 *  exception hook functions.
 */
Void Exception_handler(Bool abortFlag)
{
    extern volatile cregister unsigned EFR;
    extern volatile cregister unsigned ECR;
    extern volatile cregister unsigned NRP;
    extern volatile cregister unsigned NTSR;
    Exception_Context *excp;
    unsigned efr;

    efr = EFR;
    Exception_module->efr = efr;        /* record EFR in Exception_Status */
    Exception_module->nrp = NRP;        /* record NRP in Exception_Status */
    Exception_module->ntsr = NTSR;      /* record NTSR in Exception_Status */

    /* set exception context */
    excp = Exception_module->excContext;

    if (Exception_enablePrint) {
        /* Force MAIN threadtype So we can safely call System_printf */
        BIOS_setThreadType(BIOS_ThreadType_Main);

        System_printf("A0=0x%x A1=0x%x\n", excp->A0, excp->A1);
        System_printf("A2=0x%x A3=0x%x\n", excp->A2, excp->A3);
        System_printf("A4=0x%x A5=0x%x\n", excp->A4, excp->A5);
        System_printf("A6=0x%x A7=0x%x\n", excp->A6, excp->A7);
        System_printf("A8=0x%x A9=0x%x\n", excp->A8, excp->A9);
        System_printf("A10=0x%x A11=0x%x\n", excp->A10, excp->A11);
        System_printf("A12=0x%x A13=0x%x\n", excp->A12, excp->A13);
        System_printf("A14=0x%x A15=0x%x\n", excp->A14, excp->A15);
        System_printf("A16=0x%x A17=0x%x\n", excp->A16, excp->A17);
        System_printf("A18=0x%x A19=0x%x\n", excp->A18, excp->A19);
        System_printf("A20=0x%x A21=0x%x\n", excp->A20, excp->A21);
        System_printf("A22=0x%x A23=0x%x\n", excp->A22, excp->A23);
        System_printf("A24=0x%x A25=0x%x\n", excp->A24, excp->A25);
        System_printf("A26=0x%x A27=0x%x\n", excp->A26, excp->A27);
        System_printf("A28=0x%x A29=0x%x\n", excp->A28, excp->A29);
        System_printf("A30=0x%x A31=0x%x\n", excp->A30, excp->A31);
        System_printf("B0=0x%x B1=0x%x\n", excp->B0, excp->B1);
        System_printf("B2=0x%x B3=0x%x\n", excp->B2, excp->B3);
        System_printf("B4=0x%x B5=0x%x\n", excp->B4, excp->B5);
        System_printf("B6=0x%x B7=0x%x\n", excp->B6, excp->B7);
        System_printf("B8=0x%x B9=0x%x\n", excp->B8, excp->B9);
        System_printf("B10=0x%x B11=0x%x\n", excp->B10, excp->B11);
        System_printf("B12=0x%x B13=0x%x\n", excp->B12, excp->B13);
        System_printf("B14=0x%x B15=0x%x\n", excp->B14, excp->B15);
        System_printf("B16=0x%x B17=0x%x\n", excp->B16, excp->B17);
        System_printf("B18=0x%x B19=0x%x\n", excp->B18, excp->B19);
        System_printf("B20=0x%x B21=0x%x\n", excp->B20, excp->B21);
        System_printf("B22=0x%x B23=0x%x\n", excp->B22, excp->B23);
        System_printf("B24=0x%x B25=0x%x\n", excp->B24, excp->B25);
        System_printf("B26=0x%x B27=0x%x\n", excp->B26, excp->B27);
        System_printf("B28=0x%x B29=0x%x\n", excp->B28, excp->B29);
        System_printf("B30=0x%x B31=0x%x\n", excp->B30, excp->B31);
        System_printf("NTSR=0x%x\n", excp->NTSR);
        System_printf("ITSR=0x%x\n", excp->ITSR);
        System_printf("IRP=0x%x\n", excp->IRP);
        System_printf("SSR=0x%x\n", excp->SSR);
        System_printf("AMR=0x%x\n", excp->AMR);
        System_printf("RILC=0x%x\n", excp->RILC);
        System_printf("ILC=0x%x\n", excp->ILC);
    }

    /* print general exception info */
    if (Exception_enablePrint) {
        System_printf("Exception at 0x%x\n",
            (IArg)Exception_module->nrp);

        System_printf("EFR=0x%x NRP=0x%x\n",
            (IArg)Exception_module->efr,
            (IArg)Exception_module->nrp);
    }

    if (*Exception_exceptionHook != NULL) {
        (*Exception_exceptionHook)();
    }

    /* clear flags in EFR */
    ECR = efr;

    /* process all possible causes of exception */
    if (efr & Exception_EFRIXF) {
        /* internal exception */
        efr ^= Exception_EFRIXF;
        Exception_internalHandler();
    }

    if (efr & Exception_EFREXF) {
        /* external exception */
        efr ^= Exception_EFREXF;
        Exception_externalHandler();
    }

    if (efr & Exception_EFRNXF) {
        /* legacy NMI exception */
        efr ^= Exception_EFRNXF;
        Exception_nmiHandler();
    }

    if (abortFlag) {
        if (Exception_enablePrint) {
            Error_raise(0, Exception_E_exceptionMax, excp->NRP, excp->B15);
        }
        else {
            Error_raise(0, Exception_E_exceptionMin, excp->NRP, excp->B15);
        }
    }
}
コード例 #12
0
ファイル: Deh.c プロジェクト: Hashcode/sysbios-rpmsg
/*
 *  ======== Deh_excHandler ========
 *  Read data from HWI exception handler and print it to crash dump buffer.
 *  Notify host that exception has occurred.
 */
Void Deh_excHandler(UInt *excStack, UInt lr)
{
    Hwi_ExcContext  exc;
    Deh_ExcRegs    *excRegs;
    Char           *ttype;
    UInt            excNum;
    Char           *etype;
    Char           *name;
    UInt           sCnt = 0;

    excRegs = (Deh_ExcRegs *) Deh_module->outbuf;

    /* Copy registers from stack to excContext */
    excRegs->r0  = exc.r0 = (Ptr)excStack[8];      /* r0 */
    excRegs->r1  = exc.r1 = (Ptr)excStack[9];      /* r1 */
    excRegs->r2  = exc.r2 = (Ptr)excStack[10];     /* r2 */
    excRegs->r3  = exc.r3 = (Ptr)excStack[11];     /* r3 */
    excRegs->r4  = exc.r4 = (Ptr)excStack[0];      /* r4 */
    excRegs->r5  = exc.r5 = (Ptr)excStack[1];      /* r5 */
    excRegs->r6  = exc.r6 = (Ptr)excStack[2];      /* r6 */
    excRegs->r7  = exc.r7 = (Ptr)excStack[3];      /* r7 */
    excRegs->r8  = exc.r8 = (Ptr)excStack[4];      /* r8 */
    excRegs->r9  = exc.r9 = (Ptr)excStack[5];      /* r9 */
    excRegs->r10 = exc.r10 = (Ptr)excStack[6];     /* r10 */
    excRegs->r11 = exc.r11 = (Ptr)excStack[7];     /* r11 */
    excRegs->r12 = exc.r12 = (Ptr)excStack[12];    /* r12 */
    excRegs->sp  = exc.sp  = (Ptr)(UInt32)(excStack+16); /* sp */
    excRegs->lr  = exc.lr  = (Ptr)excStack[13];    /* lr */
    excRegs->pc  = exc.pc  = (Ptr)excStack[14];    /* pc */
    excRegs->psr = exc.psr = (Ptr)excStack[15];    /* psr */

    exc.threadType = BIOS_getThreadType();
    switch (exc.threadType) {
        case BIOS_ThreadType_Task:
            if (BIOS_taskEnabled == TRUE) {
                exc.threadHandle = (Ptr)Task_self();
                exc.threadStack = (Task_self())->stack;
                exc.threadStackSize = (Task_self())->stackSize;
            }
            break;
        case BIOS_ThreadType_Swi:
            if (BIOS_swiEnabled == TRUE) {
                exc.threadHandle = (Ptr)Swi_self();
                exc.threadStack = Deh_module->isrStackBase;
                exc.threadStackSize = Deh_module->isrStackSize;
            }
            break;
        case BIOS_ThreadType_Hwi:
        case BIOS_ThreadType_Main:
            exc.threadHandle = NULL;
            exc.threadStack = Deh_module->isrStackBase;
            exc.threadStackSize = Deh_module->isrStackSize;
            break;
        default:
            exc.threadHandle = NULL;
            exc.threadStack = NULL;
            exc.threadStackSize = 0;
            break;
    }

    excRegs->ICSR  = exc.ICSR  = (Ptr)Hwi_nvic.ICSR;
    excRegs->MMFSR = exc.MMFSR = (Ptr)Hwi_nvic.MMFSR;
    excRegs->BFSR  = exc.BFSR  = (Ptr)Hwi_nvic.BFSR;
    excRegs->UFSR  = exc.UFSR  = (Ptr)Hwi_nvic.UFSR;
    excRegs->HFSR  = exc.HFSR  = (Ptr)Hwi_nvic.HFSR;
    excRegs->DFSR  = exc.DFSR  = (Ptr)Hwi_nvic.DFSR;
    excRegs->MMAR  = exc.MMAR  = (Ptr)Hwi_nvic.MMAR;
    excRegs->BFAR  = exc.BFAR  = (Ptr)Hwi_nvic.BFAR;
    excRegs->AFSR  = exc.AFSR  = (Ptr)Hwi_nvic.AFSR;

    /* Force MAIN threadtype So we can safely call System_printf */
    BIOS_setThreadType(BIOS_ThreadType_Main);

    excNum = Hwi_nvic.ICSR & 0xff;
    if (Watchdog_isException(excNum)) {
        etype = "Watchdog fired";
    }
    else {
        VirtQueue_postCrashToMailbox();
        etype = "Exception occurred";
    }

    System_printf("%s at (PC) = %08x\n", etype, exc.pc);

    switch (lr) {
        case 0xfffffff1:
            System_printf("CPU context: ISR\n");
            break;
        case 0xfffffff9:
        case 0xfffffffd:
            System_printf("CPU context: thread\n");
            break;
        default:
            System_printf("CPU context: unknown. LR: %08x\n", lr);
            break;
    }

    switch (exc.threadType) {
        case BIOS_ThreadType_Task: {
            ttype = "Task";
            break;
        }
        case BIOS_ThreadType_Swi: {
            ttype = "Swi";
            break;
        }
        case BIOS_ThreadType_Hwi: {
            ttype = "Hwi";
            break;
        }
        case BIOS_ThreadType_Main: {
            ttype = "Main";
            break;
        }
        default:
            ttype = "Invalid!";
            break;
    }

    if (exc.threadHandle) {
        name = Task_Handle_name(exc.threadHandle);
        if (!name) {
            name = "(unnamed)";
        }
    }
    else {
        name = "(null task)";
    }
    System_printf("BIOS %s name: %s handle: 0x%x.\n", ttype, name,
                  exc.threadHandle);

    System_printf("BIOS %s stack base: 0x%x.\n", ttype, exc.threadStack);
    System_printf("BIOS %s stack size: 0x%x.\n", ttype, exc.threadStackSize);

    switch (excNum) {
        case 2:
            ti_sysbios_family_arm_m3_Hwi_excNmi(excStack);
            break;
        case 3:
            ti_sysbios_family_arm_m3_Hwi_excHardFault(excStack);
            break;
        case 4:
            ti_sysbios_family_arm_m3_Hwi_excMemFault(excStack);
            break;
        case 5:
            ti_sysbios_family_arm_m3_Hwi_excBusFault(excStack);
            break;
        case 6:
            ti_sysbios_family_arm_m3_Hwi_excUsageFault(excStack);
            break;
        case 11:
            ti_sysbios_family_arm_m3_Hwi_excSvCall(excStack);
            break;
        case 12:
            ti_sysbios_family_arm_m3_Hwi_excDebugMon(excStack);
            break;
        case 7:
        case 8:
        case 9:
        case 10:
        case 13:
            ti_sysbios_family_arm_m3_Hwi_excReserved(excStack, excNum);
            break;
        default:
            if (!Watchdog_isException(excNum)) {
                ti_sysbios_family_arm_m3_Hwi_excNoIsr(excStack, excNum);
            }
            break;
    }

    System_printf ("R0 = 0x%08x  R8  = 0x%08x\n", exc.r0, exc.r8);
    System_printf ("R1 = 0x%08x  R9  = 0x%08x\n", exc.r1, exc.r9);
    System_printf ("R2 = 0x%08x  R10 = 0x%08x\n", exc.r2, exc.r10);
    System_printf ("R3 = 0x%08x  R11 = 0x%08x\n", exc.r3, exc.r11);
    System_printf ("R4 = 0x%08x  R12 = 0x%08x\n", exc.r4, exc.r12);
    System_printf ("R5 = 0x%08x  SP(R13) = 0x%08x\n", exc.r5, exc.sp);
    System_printf ("R6 = 0x%08x  LR(R14) = 0x%08x\n", exc.r6, exc.lr);
    System_printf ("R7 = 0x%08x  PC(R15) = 0x%08x\n", exc.r7, exc.pc);
    System_printf ("PSR = 0x%08x\n", exc.psr);
    System_printf ("ICSR = 0x%08x\n", Hwi_nvic.ICSR);
    System_printf ("MMFSR = 0x%02x\n", Hwi_nvic.MMFSR);
    System_printf ("BFSR = 0x%02x\n", Hwi_nvic.BFSR);
    System_printf ("UFSR = 0x%04x\n", Hwi_nvic.UFSR);
    System_printf ("HFSR = 0x%08x\n", Hwi_nvic.HFSR);
    System_printf ("DFSR = 0x%08x\n", Hwi_nvic.DFSR);
    System_printf ("MMAR = 0x%08x\n", Hwi_nvic.MMAR);
    System_printf ("BFAR = 0x%08x\n", Hwi_nvic.BFAR);
    System_printf ("AFSR = 0x%08x\n", Hwi_nvic.AFSR);

    System_printf ("Stack trace\n");
    StackDbg_walkStack((UInt)exc.threadStack, (UInt)exc.threadStackSize,
                       (UInt)exc.sp, printStackEntry, &sCnt);

    System_printf ("Stack dump base %08x size %ld sp %08x:\n", exc.threadStack,
                   exc.threadStackSize, exc.sp);
    dump_hex((UInt)exc.threadStack, exc.threadStackSize / sizeof(UInt),
             (UInt)exc.sp);

    System_abort("Terminating execution...\n");

}