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

📄 sysel3c90xend.c

📁 vxworks bsp for pc pentium3 开发环境为tornado2.2 for pentium。
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************** sysEl3c90xEndLoad - construct a load string and load an el3c90xEnd device** This routine will be invoked by the MUX for the purpose of loading an* el3c90xEnd (elPci) device with initial parameters.  This routine is* constructed as an interface wrapper for the driver load routine.  Thus,* the arguments and return values are consistent with any xxxEndLoad()* routine defined for an END driver and the MUX API.** INTERNAL* The muxDevLoad() operation calls this routine twice.  A zero length* <pParamStr> parameter string indicates that this is the first time* through this routine.  The driver load routine should return the* driver name in <pParamStr>.** On the second pass though this routine, the initialization parameter* string is constructed.  Note that on the second pass, the <pParamStr>* consists of a colon-delimeted END device unit number and rudimentary* initialization string (often empty) constructed from entries in the* BSP END Device Table such that:**     <pParamStr> = "<unit>:<default initialization string>"** In the process of building the rest of <pParamStr>, the prepended unit* number must be preserved and passed to the driver load routine.  The* <default initialization string> portion mentioned above is discarded,* but future versions of this routine may use it.** The complete el3c90xEnd driver load string has format:**     <unit>:<devMemAddr>:<devIoAddr>:<pciMemBase>:<vecnum>:<intLvl>:*     <memAdrs>:<memSize>:<memWidth>:<flags>:<buffMultiplier>** RETURNS: An END object pointer, or NULL on error, or 0 and the name of the* device if the <pParamStr> was NULL.** SEE ALSO: el3c90xEndLoad()*/END_OBJ * sysEl3c90xEndLoad    (    char *    pParamStr,   /* pointer to initialization parameter string */    void *    unused       /* unused optional argument */    )    {    END_OBJ * pEnd;    char      paramStr [END_INIT_STR_MAX];    static const char * const paramTemplate =         "%d:0x%x:0x%x:0x%x:%d:%d:-1:-1:-1:0x%x:0x%x:%p";    /* point to 3c90x board resource table */    PCI_BOARD_RESOURCE * const pRsrc = elPciResources;    if (strlen (pParamStr) == 0)        {        /* PASS (1)         * The driver load routine returns the driver name in <pParamStr>.         */        pEnd = el3c90xEndLoad (pParamStr);        }    else        {        /* PASS (2)         * The END <unit> number is prepended to <pParamStr>.  Construct         * the rest of the driver load string based on physical devices         * discovered in sysEl3c90xPciInit().  When this routine is called         * to process a particular END <unit> number, use the END <unit> as         * an index into the PCI "resources" table to build the driver         * parameter string.         */        int    typeIdx;   /* index to the string resource table */        char * holder  = NULL;        int    endUnit = atoi (strtok_r (pParamStr, ":", &holder));        /* is there a PCI resource associated with this END unit ? */        if (endUnit >= etherLinkUnits)            {            return NULL;            }        /* construct an index into the string resource table */        typeIdx = (pRsrc[endUnit].boardType);        /* finish off the initialization parameter string */        sprintf (paramStr, paramTemplate,                 endUnit,                   /* END unit number */                 pRsrc[endUnit].bar[1],     /* memory-mapped IO base */                 pRsrc[endUnit].bar[0],     /* IO address space base */                 PCI2DRAM_BASE_ADRS,        /* host PCI mem. base */                 pRsrc[endUnit].irqvec,     /* IRQ vector */                 pRsrc[endUnit].irq,        /* IRQ number */                 EL_3C90X_END_FLAGS,        /* flags for type */                 EL_3C90X_BUFF_MTPLR,       /* buff alloc factor */                 &elDescription[typeIdx]    /* device description */                );        if ((pEnd = el3c90xEndLoad (paramStr)) == (END_OBJ *) NULL)            {            printf ("Error el3c90xEndLoad:  failed to load driver.\n");            }        }    return (pEnd);    }/********************************************************************************* sys3comDevToType - convert PCI Vendor and Device IDs to a device type** Given <vendorId>, <deviceId>, and <revisionId> values read from PCI Vendor* and Device ID registers in PCI configuration space, this routine will* attempt to map the IDs to an 3c90x device type value defined in this file.** RETURNS:* A board type value which will be one of** .IP* TYPE_BOOMERANG_10BT* .IP* TYPE_BOOMERANG_10BT_COMBO* .IP* TYPE_BOOMERANG_10_100BT* .IP* TYPE_BOOMERANG_100BT4* .IP* TYPE_CYCLONE_10BT* .IP* TYPE_CYCLONE_10BT_COMBO* .IP* TYPE_CYCLONE_10_100BT* .IP* TYPE_CYCLONE_10_100BT4* .IP* TYPE_CYCLONE_10_100FX* .IP* TYPE_CYCLONE_10_100BT_SERV* .IP* TYPE_CYCLONE_10FL* .IP* TYPE_CYCLONE_10_100_COMBO* .IP* TYPE_KRAKATOA_10BT_TPC* .IP* TYPE_TORNADO_10_100BT* .IP* TYPE_TORNADO_10_100BT_SERV* .IP* TYPE_TORNADO_HOMECONNECT* .IP* TYPE_HURRICANE_SOHO100TX* .LP** BOARD_TYPE_UNKNOWN will be returned if the Device ID does not map to* a supported board type.** NOMANUAL*/LOCAL UINT32 sys3comDevToType    (    UINT32 vendorId,    /* specifies a PCI Vendor ID value */    UINT32 deviceId,    /* specifies a PCI Device ID value */    UINT8  revisionId   /* specifies a PCI Revision ID values */    )    {    /* At the moment, we are only supporting vendor 3Com */    if (vendorId == THREECOM_PCI_VENDOR_ID)        {        switch (deviceId)            {            case TC_DEVICEID_BOOMERANG_10BT:                return TYPE_BOOMERANG_10BT;            case TC_DEVICEID_BOOMERANG_10BT_COMBO:                return TYPE_BOOMERANG_10BT_COMBO;            case TC_DEVICEID_BOOMERANG_10_100BT:                return TYPE_BOOMERANG_10_100BT;            case TC_DEVICEID_BOOMERANG_100BT4:                return TYPE_BOOMERANG_100BT4;            case TC_DEVICEID_CYCLONE_10BT:                return TYPE_CYCLONE_10BT;            case TC_DEVICEID_CYCLONE_10BT_COMBO:                return TYPE_CYCLONE_10BT_COMBO;            case TC_DEVICEID_CYCLONE_10_100BT:                return TYPE_CYCLONE_10_100BT;            case TC_DEVICEID_CYCLONE_10_100BT4:                return TYPE_CYCLONE_10_100BT4;            case TC_DEVICEID_CYCLONE_10_100FX:                return TYPE_CYCLONE_10_100FX;            case TC_DEVICEID_CYCLONE_10_100BT_SERV:                return TYPE_CYCLONE_10_100BT_SERV;            case TC_DEVICEID_CYCLONE_10FL:                return TYPE_CYCLONE_10FL;            case TC_DEVICEID_CYCLONE_10_100_COMBO:                return TYPE_CYCLONE_10_100_COMBO;            case TC_DEVICEID_KRAKATOA_10BT_TPC:                return TYPE_KRAKATOA_10BT_TPC;            case TC_DEVICEID_TORNADO_10_100BT:                return TYPE_TORNADO_10_100BT;            case TC_DEVICEID_TORNADO_10_100BT_SERV:                return TYPE_TORNADO_10_100BT_SERV;            case TC_DEVICEID_TORNADO_HOMECONNECT:                return TYPE_TORNADO_HOMECONNECT;            case TC_DEVICEID_HURRICANE_SOHO100TX:                return TYPE_HURRICANE_SOHO100TX;            default:                break;            }        }    return (BOARD_TYPE_UNKNOWN);    }/********************************************************************************* sys3comMmioGet - get a 3Com EtherLink memory mapped IO decoder value** This routine gets the memory mapped IO decoder, if any, for a 3Com* EtherLink or Fast EtherLink PCI network controller specified by PCI* bus, device, and function numbers.  Many of the WRS supported PCI* ethernet devices support both memory mapped IO and IO address space* decoders.  This assumption cannot be made in the case of supported* 3Com EtherLink PCI devices.  If a memory mapped IO decoder is* implemented, assume it is in BAR 1.** RETURNS: The 32-bit memory decoder value read from BAR 1, else NONE.** NOMANUAL*/LOCAL UINT32 sys3comMmioGet    (    UINT32  pciBus,         /* store a PCI bus number */    UINT32  pciDevice,      /* store a PCI device number */    UINT32  pciFunc         /* store a PCI function number */    )    {    UINT16  cmdSave;        /* saves 16-bit PCI command word register */    UINT32  barSave;        /* saves 32-bit PCI base address register 1 */    UINT32  barRead;        /* memory decoder (if any) read from BAR 1 */    UINT32  retVal = NONE;  /* assume the BAR is not implemented */    /* disable PCI device memory decode */    pciConfigInWord (pciBus, pciDevice, pciFunc,                     PCI_CFG_COMMAND, &cmdSave);    pciConfigOutWord (pciBus, pciDevice, pciFunc,                      PCI_CFG_COMMAND, (cmdSave & (~PCI_CMD_MEM_ENABLE)));    /* save the BAR and determine whether it specifies a memory decoder */    pciConfigInLong (pciBus, pciDevice, pciFunc,                     PCI_CFG_BASE_ADDRESS_1, &barSave);    pciConfigOutLong (pciBus, pciDevice, pciFunc,                      PCI_CFG_BASE_ADDRESS_1, 0xffffffff);    pciConfigInLong (pciBus, pciDevice, pciFunc,                     PCI_CFG_BASE_ADDRESS_1, &barRead);    /* this BAR specifies a memory decoder? */    if (barRead != 0)        {        retVal = barSave;        pciConfigOutLong (pciBus, pciDevice, pciFunc,                          PCI_CFG_BASE_ADDRESS_1, barSave);        }    /* re-enable PCI device memory decode */    pciConfigOutWord (pciBus, pciDevice, pciFunc,                      PCI_CFG_COMMAND, cmdSave);    return (retVal);    }#endif /* INCLUDE_EL_3C90X_END */

⌨️ 快捷键说明

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