First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfat\sl_dir_cache.inl
23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
32 #ifndef SL_DIR_CACHE_INL
33 #define SL_DIR_CACHE_INL
35 #include "sl_dir_cache.h"
38 Get function of TDynamicDirCachePage.
39 @return TInt64 the starting media address of the page content.
41 TInt64 TDynamicDirCachePage::StartPos() const
47 Get function of TDynamicDirCachePage.
48 @return TUint8* the starting ram content of the page content.
50 TUint8* TDynamicDirCachePage::StartPtr() const
56 Set function of TDynamicDirCachePage.
57 @param aPtr starting RAM Ptr that holds the cache page data.
59 void TDynamicDirCachePage::SetStartPtr(TUint8* aPtr)
65 Set function of TDynamicDirCachePage.
66 @param aIsValid boolean value to set validity of the page content.
68 void TDynamicDirCachePage::SetValid(TBool aIsValid)
74 Get function of TDynamicDirCachePage.
75 @return TBool boolean value that indicates validity of the page content.
77 TBool TDynamicDirCachePage::IsValid() const
83 Set function of TDynamicDirCachePage.
84 @param aLocked flag that sets if the page is locked or not.
86 void TDynamicDirCachePage::SetLocked(TBool aLocked)
92 Get function of TDynamicDirCachePage.
93 @return TBool boolean value that indicates if the page is locked.
95 TBool TDynamicDirCachePage::IsLocked() const
101 Set function of TDynamicDirCachePage.
102 @param aType set page type: EUnknown, ELocked, EUnlocked or EActivePage.
104 void TDynamicDirCachePage::SetPageType(TDynamicDirCachePage::TPageType aType)
110 Get function of TDynamicDirCachePage.
111 @return TPageType get page type: EUnknown, ELocked, EUnlocked or EActivePage.
113 TDynamicDirCachePage::TPageType TDynamicDirCachePage::PageType()
119 Get function of TDynamicDirCachePage.
120 @return TUint32 page size in bytes.
122 TUint32 TDynamicDirCachePage::PageSizeInBytes() const
124 return 1 << iOwnerCache->PageSizeInBytesLog2();
128 Deque the page from its queue.
129 @see TDblQueLink::Deque()
131 void TDynamicDirCachePage::Deque()
137 Get function of TDynamicDirCachePage.
138 @return TUint32 page size in segments.
140 TUint32 TDynamicDirCachePage::PageSizeInSegs() const
142 return iOwnerCache->PageSizeInSegs();
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.
150 TUint8* TDynamicDirCachePage::PtrInPage(TInt64 aPos) const
152 ASSERT(PosCachedInPage(aPos));
153 return iStartRamAddr + (((TUint32)aPos - (TUint32)iStartMedPos) & (PageSizeInBytes() - 1));
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.
161 TBool TDynamicDirCachePage::PosCachedInPage(TInt64 aPos) const
163 return (aPos >= iStartMedPos && aPos < iStartMedPos + PageSizeInBytes());
167 Reset the media address to 0, invalidate page content.
169 void TDynamicDirCachePage::ResetPos()
176 Set page starting media address, invalidate page content.
177 @param aPos the new media address to be set.
179 void TDynamicDirCachePage::SetPos(TInt64 aPos)
187 //========================================================================
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.
193 TInt64 CDynamicDirCache::CalcPageStartPos(TInt64 aPos) const
195 ASSERT(aPos >= iCacheBasePos);
196 return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
200 Check if the cache has reached its limited page number.
201 @return TBool ETrue if cache is full, otherwise EFalse.
203 TBool CDynamicDirCache::CacheIsFull() const
205 // active page, locked page and unlocked page
206 return (iLockedQCount + iUnlockedQCount + 1 >= iMaxSizeInPages);
210 Return the maximum allowed page number of the cache.
212 TUint32 CDynamicDirCache::MaxCacheSizeInPages() const
214 return iMaxSizeInPages;
217 #endif //SL_DIR_CACHE_INL