kernel/eka/memmodel/epoc/mmubase/mmubase.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 42 a179b74831c9
child 44 3e88ff8f41d5
equal deleted inserted replaced
42:a179b74831c9 43:c1f20ce4abcf
   646 		
   646 		
   647 		// Free the page
   647 		// Free the page
   648 		r = iRamPageAllocator->FreePhysicalRam(*page, KPageSize);
   648 		r = iRamPageAllocator->FreePhysicalRam(*page, KPageSize);
   649 		}
   649 		}
   650 	return r;
   650 	return r;
       
   651 	}
       
   652 
       
   653 
       
   654 TInt MmuBase::FreeRamZone(TUint aZoneId, TPhysAddr& aZoneBase, TUint& aZoneBytes)
       
   655 	{
       
   656 	TUint zonePages;
       
   657 	TInt r = iRamPageAllocator->GetZoneAddress(aZoneId, aZoneBase, zonePages);
       
   658 	if (r != KErrNone)
       
   659 		return r;
       
   660 	aZoneBytes = zonePages << KPageShift;
       
   661 	return MmuBase::FreePhysicalRam(aZoneBase, aZoneBytes);
   651 	}
   662 	}
   652 
   663 
   653 
   664 
   654 TInt MmuBase::ClaimPhysicalRam(TPhysAddr aPhysAddr, TInt aSize)
   665 TInt MmuBase::ClaimPhysicalRam(TPhysAddr aPhysAddr, TInt aSize)
   655 	{
   666 	{
  2047 	return r;
  2058 	return r;
  2048 	}
  2059 	}
  2049 
  2060 
  2050 
  2061 
  2051 /**
  2062 /**
       
  2063 Free a RAM zone which was previously allocated by one of these methods:
       
  2064 Epoc::AllocPhysicalRam(), Epoc::ZoneAllocPhysicalRam() or 
       
  2065 TRamDefragRequest::ClaimRamZone().
       
  2066 
       
  2067 All of the pages in the RAM zone must be allocated and only via one of the methods 
       
  2068 listed above, otherwise a system panic will occur.
       
  2069 
       
  2070 @param	aZoneId			The ID of the RAM zone to free.
       
  2071 @return	KErrNone 		If the operation was successful.
       
  2072 		KErrArgument 	If a RAM zone with ID aZoneId was not found.
       
  2073 
       
  2074 @pre Calling thread must be in a critical section.
       
  2075 @pre Interrupts must be enabled.
       
  2076 @pre Kernel must be unlocked.
       
  2077 @pre No fast mutex can be held.
       
  2078 @pre Call in a thread context.
       
  2079 @pre Can be used in a device driver.
       
  2080 */
       
  2081 EXPORT_C TInt Epoc::FreeRamZone(TUint aZoneId)
       
  2082 	{
       
  2083 	CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"Epoc::FreeRamZone");
       
  2084 	MmuBase& m = *MmuBase::TheMmu;
       
  2085 	MmuBase::Wait();
       
  2086 	TPhysAddr zoneBase;
       
  2087 	TUint zoneBytes;
       
  2088 	TInt r = m.FreeRamZone(aZoneId, zoneBase, zoneBytes);
       
  2089 #ifdef BTRACE_KERNEL_MEMORY
       
  2090 	if (r == KErrNone)
       
  2091 		{
       
  2092 		BTrace8(BTrace::EKernelMemory, BTrace::EKernelMemoryDrvPhysFree, zoneBytes, zoneBase);
       
  2093 		Epoc::DriverAllocdPhysRam -= zoneBytes;
       
  2094 		}
       
  2095 #endif
       
  2096 	MmuBase::Signal();
       
  2097 	return r;
       
  2098 	}
       
  2099 
       
  2100 
       
  2101 /**
  2052 Translate a virtual address to the corresponding physical address.
  2102 Translate a virtual address to the corresponding physical address.
  2053 
  2103 
  2054 @param	aLinAddr	The virtual address to be translated.
  2104 @param	aLinAddr	The virtual address to be translated.
  2055 @return	The physical address corresponding to the given virtual address, or
  2105 @return	The physical address corresponding to the given virtual address, or
  2056 		KPhysAddrInvalid if the specified virtual address is unmapped.
  2106 		KPhysAddrInvalid if the specified virtual address is unmapped.