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