示例#1
0
TInt DMemModelAlignedShBuf::UnMap(DProcess* aProcess)
	{
	__KTRACE_OPT(KMMU, Kern::Printf(">DMemModelAlignedShBuf::UnMap()"));

	TInt r = KErrNone;

	DMemModelProcess* pP = reinterpret_cast<DMemModelProcess*>(aProcess);

	DShBufMapping* m = NULL;
	TWait wait;

	for(;;)
		{
		iPool->LockPool();
		r = FindMapping(m, pP);

		if (r != KErrNone)
			{
			iPool->UnlockPool();
			return KErrNotFound;
			}

		if (m->iTransitioning)
			{
			wait.Link(m->iTransitions);
			iPool->UnlockPool();
			wait.Wait();
			}
		else
			{
			break;
			}
		}

	m->iTransitioning = ETrue;
	iPool->UnlockPool();

	MM::MappingUnmap(m->iMapping);

	iPool->LockPool();
	DMemModelAlignedShPoolClient* client = reinterpret_cast<DMemModelAlignedShPoolClient*>(iPool->iClientMap->Find(reinterpret_cast<TUint>(aProcess)));

	__NK_ASSERT_DEBUG(client);

	TWait* list = m->iTransitions;
	m->iTransitions = NULL;
	m->iObjLink.Deque();
	m->iTransitioning = EFalse;

	DMemModelAlignedShPool* pool = reinterpret_cast<DMemModelAlignedShPool*>(iPool);
	pool->ReleaseMapping(m, client);

	if (aProcess == K::TheKernelProcess)
	    iRelAddress = NULL;

	iPool->UnlockPool();

	wait.SignalAll(list);
	return KErrNone;
	}
示例#2
0
void Binder::Translate(BindParameter parameter, int & rootParamIndex, int & rootTableIndex) const {
	auto result = FindMapping(parameter);
	if (result.second != true) {
		throw OutOfRangeException("Parameter was not found.");
	}
	rootParamIndex = result.first->rootParamIndex;
	rootTableIndex = result.first->rootTableIndex;
}
示例#3
0
TUint8* DMemModelAlignedShBuf::Base(DProcess* aProcess)
	{
	__KTRACE_OPT(KMMU, Kern::Printf(">DMemModelAlignedShBuf::Base()"));
	DMemModelProcess* pP = reinterpret_cast<DMemModelProcess*>(aProcess);

	DShBufMapping* mapping = NULL;
	iPool->LockPool();
	TInt r = FindMapping(mapping, pP);
	TUint8* base = NULL;

	if (r == KErrNone)
		base = reinterpret_cast<TUint8*>(MM::MappingBase(mapping->iMapping));
	iPool->UnlockPool();

	return base;
	}
示例#4
0
TInt DMemModelAlignedShBuf::Map(TUint aMapAttr, DProcess* aProcess, TLinAddr& aBase)
	{
	__KTRACE_OPT(KMMU, Kern::Printf(">DMemModelAlignedShBuf::Map()"));
	TInt r = KErrNone;

	DShBufMapping* m = NULL;
	DMemoryMapping* mapping = NULL;
	DMemModelProcess* pP = reinterpret_cast<DMemModelProcess*>(aProcess);

	TBool write = (TBool)EFalse;

	// User = ETrue, ReadOnlyWrite = ETrue, Execute = EFalse
	if (aMapAttr & EShPoolWriteable)
		write = (TBool)ETrue;

	TMappingPermissions perm = MM::MappingPermissions(pP!=K::TheKernelProcess, write, (TBool)EFalse);
	TWait wait;

	for(;;)
		{
		iPool->LockPool();
		r = FindMapping(m, pP);

		if (r != KErrNone)
			break;
		
		if (m->iTransitioning)
			{
			wait.Link(m->iTransitions);
			iPool->UnlockPool();
			wait.Wait();
			}
		else
			{
			iPool->UnlockPool();
			return KErrAlreadyExists;
			}
		}

	DMemModelAlignedShPoolClient* client = reinterpret_cast<DMemModelAlignedShPoolClient*>(iPool->iClientMap->Find(reinterpret_cast<TUint>(aProcess)));

	__NK_ASSERT_DEBUG(client);

	DMemModelAlignedShPool* pool = reinterpret_cast<DMemModelAlignedShPool*>(iPool);

	__NK_ASSERT_DEBUG(m == NULL);
	r = pool->GetFreeMapping(m, client);

	if (r == KErrNone)
		{
		iMappings.AddHead(&m->iObjLink);
		m->iTransitioning = ETrue;

		mapping = m->iMapping;
		iPool->UnlockPool(); // have to release fast lock for MappingMap

		r = MM::MappingMap(mapping, perm, iMemoryObject, 0, MM::RoundToPageCount(pool->iBufSize));

		iPool->LockPool();

		TWait* list = m->iTransitions;
		m->iTransitions = NULL;

		if (r != KErrNone)
		    pool->ReleaseMapping(m, client);
		else
		    aBase = MM::MappingBase(mapping);

		m->iTransitioning = EFalse;
		iPool->UnlockPool();

		TWait::SignalAll(list);
		}
	else
		iPool->UnlockPool();

	return r;
	}