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

📄 ipiix4pci.c

📁 IXP425的BSP代码
💻 C
📖 第 1 页 / 共 2 页
字号:
             j < IPIIX4_PCI_XINT_MAX;             j++, intrCounter++)            {            iPiix4PciIntRoute [i][j] = intrCounter;            }        }    return (OK);    }/********************************************************************************* iPiix4PciDevCreate - creates the PIIX4 device ** This routine will logically create PIIX4 device and hands out a handle to* caller to use.** RETURNS: index into array of handles (PASS), or -1 (FAIL).*/int iPiix4PciDevCreate    (    int instance    )    {    int i;    int tempInt;    /* check for first available free slot in array of handles */    for (i = 0; i < IPIIX4_PCI_DEVMAX; i++)        {        iPiix4PciHdlPtr = &iPiix4PciHandle [i];        if (iPiix4PciHdlPtr->handleInUse != TRUE)            {            break;            }        }    if (i >= IPIIX4_PCI_DEVMAX)        return (IPIIX4_PCI_NOIDX);  /* haven't found any slot free */    /* yup, found a free slot. check to see if device on pci bus exists */    if (pciFindDevice (IPIIX4_PCI_VENID,                       IPIIX4_PCI_DEV0,                       instance,                       &iPiix4PciHdlPtr->busId,                       &iPiix4PciHdlPtr->devId,                       &tempInt) != OK)        {        return (IPIIX4_PCI_NOIDX);        }        /* device found. set handleInUse to TRUE */    iPiix4PciHdlPtr->instance = instance;    iPiix4PciHdlPtr->handleInUse = TRUE;        return (i);    }/********************************************************************************* iPiix4PciKbdInit - initializes the PCI-ISA/IDE bridge ** This routine will initialize PIIX4 - PCI-ISA/IDE bridge to enable keyboard* device and IRQ routing** RETURNS: OK/ERROR*/STATUS iPiix4PciKbdInit    (    int handle    )    {    int longData;    short int shortData;    /* check if handle passed is with in limited range */    if (handle >= IPIIX4_PCI_DEVMAX)      return ERROR;    iPiix4PciHdlPtr = &iPiix4PciHandle [handle];        pciConfigInWord (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                     IPIIX4_PCI_FUNC3, IPIIX4_PCI_DEVRESD, &shortData);    pciConfigOutWord (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                      IPIIX4_PCI_FUNC3, IPIIX4_PCI_DEVRESD,                      (shortData | IPIIX4_PCI_IRQ1ENDEV11));        pciConfigInLong (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                     IPIIX4_PCI_FUNC3, IPIIX4_PCI_DEVRESA, &longData);    pciConfigOutLong (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                      IPIIX4_PCI_FUNC3, IPIIX4_PCI_DEVRESA,                      (longData | IPIIX4_PCI_KBCENDEV11));        pciConfigInLong (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                     IPIIX4_PCI_FUNC3, IPIIX4_PCI_DEVRESB, &longData);    pciConfigOutLong (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                      IPIIX4_PCI_FUNC3, IPIIX4_PCI_DEVRESB,                      (longData | IPIIX4_PCI_KBCEIOEN));    return (OK);    }/********************************************************************************* iPiix4PciFdInit - initializes the floppy disk device** This routine will initialize PIIX4 - PCI-ISA/IDE bridge and DMA* for proper working of floppy disk device** RETURNS: OK/ERROR*/STATUS iPiix4PciFdInit    (    int handle    )    {    unsigned char data;    /* check if handle passed is with in limited range */        if (handle >= IPIIX4_PCI_DEVMAX)      return ERROR;    iPiix4PciHdlPtr = &iPiix4PciHandle [handle];        /* DMA controller and Floppy */        sysOutByte (IPIIX4_PCI_FD_DCM,                (IPIIX4_PCI_FD_DCM_CASCADE | IPIIX4_PCI_FD_DCM_AUTOINIT));        sysOutByte (IPIIX4_PCI_FD_RWAMB, IPIIX4_PCI_FD_RWAMB_MASKALL);        pciConfigInByte (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                     IPIIX4_PCI_FUNC3, (IPIIX4_PCI_DEVRESD + 1), &data);    pciConfigOutByte (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                      IPIIX4_PCI_FUNC3, (IPIIX4_PCI_DEVRESD + 1),                      (data | IPIIX4_PCI_RESENDEV5));    return (OK);    }/********************************************************************************* iPiix4PciAtaInit - low level initialization of ATA device ** This routine will initialize PIIX4 - PCI-ISA/IDE bridge for proper* working of ATA device.** RETURNS: OK/ERROR*/STATUS iPiix4PciAtaInit    (    int handle    )    {    /* check if handle passed is with in limited range */          if (handle >= IPIIX4_PCI_DEVMAX)      return ERROR;    iPiix4PciHdlPtr = &iPiix4PciHandle [handle];            pciConfigOutWord (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                      IPIIX4_PCI_FUNC1, IPIIX4_PCI_PCICMD,                      (IPIIX4_PCI_PCICMD_BME | IPIIX4_PCI_PCICMD_IOSE));        pciConfigOutByte (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                      IPIIX4_PCI_FUNC1, IPIIX4_PCI_MLT, IPIIX4_PCI_MLT_MLTCV);        pciConfigOutLong (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                      IPIIX4_PCI_FUNC1, IPIIX4_PCI_BMIBA, IPIIX4_PCI_BMIBA_RTE);        pciConfigOutLong (iPiix4PciHdlPtr->busId, iPiix4PciHdlPtr->devId,                      IPIIX4_PCI_FUNC1, IPIIX4_PCI_IDETIM, IPIIX4_PCI_IDETIM_VAL);    return (OK);    }/********************************************************************************* iPiix4PciIntrRoute - Route PIRQ[A:D]** This routine will initialize PIIX4 - PCI-ISA/IDE bridge for PCI expansion* slot interrupt routing.** RETURNS: OK/ERROR*/STATUS iPiix4PciIntrRoute    (    int handle    )    {    unsigned char regValue;    unsigned char tmpValue;    int i;    /* check if handle passed is with in limited range */              if (handle >= IPIIX4_PCI_DEVMAX)      return ERROR;    iPiix4PciHdlPtr = &iPiix4PciHandle [handle];        for (i = 0; i < IPIIX4_PCI_XINT_MAX; i++)        {        tmpValue = iPiix4PciIntRoute[handle][i];                /* route PIRQ signal to IRQ# input of PIC */        pciConfigOutByte (iPiix4PciHdlPtr->busId,                          iPiix4PciHdlPtr->devId,                          IPIIX4_PCI_FUNC0,                          (IPIIX4_PCI_PIRQRCA + i),                          tmpValue);                /* make IRQs level triggered */        regValue = sysInByte (IPIIX4_PCI_ELCR2);        sysOutByte (IPIIX4_PCI_ELCR2,                    (regValue | (1 << (tmpValue - 0x8))));        }    return (OK);    }/********************************************************************************* iPiix4PciGetIntr - give device an interrupt level to use** This routine will give device an interrupt level to use. An autoroute in* disguise.** RETURNS: int - interrupt level*/int iPiix4PciGetIntr    (    int handle    )    {    int tmpInt;        /* check if handle passed is with in limited range */                if ((handle >= IPIIX4_PCI_DEVMAX) ||        (iPiix4PciIntrIdx[handle] >= IPIIX4_PCI_XINT_MAX))      {        return (IPIIX4_PCI_NOINT);      }    tmpInt = iPiix4PciIntrIdx[handle]++;    return (iPiix4PciIntRoute [handle][tmpInt]);    }/********************************************************************************* iPiix4PciGetHandle - give caller a handle for given device information** This routine will give a handle to caller from array of logical PIIX4s* already configured using iPiix4PciDevCreate ().** RETURNS: int. -1 (FAIL); handle (PASS)*/int iPiix4PciGetHandle    (    int vendId,    int devId,    int instance    )    {    int i;    int tmpBus;    int tmpDev;    int tmpFunc;        /* check to see if device on pci bus exists */    if (pciFindDevice (vendId,                       devId,                       instance,                       &tmpBus,                       &tmpDev,                       &tmpFunc) != OK)        {        return (IPIIX4_PCI_NOIDX);        }    /* check for first available free slot in array of handles */    for (i = 0; i < IPIIX4_PCI_DEVMAX; i++)        {        iPiix4PciHdlPtr = &iPiix4PciHandle [i];        if ((iPiix4PciHdlPtr->handleInUse == TRUE) &&        (iPiix4PciHdlPtr->busId == tmpBus) &&        (iPiix4PciHdlPtr->devId == tmpDev) &&        (iPiix4PciHdlPtr->instance == instance))            {            break;            }        }    if (i >= IPIIX4_PCI_DEVMAX)        return (IPIIX4_PCI_NOIDX);  /* haven't found any already created device */    return (i);    }

⌨️ 快捷键说明

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