os/kernelhwsrv/kernel/eka/include/rpipe.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2006-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 //
    15 // WARNING: This file contains some APIs which are internal and are subject
    16 //          to change without notice. Such APIs should therefore not be used
    17 //          outside the Kernel and Hardware Services package.
    18 //
    19 
    20 
    21 
    22 
    23 
    24 #ifndef __RPIPE_H__
    25 #define __RPIPE_H__
    26 
    27 #include <e32cmn.h>
    28 #include <e32ver.h>
    29 #ifndef __KERNEL_MODE__
    30 #include <e32std.h>
    31 #endif
    32 
    33 #if defined(DATAPAGING_TEST_ON)
    34 #define DATAPAGING_TEST(s) s
    35 #else
    36 #define DATAPAGING_TEST(s)
    37 #endif
    38 
    39 
    40 class RPipe: public RBusLogicalChannel
    41 /**
    42 RPipe class object represent the user side handle.  It is derived from RBusLogicalChannel 
    43 which is the base class for handle to the kernel side device driver instance. It encapsulates
    44 both named and unnamed pipe methods. 
    45 @internalTechnology
    46 */
    47     {
    48 public:
    49 
    50     /**
    51     Structure for holding driver capabilities information
    52     (Just a version number.)
    53     */
    54     class TCaps
    55         {
    56     public:
    57         TVersion iVersion;
    58         };
    59 
    60 
    61 	/**
    62 	Enumeration for the modes of opening a pipe.
    63 	*/
    64 	enum TMode
    65 	{
    66 		EOpenToRead,
    67 		EOpenToWrite,
    68 		EOpenToWriteNamedPipeButFailOnNoReaders	
    69 	};
    70 	
    71 	enum TChannelType
    72 	{
    73 		EChannelUnset = 0x0,
    74 		EReadChannel = 0x1,
    75 		EWriteChannel = 0x2
    76 	};
    77 	
    78 	class TPipeInfo
    79         {
    80     public:
    81         TInt isize;
    82         TBuf8<KMaxKernelName> iName;
    83      
    84         };
    85     typedef TPckgBuf<TPipeInfo> TPipeInfoBuf;
    86 
    87 
    88 public:
    89 
    90 	/**
    91 	 Returns the version information of the  DPipe Factory object
    92 	 */
    93     inline static TVersion VersionRequired();
    94 
    95 	/**
    96 	 Returns the name of the DPipe factory object
    97 	 */
    98 	inline static const TDesC& Name();
    99 
   100   
   101 	/**
   102 	 Support for un-named pipe
   103 	 */
   104 	 IMPORT_C static TInt Create( TInt aSize, RPipe& aReader, RPipe& aWriter, TOwnerType aTypeR = EOwnerProcess,  TOwnerType aTypeW = EOwnerProcess);
   105 	
   106 	 TInt Create(const TInt sSize,  TOwnerType aType = EOwnerProcess);
   107 
   108 	 TInt Open(const RPipe& aWriter, TOwnerType  aType = EOwnerProcess);
   109 
   110 
   111 	/**
   112 	Support for named pipe
   113 	*/
   114 	
   115 	IMPORT_C static TInt Define( const TDesC& aName, TInt aSize);
   116 	
   117 	IMPORT_C static TInt Define( const  TDesC& aName, TInt aSize, const TSecurityPolicy& aPolicy);
   118 								
   119 
   120 	IMPORT_C static TInt Destroy(const TDesC& aName);
   121 
   122 	IMPORT_C TInt Open(const TDesC& aName, TMode aMode);
   123 
   124 	IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess);
   125 	
   126 	IMPORT_C TInt Open(RMessagePtr2 aMessage, TInt aParam, TOwnerType aType=EOwnerProcess);
   127 	
   128 	IMPORT_C static TInt Init();
   129   	
   130 	/**
   131 	 Non-blocking read/write operations
   132 	 */
   133 	IMPORT_C TInt Read ( TDes8& aData, TInt aSize);
   134 
   135 	IMPORT_C TInt Write( const TDesC8& aBuf, TInt aSize);
   136 
   137 	/** 
   138 	Blocking read/write operations
   139 	*/
   140 	IMPORT_C TInt ReadBlocking(TDes8& aData, TInt aSize);
   141 
   142 	IMPORT_C TInt WriteBlocking (const TDesC8& aBuf, TInt aSize);
   143 
   144 	IMPORT_C TInt Size();
   145 
   146 	IMPORT_C void NotifySpaceAvailable( TInt aSize, TRequestStatus&);
   147 
   148     IMPORT_C void NotifyDataAvailable( TRequestStatus&); 
   149 	
   150 	IMPORT_C void Wait(const TDesC& aName, TRequestStatus& aStatus);
   151 	
   152 	IMPORT_C TInt MaxSize();
   153 
   154 
   155 	IMPORT_C TInt CancelSpaceAvailable();
   156 
   157 	IMPORT_C TInt CancelDataAvailable();
   158 
   159 	IMPORT_C void CancelWait();
   160 
   161 	IMPORT_C void Flush();
   162 
   163 	IMPORT_C void Close();    
   164 	
   165 	IMPORT_C TInt HandleType()const;
   166 
   167 	TInt PipeHandle()const;
   168 	
   169 	IMPORT_C void WaitForReader(const TDesC& aName, TRequestStatus& aStatus);
   170 	
   171 	IMPORT_C void WaitForWriter(const TDesC& aName, TRequestStatus& aStatus);
   172 	    
   173     /*
   174      Enumeration of Request messages.
   175     */
   176     enum TRequest
   177         {
   178 		EDefineNamedPipe,
   179 		EOpenToReadNamedPipe,
   180 		EOpenToWriteNamedPipe,
   181 		EOpenToWriteButFailOnNoReaderNamedPipe,
   182 		EDestroyNamedPipe,
   183 		ECreateUnNamedPipe,
   184 		EOpenUnNamedPipe,
   185 		ERead,
   186         	EWrite,
   187 	    	ESize,
   188 	        EReadBlocking,
   189 		EWriteBlocking,  	
   190 		EDataAvailable,
   191 		EDataAvailableCount,
   192 		ESpaceAvailable,
   193 		EWaitNotification,
   194 		EWaitNotificationCheck,
   195 		ECancelSpaceAvailable,
   196 		ECancelDataAvailable,
   197 		ECancelWaitNotification,
   198 		EFlushPipe,
   199 		EClosePipe,
   200 		EGetPipeInfo
   201 	   };
   202 	/*
   203      Enumeration of Wait Request.
   204     */   
   205 	enum TWaitRequest
   206 		{
   207 		EWaitForReader,
   208 		EWaitForWriter
   209 		};
   210 		
   211 	private:
   212 	
   213 	void Wait(const TDesC& aName, TRequestStatus& aStatus, TInt aChoice);
   214 	
   215 	void ReqComplete(TRequestStatus& aState, TInt aval);
   216 	TInt iHandleType;
   217 	TInt iSize;
   218 	TInt iPipeHandle;
   219 };
   220 
   221 
   222 
   223 inline TVersion RPipe::VersionRequired()
   224 {
   225 	// Just a number 
   226     const TInt KMajorVersionNumber=1;
   227     const TInt KMinorVersionNumber=0;
   228     const TInt KBuildVersionNumber=1;
   229     return         
   230     TVersion (KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber);
   231 }
   232 
   233 inline const TDesC& RPipe::Name()
   234 {
   235 	_LIT(KRpipeDevice, "SymbianPipe");
   236 	return KRpipeDevice;
   237 }
   238 
   239 
   240 #endif // __RPIPE_H__