os/kernelhwsrv/userlibandfileserver/fileserver/sfat/sl_dir_cache.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-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\sfat\sl_dir_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_DIR_CACHE_INL
    33 #define SL_DIR_CACHE_INL
    34 
    35 #include "sl_dir_cache.h"
    36 
    37 /**
    38 Get function of TDynamicDirCachePage.
    39 @return TInt64  the starting media address of the page content.
    40 */
    41 TInt64 TDynamicDirCachePage::StartPos() const
    42     {
    43     return iStartMedPos;
    44     }
    45 
    46 /**
    47 Get function of TDynamicDirCachePage.
    48 @return TUint8* the starting ram content of the page content.
    49 */
    50 TUint8* TDynamicDirCachePage::StartPtr() const
    51     {
    52     return iStartRamAddr;
    53     }
    54 
    55 /**
    56 Set function of TDynamicDirCachePage.
    57 @param  aPtr    starting RAM Ptr that holds the cache page data.
    58 */
    59 void TDynamicDirCachePage::SetStartPtr(TUint8* aPtr)
    60     {
    61     iStartRamAddr = aPtr;
    62     }
    63 
    64 /**
    65 Set function of TDynamicDirCachePage.
    66 @param  aIsValid    boolean value to set validity of the page content.
    67 */
    68 void TDynamicDirCachePage::SetValid(TBool aIsValid)
    69     {
    70     iValid = aIsValid;
    71     }
    72 
    73 /**
    74 Get function of TDynamicDirCachePage.
    75 @return TBool   boolean value that indicates validity of the page content.
    76 */
    77 TBool TDynamicDirCachePage::IsValid() const
    78     {
    79     return iValid;
    80     }
    81 
    82 /**
    83 Set function of TDynamicDirCachePage.
    84 @param  aLocked flag that sets if the page is locked or not.
    85 */
    86 void TDynamicDirCachePage::SetLocked(TBool aLocked)
    87     {
    88     iLocked = aLocked;
    89     }
    90 
    91 /**
    92 Get function of TDynamicDirCachePage.
    93 @return TBool   boolean value that indicates if the page is locked.
    94 */
    95 TBool TDynamicDirCachePage::IsLocked() const
    96     {
    97     return iLocked;
    98     }
    99 
   100 /**
   101 Set function of TDynamicDirCachePage.
   102 @param  aType   set page type: EUnknown, ELocked, EUnlocked or EActivePage.
   103 */
   104 void TDynamicDirCachePage::SetPageType(TDynamicDirCachePage::TPageType aType)
   105     {
   106     iType = aType;
   107     }
   108 
   109 /**
   110 Get function of TDynamicDirCachePage.
   111 @return TPageType   get page type: EUnknown, ELocked, EUnlocked or EActivePage.
   112 */
   113 TDynamicDirCachePage::TPageType TDynamicDirCachePage::PageType()
   114     {
   115     return iType;
   116     }
   117 
   118 /**
   119 Get function of TDynamicDirCachePage.
   120 @return TUint32 page size in bytes.
   121 */
   122 TUint32 TDynamicDirCachePage::PageSizeInBytes() const
   123     {
   124     return 1 << iOwnerCache->PageSizeInBytesLog2();
   125     }
   126 
   127 /**
   128 Deque the page from its queue.
   129 @see    TDblQueLink::Deque()
   130 */
   131 void TDynamicDirCachePage::Deque()
   132     {
   133     iLink.Deque();
   134     }
   135 
   136 /**
   137 Get function of TDynamicDirCachePage.
   138 @return TUint32 page size in segments.
   139 */
   140 TUint32 TDynamicDirCachePage::PageSizeInSegs() const
   141     {
   142     return iOwnerCache->PageSizeInSegs();
   143     }
   144 
   145 /**
   146 Interpret the media address into ram address.
   147 @param  aPos    the media address to be interpreted
   148 @return TUint8* the ram content pointer that contains that media content.
   149 */
   150 TUint8* TDynamicDirCachePage::PtrInPage(TInt64 aPos) const
   151     {
   152     ASSERT(PosCachedInPage(aPos));
   153     return iStartRamAddr + (((TUint32)aPos - (TUint32)iStartMedPos) & (PageSizeInBytes() - 1));
   154     }
   155 
   156 /**
   157 Query function, to check if the media address is contained in the page.
   158 @param  aPos    the media address to be queried.
   159 @return TBool   ETrue if the media address is cached in the page, otherwise EFalse.
   160 */
   161 TBool TDynamicDirCachePage::PosCachedInPage(TInt64 aPos) const
   162     {
   163     return (aPos >= iStartMedPos && aPos < iStartMedPos + PageSizeInBytes());
   164     }
   165 
   166 /**
   167 Reset the media address to 0, invalidate page content.
   168 */
   169 void TDynamicDirCachePage::ResetPos()
   170     {
   171     iStartMedPos = 0;
   172     SetValid(EFalse);
   173     }
   174 
   175 /**
   176 Set page starting media address, invalidate page content.
   177 @param  aPos    the new media address to be set.
   178 */
   179 void TDynamicDirCachePage::SetPos(TInt64 aPos)
   180     {
   181     iStartMedPos = aPos;
   182     SetValid(EFalse);
   183     return;
   184     }
   185 
   186 
   187 //========================================================================
   188 /**
   189 Calculate the page starting media address, aligned with page size.
   190 @param  aPos    the media address to be aligned.
   191 @return TInt64  the aligned media address.
   192 */
   193 TInt64 CDynamicDirCache::CalcPageStartPos(TInt64 aPos) const
   194     {
   195     ASSERT(aPos >= iCacheBasePos);
   196     return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
   197     }
   198 
   199 /**
   200 Check if the cache has reached its limited page number.
   201 @return TBool   ETrue if cache is full, otherwise EFalse.
   202 */
   203 TBool CDynamicDirCache::CacheIsFull() const
   204     {
   205     // active page, locked page and unlocked page
   206     return (iLockedQCount + iUnlockedQCount + 1 >= iMaxSizeInPages);
   207     }
   208 
   209 /**
   210 Return the maximum allowed page number of the cache.
   211 */
   212 TUint32 CDynamicDirCache::MaxCacheSizeInPages() const
   213     {
   214     return iMaxSizeInPages;
   215     }
   216 
   217 #endif //SL_DIR_CACHE_INL
   218