?? sysdec21x40end.c
字號:
{ /* PASS (1) * The driver load routine returns the driver name in <pParamStr>. */ pEnd = dec21x40EndLoad (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 sysDec21x40PciInit(). 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; /* an index into the user flags table */ char * holder = NULL; int endUnit = atoi (strtok_r (pParamStr, ":", &holder)); /* is there a PCI resource associated with this END unit ? */ if (endUnit >= decUnitsFound) { return NULL; } /* construct an index into the user flags 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 */ PCI2DRAM_BASE_ADRS, /* Host-PCI memory base */ pRsrc[endUnit].irqvec, /* interrupt IRQ vector */ pRsrc[endUnit].irq, /* interrupt irq number */ decUsrFlags[typeIdx], 8, 0, /* flag fields ... */ MII_PHY_AUTO | DEC_USR_MII_10MB | DEC_USR_MII_HD | DEC_USR_MII_100MB | DEC_USR_MII_FD | DEC_USR_MII_BUS_MON ); if ((pEnd = dec21x40EndLoad (paramStr)) == (END_OBJ *) NULL) { printf ("Error dec21x40EndLoad: failed to load driver.\n"); } } return (pEnd); }/********************************************************************************* sysDec21x40PciInit - initialize a DEC 21x4x PCI ethernet device** This routine performs basic PCI initialization for 21x4x ethernet devices* supported by the dec21x40End END driver. If supported, the device* memory and I/O addresses are mapped into the local CPU address space and* an internal board-specific PCI resources table is updated with* information on the board type, memory address, and IO address.** CAVEATS* This routine must be performed prior to MMU initialization, usrMmuInit().* If the number of supported 21x4x physical device instances installed* on the PCI bus exceeds DEC21X40_MAX_DEV, then the extra devices will not* be initialized in this routine.** RETURNS:* OK, else ERROR when the specified device is not supported, or if the device* could not be mapped into processor memory.*/STATUS sysDec21x40PciInit ( UINT32 pciBus, /* store a PCI bus number */ UINT32 pciDevice, /* store a PCI device number */ UINT32 pciFunc, /* store a PCI function number */ UINT32 vendorId, /* store a PCI vendor ID */ UINT32 deviceId, /* store a PCI device ID */ UINT8 revisionId /* store a PCI revision ID */ ) { UINT32 boardType; /* store a BSP-specific board type constant */ UINT32 ioBase; /* IO base address (BAR 0) */ UINT32 memIo32; /* memory-mapped IO address (BAR 1) */ UINT8 irq; /* interrupt line number (IRQ) for device */ /* number of physical units exceeded the number supported ? */ if (decUnitsFound >= DEC21X40_MAX_DEV) { return (ERROR); } if ((boardType = sysDecDevToType (vendorId, deviceId, revisionId)) == BOARD_TYPE_UNKNOWN) { return (ERROR); } pciConfigInLong (pciBus, pciDevice, pciFunc, PCI_CFG_BASE_ADDRESS_0, &ioBase); pciConfigInLong (pciBus, pciDevice, pciFunc, PCI_CFG_BASE_ADDRESS_1, &memIo32); memIo32 &= PCI_MEMBASE_MASK; ioBase &= PCI_IOBASE_MASK; /* map a 4Kb 32-bit non-prefetchable memory IO address decoder */ if (sysMmuMapAdd ((void *)(memIo32 & PCI_DEV_MMU_MSK), PCI_DEV_ADRS_SIZE, VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_PCI) == ERROR) { return (ERROR); } /* read the IRQ number and vector and save to the resource table */ pciConfigInByte (pciBus, pciDevice, pciFunc, PCI_CFG_DEV_INT_LINE, &irq); /* update the board-specific resource table */ sysDecPciRsrcs[decUnitsFound].bar[0] = ioBase; sysDecPciRsrcs[decUnitsFound].bar[1] = memIo32; sysDecPciRsrcs[decUnitsFound].irq = irq; sysDecPciRsrcs[decUnitsFound].irqvec = INT_NUM_GET (irq); sysDecPciRsrcs[decUnitsFound].vendorID = vendorId; sysDecPciRsrcs[decUnitsFound].deviceID = deviceId; sysDecPciRsrcs[decUnitsFound].revisionID = revisionId; sysDecPciRsrcs[decUnitsFound].boardType = boardType; /* enable mapped memory and IO decoders */ pciConfigOutWord (pciBus, pciDevice, pciFunc, PCI_CFG_COMMAND, PCI_CMD_MEM_ENABLE | PCI_CMD_IO_ENABLE | PCI_CMD_MASTER_ENABLE); /* disable sleep mode */ pciConfigOutByte (pciBus, pciDevice, pciFunc, PCI_CFG_MODE, SLEEP_MODE_DIS); /* increment number of units initialized */ ++decUnitsFound; /* Bind the driver-specific PCI interrupt connection routine. The * unconditional MOV is generally less expensive than branch-comp. */ dec21x40IntConnectRtn = (FUNCPTR) pciIntConnect; return (OK); }/********************************************************************************* sysDec21x40EnetAddrGet - get 21x4x Ethernet (IEEE station) address** This routine provides a target-specific interface for accessing a* DEC 21x4x device Ethernet address.** CAVEATS* There is not a target-specific implementation for accessing a device* Ethernet address. This interface is not implemented.** RETURNS: ERROR, always.** NOMANUAL*/STATUS sysDec21x40EnetAddrGet ( int unit, /* END driver unit number */ char * enetAdrs /* storage location for IEEE station address */ ) { return (ERROR); }/********************************************************************************* sysDecDevToType - 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 a DEC 21x4x device type value defined in this* file.** CAVEATS* BOARD_TYPE_UNKNOWN is returned for untested device types.** RETURNS:* A board type value which will be one of** .IP* DEC_TYPE_EB143* .IP* DEC_TYPE_DC140* .IP* DEC_TYPE_DC040* .LP** BOARD_TYPE_UNKNOWN will be returned if the Device ID does not map to* a supported board type.** NOMANUAL*/LOCAL UINT32 sysDecDevToType ( UINT32 vendorId, /* specifies a PCI Vendor ID value */ UINT32 deviceId, /* specifies a PCI Device ID value */ UINT8 revisionId /* specifies a PCI Revision ID value */ ) { /* At the moment, we are only supporting vendor DEC (now Intel) */ if (vendorId == DEC21X4X_PCI_VENDOR_ID) { switch (deviceId) { case DEC21143_PCI_DEVICE_ID: return (DEC_TYPE_EB143); case DEC21140_PCI_DEVICE_ID: return (DEC_TYPE_DC140); case DEC21040_PCI_DEVICE_ID: return (DEC_TYPE_DC040); } }/* * Untested board types will be classified as BOARD_TYPE_UNKNOWN * * if ((vendorId == PNIC_PCI_VENDORID) || * (vendorId == MACRONIX_PCI_VENDOR_ID) || * (vendorId == ASIX_PCI_VENDOR_ID) || * (vendorId == COMET_PCI_VENDOR_ID) || * (vendorId == COMPEX_PCI_VENDOR_ID) || * (vendorId == INTEL_PCI_VENDOR_ID)) * { * switch (deviceId) * { * case PNIC_PCI_DEVICE_ID: * return (DEC_TYPE_LC82C168); * * case PNIC2_PCI_DEVICE_ID: * return (DEC_TYPE_PNIC2); * * case MX98713_PCI_DEVICE_ID: * return (DEC_TYPE_MX98713); * * case MX98715_PCI_DEVICE_ID: * return (DEC_TYPE_MX98715); * * case AX88140_PCI_DEVICE_ID: * return (DEC_TYPE_AX88140); * * case COMET1_PCI_DEVICE_ID: * case COMET2_PCI_DEVICE_ID: * case COMET3_PCI_DEVICE_ID: * return (DEC_TYPE_COMET); * * case COMPEX9881_PCI_DEVICE_ID: * return (DEC_TYPE_COMPEX9881); * * case I21145_PCI_DEVICE_ID: * return (DEC_TYPE_I21145); * } * } */ return (BOARD_TYPE_UNKNOWN); }#endif /* defined(INCLUDE_DEC21X40_END) */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -