os/kernelhwsrv/userlibandfileserver/fileserver/sfat/sl_cache.inl
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1996-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 // f32\sfat32\inc\sl_cache.inl
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20  @internalTechnology
    21 */
    22 
    23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    25 //!!
    26 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
    27 //!!
    28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    29 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    30 
    31 
    32 #ifndef SL_CACHE_INL
    33 #define SL_CACHE_INL
    34 
    35 
    36 /**
    37     @param  aPos media linear position
    38     @return ETrue if the aPos belongs to this page
    39 */
    40 TBool CWTCachePage::PosCached(TInt64 aPos) const
    41     {
    42     return (iValid && aPos >= iStartPos && aPos < iStartPos+PageSize());
    43     }
    44 
    45 
    46 /**
    47     Calculate data position within cache page relatively to the page beginning.
    48     @param  aPos media linear position
    49     @return data offset from the beginning of the page
    50 */
    51 TUint32 CWTCachePage::PosInCachePage(TInt64 aPos) const 
    52     { 
    53     return ((TUint32)aPos - (TUint32)iStartPos) & (PageSize()-1);
    54     }
    55 
    56 /**
    57     Obtain pointer to the data in the cache page by media inear position
    58     @param  aPos media linear position
    59     @return pointer to the data in page buffer
    60 */
    61 TUint8* CWTCachePage::PtrInCachePage(TInt64 aPos) const 
    62     { 
    63     return (TUint8*)iData.Ptr() + PosInCachePage(aPos);
    64     }
    65 
    66 /**
    67     @return cache page size in bytes
    68 */
    69 TUint32 CWTCachePage::PageSize() const 
    70     {
    71     return iData.Size();
    72     }  
    73 
    74 //---------------------------------------------------------------------------------------------------------------------------------
    75 
    76 
    77 /**
    78     Just helper method to calculate cache page start position by given media pos.
    79     @param  aPos media linear position
    80     @return rounded-down and aligned position that is the beginning of the cache page
    81 */
    82 TInt64  CMediaWTCache::CalcPageStartPos(TInt64 aPos) const 
    83     { 
    84     ASSERT(aPos >= iCacheBasePos);
    85     return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
    86     }
    87 
    88 /**
    89     @return cache page size
    90 */
    91 TUint32 CMediaWTCache::PageSize() const 
    92     {
    93     return 1<<iPageSizeLog2;
    94     }
    95 
    96 
    97 /**
    98     Set cache base position at aBasePos
    99     @param  aBasePos  base position of the cache pages. Affects pages alignment.
   100 */
   101 void CMediaWTCache::SetCacheBasePos(TInt64 aBasePos)
   102     {
   103     iCacheBasePos = aBasePos;
   104     }
   105 
   106 
   107 
   108 //---------------------------------------------------------------------------------------------------------------------------------
   109 
   110 
   111 #endif //SL_CACHE_INL
   112 
   113 
   114 
   115