📄 sysgei82544end.c
字号:
geiUnits++; } if(geiUnits) { /* one or more devices were found */ for(unitNum = 0, i = 0; unitNum < geiUnits && i < MAX_END_DEVS; ++i) { if(pendDevTbl[i].endLoadFunc == sysGei82543EndLoad || pendDevTbl[i].endLoadFunc == END_TBL_END) { pendDevTbl[i].unit = unitNum; pendDevTbl[i].endLoadFunc = sysGei82543EndLoad; pendDevTbl[i].endLoadString = ""; pendDevTbl[i].endLoan = TRUE /* GEI_BUFF_LOAN */ ; pendDevTbl[i].pBSP = NULL; pendDevTbl[i].processed = FALSE; ++unitNum; } } }}/******************************************************************************** sysGei82543EndLoad - load an istance of the gei82543End driver** This routine loads the gei driver with initial parameters specified by* values given in the BSP configuration files (config.h).** This routine only loads and initializes one instance of the device.* If the user wishes to use more than one 82543 devices, this routine* should be changed.** RETURNS: pointer to END object, (END_OBJ *) ERROR, or NULL.** SEE ALSO: gei82543EndLoad()*/END_OBJ * sysGei82543EndLoad ( char * pParamStr, /* ptr to initialization parameter string */ void * unused /* unused optional argument */ ) { /* * The gei82543End driver END_LOAD_STRING should be: * <memBase>:<memSize>:<rxDesNum>:<txDesNum>:<usrFlags>:<offset> * <offset> should be decimal, and the others hexadecimal. * Note that gei unit string is prepended by the mux, so we * don't put it here. */#define MAX_PARAM_STR 200 char * pStr = NULL; char paramStr [MAX_PARAM_STR]; END_OBJ * pEnd; UINT unit; GEI_RESOURCE *pInfo; if (pParamStr == NULL) return ((END_OBJ *) ERROR); if (strlen (pParamStr) == 0) { /* * muxDevLoad() calls us twice. If the string is * zero length, then this is the first time through * this routine. */ pEnd = (END_OBJ *) gei82543EndLoad (pParamStr); } else { UINT32 memAddr; UINT32 memSize = 0; UINT32 txDesNum; UINT32 rxDesNum; UINT32 clSize; UINT32 mtu; /* * On the second pass though here, we actually create * the initialization parameter string on the fly. * Note that we will be handed our unit number on the * second pass and we need to preserve that information. * So we use the unit number handed from the input string. */ pStr = strncpy (paramStr, pParamStr, MAX_PARAM_STR); if (pStr [MAX_PARAM_STR -1] != EOS) return NULL; if ( (unit = strtoul (paramStr, NULL, 0)) >= SYS_GEI_MAX_UNITS) { SYS_GEI_LOG ("sysGei82543EndLoad: unit number %d too large.\n", unit,0,0,0,0,0); return (END_OBJ *) NULL; } pInfo = &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; memAddr = (UINT32) cacheDmaMalloc (memSize); memAddr = (volatile INT32) ((((UINT32) memAddr) + 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); 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) adapters configuration** 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 Adapter ***********\n\n"); else if (pReso->boardType == PRO1000_544_BOARD) printf ("\n********* Intel PRO1000 544 Adapter ***********\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 (" Adapter 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.** RETURNS: N/A.*/void sys543eepromDump ( int unit ) { 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>.** RETURNS: OK or ERROR.*/STATUS sys543eepromCopy ( int unit, UINT16 * pWords ) { 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).** RETURNS: OK or ERROR.*/STATUS sys543eepromProgram ( int unit, UINT16 * pContents, BOOL checksumFix ) { 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.** 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>.** 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; }/***************************************************************************** sys543eepromEraseAll - 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.** RETURNS: OK or ERROR.*/STATUS sys543eepromWriteWord ( int unit, UINT32 index, UINT16 word ) { GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, EECD_CS_BIT); /* wait */ SYS_DELAY(10); /* 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.** RETURNS: OK or ERROR.*/STATUS sys543eepromMacAddrSet ( int unit, char * macAddrString ) { 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 [], char * macAddrString ) { 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; }#endif /* INCLUDE_GEI_END */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -