kernel/eka/memmodel/epoc/mmubase/mmubase.cpp
branchRCL_3
changeset 26 c734af59ce98
parent 22 2f92ad2dc5db
child 28 5b5d147c7838
equal deleted inserted replaced
24:41f0cfe18c80 26:c734af59ce98
   481 	}
   481 	}
   482 
   482 
   483 TInt MmuBase::AllocPhysicalRam(TInt aSize, TPhysAddr& aPhysAddr, TInt aAlign)
   483 TInt MmuBase::AllocPhysicalRam(TInt aSize, TPhysAddr& aPhysAddr, TInt aAlign)
   484 	{
   484 	{
   485 	__KTRACE_OPT(KMMU,Kern::Printf("Mmu::AllocPhysicalRam() size=%x align=%d",aSize,aAlign));
   485 	__KTRACE_OPT(KMMU,Kern::Printf("Mmu::AllocPhysicalRam() size=%x align=%d",aSize,aAlign));
   486 	TInt r=AllocContiguousRam(aSize, aPhysAddr, EPageFixed, aAlign);
   486 	TInt r=AllocContiguousRam(aSize, aPhysAddr, aAlign);
   487 	if (r!=KErrNone)
   487 	if (r!=KErrNone)
   488 		{
   488 		{
   489 		iAllocFailed=ETrue;
   489 		iAllocFailed=ETrue;
   490 		return r;
   490 		return r;
   491 		}
   491 		}
   514 size of the RAM zone or KErrNoMemory when the RAM zone is too full.
   514 size of the RAM zone or KErrNoMemory when the RAM zone is too full.
   515 */
   515 */
   516 TInt MmuBase::ZoneAllocPhysicalRam(TUint* aZoneIdList, TUint aZoneIdCount, TInt aSize, TPhysAddr& aPhysAddr, TInt aAlign)
   516 TInt MmuBase::ZoneAllocPhysicalRam(TUint* aZoneIdList, TUint aZoneIdCount, TInt aSize, TPhysAddr& aPhysAddr, TInt aAlign)
   517 	{
   517 	{
   518 	__KTRACE_OPT(KMMU,Kern::Printf("Mmu::ZoneAllocPhysicalRam() size=0x%x align=%d", aSize, aAlign));
   518 	__KTRACE_OPT(KMMU,Kern::Printf("Mmu::ZoneAllocPhysicalRam() size=0x%x align=%d", aSize, aAlign));
   519 	TInt r = ZoneAllocContiguousRam(aZoneIdList, aZoneIdCount, aSize, aPhysAddr, EPageFixed, aAlign);
   519 	TInt r = ZoneAllocContiguousRam(aZoneIdList, aZoneIdCount, aSize, aPhysAddr, aAlign);
   520 	if (r!=KErrNone)
   520 	if (r!=KErrNone)
   521 		{
   521 		{
   522 		iAllocFailed=ETrue;
   522 		iAllocFailed=ETrue;
   523 		return r;
   523 		return r;
   524 		}
   524 		}
   712 		missing = iRamPageAllocator->AllocRamPages(aPageList, aNumPages, aPageType, aBlockedZoneId, aBlockRest);
   712 		missing = iRamPageAllocator->AllocRamPages(aPageList, aNumPages, aPageType, aBlockedZoneId, aBlockRest);
   713 	return missing ? KErrNoMemory : KErrNone;
   713 	return missing ? KErrNoMemory : KErrNone;
   714 	}
   714 	}
   715 
   715 
   716 
   716 
   717 TInt MmuBase::AllocContiguousRam(TInt aSize, TPhysAddr& aPhysAddr, TZonePageType aPageType, TInt aAlign, TUint aBlockedZoneId, TBool aBlockRest)
   717 TInt MmuBase::AllocContiguousRam(TInt aSize, TPhysAddr& aPhysAddr, TInt aAlign)
   718 	{
   718 	{
   719 #ifdef _DEBUG
   719 #ifdef _DEBUG
   720 	if(K::CheckForSimulatedAllocFail())
   720 	if(K::CheckForSimulatedAllocFail())
   721 		return KErrNoMemory;
   721 		return KErrNoMemory;
   722 #endif
   722 #endif
   723 	__NK_ASSERT_DEBUG(aPageType == EPageFixed);
       
   724 	TUint contigPages = (aSize + KPageSize - 1) >> KPageShift;
   723 	TUint contigPages = (aSize + KPageSize - 1) >> KPageShift;
   725 	TInt r = iRamPageAllocator->AllocContiguousRam(contigPages, aPhysAddr, aPageType, aAlign, aBlockedZoneId, aBlockRest);
   724 	TInt r = iRamPageAllocator->AllocContiguousRam(contigPages, aPhysAddr, aAlign);
   726 	if (r == KErrNoMemory && contigPages > KMaxFreeableContiguousPages)
   725 	if (r == KErrNoMemory && contigPages > KMaxFreeableContiguousPages)
   727 		{// Allocation failed but as this is a large allocation flush the RAM cache 
   726 		{// Allocation failed but as this is a large allocation flush the RAM cache 
   728 		// and reattempt the allocation as large allocation wouldn't discard pages.
   727 		// and reattempt the allocation as large allocation wouldn't discard pages.
   729 		iRamCache->FlushAll();
   728 		iRamCache->FlushAll();
   730 		r = iRamPageAllocator->AllocContiguousRam(contigPages, aPhysAddr, aPageType, aAlign, aBlockedZoneId, aBlockRest);
   729 		r = iRamPageAllocator->AllocContiguousRam(contigPages, aPhysAddr, aAlign);
   731 		}
   730 		}
   732 	return r;
   731 	return r;
   733 	}
   732 	}
   734 
   733 
   735 
   734 
   737 Allocate contiguous RAM from the specified RAM zones.
   736 Allocate contiguous RAM from the specified RAM zones.
   738 @param aZoneIdList	An array of IDs of the RAM zones to allocate from
   737 @param aZoneIdList	An array of IDs of the RAM zones to allocate from
   739 @param aZoneIdCount	The number of IDs listed in aZoneIdList
   738 @param aZoneIdCount	The number of IDs listed in aZoneIdList
   740 @param aSize		The number of bytes to allocate
   739 @param aSize		The number of bytes to allocate
   741 @param aPhysAddr 	Will receive the physical base address of the allocated RAM
   740 @param aPhysAddr 	Will receive the physical base address of the allocated RAM
   742 @param aPageType 	The type of the pages being allocated
       
   743 @param aAlign 		The log base 2 alginment required
   741 @param aAlign 		The log base 2 alginment required
   744 */
   742 */
   745 TInt MmuBase::ZoneAllocContiguousRam(TUint* aZoneIdList, TUint aZoneIdCount, TInt aSize, TPhysAddr& aPhysAddr, TZonePageType aPageType, TInt aAlign)
   743 TInt MmuBase::ZoneAllocContiguousRam(TUint* aZoneIdList, TUint aZoneIdCount, TInt aSize, TPhysAddr& aPhysAddr, TInt aAlign)
   746 	{
   744 	{
   747 #ifdef _DEBUG
   745 #ifdef _DEBUG
   748 	if(K::CheckForSimulatedAllocFail())
   746 	if(K::CheckForSimulatedAllocFail())
   749 		return KErrNoMemory;
   747 		return KErrNoMemory;
   750 #endif
   748 #endif
   751 	return iRamPageAllocator->ZoneAllocContiguousRam(aZoneIdList, aZoneIdCount, aSize, aPhysAddr, aPageType, aAlign);
   749 	return iRamPageAllocator->ZoneAllocContiguousRam(aZoneIdList, aZoneIdCount, aSize, aPhysAddr, aAlign);
   752 	}
   750 	}
   753 
   751 
   754 SPageInfo* SPageInfo::SafeFromPhysAddr(TPhysAddr aAddress)
   752 SPageInfo* SPageInfo::SafeFromPhysAddr(TPhysAddr aAddress)
   755 	{
   753 	{
   756 	TUint index = aAddress>>(KPageShift+KPageShift-KPageInfoShift);
   754 	TUint index = aAddress>>(KPageShift+KPageShift-KPageInfoShift);
  5223 	}
  5221 	}
  5224 
  5222 
  5225 
  5223 
  5226 // Misc DPagingDevice methods
  5224 // Misc DPagingDevice methods
  5227 
  5225 
       
  5226 EXPORT_C NFastMutex* DPagingDevice::NotificationLock()
       
  5227 	{
       
  5228 	// use the system lock
       
  5229 	return &TheScheduler.iLock;
       
  5230 	}
       
  5231 
  5228 EXPORT_C void DPagingDevice::NotifyIdle()
  5232 EXPORT_C void DPagingDevice::NotifyIdle()
  5229 	{
  5233 	{
  5230 	// Not used on this memory model
  5234 	// Not used on this memory model
  5231 	}
  5235 	}
  5232 
  5236