예제 #1
0
//------------------------------------------------------------------------------
static void SYSRAM_FreeUser(SYSRAM_USER_ENUM const User)
{
    SYSRAM_MEM_BANK_ENUM const MemBankNo = SYSRAM_GetMemBankNo(User);
    //
    switch(MemBankNo)
    {
    case SYSRAM_MEM_BANK_BAD:
    case SYSRAM_MEM_BANK_AMOUNT:
    {
        //  Do nothing.
        break;
    }
    default:
    {
        if(SYSRAM_FreeUserPhy(User, MemBankNo))
        {
            SYSRAM_UnlockUser(User);
        }
        else
        {
            LOG_ERR("Cannot free User(%d)",User);
            SYSRAM_DumpLayout();
        }
        break;
    }
    }
}
/* ------------------------------------------------------------------------------ */
static MUINT32 SYSRAM_AllocUser(SYSRAM_USER_ENUM const User, MUINT32 Size, MUINT32 const Alignment)
{
	MUINT32 Addr = 0;

	SYSRAM_MEM_BANK_ENUM const MemBankNo = SYSRAM_GetMemBankNo(User);
	/*  */
	if (SYSRAM_IsBadOwner(User)) {
		LOG_ERR("User(%d) out of range(%d)", User, SYSRAM_USER_AMOUNT);
		return 0;
	}
	/*  */
	if (!SYSRAM_IsLegalSizeToAlloc(MemBankNo, User, Size)) {
		return 0;
	}
	/*  */
	switch (MemBankNo) {
	case SYSRAM_MEM_BANK_BAD:
	case SYSRAM_MEM_BANK_AMOUNT:
		{
			/* Do nothing. */
			break;
		}
	default:
		{
			Addr = SYSRAM_AllocUserPhy(User, Size, Alignment, MemBankNo);
			break;
		}
	}
	/*  */
	if (0 < Addr) {
		SYSRAM_LockUser(User, Size);
	}
	/*  */
	return Addr;
}