kernel/eka/memmodel/epoc/flexible/mmu/mptalloc.cpp
changeset 201 43365a9b78a3
parent 152 657f875b013e
equal deleted inserted replaced
200:73ea206103e6 201:43365a9b78a3
   116 		{ }
   116 		{ }
   117 
   117 
   118 
   118 
   119 	virtual TInt MovePage(	DMemoryObject* aMemory, SPageInfo* aOldPageInfo, 
   119 	virtual TInt MovePage(	DMemoryObject* aMemory, SPageInfo* aOldPageInfo, 
   120 							TPhysAddr& aNewPage, TUint aBlockZoneId, TBool aBlockRest);
   120 							TPhysAddr& aNewPage, TUint aBlockZoneId, TBool aBlockRest);
       
   121 
       
   122 	virtual TInt MoveAndAllocPage(DMemoryObject* aMemory, SPageInfo* aPageInfo, TZonePageType aType);
   121 public:
   123 public:
   122 	/**
   124 	/**
   123 	Allocate a page of RAM for storing page tables in.
   125 	Allocate a page of RAM for storing page tables in.
   124 
   126 
   125 	@param aMemory		A memory object associated with this manager.
   127 	@param aMemory		A memory object associated with this manager.
   261 	// cleanup...
   263 	// cleanup...
   262 	aMemory->iPages.RemovePageEnd(aIndex,r);
   264 	aMemory->iPages.RemovePageEnd(aIndex,r);
   263 	return r;
   265 	return r;
   264 	}
   266 	}
   265 
   267 
       
   268 
   266 TInt DPageTableMemoryManager::MovePage(	DMemoryObject* aMemory, SPageInfo* aOldPageInfo, 
   269 TInt DPageTableMemoryManager::MovePage(	DMemoryObject* aMemory, SPageInfo* aOldPageInfo, 
   267 										TPhysAddr& aNewPage, TUint aBlockZoneId, TBool aBlockRest)
   270 										TPhysAddr& aNewPage, TUint aBlockZoneId, TBool aBlockRest)
   268 		{
   271 	{
   269 		// This could be a demand paged page table info which can be discarded 
   272 	// This could be a demand paged page table info which can be discarded 
   270 		// but let the PageTableAllocator handle that.
   273 	// but let the PageTableAllocator handle that.
   271 		return ::PageTables.MovePage(aMemory, aOldPageInfo, aBlockZoneId, aBlockRest);
   274 	return ::PageTables.MovePage(aMemory, aOldPageInfo, aBlockZoneId, aBlockRest);
   272 		}
   275 	}
       
   276 
       
   277 
       
   278 TInt DPageTableMemoryManager::MoveAndAllocPage(DMemoryObject* aMemory, SPageInfo* aPageInfo, TZonePageType aPageType)
       
   279 	{
       
   280 	// This could be a demand paged page table info which can be discarded 
       
   281 	// but let the PageTableAllocator handle that.
       
   282 	return ::PageTables.MoveAndAllocPage(aMemory, aPageInfo, aPageType);
       
   283 	}
   273 
   284 
   274 
   285 
   275 //
   286 //
   276 // PageTableAllocator
   287 // PageTableAllocator
   277 //
   288 //
  1175 
  1186 
  1176 
  1187 
  1177 TInt PageTableAllocator::MovePage(DMemoryObject* aMemory, SPageInfo* aOldPageInfo, 
  1188 TInt PageTableAllocator::MovePage(DMemoryObject* aMemory, SPageInfo* aOldPageInfo, 
  1178 									TUint aBlockZoneId, TBool aBlockRest)
  1189 									TUint aBlockZoneId, TBool aBlockRest)
  1179 	{
  1190 	{
       
  1191 	__NK_ASSERT_DEBUG(MmuLock::IsHeld());
  1180 	// 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 
  1181 	// is demand paged then we may be able to discard it.
  1193 	// is demand paged then we may be able to discard it.
  1182 	MmuLock::Lock();
       
  1183 	if (aOldPageInfo->Owner() == iPageTableInfoMemory)
  1194 	if (aOldPageInfo->Owner() == iPageTableInfoMemory)
  1184 		{
  1195 		{
  1185 		if (!(iPtPageAllocator.IsDemandPagedPtInfo(aOldPageInfo)))
  1196 		if (!(iPtPageAllocator.IsDemandPagedPtInfo(aOldPageInfo)))
  1186 			{
  1197 			{
  1187 			MmuLock::Unlock();
  1198 			MmuLock::Unlock();
  1204 		return KErrInUse;
  1215 		return KErrInUse;
  1205 		}
  1216 		}
  1206 	// Let the pager discard the page as it controls the size of the live list.
  1217 	// Let the pager discard the page as it controls the size of the live list.
  1207 	// If the size of the live list allows then eventually 
  1218 	// If the size of the live list allows then eventually 
  1208 	// PageTableAllocator::StealPage() will be invoked on this page.
  1219 	// PageTableAllocator::StealPage() will be invoked on this page.
  1209 	return ThePager.DiscardPage(aOldPageInfo, aBlockZoneId, aBlockRest);
  1220 	TUint moveDisFlags = (aBlockRest)? M::EMoveDisBlockRest : 0;
       
  1221 	return ThePager.DiscardPage(aOldPageInfo, aBlockZoneId, moveDisFlags);
       
  1222 	}
       
  1223 
       
  1224 
       
  1225 TInt PageTableAllocator::MoveAndAllocPage(DMemoryObject* aMemory, SPageInfo* aPageInfo, TZonePageType aPageType)
       
  1226 	{
       
  1227 	TInt r = MovePage(aMemory, aPageInfo, KRamZoneInvalidId, EFalse);
       
  1228 	if (r == KErrNone)
       
  1229 		{
       
  1230 		TheMmu.MarkPageAllocated(aPageInfo->PhysAddr(), aPageType);
       
  1231 		}
       
  1232 	return r;
  1210 	}
  1233 	}
  1211 
  1234 
  1212 
  1235 
  1213 TInt PageTableAllocator::PinPageTable(TPte* aPageTable, TPinArgs& aPinArgs)
  1236 TInt PageTableAllocator::PinPageTable(TPte* aPageTable, TPinArgs& aPinArgs)
  1214 	{
  1237 	{