baseport/src/cedar/generic/base/syborg/svphostfs/inc/rsvphostfsdriver.h
changeset 2 d55eb581a87c
parent 1 2fb8b9db1c86
child 3 c2946f91d81f
equal deleted inserted replaced
1:2fb8b9db1c86 2:d55eb581a87c
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __RSVPHOSTFSDRIVER_H__
       
    19 #define __RSVPHOSTFSDRIVER_H__
       
    20 
       
    21 #include <e32des16.h>
       
    22 
       
    23 typedef TDes16 THostFileName;
       
    24 
       
    25 typedef enum 
       
    26 	{
       
    27 	EUnknown=0,
       
    28 	EWindows,
       
    29 	EUnix,
       
    30 	EMac,
       
    31 	} TFileTimeType;
       
    32 
       
    33 class TSVPHostFsMkDirInfo
       
    34 	{
       
    35 public:
       
    36 	inline TSVPHostFsMkDirInfo() :
       
    37 		iDrive(0),
       
    38 		iName(0),
       
    39 		iLength(0),
       
    40 		iFlags(0)
       
    41 		{};
       
    42 	inline TSVPHostFsMkDirInfo(TUint aDrive, const THostFileName & aName, TUint32 aFlags) :
       
    43 		iDrive(aDrive),
       
    44 		iName(aName.Ptr()),
       
    45 		iLength(aName.Length()),
       
    46 		iFlags(aFlags)
       
    47 		{};
       
    48 public:
       
    49 	TUint iDrive; 
       
    50 	const TUint16 * iName;
       
    51 	TUint32 iLength;
       
    52 	TUint32 iFlags;
       
    53 	};
       
    54 
       
    55 class TSVPHostFsRmDirInfo
       
    56 	{
       
    57 public:
       
    58 	inline TSVPHostFsRmDirInfo() :
       
    59 		iDrive(0),
       
    60 		iName(0),
       
    61 		iLength(0)
       
    62 		{};
       
    63 	inline TSVPHostFsRmDirInfo(TUint aDrive, const THostFileName & aName) :
       
    64 		iDrive(aDrive),
       
    65 		iName(aName.Ptr()),
       
    66 		iLength(aName.Length())
       
    67 		{};
       
    68 public:
       
    69 	TUint iDrive; 
       
    70 	const TUint16 * iName;
       
    71 	TUint32 iLength;
       
    72 	};
       
    73 
       
    74 class TSVPHostFsDeleteInfo
       
    75 	{
       
    76 public:
       
    77 	inline TSVPHostFsDeleteInfo() :
       
    78 		iDrive(0),
       
    79 		iName(0),
       
    80 		iLength(0)
       
    81 		{};
       
    82 	inline TSVPHostFsDeleteInfo(TUint aDrive, const THostFileName & aName) :
       
    83 		iDrive(aDrive),
       
    84 		iName(aName.Ptr()),
       
    85 		iLength(aName.Length())
       
    86 		{};
       
    87 public:
       
    88 	TUint iDrive; 
       
    89 	const TUint16 * iName;
       
    90 	TUint32 iLength;
       
    91 	};
       
    92 
       
    93 class TSVPHostFsRenameInfo
       
    94 	{
       
    95 public:
       
    96 	inline TSVPHostFsRenameInfo() :
       
    97 		iDrive(0),
       
    98 		iOldName(0),
       
    99 		iOldLength(0),
       
   100 		iNewName(0),
       
   101 		iNewLength(0)
       
   102 		{};
       
   103 	inline TSVPHostFsRenameInfo(TUint aDrive, const THostFileName & aOldName, const THostFileName & aNewName) :
       
   104 		iDrive(aDrive),
       
   105 		iOldName(aOldName.Ptr()),
       
   106 		iOldLength(aOldName.Length()),
       
   107 		iNewName(aNewName.Ptr()),
       
   108 		iNewLength(aNewName.Length())
       
   109 		{};
       
   110 public:
       
   111 	TUint iDrive; 
       
   112 	const TUint16 * iOldName;
       
   113 	TUint32 iOldLength;
       
   114 	const TUint16 * iNewName;
       
   115 	TUint32 iNewLength;
       
   116 	};
       
   117 
       
   118 class TSVPHostFsReplaceInfo
       
   119 	{
       
   120 public:
       
   121 	inline TSVPHostFsReplaceInfo() :
       
   122 		iDrive(0),
       
   123 		iOldName(0),
       
   124 		iOldLength(0),
       
   125 		iNewName(0),
       
   126 		iNewLength(0)
       
   127 		{};
       
   128 	inline TSVPHostFsReplaceInfo(TUint aDrive, const THostFileName & aOldName, const THostFileName & aNewName) :
       
   129 		iDrive(aDrive),
       
   130 		iOldName(aOldName.Ptr()),
       
   131 		iOldLength(aOldName.Length()),
       
   132 		iNewName(aNewName.Ptr()),
       
   133 		iNewLength(aNewName.Length())
       
   134 		{};
       
   135 public:
       
   136 	TUint iDrive; 
       
   137 	const TUint16 * iOldName;
       
   138 	TUint32 iOldLength;
       
   139 	const TUint16 * iNewName;
       
   140 	TUint32 iNewLength;
       
   141 	};
       
   142 
       
   143 class TSVPHostFsEntryInfo
       
   144 	{
       
   145 public:
       
   146 	inline TSVPHostFsEntryInfo() :
       
   147 		iDrive(0),
       
   148 		iName(0),
       
   149 		iLength(0),
       
   150 		iAtt(0),
       
   151 		iModified(0),
       
   152 		iSize(0),
       
   153 		iTimeType(EUnknown)
       
   154 		{};
       
   155 	inline TSVPHostFsEntryInfo(TUint aDrive, const THostFileName & aName) :
       
   156 		iDrive(aDrive),
       
   157 		iName(aName.Ptr()),
       
   158 		iLength(aName.Length()),
       
   159 		iAtt(0),
       
   160 		iModified(0),
       
   161 		iSize(0),
       
   162 		iTimeType(EUnknown)
       
   163 		{};
       
   164 public:
       
   165 	TUint iDrive; 
       
   166 	const TUint16 * iName;
       
   167 	TUint32 iLength;
       
   168 	TUint iAtt;
       
   169 	TUint32 iModified; // time in seconds since the epoc
       
   170 	TInt iSize;
       
   171 	TFileTimeType iTimeType;
       
   172 	char iHostName[KMaxFileName];
       
   173 };
       
   174 
       
   175 class TSVPHostFsSetEntryInfo
       
   176 	{
       
   177 public:
       
   178 	inline TSVPHostFsSetEntryInfo() :
       
   179 		iDrive(0),
       
   180 		iName(0),
       
   181 		iModified(0),
       
   182 		iNewAtt(0),
       
   183 		iTimeType(EUnknown)
       
   184 		{};
       
   185 	inline TSVPHostFsSetEntryInfo(TUint aDrive, const THostFileName & aName, TUint32 aModified, TUint aNewAtt) :
       
   186 		iDrive(aDrive),
       
   187 		iName(aName.Ptr()),
       
   188 		iModified(aModified),
       
   189 		iNewAtt(aNewAtt),
       
   190 		iTimeType(EUnknown)
       
   191 		{};
       
   192 public:
       
   193 	TUint iDrive; 
       
   194 	const TUint16 *iName;
       
   195 	TUint32 iModified; // time in seconds since the epoc
       
   196 	TUint iNewAtt;
       
   197 	TFileTimeType iTimeType;
       
   198 	};
       
   199 
       
   200 class TSVPHostFsDirOpenInfo
       
   201 	{
       
   202 public:
       
   203 	inline TSVPHostFsDirOpenInfo() :
       
   204 		iDrive(0),
       
   205 		iName(0),
       
   206 		iLength(0),
       
   207 		iHandle(0)
       
   208 		{};
       
   209 inline TSVPHostFsDirOpenInfo(TUint aDrive, const THostFileName & aName) :
       
   210 		iDrive(aDrive),
       
   211 		iName(aName.Ptr()),
       
   212 		iLength(aName.Length()),
       
   213 		iHandle(0)
       
   214 		{};
       
   215 public:
       
   216 	TUint iDrive; 
       
   217 	const TUint16 * iName;
       
   218 	TUint32 iLength;
       
   219 	TUint32 iHandle;
       
   220 	};
       
   221 
       
   222 #define SVP_HOST_FS_INVALID_FILE_HANDLE -1
       
   223 class TSVPHostFsFileOpenInfo
       
   224 	{
       
   225 public:
       
   226 	inline TSVPHostFsFileOpenInfo() :
       
   227 		iDrive(0),
       
   228 		iName(0),
       
   229 		iLength(0), // of file name
       
   230 		iMode(0),
       
   231 		iOpen(0),
       
   232 		iAtt(0),
       
   233 		iModified(0), // time in seconds since the epoc
       
   234 		iSize(0),     // of file
       
   235 		iTimeType(EUnknown),
       
   236 		iHandle(SVP_HOST_FS_INVALID_FILE_HANDLE)
       
   237 		{};
       
   238 	inline TSVPHostFsFileOpenInfo(TUint aDrive, const THostFileName & aName, TUint32 aMode, TUint32 anOpen) :
       
   239 		iDrive(aDrive),
       
   240 		iName(aName.Ptr()),
       
   241 		iLength(aName.Length()),
       
   242 		iMode(aMode),
       
   243 		iOpen(anOpen),
       
   244 		iAtt(0),
       
   245 		iModified(0), // time in seconds since the epoc
       
   246 		iSize(0),     // of file
       
   247 		iTimeType(EUnknown),
       
   248 		iHandle(SVP_HOST_FS_INVALID_FILE_HANDLE)
       
   249 		{};
       
   250 public:
       
   251 	TUint iDrive; 
       
   252 	const TUint16 * iName;
       
   253 	TUint32 iLength;
       
   254 	TUint32 iMode;
       
   255 	TUint32 iOpen;
       
   256 	TUint iAtt;
       
   257 	TUint32 iModified; // time in seconds since the epoc
       
   258 	TInt iSize;
       
   259 	TFileTimeType iTimeType;
       
   260 	TInt iHandle;
       
   261 	};
       
   262 
       
   263 class TSVPHostFsFileReadInfo
       
   264 	{
       
   265 public:
       
   266 	inline TSVPHostFsFileReadInfo() :
       
   267 		iDrive(0),
       
   268 		iHandle(0),
       
   269 		iLength(0),
       
   270 		iPos(0),
       
   271 		iBuf(0)
       
   272 		{};
       
   273 	inline TSVPHostFsFileReadInfo(TUint aDrive, TUint aHandle,TInt aLength,TInt aPos, char * aBuf):
       
   274 		iDrive(aDrive),
       
   275 		iHandle(aHandle),
       
   276 		iLength(aLength),
       
   277 		iPos(aPos),
       
   278 		iBuf(aBuf)
       
   279 		{};
       
   280 public:
       
   281 	TUint iDrive; 
       
   282 	TUint iHandle;
       
   283 	TInt iLength;
       
   284 	TInt iPos;
       
   285 	char * iBuf;
       
   286 	};	
       
   287 
       
   288 class TSVPHostFsFileWriteInfo
       
   289 	{
       
   290 public:
       
   291 	inline TSVPHostFsFileWriteInfo() :
       
   292 		iDrive(0),
       
   293 		iHandle(0),
       
   294 		iLength(0),
       
   295 		iPos(0),
       
   296 		iBuf(0)
       
   297 		{};
       
   298 	inline TSVPHostFsFileWriteInfo(TUint aDrive, TUint aHandle,TInt aLength,TInt aPos, char * aBuf):
       
   299 		iDrive(aDrive),
       
   300 		iHandle(aHandle),
       
   301 		iLength(aLength),
       
   302 		iPos(aPos),
       
   303 		iBuf(aBuf)
       
   304 		{};
       
   305 public:
       
   306 	TUint iDrive; 
       
   307 	TUint iHandle;
       
   308 	TInt iLength;
       
   309 	TInt iPos;
       
   310 	char * iBuf;
       
   311 	};
       
   312 
       
   313 class TSVPHostFsFileSetSizeInfo
       
   314 	{
       
   315 public:
       
   316 	inline TSVPHostFsFileSetSizeInfo() :
       
   317 		iDrive(0),
       
   318 		iHandle(0),
       
   319 		iLength(0)
       
   320 		{};
       
   321 	inline TSVPHostFsFileSetSizeInfo(TUint aDrive, TUint aHandle, TInt aLength) :
       
   322 		iDrive(aDrive),
       
   323 		iHandle(aHandle),
       
   324 		iLength(aLength)
       
   325 		{};
       
   326 public:
       
   327 	TUint iDrive; 
       
   328 	TUint iHandle;
       
   329 	TInt iLength;
       
   330 	};
       
   331 
       
   332 class TSVPHostFsDirReadInfo
       
   333 {
       
   334 public:
       
   335 	inline TSVPHostFsDirReadInfo() :
       
   336 		iDrive(0),
       
   337 		iHandle(0),
       
   338 		iLength(0),
       
   339 		iAtt(0),
       
   340 		iModified(0),
       
   341 		iSize(0),
       
   342 		iTimeType(EUnknown)
       
   343 		{};
       
   344 	inline TSVPHostFsDirReadInfo(TUint aDrive, TUint32 aHandle) :
       
   345 		iDrive(aDrive),
       
   346 		iHandle(aHandle),
       
   347 		iLength(-1),
       
   348 		iAtt(0),
       
   349 		iModified(666),
       
   350 		iSize(-1),
       
   351 		iTimeType(EUnknown)
       
   352 		{};
       
   353 public:
       
   354 	TUint iDrive; 
       
   355 	TUint32 iHandle;
       
   356 	TInt iLength;
       
   357 	TUint16 iName[KMaxPath];
       
   358 	TUint iAtt;
       
   359 	TUint32 iModified; // time in seconds since the epoc
       
   360 	TInt iSize;
       
   361 	TFileTimeType iTimeType;
       
   362 	};
       
   363 
       
   364 class TCapsSVPHostFsDriver
       
   365 	{
       
   366 public:
       
   367 	TVersion	iVersion;
       
   368 	};
       
   369 
       
   370 _LIT(KSVPHostFsDriverName,"SVP Host Filesystem Driver");
       
   371 _LIT(KSVPHostFsDriverLDD, "svphostfsdriver.ldd");
       
   372 
       
   373 // Version information
       
   374 const TInt KMajorVersionNumber=0;
       
   375 const TInt KMinorVersionNumber=0;
       
   376 const TInt KBuildVersionNumber=1;
       
   377 
       
   378 // keep in sync with the definitions in QEMU/hw/svphostfs.c 
       
   379 #define LOWEST_DRIVE 'A'
       
   380 #define HIGHEST_DRIVE 'Z'
       
   381 #define DRIVE_MAP_SIZE (HIGHEST_DRIVE - LOWEST_DRIVE + 1)
       
   382 
       
   383 class RSVPHostFsDriver : public RBusLogicalChannel
       
   384 	{
       
   385 public:
       
   386 
       
   387 	enum TControl
       
   388 		{
       
   389 		EDummu = 0,
       
   390 
       
   391 		// Codes for CMountCB operations
       
   392 		EMkDir,
       
   393 		ERmDir,
       
   394 		EDelete,
       
   395 		ERename,
       
   396 		EReplace,
       
   397 		EReadUid,
       
   398 		EEntry,
       
   399 		ESetEntry,
       
   400 		EFileOpen,
       
   401 		EDirOpen,
       
   402 		
       
   403 		// Code for CFileCB operations
       
   404 		EFileClose, 
       
   405 		EFileRead,
       
   406 		EFileWrite,
       
   407 		EFileSetSize,
       
   408 		EFileFlushAll,
       
   409 
       
   410 		// Code for CDirCB operations
       
   411 		EDirClose, 
       
   412 		EDirRead,
       
   413 
       
   414 		// Device ops
       
   415 		EGetDeviceID,
       
   416 		EGetDriveMap,
       
   417 
       
   418 		};
       
   419 	
       
   420 		
       
   421 public:
       
   422 #ifndef __KERNEL_MODE__  // don't need to see these in the driver
       
   423 	TInt Open();
       
   424 	TInt MkDir(TSVPHostFsMkDirInfo& aInfo);
       
   425 	TInt RmDir(TSVPHostFsRmDirInfo& aInfo);
       
   426 	TInt Delete(TSVPHostFsDeleteInfo& aInfo);
       
   427 	TInt Rename(TSVPHostFsRenameInfo& aInfo);
       
   428 	TInt Replace(TSVPHostFsReplaceInfo& aInfo);
       
   429 	TInt ReadUid(const TDesC& aName,TEntry& anEntry);
       
   430 	TInt Entry(TSVPHostFsEntryInfo& aInfo);
       
   431 	TInt SetEntry(TSVPHostFsSetEntryInfo &aInfo);
       
   432 	TInt FileOpen(TSVPHostFsFileOpenInfo &aInfo);
       
   433 	TInt DirOpen(TSVPHostFsDirOpenInfo& aInfo);
       
   434 	TInt FileClose(TUint32 aDrive, TUint32 aHandle);
       
   435 	TInt FileRead(TSVPHostFsFileReadInfo& aInfo);		
       
   436 	TInt FileWrite(TSVPHostFsFileWriteInfo& aInfo);
       
   437 	TInt FileSetSize(TSVPHostFsFileSetSizeInfo &aInfo);
       
   438 	TInt FileSetEntry(TSVPHostFsSetEntryInfo &aInfo);
       
   439 	TInt FlushData(TUint32 aDrive);
       
   440 	TInt FlushAll(TUint32 aDrive);
       
   441 
       
   442 	TInt DirClose(TUint32 aDrive, TUint32 aHandle);
       
   443 	TInt DirRead(TSVPHostFsDirReadInfo& aInfo);
       
   444 
       
   445 	TUint32 GetDeviceID(TUint32 aDrive);
       
   446 
       
   447 	TInt GetDriveMap(TUint32 * aMap);
       
   448 
       
   449 private:
       
   450 	inline TInt DoSVPRequest(TInt aReqNo, TAny * a1) 
       
   451 		{
       
   452 		TRequestStatus status;
       
   453 		DoRequest(aReqNo, status, a1);
       
   454 		User::WaitForRequest(status);
       
   455 		return status.Int();
       
   456 		}
       
   457 
       
   458 	inline TInt DoSVPRequest(TInt aReqNo, TAny * a1, TAny * a2) 
       
   459 		{
       
   460 		TRequestStatus status;
       
   461 		DoRequest(aReqNo, status, a1, a2);
       
   462 		User::WaitForRequest(status);
       
   463 		return status.Int();
       
   464 		}
       
   465 #endif
       
   466 	};
       
   467 
       
   468 #endif // __rsvphostfsdriver_H__