os/kernelhwsrv/kerneltest/f32test/fileutils/inc/f32_test_utils.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// @file
sl@0
    15
// various FAT utilities header file
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
sl@0
    20
        
sl@0
    21
#ifndef F32_TEST_UTILS_HEADER
sl@0
    22
#define F32_TEST_UTILS_HEADER
sl@0
    23
sl@0
    24
#include <f32fsys.h>
sl@0
    25
sl@0
    26
namespace F32_Test_Utils
sl@0
    27
{
sl@0
    28
sl@0
    29
const TUint32 K1KiloByte = 1<<10;
sl@0
    30
const TUint32 K1MegaByte = 1<<20;
sl@0
    31
const TUint32 K1GigaByte = 1<<30;
sl@0
    32
sl@0
    33
const TUint K1uSec = 1;             ///< 1 misrosecond in TTimeIntervalMicroSeconds32
sl@0
    34
const TUint K1mSec = 1000;          ///< 1 millisecond in TTimeIntervalMicroSeconds32
sl@0
    35
const TUint K1Sec  = 1000*K1mSec;   ///< 1 second in TTimeIntervalMicroSeconds32
sl@0
    36
sl@0
    37
//-----------------------------------------------------------------------------
sl@0
    38
sl@0
    39
void SetConsole(CConsoleBase* apConsole);
sl@0
    40
sl@0
    41
TBool EnablePrintOutput(TBool bEnable);
sl@0
    42
sl@0
    43
sl@0
    44
//#############################################################################
sl@0
    45
//#    File System independent functions and classes
sl@0
    46
//#############################################################################
sl@0
    47
sl@0
    48
TInt  PrintDrvInfo(RFs &aFs, TInt aDrive);
sl@0
    49
TInt  MediaRawRead(RFs &aFs, TInt aDrive, TInt64 aMediaPos, TUint32 aLen, TDes8& aData); 
sl@0
    50
TInt  MediaRawWrite(RFs &aFs, TInt aDrive, TInt64 aMediaPos, const TDesC8& aData);
sl@0
    51
TInt  FillMedia(RFs &aFs, TInt aDrive, TInt64 aMediaStartPos, TInt64 aMediaEndPos, TUint8 aBytePattern=0);
sl@0
    52
sl@0
    53
TInt  CreateCheckableStuffedFile(RFs& aFs, const TDesC& aFileName, TUint64 aSize);
sl@0
    54
TInt  VerifyCheckableFile(RFs& aFs, const TDesC& aFileName);
sl@0
    55
sl@0
    56
TInt  CreateEmptyFile(RFs& aFs, const TDesC& aFileName, TUint64 aSize);
sl@0
    57
sl@0
    58
TInt  RemountFS(RFs& aFs, TInt aDrive, TTime* apTimeMountStart=NULL);
sl@0
    59
sl@0
    60
TInt FormatDrive(RFs &aFs, TInt aDrive, TBool aQuickFormat); 
sl@0
    61
sl@0
    62
sl@0
    63
//-----------------------------------------------------------------------------
sl@0
    64
/** 
sl@0
    65
    a file system descriptor. Contains the information about file system.
sl@0
    66
    support for non-primary FS extensions is not implemented yet, it suports primary extensions only
sl@0
    67
*/
sl@0
    68
class TFSDescriptor
sl@0
    69
{
sl@0
    70
 public:
sl@0
    71
    TFSDescriptor();
sl@0
    72
    void Init();
sl@0
    73
sl@0
    74
    TBool operator==(const TFSDescriptor& aRhs) const;
sl@0
    75
sl@0
    76
 public:
sl@0
    77
    
sl@0
    78
    TBuf<32> iFsName;    ///< file system name. 
sl@0
    79
    TBuf<32> iPExtName;  ///< primary extension name if it is present. Length == 0 means that there is no primary extension    
sl@0
    80
    TBool    iDriveSynch;///< ETrue if the drive is synchronous
sl@0
    81
sl@0
    82
};
sl@0
    83
sl@0
    84
TInt GetFileSystemDescriptor(RFs &aFs, TInt aDrive, TFSDescriptor& aFsDesc);
sl@0
    85
TInt MountFileSystem(RFs &aFs, TInt aDrive, const TFSDescriptor& aFsDesc);
sl@0
    86
sl@0
    87
//-----------------------------------------------------------------------------
sl@0
    88
sl@0
    89
sl@0
    90
/**
sl@0
    91
Indicates if a number passed in is a power of two
sl@0
    92
@return ETrue if aVal is a power of 2 
sl@0
    93
*/
sl@0
    94
TBool IsPowerOf2(TUint32 aVal);
sl@0
    95
sl@0
    96
/**
sl@0
    97
Calculates the log2 of a number
sl@0
    98
sl@0
    99
@param aNum Number to calulate the log two of
sl@0
   100
@return The log two of the number passed in
sl@0
   101
*/
sl@0
   102
TUint32 Log2(TUint32 aVal);
sl@0
   103
sl@0
   104
//-----------------------------------------------------------------------------
sl@0
   105
sl@0
   106
/** 
sl@0
   107
    This is normal implementation that unlike Symbian's doesn't have 2^32 max. bits message length limitation.
sl@0
   108
*/
sl@0
   109
class TMD5
sl@0
   110
{
sl@0
   111
 public:
sl@0
   112
sl@0
   113
    enum {HashSize = 16}; ///< MD5 hash size in bytes
sl@0
   114
    TMD5();
sl@0
   115
sl@0
   116
    void Reset();
sl@0
   117
    void Update(const TDesC8& aMessage);
sl@0
   118
    TPtrC8 Final(const TDesC8& aMessage);
sl@0
   119
    TPtrC8 Final();
sl@0
   120
sl@0
   121
  private:
sl@0
   122
    
sl@0
   123
    void Md5_process(const TUint8 *data /*[64]*/);
sl@0
   124
    void Md5_finish();
sl@0
   125
    void Md5_append(const TUint8 *data, TInt nbytes);
sl@0
   126
sl@0
   127
    struct TState 
sl@0
   128
        {
sl@0
   129
        TUint32 count[2]; ///< message length in bits, lsw first
sl@0
   130
        TUint32 abcd[4];  ///< digest buffer
sl@0
   131
        TUint8  buf[64];   ///< accumulate block
sl@0
   132
        };
sl@0
   133
 
sl@0
   134
    TState iState;
sl@0
   135
    TUint8 iDigest[HashSize];
sl@0
   136
};
sl@0
   137
sl@0
   138
sl@0
   139
sl@0
   140
sl@0
   141
TBool Is_Lffs(RFs &aFs, TInt aDrive);   //-- returns ETrue if "lffs" FS is mounted on this drive 
sl@0
   142
TBool Is_Win32(RFs &aFs, TInt aDrive);  //-- returns ETrue if "win32" FS is mounted on this drive (i.e this is emulator's drive c:)
sl@0
   143
TBool Is_ExFat(RFs &aFs, TInt aDrive);  //-- returns ETrue if "exFAT" FS is mounted on this drive 
sl@0
   144
TBool Is_Automounter(RFs &aFs, TInt aDrive);  //-- returns ETrue if "Automounter" FS is mounted on this drive 
sl@0
   145
sl@0
   146
sl@0
   147
TBool Is_Fat(RFs &aFs, TInt aDrive);    //-- returns ETrue if "FAT" FS (FAT12/16/32) is mounted on this drive 
sl@0
   148
sl@0
   149
TBool Is_Fat32(RFs &aFs, TInt aDrive);  //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT32 type
sl@0
   150
TBool Is_Fat16(RFs &aFs, TInt aDrive);  //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT16 type    
sl@0
   151
TBool Is_Fat12(RFs &aFs, TInt aDrive);  //-- returns ETrue if "FAT" FS is mounted on this drive and it is FAT12 type
sl@0
   152
sl@0
   153
sl@0
   154
sl@0
   155
//#############################################################################
sl@0
   156
//#  some  private helper functions  
sl@0
   157
//#############################################################################
sl@0
   158
void DoPrintf(TRefByValue<const TDesC> aFmt,...);
sl@0
   159
void DoMediaRawReadL(RFs &aFs, TInt aDrive, TInt64 aMediaPos, TUint32 aLen, TDes8& aData);
sl@0
   160
void DoMediaRawWriteL(RFs &aFs, TInt aDrive, TInt64 aMediaPos, const TDesC8& aData);
sl@0
   161
sl@0
   162
sl@0
   163
sl@0
   164
}//F32_Test_Utils
sl@0
   165
sl@0
   166
sl@0
   167
#endif //F32_TEST_UTILS_HEADER
sl@0
   168
sl@0
   169
sl@0
   170
sl@0
   171
sl@0
   172
sl@0
   173
sl@0
   174
sl@0
   175
sl@0
   176
sl@0
   177
sl@0
   178
sl@0
   179
sl@0
   180
sl@0
   181
sl@0
   182
sl@0
   183
sl@0
   184
sl@0
   185
sl@0
   186
sl@0
   187
sl@0
   188
sl@0
   189
sl@0
   190
sl@0
   191
sl@0
   192
sl@0
   193
sl@0
   194
sl@0
   195
sl@0
   196
sl@0
   197
sl@0
   198
sl@0
   199
sl@0
   200
sl@0
   201