sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32\sfat\sl_dir_cache.inl sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef SL_DIR_CACHE_INL sl@0: #define SL_DIR_CACHE_INL sl@0: sl@0: #include "sl_dir_cache.h" sl@0: sl@0: /** sl@0: Get function of TDynamicDirCachePage. sl@0: @return TInt64 the starting media address of the page content. sl@0: */ sl@0: TInt64 TDynamicDirCachePage::StartPos() const sl@0: { sl@0: return iStartMedPos; sl@0: } sl@0: sl@0: /** sl@0: Get function of TDynamicDirCachePage. sl@0: @return TUint8* the starting ram content of the page content. sl@0: */ sl@0: TUint8* TDynamicDirCachePage::StartPtr() const sl@0: { sl@0: return iStartRamAddr; sl@0: } sl@0: sl@0: /** sl@0: Set function of TDynamicDirCachePage. sl@0: @param aPtr starting RAM Ptr that holds the cache page data. sl@0: */ sl@0: void TDynamicDirCachePage::SetStartPtr(TUint8* aPtr) sl@0: { sl@0: iStartRamAddr = aPtr; sl@0: } sl@0: sl@0: /** sl@0: Set function of TDynamicDirCachePage. sl@0: @param aIsValid boolean value to set validity of the page content. sl@0: */ sl@0: void TDynamicDirCachePage::SetValid(TBool aIsValid) sl@0: { sl@0: iValid = aIsValid; sl@0: } sl@0: sl@0: /** sl@0: Get function of TDynamicDirCachePage. sl@0: @return TBool boolean value that indicates validity of the page content. sl@0: */ sl@0: TBool TDynamicDirCachePage::IsValid() const sl@0: { sl@0: return iValid; sl@0: } sl@0: sl@0: /** sl@0: Set function of TDynamicDirCachePage. sl@0: @param aLocked flag that sets if the page is locked or not. sl@0: */ sl@0: void TDynamicDirCachePage::SetLocked(TBool aLocked) sl@0: { sl@0: iLocked = aLocked; sl@0: } sl@0: sl@0: /** sl@0: Get function of TDynamicDirCachePage. sl@0: @return TBool boolean value that indicates if the page is locked. sl@0: */ sl@0: TBool TDynamicDirCachePage::IsLocked() const sl@0: { sl@0: return iLocked; sl@0: } sl@0: sl@0: /** sl@0: Set function of TDynamicDirCachePage. sl@0: @param aType set page type: EUnknown, ELocked, EUnlocked or EActivePage. sl@0: */ sl@0: void TDynamicDirCachePage::SetPageType(TDynamicDirCachePage::TPageType aType) sl@0: { sl@0: iType = aType; sl@0: } sl@0: sl@0: /** sl@0: Get function of TDynamicDirCachePage. sl@0: @return TPageType get page type: EUnknown, ELocked, EUnlocked or EActivePage. sl@0: */ sl@0: TDynamicDirCachePage::TPageType TDynamicDirCachePage::PageType() sl@0: { sl@0: return iType; sl@0: } sl@0: sl@0: /** sl@0: Get function of TDynamicDirCachePage. sl@0: @return TUint32 page size in bytes. sl@0: */ sl@0: TUint32 TDynamicDirCachePage::PageSizeInBytes() const sl@0: { sl@0: return 1 << iOwnerCache->PageSizeInBytesLog2(); sl@0: } sl@0: sl@0: /** sl@0: Deque the page from its queue. sl@0: @see TDblQueLink::Deque() sl@0: */ sl@0: void TDynamicDirCachePage::Deque() sl@0: { sl@0: iLink.Deque(); sl@0: } sl@0: sl@0: /** sl@0: Get function of TDynamicDirCachePage. sl@0: @return TUint32 page size in segments. sl@0: */ sl@0: TUint32 TDynamicDirCachePage::PageSizeInSegs() const sl@0: { sl@0: return iOwnerCache->PageSizeInSegs(); sl@0: } sl@0: sl@0: /** sl@0: Interpret the media address into ram address. sl@0: @param aPos the media address to be interpreted sl@0: @return TUint8* the ram content pointer that contains that media content. sl@0: */ sl@0: TUint8* TDynamicDirCachePage::PtrInPage(TInt64 aPos) const sl@0: { sl@0: ASSERT(PosCachedInPage(aPos)); sl@0: return iStartRamAddr + (((TUint32)aPos - (TUint32)iStartMedPos) & (PageSizeInBytes() - 1)); sl@0: } sl@0: sl@0: /** sl@0: Query function, to check if the media address is contained in the page. sl@0: @param aPos the media address to be queried. sl@0: @return TBool ETrue if the media address is cached in the page, otherwise EFalse. sl@0: */ sl@0: TBool TDynamicDirCachePage::PosCachedInPage(TInt64 aPos) const sl@0: { sl@0: return (aPos >= iStartMedPos && aPos < iStartMedPos + PageSizeInBytes()); sl@0: } sl@0: sl@0: /** sl@0: Reset the media address to 0, invalidate page content. sl@0: */ sl@0: void TDynamicDirCachePage::ResetPos() sl@0: { sl@0: iStartMedPos = 0; sl@0: SetValid(EFalse); sl@0: } sl@0: sl@0: /** sl@0: Set page starting media address, invalidate page content. sl@0: @param aPos the new media address to be set. sl@0: */ sl@0: void TDynamicDirCachePage::SetPos(TInt64 aPos) sl@0: { sl@0: iStartMedPos = aPos; sl@0: SetValid(EFalse); sl@0: return; sl@0: } sl@0: sl@0: sl@0: //======================================================================== sl@0: /** sl@0: Calculate the page starting media address, aligned with page size. sl@0: @param aPos the media address to be aligned. sl@0: @return TInt64 the aligned media address. sl@0: */ sl@0: TInt64 CDynamicDirCache::CalcPageStartPos(TInt64 aPos) const sl@0: { sl@0: ASSERT(aPos >= iCacheBasePos); sl@0: return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos; sl@0: } sl@0: sl@0: /** sl@0: Check if the cache has reached its limited page number. sl@0: @return TBool ETrue if cache is full, otherwise EFalse. sl@0: */ sl@0: TBool CDynamicDirCache::CacheIsFull() const sl@0: { sl@0: // active page, locked page and unlocked page sl@0: return (iLockedQCount + iUnlockedQCount + 1 >= iMaxSizeInPages); sl@0: } sl@0: sl@0: /** sl@0: Return the maximum allowed page number of the cache. sl@0: */ sl@0: TUint32 CDynamicDirCache::MaxCacheSizeInPages() const sl@0: { sl@0: return iMaxSizeInPages; sl@0: } sl@0: sl@0: #endif //SL_DIR_CACHE_INL sl@0: