Exemple #1
0
//------------------------------------------------------------------------------
static MUINT32 SYSRAM_TryAllocUser(
    SYSRAM_USER_ENUM const  User,
    MUINT32 const           Size,
    MUINT32 const           Alignment)
{
    MUINT32 Addr = 0;
    //
    SYSRAM_SpinLock();
    //
    if(SYSRAM_UserIsLocked(User))
    {
        SYSRAM_SpinUnlock();
        LOG_ERR("[User:%s]has been already allocated!",SysramUserName[User]);
        return 0;
    }
    //
    Addr = SYSRAM_AllocUser(User, Size, Alignment);
    if(Addr != 0)
    {
        SYSRAM_CheckClock();
    }
    SYSRAM_SpinUnlock();
    //
    return  Addr;
}
/* ------------------------------------------------------------------------------ */
static void SYSRAM_IOC_Free(SYSRAM_USER_ENUM User)
{
	if (SYSRAM_IsBadOwner(User)) {
		LOG_ERR("User(%d) out of range(%d)", User, SYSRAM_USER_AMOUNT);
		return;
	}
	/*  */
	SYSRAM_SpinLock();
	SYSRAM_FreeUser(User);
	wake_up_interruptible(&Sysram.WaitQueueHead);
	SYSRAM_CheckClock();
	SYSRAM_SpinUnlock();
	/*  */
	if ((1 << User) & SysramLogUserMask) {
		LOG_MSG("[User:%s]Done", SysramUserName[User]);
	}
}