kernel/eka/memmodel/epoc/flexible/mmu/mpdalloc.cpp
changeset 149 d9f1e5bfe28c
parent 0 a41df078684a
equal deleted inserted replaced
135:5e441a173c63 149:d9f1e5bfe28c
   132 	TUint offset = aOsAsid*KPageDirectorySize;
   132 	TUint offset = aOsAsid*KPageDirectorySize;
   133 	TPhysAddr pdPhys;
   133 	TPhysAddr pdPhys;
   134 	RamAllocLock::Lock();
   134 	RamAllocLock::Lock();
   135 	TInt r = m.AllocContiguousRam(pdPhys, KLocalPdPages, KLocalPdShift-KPageShift, iPageDirectoryMemory->RamAllocFlags());
   135 	TInt r = m.AllocContiguousRam(pdPhys, KLocalPdPages, KLocalPdShift-KPageShift, iPageDirectoryMemory->RamAllocFlags());
   136 	if(r==KErrNone)
   136 	if(r==KErrNone)
       
   137 		{
   137 		AssignPages(offset>>KPageShift,KLocalPdPages,pdPhys);
   138 		AssignPages(offset>>KPageShift,KLocalPdPages,pdPhys);
       
   139 
       
   140 #ifdef BTRACE_KERNEL_MEMORY
       
   141 		BTrace4(BTrace::EKernelMemory, BTrace::EKernelMemoryMiscAlloc, KLocalPdPages << KPageShift);
       
   142 		Epoc::KernelMiscPages += KLocalPdPages;
       
   143 #endif
       
   144 		}
   138 	RamAllocLock::Unlock();
   145 	RamAllocLock::Unlock();
   139 
   146 
   140 	if(r==KErrNone)
   147 	if(r==KErrNone)
   141 		{
   148 		{
   142 		TRACE(("PageDirectoryAllocator::Alloc pdPhys = 0x%08x",pdPhys));
   149 		TRACE(("PageDirectoryAllocator::Alloc pdPhys = 0x%08x",pdPhys));
   145 		r = MM::MemoryAddContiguous(iPageDirectoryMemory,MM::BytesToPages(offset),KLocalPdPages,pdPhys);
   152 		r = MM::MemoryAddContiguous(iPageDirectoryMemory,MM::BytesToPages(offset),KLocalPdPages,pdPhys);
   146 		if(r!=KErrNone)
   153 		if(r!=KErrNone)
   147 			{
   154 			{
   148 			RamAllocLock::Lock();
   155 			RamAllocLock::Lock();
   149 			m.FreeContiguousRam(pdPhys,KLocalPdPages);
   156 			m.FreeContiguousRam(pdPhys,KLocalPdPages);
       
   157 
       
   158 #ifdef BTRACE_KERNEL_MEMORY
       
   159 			BTrace4(BTrace::EKernelMemory, BTrace::EKernelMemoryMiscFree, KLocalPdPages << KPageShift);
       
   160 			Epoc::KernelMiscPages -= KLocalPdPages;
       
   161 #endif
   150 			RamAllocLock::Unlock();
   162 			RamAllocLock::Unlock();
   151 			}
   163 			}
   152 		else
   164 		else
   153 			{
   165 			{
   154 			aPageDirectory = pdPhys;
   166 			aPageDirectory = pdPhys;
   204 
   216 
   205 	RamAllocLock::Lock();
   217 	RamAllocLock::Lock();
   206 	Mmu& m = TheMmu;
   218 	Mmu& m = TheMmu;
   207 	// Page directories are fixed.
   219 	// Page directories are fixed.
   208 	m.FreeRam(pages, KLocalPdPages, EPageFixed);
   220 	m.FreeRam(pages, KLocalPdPages, EPageFixed);
       
   221 
       
   222 #ifdef BTRACE_KERNEL_MEMORY
       
   223 	BTrace4(BTrace::EKernelMemory, BTrace::EKernelMemoryMiscFree, KLocalPdPages << KPageShift);
       
   224 	Epoc::KernelMiscPages -= KLocalPdPages;
       
   225 #endif
   209 	RamAllocLock::Unlock();
   226 	RamAllocLock::Unlock();
   210 	}
   227 	}
   211 
   228