--- a/kernel/eka/memmodel/epoc/mmubase/mmubase.cpp Fri Apr 16 16:24:37 2010 +0300
+++ b/kernel/eka/memmodel/epoc/mmubase/mmubase.cpp Mon May 03 13:47:38 2010 +0300
@@ -651,6 +651,17 @@
}
+TInt MmuBase::FreeRamZone(TUint aZoneId, TPhysAddr& aZoneBase, TUint& aZoneBytes)
+ {
+ TUint zonePages;
+ TInt r = iRamPageAllocator->GetZoneAddress(aZoneId, aZoneBase, zonePages);
+ if (r != KErrNone)
+ return r;
+ aZoneBytes = zonePages << KPageShift;
+ return MmuBase::FreePhysicalRam(aZoneBase, aZoneBytes);
+ }
+
+
TInt MmuBase::ClaimPhysicalRam(TPhysAddr aPhysAddr, TInt aSize)
{
__KTRACE_OPT(KMMU,Kern::Printf("Mmu::ClaimPhysicalRam(%08x,%x)",aPhysAddr,aSize));
@@ -1263,14 +1274,14 @@
#endif
#ifdef BTRACE_RAM_ALLOCATOR
- // Must check for -1 as that is the default value of aCategroy for
+ // Must check for -1 as that is the default value of aCategory for
// BTrace::Prime() which is intended to prime all categories that are
// currently enabled via a single invocation of BTrace::Prime().
if(aCategory==BTrace::ERamAllocator || (TInt)aCategory == -1)
{
NKern::ThreadEnterCS();
Mmu::Wait();
- Mmu::Get().iRamPageAllocator->SendInitialBtraceLogs();
+ Mmu::Get().iRamPageAllocator->DoBTracePrime();
Mmu::Signal();
NKern::ThreadLeaveCS();
}
@@ -2051,6 +2062,45 @@
/**
+Free a RAM zone which was previously allocated by one of these methods:
+Epoc::AllocPhysicalRam(), Epoc::ZoneAllocPhysicalRam() or
+TRamDefragRequest::ClaimRamZone().
+
+All of the pages in the RAM zone must be allocated and only via one of the methods
+listed above, otherwise a system panic will occur.
+
+@param aZoneId The ID of the RAM zone to free.
+@return KErrNone If the operation was successful.
+ KErrArgument If a RAM zone with ID aZoneId was not found.
+
+@pre Calling thread must be in a critical section.
+@pre Interrupts must be enabled.
+@pre Kernel must be unlocked.
+@pre No fast mutex can be held.
+@pre Call in a thread context.
+@pre Can be used in a device driver.
+*/
+EXPORT_C TInt Epoc::FreeRamZone(TUint aZoneId)
+ {
+ CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"Epoc::FreeRamZone");
+ MmuBase& m = *MmuBase::TheMmu;
+ MmuBase::Wait();
+ TPhysAddr zoneBase;
+ TUint zoneBytes;
+ TInt r = m.FreeRamZone(aZoneId, zoneBase, zoneBytes);
+#ifdef BTRACE_KERNEL_MEMORY
+ if (r == KErrNone)
+ {
+ BTrace8(BTrace::EKernelMemory, BTrace::EKernelMemoryDrvPhysFree, zoneBytes, zoneBase);
+ Epoc::DriverAllocdPhysRam -= zoneBytes;
+ }
+#endif
+ MmuBase::Signal();
+ return r;
+ }
+
+
+/**
Translate a virtual address to the corresponding physical address.
@param aLinAddr The virtual address to be translated.