7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 // |
8 // |
9 // Initial Contributors: |
9 // Initial Contributors: |
10 // Accenture - Initial contribution |
10 // Accenture - Initial contribution |
11 // |
11 // |
12 |
12 // Contributors: |
|
13 // Adrian Issott (Nokia) - Updates for kernel-side alloc helper |
|
14 // |
13 |
15 |
14 #ifndef FSHELL_HEAP_UTILS_H |
16 #ifndef FSHELL_HEAP_UTILS_H |
15 #define FSHELL_HEAP_UTILS_H |
17 #define FSHELL_HEAP_UTILS_H |
16 |
18 |
17 #include <e32cmn.h> |
19 #include <e32cmn.h> |
39 HUCLASS(RAllocatorHelper) // class RAllocatorHelper |
41 HUCLASS(RAllocatorHelper) // class RAllocatorHelper |
40 { |
42 { |
41 public: |
43 public: |
42 HUIMPORT_C RAllocatorHelper(); |
44 HUIMPORT_C RAllocatorHelper(); |
43 #ifdef __KERNEL_MODE__ |
45 #ifdef __KERNEL_MODE__ |
|
46 TLinAddr GetKernelAllocator(DChunk* aKernelChunk); |
44 TInt OpenKernelHeap(); |
47 TInt OpenKernelHeap(); |
45 #else |
48 #else |
46 HUIMPORT_C TInt Open(RAllocator* aAllocator); |
49 HUIMPORT_C TInt Open(RAllocator* aAllocator); |
47 #endif |
50 #endif |
48 HUIMPORT_C TInt SetCellNestingLevel(TAny* aCell, TInt aNestingLevel); |
51 HUIMPORT_C TInt SetCellNestingLevel(TAny* aCell, TInt aNestingLevel); |
114 TType GetType() const; // This is for information only, nothing should care about the return value |
117 TType GetType() const; // This is for information only, nothing should care about the return value |
115 #endif |
118 #endif |
116 |
119 |
117 protected: |
120 protected: |
118 TInt FinishConstruction(); |
121 TInt FinishConstruction(); |
119 TInt IdentifyAllocatorType(TBool aAllocatorIsUdeb); |
122 TInt IdentifyAllocatorType(TBool aAllocatorIsUdeb, TBool aIsTheKernelHeap=EFalse); |
120 TInt OpenChunkHeap(TLinAddr aChunkBase, TInt aChunkMaxSize); |
123 TInt OpenChunkHeap(TLinAddr aChunkBase, TInt aChunkMaxSize); |
121 #ifndef __KERNEL_MODE__ |
124 #ifndef __KERNEL_MODE__ |
122 static TInt EuserIsUdeb(); |
125 static TInt EuserIsUdeb(); |
123 #endif |
126 #endif |
124 virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const; |
127 virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const; |
125 virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize); |
128 virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize); |
|
129 |
|
130 #ifndef __KERNEL_MODE__ |
|
131 protected: |
|
132 #else |
|
133 public: |
|
134 #endif |
126 virtual TInt TryLock(); |
135 virtual TInt TryLock(); |
127 virtual void TryUnlock(); |
136 virtual void TryUnlock(); |
128 |
137 |
129 private: |
138 private: |
130 TInt ReadWord(TLinAddr aLocation, TUint32& aResult) const; |
139 TInt ReadWord(TLinAddr aLocation, TUint32& aResult) const; |
169 #endif |
178 #endif |
170 }; |
179 }; |
171 |
180 |
172 #ifdef __KERNEL_MODE__ |
181 #ifdef __KERNEL_MODE__ |
173 |
182 |
174 class RKernelSideAllocatorHelper : public RAllocatorHelper |
183 class RUserAllocatorHelper : public RAllocatorHelper |
175 { |
184 { |
176 public: |
185 public: |
177 RKernelSideAllocatorHelper(); |
186 RUserAllocatorHelper(); |
178 TInt OpenUserHeap(TUint aThreadId, TLinAddr aAllocatorAddress, TBool aEuserIsUdeb); |
187 TInt OpenUserHeap(TUint aThreadId, TLinAddr aAllocatorAddress, TBool aEuserIsUdeb); |
179 virtual DChunk* OpenUnderlyingChunk(); // Must be in CS |
188 virtual DChunk* OpenUnderlyingChunk(); // Must be in CS |
180 virtual void Close(); |
189 virtual void Close(); |
181 |
190 |
182 protected: |
191 protected: |
184 virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize); |
193 virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize); |
185 virtual TInt TryLock(); |
194 virtual TInt TryLock(); |
186 virtual void TryUnlock(); |
195 virtual void TryUnlock(); |
187 private: |
196 private: |
188 DThread* iThread; |
197 DThread* iThread; |
|
198 }; |
|
199 |
|
200 class RKernelCopyAllocatorHelper : public RAllocatorHelper |
|
201 { |
|
202 public: |
|
203 RKernelCopyAllocatorHelper(); |
|
204 TInt OpenCopiedHeap(DChunk* aOriginalChunk, DChunk* aCopiedChunk, TInt aOffset); |
|
205 virtual DChunk* OpenUnderlyingChunk(); // Must be in CS |
|
206 virtual void Close(); |
|
207 |
|
208 protected: |
|
209 virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const; |
|
210 virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize); |
|
211 virtual TInt TryLock(); |
|
212 virtual void TryUnlock(); |
|
213 private: |
|
214 DChunk* iCopiedChunk; |
|
215 TInt iOffset; // from the original kernel heap to the copied heap |
189 }; |
216 }; |
190 |
217 |
191 #else |
218 #else |
192 |
219 |
193 class RProxyAllocatorHelper : public RAllocatorHelper |
220 class RProxyAllocatorHelper : public RAllocatorHelper |