os/kernelhwsrv/kernel/eka/klib/kheap.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/klib/kheap.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,105 @@
     1.4 +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\klib\kheap.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <kernel/kern_priv.h>
    1.22 +
    1.23 +_LIT(KLitKernHeap,"KernHeap");
    1.24 +
    1.25 +RHeapK::RHeapK(TInt aInitialSize)
    1.26 +	: RHeap(aInitialSize, 0, EFalse)
    1.27 +	{
    1.28 +	}
    1.29 +
    1.30 +TInt RHeapK::Compress()
    1.31 +	{
    1.32 +	return 0;
    1.33 +	}
    1.34 +
    1.35 +void RHeapK::Reset()
    1.36 +	{
    1.37 +	Fault(KErrNotSupported);
    1.38 +	}
    1.39 +
    1.40 +TInt RHeapK::AllocSize(TInt& aTotalAllocSize) const
    1.41 +	{
    1.42 +	(void)aTotalAllocSize;
    1.43 +	Fault(KErrNotSupported);
    1.44 +	return 0;
    1.45 +	}
    1.46 +
    1.47 +TInt RHeapK::Available(TInt& aBiggestBlock) const
    1.48 +	{
    1.49 +	(void)aBiggestBlock;
    1.50 +	Fault(KErrNotSupported);
    1.51 +	return 0;
    1.52 +	}
    1.53 +
    1.54 +TInt RHeapK::CreateMutex()
    1.55 +	{
    1.56 +	DMutex*& m = *(DMutex**)&iLock;
    1.57 +	return K::MutexCreate(m, KLitKernHeap, NULL, EFalse, KMutexOrdKernelHeap);
    1.58 +	}
    1.59 +
    1.60 +RHeapK* RHeapK::FixedHeap(TAny* aBase, TInt aInitialSize)
    1.61 +//
    1.62 +// Create a kernel fixed heap.
    1.63 +//
    1.64 +	{
    1.65 +
    1.66 +	__ASSERT_ALWAYS(aInitialSize>KMinHeapSize, K::Fault(K::ETHeapMaxLengthNegative));
    1.67 +	return new(aBase) RHeapK(aInitialSize);
    1.68 +	}
    1.69 +
    1.70 +void RHeapK::CheckThreadState()
    1.71 +//
    1.72 +// Check that the kernel is not locked and the thread is unkillable
    1.73 +//
    1.74 +	{
    1.75 +	if (K::Initialising)
    1.76 +		return;
    1.77 +	__NK_ASSERT_UNLOCKED;
    1.78 +	__ASSERT_NO_FAST_MUTEX;
    1.79 +	__ASSERT_CRITICAL;
    1.80 +	}
    1.81 +
    1.82 +void RHeapK::Fault(TInt aFault)
    1.83 +	{
    1.84 +	Kern::Fault("KERN-HEAP", aFault);
    1.85 +	}
    1.86 +
    1.87 +#if defined(__HEAP_MACHINE_CODED__) && !defined(_DEBUG)
    1.88 +GLDEF_C void RHeapK_PanicBadAllocatedCellSize()
    1.89 +	{
    1.90 +	K::Fault(K::EKHeapBadAllocatedCellSize);
    1.91 +	}
    1.92 +
    1.93 +GLDEF_C void RHeapK_PanicBadNextCell()
    1.94 +	{
    1.95 +	K::Fault(K::EKHeapFreeBadNextCell);
    1.96 +	}
    1.97 +
    1.98 +GLDEF_C void RHeapK_PanicBadPrevCell()
    1.99 +	{
   1.100 +	K::Fault(K::EKHeapFreeBadPrevCell);
   1.101 +	}
   1.102 +
   1.103 +GLDEF_C void RHeapK_PanicBadCellAddress()
   1.104 +	{
   1.105 +	K::Fault(K::EKHeapBadCellAddress);
   1.106 +	}
   1.107 +#endif
   1.108 +