perfsrv/memspy/Driver/Shared/heaputils.h
changeset 55 f2950aff7424
parent 48 516af714ebb4
child 54 a151135b0cf9
equal deleted inserted replaced
48:516af714ebb4 55:f2950aff7424
    39 HUCLASS(RAllocatorHelper) // class RAllocatorHelper
    39 HUCLASS(RAllocatorHelper) // class RAllocatorHelper
    40 	{
    40 	{
    41 public:
    41 public:
    42 	HUIMPORT_C RAllocatorHelper();
    42 	HUIMPORT_C RAllocatorHelper();
    43 #ifdef __KERNEL_MODE__
    43 #ifdef __KERNEL_MODE__
       
    44 	TLinAddr GetKernelAllocator(DChunk* aKernelChunk);
    44 	TInt OpenKernelHeap();
    45 	TInt OpenKernelHeap();
    45 #else
    46 #else
    46 	HUIMPORT_C TInt Open(RAllocator* aAllocator);
    47 	HUIMPORT_C TInt Open(RAllocator* aAllocator);
    47 #endif
    48 #endif
    48 	HUIMPORT_C TInt SetCellNestingLevel(TAny* aCell, TInt aNestingLevel);
    49 	HUIMPORT_C TInt SetCellNestingLevel(TAny* aCell, TInt aNestingLevel);
   121 #ifndef __KERNEL_MODE__
   122 #ifndef __KERNEL_MODE__
   122 	static TInt EuserIsUdeb();
   123 	static TInt EuserIsUdeb();
   123 #endif
   124 #endif
   124 	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
   125 	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
   125 	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
   126 	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
       
   127 
       
   128 #ifndef __KERNEL_MODE__
       
   129 protected:
       
   130 #else
       
   131 public:
       
   132 #endif	
   126 	virtual TInt TryLock();
   133 	virtual TInt TryLock();
   127 	virtual void TryUnlock();
   134 	virtual void TryUnlock();
   128 
   135 
   129 private:
   136 private:
   130 	TInt ReadWord(TLinAddr aLocation, TUint32& aResult) const;
   137 	TInt ReadWord(TLinAddr aLocation, TUint32& aResult) const;
   169 #endif
   176 #endif
   170 	};
   177 	};
   171 
   178 
   172 #ifdef __KERNEL_MODE__
   179 #ifdef __KERNEL_MODE__
   173 
   180 
   174 class RKernelSideAllocatorHelper : public RAllocatorHelper
   181 class RUserAllocatorHelper : public RAllocatorHelper
       
   182     {
       
   183 public:
       
   184     RUserAllocatorHelper();
       
   185     TInt OpenUserHeap(TUint aThreadId, TLinAddr aAllocatorAddress, TBool aEuserIsUdeb);
       
   186     virtual DChunk* OpenUnderlyingChunk(); // Must be in CS
       
   187     virtual void Close();
       
   188 
       
   189 protected:
       
   190     virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
       
   191     virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
       
   192     virtual TInt TryLock();
       
   193     virtual void TryUnlock();
       
   194 private:
       
   195     DThread* iThread;
       
   196     };
       
   197 
       
   198 class RKernelCopyAllocatorHelper : public RAllocatorHelper
       
   199     {
       
   200 public:
       
   201     RKernelCopyAllocatorHelper();
       
   202     TInt OpenCopiedHeap(DChunk* aOriginalChunk, DChunk* aCopiedChunk, TInt aOffset);
       
   203     virtual DChunk* OpenUnderlyingChunk(); // Must be in CS
       
   204     virtual void Close();
       
   205 
       
   206 protected:
       
   207     virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
       
   208     virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
       
   209     virtual TInt TryLock();
       
   210     virtual void TryUnlock();
       
   211 private:
       
   212     DChunk* iCopiedChunk;
       
   213     TInt iOffset; // from the original kernel heap to the copied heap
       
   214     };
       
   215 
       
   216 #else
       
   217 
       
   218 class RProxyAllocatorHelper : public RAllocatorHelper
   175 	{
   219 	{
   176 public:
   220 public:
   177 	RKernelSideAllocatorHelper();
   221 	HUIMPORT_C RProxyAllocatorHelper();
   178 	TInt OpenUserHeap(TUint aThreadId, TLinAddr aAllocatorAddress, TBool aEuserIsUdeb);
   222 	HUIMPORT_C TInt Open(RMemoryAccess& aMem, TUint aThreadId);
   179 	virtual DChunk* OpenUnderlyingChunk(); // Must be in CS
   223 	HUIMPORT_C TInt OpenChunkHeap(RMemoryAccess& aMem, TAny* aDChunkPtr);
   180 	virtual void Close();
   224 	HUIMPORT_C virtual void Close();
   181 
   225 
   182 protected:
   226 protected:
   183 	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
   227 	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
   184 	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
   228 	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
   185 	virtual TInt TryLock();
   229 	virtual TInt TryLock();
   186 	virtual void TryUnlock();
   230 	virtual void TryUnlock();
   187 private:
       
   188 	DThread* iThread;
       
   189 	};
       
   190 
       
   191 #else
       
   192 
       
   193 class RProxyAllocatorHelper : public RAllocatorHelper
       
   194 	{
       
   195 public:
       
   196 	HUIMPORT_C RProxyAllocatorHelper();
       
   197 	HUIMPORT_C TInt Open(RMemoryAccess& aMem, TUint aThreadId);
       
   198 	HUIMPORT_C TInt OpenChunkHeap(RMemoryAccess& aMem, TAny* aDChunkPtr);
       
   199 	HUIMPORT_C virtual void Close();
       
   200 
       
   201 protected:
       
   202 	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
       
   203 	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
       
   204 	virtual TInt TryLock();
       
   205 	virtual void TryUnlock();
       
   206 
   231 
   207 private:
   232 private:
   208 	RMemoryAccess* iMemoryAccess;
   233 	RMemoryAccess* iMemoryAccess;
   209 	TUint iThreadId;
   234 	TUint iThreadId;
   210 	};
   235 	};