os/kernelhwsrv/kerneltest/e32test/system/d_kucopy.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1999-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 // e32test\system\d_kucopy.h
    15 // 
    16 //
    17 
    18 #if !defined(__D_KUCOPY_H__)
    19 #define __D_KUCOPY_H__
    20 #include <e32cmn.h>
    21 #ifndef __KERNEL_MODE__
    22 #include <e32std.h>
    23 #endif
    24 
    25 _LIT(KKUCopyLddName,"KUCopy");
    26 
    27 class TCapsKUCopyV01
    28 	{
    29 public:
    30 	TVersion	iVersion;
    31 	};
    32 
    33 struct SCopyInfo
    34 	{
    35 	SCopyInfo()
    36 		: iPtr(NULL), iOffset(0), iLength(0)
    37 		{}
    38 	SCopyInfo(const TUint8* aPtr, TInt aOffset, TInt aLength)
    39 		: iPtr(aPtr), iOffset(aOffset), iLength(aLength)
    40 		{}
    41 	const TUint8* iPtr;
    42 	TInt iOffset;
    43 	TInt iLength;
    44 	};
    45 
    46 struct SSetInfo
    47 	{
    48 	SSetInfo()
    49 		: iPtr(NULL), iLength(0), iValue(0)
    50 		{}
    51 	SSetInfo(TUint8* aPtr, TInt aLength, TUint8 aValue)
    52 		: iPtr(aPtr), iLength(aLength), iValue(aValue)
    53 		{}
    54 	TUint8* iPtr;
    55 	TInt iLength;
    56 	TUint iValue;
    57 	};
    58 
    59 struct SDesInfo
    60 	{
    61 	TInt iLength;
    62 	TInt iMaxLength;
    63 	TAny* iPtr;
    64 	};
    65 
    66 class RKUCopy : public RBusLogicalChannel
    67 	{
    68 public:
    69 	enum TControl
    70 		{
    71 		EControlPut,
    72 		EControlGet,
    73 		EControlPut32,
    74 		EControlGet32,
    75 		EControlSet,
    76 		EControlLength,
    77 		EControlRead,
    78 		EControlRandomLength,
    79 		EControlReadRandom,
    80 		EControlDesPut8,
    81 		EControlDesGet8,
    82 		EControlDesInfo8,
    83 		EControlDesPut16,
    84 		EControlDesGet16,
    85 		EControlDesInfo16,
    86 		EControlKernBufAddr,
    87 		EControlRequestComplete, 
    88 		EControlRequestCompleteLocal, 
    89 		EControlQueueRequestComplete, 
    90 		};
    91 public:
    92 #ifndef __KERNEL_MODE__
    93 	inline TInt Open();
    94 	inline void Put(TUint8* aDest, TInt aOffset, TInt aLength);
    95 	inline void Get(const TUint8* aSrc, TInt aOffset, TInt aLength);
    96 	inline void Put32(TUint32* aDest, TInt aOffset, TInt aLength);
    97 	inline void Get32(const TUint32* aSrc, TInt aOffset, TInt aLength);
    98 	inline void Set(TUint8* aDest, TInt aLength, TUint8 aValue);
    99 	inline TInt Length();
   100 	inline void Read(TUint8* aDest);
   101 	inline TInt RandomLength();
   102 	inline void ReadRandom(TUint8* aDest);
   103 	inline void DesPut(TDes8& aDest, const TDesC8& aSrc);
   104 	inline void DesGet(TDes8& aDest, const TDesC8& aSrc);
   105 	inline void DesInfo(const TDesC8& aDes, SDesInfo& aInfo);
   106 	inline void DesPut(TDes16& aDest, const TDesC16& aSrc);
   107 	inline void DesGet(TDes16& aDest, const TDesC16& aSrc);
   108 	inline void DesInfo(const TDesC16& aDes, SDesInfo& aInfo);
   109 	inline TUint8* KernelBufferAddress();
   110 	inline void RequestComplete(TRequestStatus* status);
   111 	inline void RequestCompleteLocal(TRequestStatus* status);
   112 	inline TInt QueueRequestComplete(TRequestStatus* status);
   113 #endif
   114 	};
   115 
   116 #ifndef __KERNEL_MODE__
   117 inline TInt RKUCopy::Open()
   118 	{ return DoCreate(KKUCopyLddName,TVersion(1,0,0),KNullUnit,NULL,NULL); }
   119 
   120 inline void RKUCopy::Put(TUint8* aDest, TInt aOffset, TInt aLength)
   121 	{ SCopyInfo info(aDest,aOffset,aLength); DoControl(EControlPut,&info); }
   122 
   123 inline void RKUCopy::Get(const TUint8* aSrc, TInt aOffset, TInt aLength)
   124 	{ SCopyInfo info(aSrc,aOffset,aLength); DoControl(EControlGet,&info); }
   125 
   126 inline void RKUCopy::Put32(TUint32* aDest, TInt aOffset, TInt aLength)
   127 	{ SCopyInfo info((const TUint8*)aDest,aOffset,aLength); DoControl(EControlPut32,&info); }
   128 
   129 inline void RKUCopy::Get32(const TUint32* aSrc, TInt aOffset, TInt aLength)
   130 	{ SCopyInfo info((const TUint8*)aSrc,aOffset,aLength); DoControl(EControlGet32,&info); }
   131 
   132 inline void RKUCopy::Set(TUint8* aDest, TInt aLength, TUint8 aValue)
   133 	{ SSetInfo info(aDest,aLength,aValue); DoControl(EControlSet,&info); }
   134 
   135 inline TInt RKUCopy::Length()
   136 	{ return DoControl(EControlLength); }
   137 
   138 inline void RKUCopy::Read(TUint8* aDest)
   139 	{ DoControl(EControlRead,aDest); }
   140 
   141 inline TInt RKUCopy::RandomLength()
   142 	{ return DoControl(EControlRandomLength); }
   143 
   144 inline void RKUCopy::ReadRandom(TUint8* aDest)
   145 	{ DoControl(EControlReadRandom,aDest); }
   146 
   147 inline void RKUCopy::DesPut(TDes8& aDest, const TDesC8& aSrc)
   148 	{ DoControl(EControlDesPut8, &aDest, (TAny*)&aSrc); }
   149 
   150 inline void RKUCopy::DesGet(TDes8& aDest, const TDesC8& aSrc)
   151 	{ DoControl(EControlDesGet8, &aDest, (TAny*)&aSrc); }
   152 
   153 inline void RKUCopy::DesInfo(const TDesC8& aDes, SDesInfo& aInfo)
   154 	{ DoControl(EControlDesInfo8, (TAny*)&aDes, &aInfo); }
   155 
   156 inline void RKUCopy::DesPut(TDes16& aDest, const TDesC16& aSrc)
   157 	{ DoControl(EControlDesPut16, &aDest, (TAny*)&aSrc); }
   158 
   159 inline void RKUCopy::DesGet(TDes16& aDest, const TDesC16& aSrc)
   160 	{ DoControl(EControlDesGet16, &aDest, (TAny*)&aSrc); }
   161 
   162 inline void RKUCopy::DesInfo(const TDesC16& aDes, SDesInfo& aInfo)
   163 	{ DoControl(EControlDesInfo16, (TAny*)&aDes, &aInfo); }
   164 
   165 inline TUint8* RKUCopy::KernelBufferAddress()
   166 	{ return (TUint8*)DoControl(EControlKernBufAddr); }
   167 
   168 inline void RKUCopy::RequestComplete(TRequestStatus* status)
   169 	{ DoControl(EControlRequestComplete, status); }
   170 
   171 inline void RKUCopy::RequestCompleteLocal(TRequestStatus* status)
   172 	{ DoControl(EControlRequestCompleteLocal, status); }
   173 
   174 inline TInt RKUCopy::QueueRequestComplete(TRequestStatus* status)
   175 	{ return DoControl(EControlQueueRequestComplete, status); }
   176 #endif
   177 
   178 #endif