1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat32/sl_cache.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,106 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32\sfat32\inc\sl_cache.inl
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @internalTechnology
1.24 +*/
1.25 +
1.26 +#ifndef SL_CACHE_INL
1.27 +#define SL_CACHE_INL
1.28 +
1.29 +
1.30 +/**
1.31 + @param aPos media linear position
1.32 + @return ETrue if the aPos belongs to this page
1.33 +*/
1.34 +TBool CWTCachePage::PosCached(TInt64 aPos) const
1.35 + {
1.36 + return (iValid && aPos >= iStartPos && aPos < iStartPos+PageSize());
1.37 + }
1.38 +
1.39 +
1.40 +/**
1.41 + Calculate data position within cache page relatively to the page beginning.
1.42 + @param aPos media linear position
1.43 + @return data offset from the beginning of the page
1.44 +*/
1.45 +TUint32 CWTCachePage::PosInCachePage(TInt64 aPos) const
1.46 + {
1.47 + return ((TUint32)aPos - (TUint32)iStartPos) & (PageSize()-1);
1.48 + }
1.49 +
1.50 +/**
1.51 + Obtain pointer to the data in the cache page by media inear position
1.52 + @param aPos media linear position
1.53 + @return pointer to the data in page buffer
1.54 +*/
1.55 +TUint8* CWTCachePage::PtrInCachePage(TInt64 aPos) const
1.56 + {
1.57 + return (TUint8*)iData.Ptr() + PosInCachePage(aPos);
1.58 + }
1.59 +
1.60 +/**
1.61 + @return cache page size in bytes
1.62 +*/
1.63 +TUint32 CWTCachePage::PageSize() const
1.64 + {
1.65 + return iData.Size();
1.66 + }
1.67 +
1.68 +//---------------------------------------------------------------------------------------------------------------------------------
1.69 +
1.70 +
1.71 +/**
1.72 + Just helper method to calculate cache page start position by given media pos.
1.73 + @param aPos media linear position
1.74 + @return rounded-down and aligned position that is the beginning of the cache page
1.75 +*/
1.76 +TInt64 CMediaWTCache::CalcPageStartPos(TInt64 aPos) const
1.77 + {
1.78 + ASSERT(aPos >= iCacheBasePos);
1.79 + return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
1.80 + }
1.81 +
1.82 +/**
1.83 + @return cache page size
1.84 +*/
1.85 +TUint32 CMediaWTCache::PageSize() const
1.86 + {
1.87 + return 1<<iPageSizeLog2;
1.88 + }
1.89 +
1.90 +
1.91 +/**
1.92 + Set cache base position at aBasePos
1.93 + @param aBasePos base position of the cache pages. Affects pages alignment.
1.94 +*/
1.95 +void CMediaWTCache::SetCacheBasePos(TInt64 aBasePos)
1.96 + {
1.97 + iCacheBasePos = aBasePos;
1.98 + }
1.99 +
1.100 +
1.101 +
1.102 +//---------------------------------------------------------------------------------------------------------------------------------
1.103 +
1.104 +
1.105 +#endif //SL_CACHE_INL
1.106 +
1.107 +
1.108 +
1.109 +