sl@0: // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of the License "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // e32\klib\kheap.cpp
sl@0: // 
sl@0: //
sl@0: 
sl@0: #include <kernel/kern_priv.h>
sl@0: 
sl@0: _LIT(KLitKernHeap,"KernHeap");
sl@0: 
sl@0: RHeapK::RHeapK(TInt aInitialSize)
sl@0: 	: RHeap(aInitialSize, 0, EFalse)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: TInt RHeapK::Compress()
sl@0: 	{
sl@0: 	return 0;
sl@0: 	}
sl@0: 
sl@0: void RHeapK::Reset()
sl@0: 	{
sl@0: 	Fault(KErrNotSupported);
sl@0: 	}
sl@0: 
sl@0: TInt RHeapK::AllocSize(TInt& aTotalAllocSize) const
sl@0: 	{
sl@0: 	(void)aTotalAllocSize;
sl@0: 	Fault(KErrNotSupported);
sl@0: 	return 0;
sl@0: 	}
sl@0: 
sl@0: TInt RHeapK::Available(TInt& aBiggestBlock) const
sl@0: 	{
sl@0: 	(void)aBiggestBlock;
sl@0: 	Fault(KErrNotSupported);
sl@0: 	return 0;
sl@0: 	}
sl@0: 
sl@0: TInt RHeapK::CreateMutex()
sl@0: 	{
sl@0: 	DMutex*& m = *(DMutex**)&iLock;
sl@0: 	return K::MutexCreate(m, KLitKernHeap, NULL, EFalse, KMutexOrdKernelHeap);
sl@0: 	}
sl@0: 
sl@0: RHeapK* RHeapK::FixedHeap(TAny* aBase, TInt aInitialSize)
sl@0: //
sl@0: // Create a kernel fixed heap.
sl@0: //
sl@0: 	{
sl@0: 
sl@0: 	__ASSERT_ALWAYS(aInitialSize>KMinHeapSize, K::Fault(K::ETHeapMaxLengthNegative));
sl@0: 	return new(aBase) RHeapK(aInitialSize);
sl@0: 	}
sl@0: 
sl@0: void RHeapK::CheckThreadState()
sl@0: //
sl@0: // Check that the kernel is not locked and the thread is unkillable
sl@0: //
sl@0: 	{
sl@0: 	if (K::Initialising)
sl@0: 		return;
sl@0: 	__NK_ASSERT_UNLOCKED;
sl@0: 	__ASSERT_NO_FAST_MUTEX;
sl@0: 	__ASSERT_CRITICAL;
sl@0: 	}
sl@0: 
sl@0: void RHeapK::Fault(TInt aFault)
sl@0: 	{
sl@0: 	Kern::Fault("KERN-HEAP", aFault);
sl@0: 	}
sl@0: 
sl@0: #if defined(__HEAP_MACHINE_CODED__) && !defined(_DEBUG)
sl@0: GLDEF_C void RHeapK_PanicBadAllocatedCellSize()
sl@0: 	{
sl@0: 	K::Fault(K::EKHeapBadAllocatedCellSize);
sl@0: 	}
sl@0: 
sl@0: GLDEF_C void RHeapK_PanicBadNextCell()
sl@0: 	{
sl@0: 	K::Fault(K::EKHeapFreeBadNextCell);
sl@0: 	}
sl@0: 
sl@0: GLDEF_C void RHeapK_PanicBadPrevCell()
sl@0: 	{
sl@0: 	K::Fault(K::EKHeapFreeBadPrevCell);
sl@0: 	}
sl@0: 
sl@0: GLDEF_C void RHeapK_PanicBadCellAddress()
sl@0: 	{
sl@0: 	K::Fault(K::EKHeapBadCellAddress);
sl@0: 	}
sl@0: #endif
sl@0: