author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 11:08:29 +0300 | |
changeset 247 | d8d70de2bd36 |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
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) |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
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 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
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 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
78 |
void RHybridHeap::Lock() const |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
DMutex* m = *(DMutex**)&iLock; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
if (m) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
Kern::MutexWait(*m); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
83 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
84 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
void RHybridHeap::Unlock() const |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
87 |
DMutex* m = *(DMutex**)&iLock; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
88 |
if (m) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
Kern::MutexSignal(*m); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
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 |