/******************************************************************************* * mvPp2WinInit * * DESCRIPTION: * This function initialize ETH window decode unit. It set the default * address decode windows of the unit. * * INPUT: * addWinMap: An array holding the address decoding information for the * system. * * OUTPUT: * None. * * RETURN: * MV_ERROR if setting fail. *******************************************************************************/ MV_STATUS mvPp2WinInit(MV_U32 dummy/*backward compability*/, MV_UNIT_WIN_INFO *addrWinMap) { MV_U32 winNum, winPrioIndex = 0, regVal = 0; MV_UNIT_WIN_INFO *addrDecWin; /* Initiate Ethernet address decode */ /* First disable all address decode windows */ for (winNum = 0; winNum < ETH_MAX_DECODE_WIN; winNum++) regVal |= MV_BIT_MASK(winNum); mvPp2WrReg(ETH_BASE_ADDR_ENABLE_REG, regVal); /* Go through all windows in user table until table terminator */ for (winNum = 0; ((ethAddrDecPrioTab[winPrioIndex] != TBL_TERM) && (winNum < ETH_MAX_DECODE_WIN));) { addrDecWin = &addrWinMap[ethAddrDecPrioTab[winPrioIndex]]; if (addrDecWin->enable == MV_TRUE) { if (MV_OK != mvPp2WinWrite(0, winNum, addrDecWin)) { mvOsPrintf("mvPp2WinInit failed: winNum=%d (%d, %d)\n", winNum, winPrioIndex, ethAddrDecPrioTab[winPrioIndex]); return MV_ERROR; } winNum++; } winPrioIndex++; } return MV_OK; }
/* Configure EthDrv memory map registes. */ MV_STATUS mvEthWinInit (int port) { MV_U32 winNum, status, winPrioIndex=0, i, regVal=0; MV_ETH_DEC_WIN ethWin; MV_CPU_DEC_WIN cpuAddrDecWin; static MV_U32 accessProtReg = 0; #if (MV_ETH_VERSION <= 1) static MV_BOOL isFirst = MV_TRUE; if(isFirst == MV_FALSE) { MV_REG_WRITE(ETH_ACCESS_PROTECT_REG(port), accessProtReg); return MV_OK; } isFirst = MV_FALSE; #endif /* MV_GIGA_ETH_VERSION */ /* Initiate Ethernet address decode */ /* First disable all address decode windows */ for(winNum=0; winNum<ETH_MAX_DECODE_WIN; winNum++) { regVal |= MV_BIT_MASK(winNum); } MV_REG_WRITE(ETH_BASE_ADDR_ENABLE_REG(port), regVal); /* Go through all windows in user table until table terminator */ for (winNum=0; ((ethAddrDecPrioTap[winPrioIndex] != TBL_TERM) && (winNum < ETH_MAX_DECODE_WIN)); ) { /* first get attributes from CPU If */ status = mvCpuIfTargetWinGet(ethAddrDecPrioTap[winPrioIndex], &cpuAddrDecWin); if(MV_NO_SUCH == status) { winPrioIndex++; continue; } if (MV_OK != status) { mvOsPrintf("mvEthWinInit: ERR. mvCpuIfTargetWinGet failed\n"); return MV_ERROR; } if (cpuAddrDecWin.enable == MV_TRUE) { ethWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; ethWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; ethWin.addrWin.size = cpuAddrDecWin.addrWin.size; ethWin.enable = MV_TRUE; ethWin.target = ethAddrDecPrioTap[winPrioIndex]; if(MV_OK != mvEthWinSet(port, winNum, ðWin)) { mvOsPrintf("mvEthWinInit: ERR. mvEthWinSet failed winNum=%d\n", winNum); return MV_ERROR; } winNum++; } winPrioIndex ++; } /* set full access to all windows. */ for(i=0; i<winNum; i++) { accessProtReg |= (FULL_ACCESS << (i*2)); } MV_REG_WRITE(ETH_ACCESS_PROTECT_REG(port), accessProtReg); return MV_OK; }