os/kernelhwsrv/kernel/eka/klib/kheap.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\klib\kheap.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <kernel/kern_priv.h>
sl@0
    19
sl@0
    20
_LIT(KLitKernHeap,"KernHeap");
sl@0
    21
sl@0
    22
RHeapK::RHeapK(TInt aInitialSize)
sl@0
    23
	: RHeap(aInitialSize, 0, EFalse)
sl@0
    24
	{
sl@0
    25
	}
sl@0
    26
sl@0
    27
TInt RHeapK::Compress()
sl@0
    28
	{
sl@0
    29
	return 0;
sl@0
    30
	}
sl@0
    31
sl@0
    32
void RHeapK::Reset()
sl@0
    33
	{
sl@0
    34
	Fault(KErrNotSupported);
sl@0
    35
	}
sl@0
    36
sl@0
    37
TInt RHeapK::AllocSize(TInt& aTotalAllocSize) const
sl@0
    38
	{
sl@0
    39
	(void)aTotalAllocSize;
sl@0
    40
	Fault(KErrNotSupported);
sl@0
    41
	return 0;
sl@0
    42
	}
sl@0
    43
sl@0
    44
TInt RHeapK::Available(TInt& aBiggestBlock) const
sl@0
    45
	{
sl@0
    46
	(void)aBiggestBlock;
sl@0
    47
	Fault(KErrNotSupported);
sl@0
    48
	return 0;
sl@0
    49
	}
sl@0
    50
sl@0
    51
TInt RHeapK::CreateMutex()
sl@0
    52
	{
sl@0
    53
	DMutex*& m = *(DMutex**)&iLock;
sl@0
    54
	return K::MutexCreate(m, KLitKernHeap, NULL, EFalse, KMutexOrdKernelHeap);
sl@0
    55
	}
sl@0
    56
sl@0
    57
RHeapK* RHeapK::FixedHeap(TAny* aBase, TInt aInitialSize)
sl@0
    58
//
sl@0
    59
// Create a kernel fixed heap.
sl@0
    60
//
sl@0
    61
	{
sl@0
    62
sl@0
    63
	__ASSERT_ALWAYS(aInitialSize>KMinHeapSize, K::Fault(K::ETHeapMaxLengthNegative));
sl@0
    64
	return new(aBase) RHeapK(aInitialSize);
sl@0
    65
	}
sl@0
    66
sl@0
    67
void RHeapK::CheckThreadState()
sl@0
    68
//
sl@0
    69
// Check that the kernel is not locked and the thread is unkillable
sl@0
    70
//
sl@0
    71
	{
sl@0
    72
	if (K::Initialising)
sl@0
    73
		return;
sl@0
    74
	__NK_ASSERT_UNLOCKED;
sl@0
    75
	__ASSERT_NO_FAST_MUTEX;
sl@0
    76
	__ASSERT_CRITICAL;
sl@0
    77
	}
sl@0
    78
sl@0
    79
void RHeapK::Fault(TInt aFault)
sl@0
    80
	{
sl@0
    81
	Kern::Fault("KERN-HEAP", aFault);
sl@0
    82
	}
sl@0
    83
sl@0
    84
#if defined(__HEAP_MACHINE_CODED__) && !defined(_DEBUG)
sl@0
    85
GLDEF_C void RHeapK_PanicBadAllocatedCellSize()
sl@0
    86
	{
sl@0
    87
	K::Fault(K::EKHeapBadAllocatedCellSize);
sl@0
    88
	}
sl@0
    89
sl@0
    90
GLDEF_C void RHeapK_PanicBadNextCell()
sl@0
    91
	{
sl@0
    92
	K::Fault(K::EKHeapFreeBadNextCell);
sl@0
    93
	}
sl@0
    94
sl@0
    95
GLDEF_C void RHeapK_PanicBadPrevCell()
sl@0
    96
	{
sl@0
    97
	K::Fault(K::EKHeapFreeBadPrevCell);
sl@0
    98
	}
sl@0
    99
sl@0
   100
GLDEF_C void RHeapK_PanicBadCellAddress()
sl@0
   101
	{
sl@0
   102
	K::Fault(K::EKHeapBadCellAddress);
sl@0
   103
	}
sl@0
   104
#endif
sl@0
   105