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

📄 universe_dy4.c

📁 sbc7410的vxworksbsp
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* disable the interrupt */    *UNIVERSE_LINT_EN &= LONGSWAP( ~(1 << intLevel) );    return (OK);}/********************************************************************************* sysIntEnable - enable a bus interrupt level** This routine enables a specified VMEbus interrupt level.** RETURNS: OK, or ERROR if <intLevel> is not in the range 1 - 7.** SEE ALSO: sysIntDisable()*/STATUS sysIntEnable    (    int intLevel        /* interrupt level to enable (1-7) */    ){    if (intLevel < 1 || intLevel > 7)        return (ERROR);    /* clear any pending intr. for this level */    *UNIVERSE_LINT_STAT = LONGSWAP( (1 << intLevel ) );    /* enable the interrupt */    *UNIVERSE_LINT_EN |= LONGSWAP( (1 << intLevel) );    return (OK);}/********************************************************************************* sysBusIntAck - acknowledge a bus interrupt** This routine acknowledges a specified VMEbus interrupt level.** NOTE: This routine has no effect, since VMEbus interrupts are acknowledged* automatically by hardware if the interrupt level is enabled.** RETURNS: NULL.** SEE ALSO: sysBusIntGen()*/int sysBusIntAck    (    int intLevel        /* interrupt level to acknowledge */    ){    return ((int)NULL);}/********************************************************************************* sysBusIntGen - generate a bus interrupt** This routine generates a VMEbus interrupt for a specified level with a* specified vector.* This routine cannot be used to simulate a VME interrupt for the local* SBC due to a limitation of the UNIVERSE.** RETURNS: OK, or ERROR if <level> or <vector> are out of range.** SEE ALSO: sysBusIntAck()*/STATUS sysBusIntGen    (    int level,      /* interrupt level to generate    */    int vector      /* interrupt vector for interrupt */    ){    UINT32 intReg;    int lock;    if (level < 1 || level > 7 || vector > 255 || vector < 2)        return (ERROR);    lock = intLock();        /* Ensure bus interrupt is not already asserted */    intReg = sysInLong ((UINT32)UNIVERSE_VINT_STAT);    if (intReg & ((1 << level) << 24))    {        intUnlock(lock);        logMsg("level error\n",0,0,0,0,0,0);        return (ERROR);    }    /* store vector # */    *UNIVERSE_STATID    = LONGSWAP((vector << 24) | STATID_MASK);    /* clear VME_SW int enable bit */    *UNIVERSE_VINT_EN  &= LONGSWAP(~(1<<(VME_SW_OFFSET+level)));    /* generate VME_SW int enable bit */    *UNIVERSE_VINT_EN  |= LONGSWAP((1<<(VME_SW_OFFSET+level)));              /* unlock the interrupt */    intUnlock(lock);    return (OK);}/********************************************************************************* sysUnivIntEnable - enable Universe local interrupts** This routine enables the given Universe chip interrupt by setting the* corresponding bit in the LINT_EN register of the UNIVERSE chip.** RETURNS: OK, or ERROR if the argument is invalid.** SEE ALSO: UNIVERSE User's Manual*/STATUS sysUnivIntEnable    (    int lintEnBit   /* interrupt bit */    ){    /* make sure the interrupt type is valid */    if ((lintEnBit & UNIVERSE_INT_MASK) == 0)        return(ERROR);    /* clear any pending intr. for the DMA */    *UNIVERSE_LINT_STAT = LONGSWAP(lintEnBit);    /* enable the interrupt */    *UNIVERSE_LINT_EN |= LONGSWAP(lintEnBit);    return (OK);}/********************************************************************************* sysUnivIntDisable - disable Universe local interrupts** This routine disables the given Universe chip interrupt by clearing the* corresponding bit in the LINT_EN register of the UNIVERSE chip.** RETURNS: OK, or ERROR if the argument is invalid.** SEE ALSO: UNIVERSE User's Manual*/STATUS sysUnivIntDisable    (    int lintEnBit /* interrupt bit */    ){    /* make sure the interrupt type is valid */    if ((lintEnBit & UNIVERSE_INT_MASK) == 0)        return (ERROR);    /* clear any pending intr. for the DMA */    *UNIVERSE_LINT_STAT = LONGSWAP(lintEnBit);    /* disable the interrupt */    *UNIVERSE_LINT_EN &= LONGSWAP(~(lintEnBit));    return (OK);}/********************************************************************************* sysMailboxInt - handle mailbox interrupt** This is a generic mailbox interrupt handler that invokes the appropriate* installed mailbox interrupt routine.  If the installed argument is* SYS_MAILBOX_DATA, then the mailbox data is passed to the installed handler,* otherwise, the installed argument is passed to the installed handler.** NOMANUAL*/LOCAL void sysMailboxInt        (        int mailboxId       /* one of SYS_MAILBOX[0..3] */        ){    FUNCPTR routine;    int     arg;    switch(mailboxId)    {        case SYS_MAILBOX0 :            routine = sysMailbox0Routine;            arg = (sysMailbox0Arg==SYS_MAILBOX_DATA)?sysMailbox0:sysMailbox0Arg;            break;        case SYS_MAILBOX1 :            routine = sysMailbox1Routine;            arg = (sysMailbox1Arg==SYS_MAILBOX_DATA)?sysMailbox1:sysMailbox1Arg;            break;        case SYS_MAILBOX2 :            routine = sysMailbox2Routine;            arg = (sysMailbox2Arg==SYS_MAILBOX_DATA)?sysMailbox2:sysMailbox2Arg;            break;        case SYS_MAILBOX3 :            routine = sysMailbox3Routine;            arg = (sysMailbox3Arg==SYS_MAILBOX_DATA)?sysMailbox3:sysMailbox3Arg;            break;        default :            return;    }    if (routine != NULL)        routine (arg);    else        logMsg("Default Mailbox handler : mailboxID = %d, data = 0x%x\n",                mailboxId, arg, 0,0,0,0);}/********************************************************************************* sysUnivMailboxConnect - connect a routine to the mailbox interrupt** This routine specifies the interrupt service routine to be called at each interrupt for* the corresponding mailbox.* The interrupt service routine should have the following prototype:*                      void Routine(UINT32 arg)** RETURNS: OK, or ERROR if the routine cannot be connected to the interrupt.** SEE ALSO: intConnect(), sysMailboxEnable()*/STATUS sysUnivMailboxConnect    (    int mailboxId,      /* SYS_MAILBOX[0..3] */    FUNCPTR routine,    /* routine called at each mailbox interrupt */    int     arg         /* argument with which to call routine      */    ){    switch(mailboxId)    {        case SYS_MAILBOX0 :            sysMailbox0Routine = routine;            sysMailbox0Arg = arg;            break;        case SYS_MAILBOX1 :            sysMailbox1Routine = routine;            sysMailbox1Arg = arg;            break;        case SYS_MAILBOX2 :            sysMailbox2Routine = routine;            sysMailbox2Arg = arg;            break;        case SYS_MAILBOX3 :            sysMailbox3Routine = routine;            sysMailbox3Arg = arg;            break;        default :            return ERROR;    }    return OK;}/********************************************************************************* sysMailboxConnect - connect a routine to the system mailbox interrupt** This routine specifies the interrupt service routine to be called at each* interrupt for the system's reserved mailbox (default to SYS_MAILBOX0).* If arg is SYS_MAILBOX_DATA, the mailbox content is passed to the user mailbox* interrupt handler. If arg is any other value, arg itself is passed.** RETURNS: OK, or ERROR if the routine cannot be connected to the interrupt.** SEE ALSO: intConnect(), sysMailboxEnable()*/STATUS sysMailboxConnect    (    FUNCPTR routine,    /* routine called at each mailbox interrupt */    int     arg             /* argument with which to call routine      */    ){    return sysUnivMailboxConnect (SYS_MAILBOX0, routine, arg);}/********************************************************************************* sysMailboxEnable - enable the mailbox interrupt* This routine enables the mailbox interrupt.* Mailbox 0 (SYS_MAILBOX0) is reserved for shared memory networking.* Applications may use SYS_MAILBOX[1..3] as the given mailbox id.* If shared memory networking is not used, applications may use SYS_MAILBOX0.** RETURNS: OK, always.** SEE ALSO: sysMailboxConnect(), sysMailboxDisable()*/STATUS sysMailboxEnable    (    char *  mailboxId       /* One of SYS_MAILBOX[0..3] */    ){    int mailboxEnableBit;    switch ((int)mailboxId)    {        case SYS_MAILBOX1 :            mailboxEnableBit = LINT_EN_MBOX1;            break;        case SYS_MAILBOX2 :            mailboxEnableBit = LINT_EN_MBOX2;            break;        case SYS_MAILBOX3 :            mailboxEnableBit = LINT_EN_MBOX3;            break;        case SYS_MAILBOX0 : /* SYS_MAILBOX0 and others */        default :            mailboxEnableBit = LINT_EN_MBOX0;            break;    }    *UNIVERSE_LINT_EN |= LONGSWAP(mailboxEnableBit);    return (OK);}/********************************************************************************* sysMailboxDisable - disable the mailbox interrupt** This routine disables the mailbox interrupt.* Mailbox 0 (SYS_MAILBOX0) is reserved for shared memory networking.* Applications may use SYS_MAILBOX[1..3] as the given mailbox id* If shared memory networking is not used, applications may use SYS_MAILBOX0.** RETURNS: OK, always.** SEE ALSO: sysMailboxConnect(), sysMailboxEnable()*/STATUS sysMailboxDisable    (    char *  mailboxId       /* One of SYS_MAILBOX[0..3] */    ){    int mailboxEnableBit;    switch ((int)mailboxId)    {        case SYS_MAILBOX1 :            mailboxEnableBit = LINT_EN_MBOX1;            break;        case SYS_MAILBOX2 :            mailboxEnableBit = LINT_EN_MBOX2;            break;        case SYS_MAILBOX3 :            mailboxEnableBit = LINT_EN_MBOX3;            break;                    case SYS_MAILBOX0 : /* SYS_MAILBOX0 and others */        default :            mailboxEnableBit = LINT_EN_MBOX0;            break;    }    *UNIVERSE_LINT_EN &= ~LONGSWAP(mailboxEnableBit);    return (OK);}/********************************************************************************* sysUniverseIntr - handle Universe interrupts** This routine is the general interrupt handler for the Universe chip.* This routine then examines the chip's status to determine the interrupt* source, and the corresponding vector.  It then invokes the handler for the* determined vector in the system vector table.** RETURNS: N/A.** NOMANUAL*/void sysUniverseIntr (void){    INT_HANDLER_DESC *  currHandler;    UINT8               intVecNum = 0;    int                 vmeIntLvl = 0;    int                 vec_num = 0;    int clearInt;    int prevIntLvl;#if  defined(INCLUDE_VME_DMA)    UINT32    lint_status;#endif        /* get the interrupt level */    vmeIntLvl = LONGSWAP( *UNIVERSE_LINT_STAT);    vmeIntLvl &= LINT_STAT_INT_MASK;    vmeIntLvl &= LONGSWAP( *UNIVERSE_LINT_EN );  /* MR #39 */    /* Added by fzz for test UniverseII interrupt */    #ifdef VME_INT_DEBUG    logMsg ("SBC7410 sysUniverseIntr:entry, the level is %#x\n", vmeIntLvl, 0, 0, 0, 0, 0);    #endif#if  defined(INCLUDE_VME_DMA)

⌨️ 快捷键说明

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