示例#1
0
/*******************************************************************************
* mvCpuIfTargetWinEnable - Enable/disable a CPU address decode window
*
* DESCRIPTION:
*       This function enable/disable a CPU address decode window.
*       if parameter 'enable' == MV_TRUE the routine will enable the 
*       window, thus enabling CPU accesses (before enabling the window it is 
*       tested for overlapping). Otherwise, the window will be disabled.
*
* INPUT:
*       target - Peripheral target enumerator.
*       enable - Enable/disable parameter.
*
* OUTPUT:
*       N/A
*
* RETURN:
*       MV_ERROR if protection window number was wrong, or the window 
*       overlapps other target window.
*
*******************************************************************************/
MV_STATUS mvCpuIfTargetWinEnable(MV_TARGET target,MV_BOOL enable)
{
	MV_U32 winNum, temp;
	MV_CPU_DEC_WIN addrDecWin;

	/* Check parameters */
	if (target >= MAX_TARGETS)
	{
		mvOsPrintf("mvCpuIfTargetWinEnable: target %d is Illigal\n", target);
		return MV_ERROR;
	}

	/* get the window and check if it exist */
	temp = mvCpuIfTargetWinGet(target, &addrDecWin);
	if (MV_NO_SUCH == temp)
	{
		return (enable? MV_ERROR: MV_OK);
	}
	else if( MV_OK != temp)
	{
		mvOsPrintf("%s: ERR. Getting target %d failed.\n",__FUNCTION__, target);
		return MV_ERROR;
	}

	/* check overlap */

	if (MV_TRUE == enable)
	{
		if (MV_TRUE == cpuTargetWinOverlap(target, &addrDecWin.addrWin))
		{
			DB(mvOsPrintf("%s: ERR. Target %d overlap\n",__FUNCTION__, target));
			return MV_ERROR;
		}
		
	}

	if (!MV_TARGET_IS_DRAM(target))
	{
		/* get the Window number associated with this target */

		winNum = mvAhbToMbusWinTargetGet(target);

		if (winNum >= MAX_AHB_TO_MBUS_WINS)
		{
			return (enable? MV_ERROR: MV_OK);
		}

		if (mvAhbToMbusWinEnable(winNum , enable) != MV_OK)
		{
			mvOsPrintf("mvCpuIfTargetWinGet: Failed to enable window = %d\n",
					   winNum);
			return MV_ERROR;

		}
	}

	return MV_OK;
}
示例#2
0
/*******************************************************************************
* mvCpuIfTargetWinSet - Set CPU-to-peripheral target address window
*
* DESCRIPTION:
*       This function sets a peripheral target (e.g. SDRAM bank0, PCI0_MEM0)
*       address window, also known as address decode window.
*       A new address decode window is set for specified target address window.
*       If address decode window parameter structure enables the window,
*       the routine will also enable the target window, allowing CPU to access
*       the target window.
*
* INPUT:
*       target      - Peripheral target enumerator.
*       pAddrDecWin - CPU target window data structure.
*
* OUTPUT:
*       N/A
*
* RETURN:
*       MV_OK if CPU target window was set correctly, MV_ERROR in case of
*       address window overlapps with other active CPU target window or
*		trying to assign 36bit base address while CPU does not support that.
*       The function returns MV_NOT_SUPPORTED, if the target is unsupported.
*
*******************************************************************************/
MV_STATUS mvCpuIfTargetWinSet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin)
{
    MV_AHB_TO_MBUS_DEC_WIN decWin;
    MV_U32 existingWinNum;
    MV_DRAM_DEC_WIN addrDecWin;

    target = MV_CHANGE_BOOT_CS(target);

    /* Check parameters */
    if (target >= MAX_TARGETS)
    {
        mvOsPrintf("mvCpuIfTargetWinSet: target %d is illegal\n", target);
        return MV_ERROR;
    }

    /* 2) Check if the requested window overlaps with current windows		*/
    if (MV_TRUE == cpuTargetWinOverlap(target, &pAddrDecWin->addrWin))
    {
        mvOsPrintf("mvCpuIfTargetWinSet: ERR. Target %d overlap\n", target);
        return MV_BAD_PARAM;
    }

    if (MV_TARGET_IS_DRAM(target))
    {
        /* copy relevant data to MV_DRAM_DEC_WIN structure */
        addrDecWin.addrWin.baseHigh = pAddrDecWin->addrWin.baseHigh;
        addrDecWin.addrWin.baseLow = pAddrDecWin->addrWin.baseLow;
        addrDecWin.addrWin.size = pAddrDecWin->addrWin.size;
        addrDecWin.enable = pAddrDecWin->enable;


        if (mvDramIfWinSet(target,&addrDecWin) != MV_OK);
        {
            mvOsPrintf("mvCpuIfTargetWinSet: mvDramIfWinSet Failed\n");
            return MV_ERROR;
        }

    }
    else
    {
        /* copy relevant data to MV_AHB_TO_MBUS_DEC_WIN structure */
        decWin.addrWin.baseLow = pAddrDecWin->addrWin.baseLow;
        decWin.addrWin.baseHigh = pAddrDecWin->addrWin.baseHigh;
        decWin.addrWin.size = pAddrDecWin->addrWin.size;
        decWin.enable = pAddrDecWin->enable;
        decWin.target = target;

        existingWinNum = mvAhbToMbusWinTargetGet(target);

        /* check if there is already another Window configured
        for this target */
        if ((existingWinNum < MAX_AHB_TO_MBUS_WINS )&&
                (existingWinNum != pAddrDecWin->winNum))
        {
            /* if we want to enable the new winow number
            passed by the user , then the old one should
            be disabled */
            if (MV_TRUE == pAddrDecWin->enable)
            {
                /* be sure it is disabled */
                mvAhbToMbusWinEnable(existingWinNum , MV_FALSE);
            }
        }

        if (mvAhbToMbusWinSet(pAddrDecWin->winNum,&decWin) != MV_OK)
        {
            mvOsPrintf("mvCpuIfTargetWinSet: mvAhbToMbusWinSet Failed\n");
            return MV_ERROR;
        }

    }

    return MV_OK;
}