kernel/eka/memmodel/epoc/flexible/mmu/mobject.cpp
changeset 44 36bfc973b146
parent 43 96e5fb8b040d
equal deleted inserted replaced
43:96e5fb8b040d 44:36bfc973b146
   646 		TPte* pt = GetOrAllocatePageTable(aChunkIndex);
   646 		TPte* pt = GetOrAllocatePageTable(aChunkIndex);
   647 
   647 
   648 		if(pinnedPt && pinnedPt!=pt)
   648 		if(pinnedPt && pinnedPt!=pt)
   649 			{
   649 			{
   650 			// previously pinned page table not needed...
   650 			// previously pinned page table not needed...
   651 			PageTableAllocator::UnpinPageTable(pinnedPt,aPinArgs);
   651 			::PageTables.UnpinPageTable(pinnedPt,aPinArgs);
   652 
   652 
   653 			// make sure we have memory for next pin attempt...
   653 			// make sure we have memory for next pin attempt...
   654 			MmuLock::Unlock();
   654 			MmuLock::Unlock();
   655 			aPinArgs.AllocReplacementPages(KNumPagesToPinOnePageTable);
   655 			aPinArgs.AllocReplacementPages(KNumPagesToPinOnePageTable);
   656 			MmuLock::Lock();
       
   657 			if(!aPinArgs.HaveSufficientPages(KNumPagesToPinOnePageTable)) // if out of memory...
   656 			if(!aPinArgs.HaveSufficientPages(KNumPagesToPinOnePageTable)) // if out of memory...
   658 				{
   657 				{
   659 				// make sure we free any unneeded page table we allocated...
   658 				// make sure we free any unneeded page table we allocated...
   660 				if(pt)
   659 				if(pt)
   661 					FreePageTable(aChunkIndex);
   660 					FreePageTable(aChunkIndex);
       
   661 				MmuLock::Lock();
   662 				return 0;
   662 				return 0;
   663 				}
   663 				}
       
   664 			MmuLock::Lock();
   664 			}
   665 			}
   665 
   666 
   666 		if(!pt)
   667 		if(!pt)
   667 			return 0; // out of memory
   668 			return 0; // out of memory
   668 
   669 
   678 		SPageTableInfo* pti = SPageTableInfo::FromPtPtr(pt);
   679 		SPageTableInfo* pti = SPageTableInfo::FromPtPtr(pt);
   679 		if(!pti->IsDemandPaged())
   680 		if(!pti->IsDemandPaged())
   680 			return pt;
   681 			return pt;
   681 
   682 
   682 		// pin the page table...
   683 		// pin the page table...
       
   684 		if (::PageTables.PinPageTable(pt,aPinArgs) != KErrNone)
       
   685 			{
       
   686 			// Couldn't pin the page table...
       
   687 			MmuLock::Unlock();
       
   688 			// make sure we free any unneeded page table we allocated...
       
   689 			FreePageTable(aChunkIndex);
       
   690 			MmuLock::Lock();
       
   691 			return 0;
       
   692 			}
   683 		pinnedPt = pt;
   693 		pinnedPt = pt;
   684 		PageTableAllocator::PinPageTable(pinnedPt,aPinArgs);
       
   685 		}
   694 		}
   686 	}
   695 	}
   687 
   696 
   688 
   697 
   689 TPte* DCoarseMemory::DPageTables::AllocatePageTable(TUint aChunkIndex, TBool aDemandPaged, TBool aPermanent)
   698 TPte* DCoarseMemory::DPageTables::AllocatePageTable(TUint aChunkIndex, TBool aDemandPaged, TBool aPermanent)