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

📄 sysgei82544end.c

📁 intel xscale 425的bsp源码
💻 C
📖 第 1 页 / 共 4 页
字号:
            return (END_OBJ *) NULL;            }        pReso = &geiResources [unit];        /* Now, we go to the end of the string, past unit number + : */        pStr += strlen (paramStr);        txDesNum = geiConfig[unit].txDesNum;        if (txDesNum == 0)            txDesNum = GEI_TXDES_NUM;        rxDesNum = geiConfig[unit].rxDesNum;        if (rxDesNum == 0)            rxDesNum = GEI_RXDES_NUM;        clSize = (1536 + _CACHE_ALIGN_SIZE - CL_OVERHEAD);        mtu = ETHERMTU;        if (geiConfig[unit].clSize != 0)            clSize = geiConfig[unit].clSize;        if (geiConfig[unit].mtu != 0)            mtu = geiConfig[unit].mtu;        memSize = txDesNum * TXDESC_SIZE +      /* for TX descriptor */           rxDesNum * RXDESC_SIZE +             /* for RX descriptor */           rxDesNum * (clSize + CL_OVERHEAD) *  /* for RX buffer */           (DEFAULT_LOAN_RXBUF_FACTOR + 1) +    /* for RX loan buffer */           1024;        memAddrAlloc = (UINT32) cacheDmaMalloc (memSize);        memAddr = (volatile INT32) ((((UINT32) memAddrAlloc) + 0x400) & ~0x400);        if (memAddr == 0)            {            SYS_GEI_LOG ("gei82543EndLoad: failed to allocate descriptor "                         "memory for unit %d.\n", unit, 0, 0, 0, 0, 0);            return NULL;            }        /* finish off the initialization parameter string */        sprintf (pStr, "%#x:%#x:%#x:%#x:%x:2:%#x:%d",  /* Use 2 for offset */                 memAddr,                 memSize,                 txDesNum,                 rxDesNum,                 geiConfig[unit].usrFlags,                 clSize,                 mtu);        /* Set up BAR in PCI controller so that the PCI device can access         * the memory that has just been set up for it         */        if(sysPciMappingAdd((UINT32)memAddr, memSize)!=OK)            {            printf("sysPciMappingAdd failed in sysLanPciInit\n");            cacheDmaFree ((void *)memAddrAlloc);            return NULL;            }        if ((pEnd = (END_OBJ *) gei82543EndLoad (paramStr)) == NULL)            {            SYS_GEI_LOG ("Error: sysGei82543EndLoad failed to load driver for "                         "unit %d, errno = 0x%x\n", unit, errno, 0, 0, 0, 0);            }        }    return (pEnd);    }/******************************************************************************* sys543Show - shows 82543 configuration** This routine shows (Intel Pro 1000F/T) adaptors configuration** ERRNO: N/A** RETURNS: N/A*/void sys543Show    (    int    unit        /* unit number */    )    {    int ix;    GEI_RESOURCE *pReso = &geiResources [unit];    if (unit >= geiUnits)        {        printf ("invalid unit number: %d\n", unit);        return;        }    if (pReso->boardType == PRO1000_543_BOARD)        printf ("\n********* Intel PRO1000 543 Adaptor ***********\n\n");    else if (pReso->boardType == PRO1000_544_BOARD)        printf ("\n********* Intel PRO1000 544 Adaptor ***********\n\n");    else if (pReso->boardType == PRO1000_546_BOARD)        printf ("\n********* Intel PRO1000 546 Adaptor ***********\n\n");    else        printf ("\n********* UNKNOWN Adaptor ************ \n\n");    printf ("  Vendor ID = 0x%x\n", pReso->pciVendID);    printf ("  Device ID = 0x%x\n\n", pReso->pciDevID);    printf ("  Subsystem Vendor ID = 0x%x\n", pReso->subSysVendID);    printf ("  Subsystem Device ID = 0x%x\n\n", pReso->subSysDevID);    printf ("  Revision ID = 0x%x\n\n", pReso->revID);    printf ("  Class Code = 0x%x\n", pReso->classCode);    printf ("  Sub-Class Code = 0x%x\n", pReso->subClassCode);    printf ("  Programming Interface = 0x%x\n\n", pReso->progIF);    if (pReso->addr64)        {         printf ("  CSR PCI Membase address (LOW)= 0x%x\n", pReso->memBaseLow);         printf ("  CSR PCI Membase address (HIGH)= 0x%x\n", pReso->memBaseHigh);         printf ("  Flash PCI Membase address (LOW)= 0x%x\n", pReso->flashBaseLow);         printf ("  Flash PCI Membase address (HIGH)= 0x%x\n", pReso->flashBaseHigh);         printf ("  PCI IObase address = 0x%x\n\n", pReso->ioBase);        }    else        {         printf ("  CSR PCI Membase address = 0x%x\n", pReso->memBaseLow);         printf ("  Flash PCI Membase address = 0x%x\n", pReso->flashBaseLow);         printf ("  PCI IObase address = 0x%x\n\n", pReso->ioBase);        }    printf ("  PCI bus no.= 0x%x, device no.= 0x%x, function no.= 0x%x\n\n",             pReso->pciBus, pReso->pciDevice, pReso->pciFunc);    printf ("  IRQ = %d\n\n", pReso->irq);    if (pReso->iniStatus == ERROR)        return;    printf ("  Adaptor Ethernet Address");    for (ix = 0; ix < 6; ix ++)        printf (":%2.2X", (UINT32)pReso->enetAddr[ix]);    printf ("\n\n");    printf ("  EEPROM Initialization Control Word 1 = 0x%4.4X\n",            pReso->eeprom_icw1);    printf ("  EEPROM Initialization Control Word 2 = 0x%4.4X\n\n",            pReso->eeprom_icw2);    printf ("*********************************************\n\n");    return;    }#ifdef SYS_543_EEPROM_UTILS/***************************************************************************** sys543eepromDump - dump EEPROM contents for unit** The EEPROM contents for the specified unit are printed to standard output.** ERRNO: N/A** RETURNS: N/A.*/void sys543eepromDump    (    int unit        /* unit number */    )    {    int ix;    UINT16 word;    for (ix = 0; ix < EEPROM_WORD_SIZE; ix++)        {        if ((ix & 7) == 0)            printf ("\n0x%02x: ", ix);        word = sys543eepromReadWord (unit, ix);        printf ("  %04x", word);        }    printf ("\n");    }/***************************************************************************** sys543eepromDump - copy EEPROM contents for unit to memory** The 64 two-byte words of EEPROM for unit <unit> are copied to* memory at address <pWords>.** ERRNO: N/A** RETURNS: OK or ERROR.*/STATUS sys543eepromCopy    (    int unit,        /* unit number */    UINT16 * pWords  /* fill this array */    )    {    int ix;    if (pWords == NULL)        return ERROR;    for (ix = 0; ix < EEPROM_WORD_SIZE; ix++)        pWords [ix] = sys543eepromReadWord (unit, ix);    return OK;    }/***************************************************************************** sys543eepromProgram - program EEPROM contents** This routine programs the 82543 EEPROM for unit number <unit> with the* contents of the array of 64 UINT16's at address <pContents>. If the* <checksumFix> argument is TRUE, then the checksum word (index 0x3f)* will be modified to give the required checksum of EEPROM_SUM (0xbaba).** ERRNO: N/A** RETURNS: OK or ERROR.*/STATUS sys543eepromProgram    (    int unit,            /* unit number */    UINT16 * pContents,  /* fill EEPROM with contents of this array */    BOOL checksumFix     /* TRUE = adjust so checksum is 0xbaba */    )    {    UINT16 checksum;    int ix;    if (pContents == NULL)        return ERROR;    checksum = 0;    for (ix = 0; ix < EEPROM_WORD_SIZE; ix++)        checksum += pContents[ix];    if (!checksumFix && checksum != EEPROM_SUM)        printf ("Warning: checksum is 0x%4x, not 0x%4x.\n",                checksum, EEPROM_SUM);    if (checksumFix)        pContents [EEPROM_WORD_SIZE - 1] += (EEPROM_SUM - checksum);    sys543eepromEraseWriteAllow (unit, TRUE);    sys543eepromEraseAll (unit);    for (ix = 0; ix < EEPROM_WORD_SIZE; ix++)        {        sys543eepromWriteWord (unit, ix, pContents[ix]);        }    sys543eepromEraseWriteAllow (unit, FALSE);    return OK;    }/***************************************************************************** sys543eepromEraseWriteAllow - enable or disable EEPROM erases and writes** If <enable> is TRUE, enables erases and writes to EEPROM on unit <unit>.* If <enable> is FALSE, disables erases and writes to the EEPROM.** ERRNO: N/A** RETURNS: OK or ERROR.*/STATUS sys543eepromEraseWriteAllow    (    int unit,    BOOL enable    )    {    UINT16 word;    GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, EECD_CS_BIT);    /* wait */    SYS_DELAY(10);    /* write the opcode out */    word = enable ? EEPROM_EWEN_OPCODE : EEPROM_EWDS_OPCODE;    sys543eepromWriteBits (unit, word, EEPROM_CMD_BITS + EEPROM_INDEX_BITS);    GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, 0);    /* wait */    SYS_DELAY(300);    return OK;    }/***************************************************************************** sys543eepromEraseAll - erase entire EEPROM for unit** This routine erases the entire EEPROM for unit number <unit>.** ERRNO: N/A** RETURNS: OK or ERROR.*/STATUS sys543eepromEraseAll    (    int unit    )    {    GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, EECD_CS_BIT);    /* wait */    SYS_DELAY(10);    /* write the opcode out */    sys543eepromWriteBits (unit, EEPROM_ERAL_OPCODE,                           EEPROM_CMD_BITS + EEPROM_INDEX_BITS);    GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, 0);    /* wait */    SYS_DELAY(300);    return OK;    }/***************************************************************************** sys543eepromWriteWord - write EEPROM word** This routine writes the word at index <index> to value <word> in the* EEPROM of unit <unit>.  The word must have been erased already.** ERRNO: N/A** RETURNS: OK or ERROR.*/STATUS sys543eepromWriteWord    (    int unit,        /* unit number */    UINT32 index,    /* where to write in EEPROM */    UINT16 word      /* the data to stuff in EEPROM */    )    {    /* write the opcode out */    sys543eepromWriteBits (unit, EEPROM_WRITE_OPCODE, EEPROM_CMD_BITS);    /* write the index out */    sys543eepromWriteBits (unit, index, EEPROM_INDEX_BITS);    /* write the data out */    sys543eepromWriteBits (unit, word, EEPROM_DATA_BITS);    GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, 0);    /* wait */    SYS_DELAY(300);    return OK;    }/***************************************************************************** sys543eepromMacAddrSet - modify MAC address stored in EEPROM for unit** This routine stores the MAC address specified by <macAddrString> (which* should have the form "XX:XX:XX:XX:XX:XX", with each X being a* hexadecimal digit) in the EEPROM of the specified unit.** ERRNO: N/A** RETURNS: OK or ERROR.*/STATUS sys543eepromMacAddrSet    (    int unit,             /* unit number */    char * macAddrString  /* pointer to Ethernet address */    )    {    UINT16 eeImage [EEPROM_WORD_SIZE];    if (macAddrString == NULL)        return ERROR;    if (sys543eepromCopy (unit, eeImage) != OK)        return ERROR;    if (sys543MacAddrStringConvert ((UINT8 *) eeImage, macAddrString) != OK)        return ERROR;    return sys543eepromProgram (unit, eeImage, TRUE);    }#endif /* SYS_543_EEPROM_UTILS *//***************************************************************************** sys543MacAddrStringConvert - ethernet MAC addr string to internal form** This routine converts an ethernet MAC address string <macAddrString>* (e.g. "08:00:20:a8:74:13") to the internal 6-byte form stored at* <internAddr>.*/STATUS sys543MacAddrStringConvert    (    UINT8 mac [],        /* 6 byte result */    char * macAddrString /* Ethernet address to be converted to bytes */    )    {    UINT m0, m1, m2, m3, m4, m5;    if (sscanf (macAddrString, "%2x:%2x:%2x:%2x:%2x:%2x",                &m0, &m1, &m2, &m3, &m4, &m5) != 6)        return ERROR;    mac[0] = m0; mac[1] = m1; mac[2] = m2;    mac[3] = m3; mac[4] = m4; mac[5] = m5;    return OK;    }LOCAL STATUS sys543IntConnect    (     void *vector,     VOIDFUNCPTR *intHandler,     int drvCtrl    )    {    int irq;    int pin = 0;    STATUS retval;    retval = pciIntConnect ((VOIDFUNCPTR *)vector,                             (VOIDFUNCPTR)intHandler,                             drvCtrl);    irq = sysPciIntVectorToIrq(vector);    switch (irq)        {        case IXP425_PCI_INTA_INDEX:            pin = IXP425_PCI_INTA_PIN;            break;        case IXP425_PCI_INTB_INDEX:            pin = IXP425_PCI_INTB_PIN;            break;        case IXP425_PCI_INTC_INDEX:            pin = IXP425_PCI_INTC_PIN;            break;        case IXP425_PCI_INTD_INDEX:            pin = IXP425_PCI_INTD_PIN;            break;        }    /* We need to clear the GPIO status after every interrupt.  * ixp425PciInt() does this "post-processing" *//*Note: This is slightly slower than combining the two routines into one */    if (retval != ERROR)        retval = pciIntConnect ((VOIDFUNCPTR *)vector,                                 (VOIDFUNCPTR)ixp425PciInt,                                 pin);    return retval;    }#endif /* INCLUDE_GEI_END */

⌨️ 快捷键说明

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