1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/rpipe.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,240 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +// WARNING: This file contains some APIs which are internal and are subject
1.19 +// to change without notice. Such APIs should therefore not be used
1.20 +// outside the Kernel and Hardware Services package.
1.21 +//
1.22 +
1.23 +
1.24 +
1.25 +
1.26 +
1.27 +#ifndef __RPIPE_H__
1.28 +#define __RPIPE_H__
1.29 +
1.30 +#include <e32cmn.h>
1.31 +#include <e32ver.h>
1.32 +#ifndef __KERNEL_MODE__
1.33 +#include <e32std.h>
1.34 +#endif
1.35 +
1.36 +#if defined(DATAPAGING_TEST_ON)
1.37 +#define DATAPAGING_TEST(s) s
1.38 +#else
1.39 +#define DATAPAGING_TEST(s)
1.40 +#endif
1.41 +
1.42 +
1.43 +class RPipe: public RBusLogicalChannel
1.44 +/**
1.45 +RPipe class object represent the user side handle. It is derived from RBusLogicalChannel
1.46 +which is the base class for handle to the kernel side device driver instance. It encapsulates
1.47 +both named and unnamed pipe methods.
1.48 +@internalTechnology
1.49 +*/
1.50 + {
1.51 +public:
1.52 +
1.53 + /**
1.54 + Structure for holding driver capabilities information
1.55 + (Just a version number.)
1.56 + */
1.57 + class TCaps
1.58 + {
1.59 + public:
1.60 + TVersion iVersion;
1.61 + };
1.62 +
1.63 +
1.64 + /**
1.65 + Enumeration for the modes of opening a pipe.
1.66 + */
1.67 + enum TMode
1.68 + {
1.69 + EOpenToRead,
1.70 + EOpenToWrite,
1.71 + EOpenToWriteNamedPipeButFailOnNoReaders
1.72 + };
1.73 +
1.74 + enum TChannelType
1.75 + {
1.76 + EChannelUnset = 0x0,
1.77 + EReadChannel = 0x1,
1.78 + EWriteChannel = 0x2
1.79 + };
1.80 +
1.81 + class TPipeInfo
1.82 + {
1.83 + public:
1.84 + TInt isize;
1.85 + TBuf8<KMaxKernelName> iName;
1.86 +
1.87 + };
1.88 + typedef TPckgBuf<TPipeInfo> TPipeInfoBuf;
1.89 +
1.90 +
1.91 +public:
1.92 +
1.93 + /**
1.94 + Returns the version information of the DPipe Factory object
1.95 + */
1.96 + inline static TVersion VersionRequired();
1.97 +
1.98 + /**
1.99 + Returns the name of the DPipe factory object
1.100 + */
1.101 + inline static const TDesC& Name();
1.102 +
1.103 +
1.104 + /**
1.105 + Support for un-named pipe
1.106 + */
1.107 + IMPORT_C static TInt Create( TInt aSize, RPipe& aReader, RPipe& aWriter, TOwnerType aTypeR = EOwnerProcess, TOwnerType aTypeW = EOwnerProcess);
1.108 +
1.109 + TInt Create(const TInt sSize, TOwnerType aType = EOwnerProcess);
1.110 +
1.111 + TInt Open(const RPipe& aWriter, TOwnerType aType = EOwnerProcess);
1.112 +
1.113 +
1.114 + /**
1.115 + Support for named pipe
1.116 + */
1.117 +
1.118 + IMPORT_C static TInt Define( const TDesC& aName, TInt aSize);
1.119 +
1.120 + IMPORT_C static TInt Define( const TDesC& aName, TInt aSize, const TSecurityPolicy& aPolicy);
1.121 +
1.122 +
1.123 + IMPORT_C static TInt Destroy(const TDesC& aName);
1.124 +
1.125 + IMPORT_C TInt Open(const TDesC& aName, TMode aMode);
1.126 +
1.127 + IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess);
1.128 +
1.129 + IMPORT_C TInt Open(RMessagePtr2 aMessage, TInt aParam, TOwnerType aType=EOwnerProcess);
1.130 +
1.131 + IMPORT_C static TInt Init();
1.132 +
1.133 + /**
1.134 + Non-blocking read/write operations
1.135 + */
1.136 + IMPORT_C TInt Read ( TDes8& aData, TInt aSize);
1.137 +
1.138 + IMPORT_C TInt Write( const TDesC8& aBuf, TInt aSize);
1.139 +
1.140 + /**
1.141 + Blocking read/write operations
1.142 + */
1.143 + IMPORT_C TInt ReadBlocking(TDes8& aData, TInt aSize);
1.144 +
1.145 + IMPORT_C TInt WriteBlocking (const TDesC8& aBuf, TInt aSize);
1.146 +
1.147 + IMPORT_C TInt Size();
1.148 +
1.149 + IMPORT_C void NotifySpaceAvailable( TInt aSize, TRequestStatus&);
1.150 +
1.151 + IMPORT_C void NotifyDataAvailable( TRequestStatus&);
1.152 +
1.153 + IMPORT_C void Wait(const TDesC& aName, TRequestStatus& aStatus);
1.154 +
1.155 + IMPORT_C TInt MaxSize();
1.156 +
1.157 +
1.158 + IMPORT_C TInt CancelSpaceAvailable();
1.159 +
1.160 + IMPORT_C TInt CancelDataAvailable();
1.161 +
1.162 + IMPORT_C void CancelWait();
1.163 +
1.164 + IMPORT_C void Flush();
1.165 +
1.166 + IMPORT_C void Close();
1.167 +
1.168 + IMPORT_C TInt HandleType()const;
1.169 +
1.170 + TInt PipeHandle()const;
1.171 +
1.172 + IMPORT_C void WaitForReader(const TDesC& aName, TRequestStatus& aStatus);
1.173 +
1.174 + IMPORT_C void WaitForWriter(const TDesC& aName, TRequestStatus& aStatus);
1.175 +
1.176 + /*
1.177 + Enumeration of Request messages.
1.178 + */
1.179 + enum TRequest
1.180 + {
1.181 + EDefineNamedPipe,
1.182 + EOpenToReadNamedPipe,
1.183 + EOpenToWriteNamedPipe,
1.184 + EOpenToWriteButFailOnNoReaderNamedPipe,
1.185 + EDestroyNamedPipe,
1.186 + ECreateUnNamedPipe,
1.187 + EOpenUnNamedPipe,
1.188 + ERead,
1.189 + EWrite,
1.190 + ESize,
1.191 + EReadBlocking,
1.192 + EWriteBlocking,
1.193 + EDataAvailable,
1.194 + EDataAvailableCount,
1.195 + ESpaceAvailable,
1.196 + EWaitNotification,
1.197 + EWaitNotificationCheck,
1.198 + ECancelSpaceAvailable,
1.199 + ECancelDataAvailable,
1.200 + ECancelWaitNotification,
1.201 + EFlushPipe,
1.202 + EClosePipe,
1.203 + EGetPipeInfo
1.204 + };
1.205 + /*
1.206 + Enumeration of Wait Request.
1.207 + */
1.208 + enum TWaitRequest
1.209 + {
1.210 + EWaitForReader,
1.211 + EWaitForWriter
1.212 + };
1.213 +
1.214 + private:
1.215 +
1.216 + void Wait(const TDesC& aName, TRequestStatus& aStatus, TInt aChoice);
1.217 +
1.218 + void ReqComplete(TRequestStatus& aState, TInt aval);
1.219 + TInt iHandleType;
1.220 + TInt iSize;
1.221 + TInt iPipeHandle;
1.222 +};
1.223 +
1.224 +
1.225 +
1.226 +inline TVersion RPipe::VersionRequired()
1.227 +{
1.228 + // Just a number
1.229 + const TInt KMajorVersionNumber=1;
1.230 + const TInt KMinorVersionNumber=0;
1.231 + const TInt KBuildVersionNumber=1;
1.232 + return
1.233 + TVersion (KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber);
1.234 +}
1.235 +
1.236 +inline const TDesC& RPipe::Name()
1.237 +{
1.238 + _LIT(KRpipeDevice, "SymbianPipe");
1.239 + return KRpipeDevice;
1.240 +}
1.241 +
1.242 +
1.243 +#endif // __RPIPE_H__