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

📄 mpc107msg.c

📁 IXP425的BSP代码
💻 C
📖 第 1 页 / 共 3 页
字号:
        /* Write the MFA to Outbound Post Fifo Head Pointer Reg OPHPR */        mpc107MsgRegMod (0, MPC107_MSG_WRITE,                            MPC107_MSG_I2O_OPHPR,(UINT32) ppTempMfa, 0);        }    }/***************************************************************************** mpc107MsgI2oOutboundRead -  read  from  I20 Outbound interface** This routine is used by the external PCI master to read messages posted to* the I2O Outbound Interface  by the host processor .** RETURNS: N/A*/void mpc107MsgI2oOutboundRead (void)    {    UINT32 **ppTempMfa;    /* pointer to Message Frame pointer */    UINT32 *pTempReadMfa;  /* pointer to Message Frame */    ULONG tempIndex;       /* index  */    UINT32 pBuf[MPC107_MSG_I2O_MFRAME_SIZE]; /* buffer to read data */    /*     * Read Outbound Fifo Queue Port Register (OFQPR)  to get the MFA     * While FIFO is not empty     */     while((ppTempMfa = (UINT32 **)mpc107MsgRegMod(pciBaseAddr, MPC107_MSG_READ,                                      MPC107_MSG_I2O_PCI_OFQPR, 0, 0)) !=                                      (UINT32 **)MPC107_MSG_I2O_FIFO_EMPTY)        {        /* Read the messages  */        pTempReadMfa  = *ppTempMfa;        for (tempIndex = 0; tempIndex < MPC107_MSG_I2O_MFRAME_SIZE; tempIndex++)            {            *((UINT32 *)(pBuf+ tempIndex)) =                      *((UINT32 *)(pTempReadMfa + tempIndex));            /* Write the MFA to Outbound Fifo Queue Port Register (OFQPR) */            mpc107MsgRegMod (pciBaseAddr, MPC107_MSG_WRITE,                            MPC107_MSG_I2O_PCI_OFQPR,(UINT32) ppTempMfa, 0);            }        }    }/***************************************************************************** mpc107MsgI2oInboundWrite -  write  to  I20 Inbound interface** This routine is used by the external PCI master for writing messages to* the I2O Inbound Interface .** The external PCI master obtains a free MFA  and  posts  the messages.** RETURNS: OK, or ERROR if free MFAs are not available.*/STATUS mpc107MsgI2oInboundWrite    (    UINT32 *	pBuf  /* pointer to message to be written to the Inbound */                      /* I2O interface */    )    {    UINT32 **	ppTempMfa;      /* pointer to Message Frame pointer */    UINT32 *	pTempWriteMfa;  /* pointer to Message Frame  */    ULONG 	tempIndex;      /* index */    /* Read Inbound Fifo Queue Port Register  to Get MFA */    ppTempMfa = (UINT32 **)mpc107MsgRegMod (pciBaseAddr, MPC107_MSG_READ,                                            MPC107_MSG_I2O_PCI_IFQPR, 0, 0);    /* Check to see if the Inbound interface has free MFAs  */    if (ppTempMfa == (UINT32 **)MPC107_MSG_I2O_NO_FREE_MFA)        {        return(ERROR) ;  /* No free MFAs */        }    else  /* Free MFAs are available */        {        pTempWriteMfa =  *(ppTempMfa) ;        /* Write the message in the Message Frame */        for (tempIndex = 0; tempIndex < MPC107_MSG_I2O_MFRAME_SIZE;                            tempIndex++)            {            *(UINT32 *)(pTempWriteMfa + tempIndex) =                                      *(UINT32 *)(pBuf + tempIndex);            }        /* Write the MFA to the Inbound Fifo Queuue Port Register  */        mpc107MsgRegMod (pciBaseAddr, MPC107_MSG_WRITE,                         MPC107_MSG_I2O_PCI_IFQPR, (UINT32)ppTempMfa, 0);        return (OK);        }   }/***************************************************************************** mpc107MessageInInt - ISR for interrupts from the Inbound Message Unit** This routine services the Inbound Message,Inbound Doorbell and* Inbound I2O interrupts .** RETURNS: N/A*/void mpc107MessageInInt (void)    {     ULONG 	tempStatusData; /* interrupt status register contents */     ULONG 	tempMaskData;   /* interrupt Mask register contents */     UINT32 	pMessageRead;   /* data read */     /* Read the Inbound Message Interrupt Status Register */    tempStatusData = mpc107MsgRegMod (0x0,MPC107_MSG_READ,                                          MPC107_MSG_I2O_IMISR, 0, 0);    /* Read the Inbound Message Interrupt Mask Register */    tempMaskData = mpc107MsgRegMod (0x0, MPC107_MSG_READ ,                                         MPC107_MSG_I2O_IMIMR, 0, 0);    /* Inbound Message 0 Interrupt */    if ((tempStatusData & MPC107_MSG_I2O_IM0I & MPC107_MSG_I2O_IM0IM) != 0)        {        mpc107MsgMessageRead (MPC107_MSG_INBOUND ,                              MPC107_MSG_REGISTER0 , &pMessageRead);        }    /* Inbound Message 1 Interrupt */    if ((tempStatusData & MPC107_MSG_I2O_IM1I & MPC107_MSG_I2O_IM1IM) !=0 )        {         mpc107MsgMessageRead (MPC107_MSG_INBOUND ,                               MPC107_MSG_REGISTER1 , &pMessageRead);        }    /* Inbound Doorbell  Interrupt */    if ((tempStatusData & MPC107_MSG_I2O_IDI & MPC107_MSG_I2O_IDIM) !=0 )        {        mpc107MsgDoorbellRead (MPC107_MSG_INBOUND,&pMessageRead);        }    /* Inbound Doorbell  Register Machine Check */    if ((tempStatusData & MPC107_MSG_I2O_MCI & MPC107_MSG_I2O_MCIM) != 0)        {        }    /* Inbound Post Queue interrupt ,indicating  MFA in IFQPR */    if ((tempStatusData & MPC107_MSG_I2O_IPQI & MPC107_MSG_I2O_IPQIM) !=0 )        {           mpc107MsgI2oInboundRead();        }    /* Inbound Post List Overflow  */    if ((tempStatusData & MPC107_MSG_I2O_IPOI & MPC107_MSG_I2O_IPOIM) != 0)        {        }   /* Outbound Post List Overflow  */    if ((tempStatusData & MPC107_MSG_I2O_OFOI & MPC107_MSG_I2O_OFOIM) != 0)        {        }    /* Clear the interrupts */    mpc107MsgRegMod (0x0,MPC107_MSG_WRITE,                         MPC107_MSG_I2O_IMISR, tempStatusData, 0);    }/***************************************************************************** mpc107MessageOutInt - ISR for the interrupts  from Outbound Message Unit** This routine services the Outbound Message,Outbound Doorbell and* Outbound I2O interrupts .** RETURNS: N/A*/void mpc107MessageOutInt (void)    {     ULONG 	tempStatusData; /* interrupt status register contents */     ULONG 	tempMaskData;   /* interrupt Mask register contents */     UINT32 	pMessageRead;    /* Read the Outbound Message Interrupt Status Register */    tempStatusData = mpc107MsgRegMod (pciBaseAddr, MPC107_MSG_READ,                                      MPC107_MSG_I2O_PCI_OMISR, 0, 0);    /* Read the Outbound Message Interrupt Mask Register */    tempMaskData = mpc107MsgRegMod (pciBaseAddr, MPC107_MSG_READ ,                                    MPC107_MSG_I2O_PCI_OMIMR, 0, 0);    /* Outbound Message 0 Interrupt */    if ((tempStatusData & MPC107_MSG_I2O_OM0I & MPC107_MSG_I2O_OM0IM) != 0)        {        mpc107MsgMessageRead (MPC107_MSG_OUTBOUND ,                              MPC107_MSG_REGISTER0 , &pMessageRead);        }    /* Outbound Message 1 Interrupt */    if ((tempStatusData & MPC107_MSG_I2O_OM1I & MPC107_MSG_I2O_OM1IM) != 0)        {         mpc107MsgMessageRead (MPC107_MSG_OUTBOUND ,                               MPC107_MSG_REGISTER1 , &pMessageRead);        }    /* Outbound Doorbell  Interrupt */    if ((tempStatusData & MPC107_MSG_I2O_ODI & MPC107_MSG_I2O_ODIM) != 0)        {        mpc107MsgDoorbellRead (MPC107_MSG_OUTBOUND, &pMessageRead);        }    /* Outbound Post Queue interrupt ,indicating  MFA in OFQPR */    if ((tempStatusData & MPC107_MSG_I2O_OPQI & MPC107_MSG_I2O_OPQIM) != 0)        {           mpc107MsgI2oOutboundRead();        }    /* Clear the interrupts */    mpc107MsgRegMod (pciBaseAddr,MPC107_MSG_WRITE,                     MPC107_MSG_I2O_PCI_OMISR, tempStatusData, 0);    }/***************************************************************************** mpc107MsgRegMod - i2o Registers In/OutLong and/or-ing wrapper.** The purpose of this function is to perform and, or and* and/or i2oPciIn/OutLong operations with syncronization.** RETURNS: The data  for read operations.*/LOCAL UINT32 mpc107MsgRegMod    (    UINT32 	pciBar,        /* Zero for EUMBBAR or a base Address */                               /* for PCI access */    UINT32 	ioControlFlag, /* input/ouput control flag */                               /* 0, write */                               /* 1, read */                               /* 2, read/modify/write (ORing) */                               /* 3, read/modify/write (ANDing) */                               /* 4, read/modify/write (AND/ORing) */    UINT32 	address,       /* address of device register  */    UINT32 	wdata1,        /* data item 1 for read/write operation */    UINT32 	wdata2         /* data item 2 for read/write operation */    )    {    UINT32 i2oTempData;    if (ioControlFlag == MPC107_MSG_WRITE) /* Write */        {        /*         * Data wdata1 is to be written in         * the register specified by address         */        mpc107MsgWrite (pciBar, address, wdata1);        }    else if (ioControlFlag == MPC107_MSG_READ) /* Read */        {        /*         * Data wdata1 is read from the register         * specified by address         */        i2oTempData = mpc107MsgRead (pciBar, address);        }    else if (ioControlFlag == MPC107_MSG_READ_OR_WRITE) /* Read OR write */        {        /*         * Data wdata1 is bitwise ORed with the data         * read from the register specified by address         * and the resultant  data is written to the         * register         */        i2oTempData = mpc107MsgRead (pciBar, address);        SYNC;        i2oTempData |= wdata1;        mpc107MsgWrite (pciBar, address, i2oTempData);        }    else if (ioControlFlag == MPC107_MSG_READ_AND_WRITE)  /* Read AND Write */        {        /*         * Data wdata1 is bitwise ANDed with the data         * read from the register specified by address         * and the resultant  data is written to the         * register         */        i2oTempData = mpc107MsgRead (pciBar, address);        SYNC;        i2oTempData &= wdata1;        mpc107MsgWrite (pciBar, address, i2oTempData);        }     else if (ioControlFlag == MPC107_MSG_READ_ANDOR_WRITE)        {        /*         * Data wdata1 is bitwise ANDed with the data         * read from the register specified by address         * and  data wdata2 is bitwise ORed  ,         * and the resultant  data is written to the register         */        i2oTempData = mpc107MsgRead (pciBar, address);        SYNC;        i2oTempData &= wdata1;        i2oTempData |= wdata2;        mpc107MsgWrite (pciBar, address, i2oTempData);        }    SYNC;    return (i2oTempData);    }/***************************************************************************** mpc107MsgWrite - write data to  Message Unit Registers** This routine writes the data in the specified Register* added to the offset  specified by the base address register .** RETURNS: N/A*/LOCAL void mpc107MsgWrite    (    UINT32 	pciBar,        /* Zero for EUMBBAR or a base Address */                               /* for PCI access */    UINT32 	messageRegNum, /* Message Register Number */    UINT32 	message        /* Message */    )    {    if ((pciBar) != 0)        {        *(UINT32 *)(pciBar + messageRegNum) = MPC107LONGSWAP(message);        }    else        {        MPC107EUMBBARWRITE (messageRegNum, message);        }    }/***************************************************************************** mpc107MsgRead - read data from  Message Unit Registers** This routine  reads  the data in the specified Register  added to the offset* specified by the base address register.** RETURNS: The data read from the register is returned*/LOCAL ULONG mpc107MsgRead    (    UINT32 	pciBar,        /* zero for EUMBBAR or a base Address */                               /* for PCI access */    UINT32 	messageRegNum  /* message register number */    )    {    if ((pciBar) != 0)        {        return (*(UINT32 *)(pciBar + messageRegNum));        }    else        {        return (MPC107EUMBBARREAD(messageRegNum));        }    }

⌨️ 快捷键说明

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