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)
|
149
|
23 |
: RHybridHeap(aInitialSize, 0, EFalse)
|
0
|
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 |
{
|
149
|
62 |
__ASSERT_ALWAYS(aInitialSize>(TInt)sizeof(RHeapK), K::Fault(K::ETHeapMaxLengthNegative));
|
0
|
63 |
return new(aBase) RHeapK(aInitialSize);
|
|
64 |
}
|
|
65 |
|
|
66 |
void RHeapK::CheckThreadState()
|
|
67 |
//
|
|
68 |
// Check that the kernel is not locked and the thread is unkillable
|
|
69 |
//
|
|
70 |
{
|
|
71 |
if (K::Initialising)
|
|
72 |
return;
|
|
73 |
__NK_ASSERT_UNLOCKED;
|
|
74 |
__ASSERT_NO_FAST_MUTEX;
|
|
75 |
__ASSERT_CRITICAL;
|
|
76 |
}
|
|
77 |
|
149
|
78 |
void RHybridHeap::Lock() const
|
|
79 |
{
|
|
80 |
DMutex* m = *(DMutex**)&iLock;
|
|
81 |
if (m)
|
|
82 |
Kern::MutexWait(*m);
|
|
83 |
}
|
|
84 |
|
|
85 |
void RHybridHeap::Unlock() const
|
|
86 |
{
|
|
87 |
DMutex* m = *(DMutex**)&iLock;
|
|
88 |
if (m)
|
|
89 |
Kern::MutexSignal(*m);
|
|
90 |
}
|
|
91 |
|
0
|
92 |
void RHeapK::Fault(TInt aFault)
|
|
93 |
{
|
|
94 |
Kern::Fault("KERN-HEAP", aFault);
|
|
95 |
}
|
|
96 |
|
|
97 |
#if defined(__HEAP_MACHINE_CODED__) && !defined(_DEBUG)
|
|
98 |
GLDEF_C void RHeapK_PanicBadAllocatedCellSize()
|
|
99 |
{
|
|
100 |
K::Fault(K::EKHeapBadAllocatedCellSize);
|
|
101 |
}
|
|
102 |
|
|
103 |
GLDEF_C void RHeapK_PanicBadNextCell()
|
|
104 |
{
|
|
105 |
K::Fault(K::EKHeapFreeBadNextCell);
|
|
106 |
}
|
|
107 |
|
|
108 |
GLDEF_C void RHeapK_PanicBadPrevCell()
|
|
109 |
{
|
|
110 |
K::Fault(K::EKHeapFreeBadPrevCell);
|
|
111 |
}
|
|
112 |
|
|
113 |
GLDEF_C void RHeapK_PanicBadCellAddress()
|
|
114 |
{
|
|
115 |
K::Fault(K::EKHeapBadCellAddress);
|
|
116 |
}
|
|
117 |
#endif
|
|
118 |
|