⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tminterrupts.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的设备库的源码
💻 C
📖 第 1 页 / 共 2 页
字号:

/*
 * Function         : Retrieve instance parameters.
 * Parameters       : instance (I)  instance to get parameters from
 *                    setup    (O)  pointer to buffer
 *                                  receiving returned parameters
 * Function Result  : resulting error condition
 */

extern      tmLibdevErr_t
intGetInstanceSetup(
            intInterrupt_t instance,
            intInstanceSetup_t * setup)
{
    UInt        ien;

    /*
     * Precondition checks:
     */
    tmAssert(setup != Null, TMLIBDEV_ERR_NULL_PARAMETER);
    tmAssert(IS_ALLOCATED(instance), TMLIBDEV_ERR_NOT_OWNER);
    tmAssert(sizeof (*setup) == 4 * WORDSIZE, INT_ERR_STRUCT_CHANGED);

    /*
     * Extraction of result:
     */
    ien = intCLEAR_IEN();
    {
        setup->enabled         = (enabled_interrupts & INT_MASK(instance)) != 0;
        setup->handler         = (intHandler_t) intGetHANDLER(instance);
        setup->level_triggered = intCheckLEVEL_TRIGGERED(instance) != 0;
        setup->priority        = (intPriority_t) intGetPRIO(instance);

        if (setup->handler == _default_interrupt_handler) {
            setup->handler = Null;
        }
    }
    intRESTORE_IEN(ien);

    return TMLIBDEV_OK;
}


/*--------------------- open/close functions ---------------------------------*/


/*
 * Function         : Reserve the use of a specified interrupt.
 * Parameters       : interrupt (I)  required interrupt
 * Function Result  : resulting error condition
 *                         (INT_ERR_ALREADY_OPEN)
 */

extern      tmLibdevErr_t
intOpen(intInterrupt_t interrupt)
{
/* atomic for circumventing hardware bugs 21298 21388 */
#pragma TCS_atomic
    if (IS_ALLOCATED(interrupt)) {
        return INT_ERR_ALREADY_OPEN;

    }
    else {
        ALLOCATE(interrupt);

        capabilities.numCurrentInstances++;

        intAckCLEAR(interrupt);

        return TMLIBDEV_OK;
    }
}



/*
 * Function         : Deallocates the interrupt instance,
 *                    and uninstall its handler when it has one.
 * Parameters       : instance  (I)  instance to give up
 * Function Result  : resulting error condition
 */

extern      tmLibdevErr_t
intClose(intInterrupt_t instance)
{
    UInt        ien;
    intInstanceSetup_t setup;

    tmAssert(IS_ALLOCATED(instance), TMLIBDEV_ERR_NOT_OWNER);

    ien = intCLEAR_IEN();
    {
        intGetInstanceSetup(instance, &setup);

        setup.enabled = False;
        setup.handler = Null;

        intInstanceSetup(instance, &setup);

        DEALLOCATE(instance);

        capabilities.numCurrentInstances--;
    }
    intRESTORE_IEN(ien);

    return TMLIBDEV_OK;
}


/*---------------------- int access functions --------------------------------*/




/*
 * Function         : Set the global interrupt priority, or interrupt level,
 *                    and return previous priority
 * Parameters       : prio  (I)  new global priority
 * Function Result  : Old global priority
 * NB               : This function is redundant, since its
 *                    effect can also be achieved using intSetup
 */
extern      intPriority_t
intSetPriority(intPriority_t prio)
{
    UInt        ien;
    intPriority_t result;

    ien = intCLEAR_IEN();
    {
        result   = cur_prio;
        cur_prio = prio;

        MMIO(IMASK) = enabled_interrupts & priority_masks[cur_prio];
    }
    intRESTORE_IEN(ien);

    return result;
}




/*
 * Function         : Set the global interrupt enabling bit,
 *                    and return information on previous enabling
 * Function Result  : See above
 * NB               : This function is redundant, since its
 *                    effect can also be achieved using intSetup
 */
extern      UInt
intSetIEN(void)
{
    UInt result = intSET_IEN();

    return result;
}




/*
 * Function         : Clear the global interrupt enabling bit,
 *                    and return information on previous enabling
 * Function Result  : See above
 * NB               : This function is redundant, since its
 *                    effect can also be achieved using intSetup
 */
extern      UInt
intClearIEN(void)
{
    UInt result = intCLEAR_IEN();

    return result;
}




/*
 * Function         : Restore specified interrupt enabling,
 *                    which was returned by a previous call
 *                    to intSetIEN or intClearIEN
 * Parameters       : ien   (I)  interrupt enable info
 * NB               : This function is redundant, since its
 *                    effect can also be achieved using intSetup
 */
extern void
intRestoreIEN(UInt ien)
{
    intRESTORE_IEN(ien);
}




/*
 * Function         : Clear an interrupt (may or may not be pending)
 * Parameters       : instance   (I) id of interrupt to clear
 * Function Result  : resulting error condition
 * NB               : interrupts to be cleared by this function
 *                    must be setup as edge triggered
 */
extern      tmLibdevErr_t
intClear(intInterrupt_t instance)
{
/* atomic for circumventing hardware bugs 21298 21388 */
#pragma TCS_atomic
    tmAssert(IS_ALLOCATED(instance), TMLIBDEV_ERR_NOT_OWNER);
    intAckCLEAR(instance);
    return TMLIBDEV_OK;
}




/*
 * Function         : Cause a software interrupt to be raised
 *                    on the current node
 * Parameters       : instance   (I) id of interrupt to raise
 * Function Result  : resulting error condition
 * NB               : interrupts to be raised by this function
 *            must be setup as edge triggered.
 */
extern      tmLibdevErr_t
intRaise(intInterrupt_t instance)
{
/* atomic for circumventing hardware bugs 21298 21388 */
#pragma TCS_atomic
    tmAssert(IS_ALLOCATED(instance), TMLIBDEV_ERR_NOT_OWNER);
    intAckPENDING(instance);
    return TMLIBDEV_OK;
}




/*
 * Function         : Inspect whether the specified
 *                    interrupt is pending
 * Parameters       : instance   (I) id of interrupt to inspect
 *                    pending    (O) returned True iff. interrupt
 *                                   is pending
 * Function Result  : resulting error condition
 */
extern      tmLibdevErr_t
intGetPending(intInterrupt_t instance, Bool * pending)
{
    tmAssert(IS_ALLOCATED(instance), TMLIBDEV_ERR_NOT_OWNER);
    tmAssert(pending != Null, TMLIBDEV_ERR_NULL_PARAMETER);

    *pending = intCheckPENDING(instance) != 0;

    return TMLIBDEV_OK;
}




/*
 * Function         : Cause a software interrupt to be raised
 *                    on another (or the current) node.
 * Parameters       : node_number   (I) number of the node to raise
 *                                      the interrupt on
 *                    instance      (I) id of interrupt to raise
 * Function Result  : resulting error condition
 * NB               : interrupts to be raised by this function
 *                    must be setup as edge triggered
 */

extern      tmLibdevErr_t
intRaise_M(UInt node_number, intInterrupt_t instance)
{
    UInt mask        = INT_MASK(instance);

    Bool swap_needed = (node_number != _node_number)
                       && ((MMIO(BIU_CTL) & 0x1)
                           != ((readpcsw() >> BSX_bit) & 0x1)
                          );

    if (swap_needed) {
        mask = REVERSE(mask);
    }

    tmAssert(node_number < _number_of_nodes, INT_ERR_INVALID_NODE);

    MMIO_M(node_number, IPENDING) = mask;

    return TMLIBDEV_OK;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -