kernel/eka/memmodel/epoc/flexible/mmu/mptalloc.cpp
branchRCL_3
changeset 41 0ffb4e86fcc9
parent 28 5b5d147c7838
equal deleted inserted replaced
39:2bb754abd467 41:0ffb4e86fcc9
   182 			BTrace4(BTrace::EKernelMemory, BTrace::EKernelMemoryMiscAlloc, KPageSize);
   182 			BTrace4(BTrace::EKernelMemory, BTrace::EKernelMemoryMiscAlloc, KPageSize);
   183 			++Epoc::KernelMiscPages;
   183 			++Epoc::KernelMiscPages;
   184 			}
   184 			}
   185 #endif
   185 #endif
   186 		}
   186 		}
       
   187 	RamAllocLock::Unlock();
   187 
   188 
   188 	TUint usedNew = 0;
   189 	TUint usedNew = 0;
   189 	if(r==KErrNone)
   190 	if(r==KErrNone)
   190 		{
   191 		{
   191 		// add RAM to page array...
   192 		// add RAM to page array...
   196 		pi->SetManaged(aMemory,aIndex,aMemory->PageInfoFlags());
   197 		pi->SetManaged(aMemory,aIndex,aMemory->PageInfoFlags());
   197 		RPageArray::AddPage(p,pagePhys);
   198 		RPageArray::AddPage(p,pagePhys);
   198 		MmuLock::Unlock();
   199 		MmuLock::Unlock();
   199 		usedNew = 1;
   200 		usedNew = 1;
   200 
   201 
   201 		// Must hold the ram alloc lock until the page has been set as managed
       
   202 		// otherwise it will still be seen as free by the rest of the system.
       
   203 		RamAllocLock::Unlock();
       
   204 
       
   205 		// map page...
   202 		// map page...
   206 		r = aMemory->MapPages(pageList);
   203 		r = aMemory->MapPages(pageList);
   207 		}
   204 		}
   208 	else
       
   209 		RamAllocLock::Unlock();
       
   210 
   205 
   211 	// release page array entry...
   206 	// release page array entry...
   212 	aMemory->iPages.AddPageEnd(aIndex,usedNew);
   207 	aMemory->iPages.AddPageEnd(aIndex,usedNew);
   213 
   208 
   214 	// revert if error...
   209 	// revert if error...
  1191 
  1186 
  1192 
  1187 
  1193 TInt PageTableAllocator::MovePage(DMemoryObject* aMemory, SPageInfo* aOldPageInfo, 
  1188 TInt PageTableAllocator::MovePage(DMemoryObject* aMemory, SPageInfo* aOldPageInfo, 
  1194 									TUint aBlockZoneId, TBool aBlockRest)
  1189 									TUint aBlockZoneId, TBool aBlockRest)
  1195 	{
  1190 	{
       
  1191 	__NK_ASSERT_DEBUG(MmuLock::IsHeld());
  1196 	// We don't move page table or page table info pages, however, if this page 
  1192 	// We don't move page table or page table info pages, however, if this page 
  1197 	// is demand paged then we may be able to discard it.
  1193 	// is demand paged then we may be able to discard it.
  1198 	MmuLock::Lock();
       
  1199 	if (aOldPageInfo->Owner() == iPageTableInfoMemory)
  1194 	if (aOldPageInfo->Owner() == iPageTableInfoMemory)
  1200 		{
  1195 		{
  1201 		if (!(iPtPageAllocator.IsDemandPagedPtInfo(aOldPageInfo)))
  1196 		if (!(iPtPageAllocator.IsDemandPagedPtInfo(aOldPageInfo)))
  1202 			{
  1197 			{
  1203 			MmuLock::Unlock();
  1198 			MmuLock::Unlock();