userlibandfileserver/fileserver/inc/filesystem_utils.h
changeset 10 36bfc973b146
equal deleted inserted replaced
9:96e5fb8b040d 10:36bfc973b146
       
     1 // Copyright (c) 1995-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 //  Collection of common constants, utility functions, etc. for the file server and file systems.
       
    16 //  Definitions here must be filesystem-agnostic, i.e. generic enougs to be used by every file system
       
    17 //
       
    18 //  This is the internal file and must not be exported.
       
    19 
       
    20 /**
       
    21     @file
       
    22     @internalTechnology
       
    23 */
       
    24 
       
    25 #if !defined(__FILESYSTEM_UTILS_H__)
       
    26 #define __FILESYSTEM_UTILS_H__
       
    27 
       
    28 #if !defined(__E32BASE_H__)
       
    29 #include <e32base.h>
       
    30 #endif
       
    31 
       
    32 //#######################################################################################################################################
       
    33 //#   constants definitions
       
    34 //#######################################################################################################################################
       
    35 
       
    36 const TUint KBitsInByteLog2 = 3;
       
    37 const TUint KBitsInByte = 1<<KBitsInByteLog2;
       
    38 
       
    39 
       
    40 const TUint16 K1KiloByteLog2 = 10;
       
    41 const TUint32 K1KiloByte = 1<<K1KiloByteLog2; 
       
    42 const TUint32 K1MegaByte = 1<<20; 
       
    43 
       
    44 const TUint32 K1uSec = 1;               ///< 1 misrosecond in TTimeIntervalMicroSeconds32
       
    45 const TUint32 K1mSec = 1000;            ///< 1 millisecond in TTimeIntervalMicroSeconds32
       
    46 const TUint32 K1Sec  = 1000*K1mSec;     ///< 1 second in TTimeIntervalMicroSeconds32
       
    47 
       
    48 //---------------------------------------------------------------------------------------------------------------------------------------
       
    49 
       
    50 const TUint KDefSectorSzLog2=9;                         ///< Log2 of the default sector size for the media 
       
    51 const TUint KDefaultSectorSize = 1 << KDefSectorSzLog2; ///< Default sector size for the media, 512 bytes
       
    52 
       
    53 //#######################################################################################################################################
       
    54 //#   some useful utility functions
       
    55 //#######################################################################################################################################
       
    56 
       
    57 inline TUint32 Pow2(TUint32 aVal);          //-- return 2^aVal
       
    58 inline TUint32 Pow2_32(TUint32 aVal);       //-- return 2^aVal
       
    59 inline TUint64 Pow2_64(TUint32 aVal);       //-- return 2^aVal
       
    60 
       
    61 inline TBool IsPowerOf2(TUint32 aVal);      //-- return ETrue if aVal is a power of 2 
       
    62 inline TBool IsPowerOf2_64(TUint64 aVal);   //-- return ETrue if aVal is a power of 2 
       
    63 
       
    64 inline TUint32 RoundDown(TUint32 aVal, TUint32 aGranularityLog2);
       
    65 inline TUint32 RoundUp(TUint32 aVal, TUint32 aGranularityLog2);
       
    66 
       
    67 inline TBool BoolXOR(TBool a1, TBool a2);    //-- return Boolean XOR of a1 and a2
       
    68 
       
    69 inline TUint32 Log2_inline(TUint32 aVal);           //-- Calculates the Log2(aVal)
       
    70 inline TUint32 Count1Bits_inline(TUint32 aVal);     //-- counts number of '1' bits in the aVal
       
    71 
       
    72  
       
    73 
       
    74 
       
    75 #include "filesystem_utils.inl"
       
    76 
       
    77 
       
    78 #endif //__FILESYSTEM_UTILS_H__
       
    79 
       
    80 
       
    81 
       
    82 
       
    83 
       
    84 
       
    85 
       
    86 
       
    87 
       
    88 
       
    89 
       
    90