1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat/sl_cache.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,115 @@
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 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.27 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.28 +//!!
1.29 +//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
1.30 +//!!
1.31 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.32 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.33 +
1.34 +
1.35 +#ifndef SL_CACHE_INL
1.36 +#define SL_CACHE_INL
1.37 +
1.38 +
1.39 +/**
1.40 + @param aPos media linear position
1.41 + @return ETrue if the aPos belongs to this page
1.42 +*/
1.43 +TBool CWTCachePage::PosCached(TInt64 aPos) const
1.44 + {
1.45 + return (iValid && aPos >= iStartPos && aPos < iStartPos+PageSize());
1.46 + }
1.47 +
1.48 +
1.49 +/**
1.50 + Calculate data position within cache page relatively to the page beginning.
1.51 + @param aPos media linear position
1.52 + @return data offset from the beginning of the page
1.53 +*/
1.54 +TUint32 CWTCachePage::PosInCachePage(TInt64 aPos) const
1.55 + {
1.56 + return ((TUint32)aPos - (TUint32)iStartPos) & (PageSize()-1);
1.57 + }
1.58 +
1.59 +/**
1.60 + Obtain pointer to the data in the cache page by media inear position
1.61 + @param aPos media linear position
1.62 + @return pointer to the data in page buffer
1.63 +*/
1.64 +TUint8* CWTCachePage::PtrInCachePage(TInt64 aPos) const
1.65 + {
1.66 + return (TUint8*)iData.Ptr() + PosInCachePage(aPos);
1.67 + }
1.68 +
1.69 +/**
1.70 + @return cache page size in bytes
1.71 +*/
1.72 +TUint32 CWTCachePage::PageSize() const
1.73 + {
1.74 + return iData.Size();
1.75 + }
1.76 +
1.77 +//---------------------------------------------------------------------------------------------------------------------------------
1.78 +
1.79 +
1.80 +/**
1.81 + Just helper method to calculate cache page start position by given media pos.
1.82 + @param aPos media linear position
1.83 + @return rounded-down and aligned position that is the beginning of the cache page
1.84 +*/
1.85 +TInt64 CMediaWTCache::CalcPageStartPos(TInt64 aPos) const
1.86 + {
1.87 + ASSERT(aPos >= iCacheBasePos);
1.88 + return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
1.89 + }
1.90 +
1.91 +/**
1.92 + @return cache page size
1.93 +*/
1.94 +TUint32 CMediaWTCache::PageSize() const
1.95 + {
1.96 + return 1<<iPageSizeLog2;
1.97 + }
1.98 +
1.99 +
1.100 +/**
1.101 + Set cache base position at aBasePos
1.102 + @param aBasePos base position of the cache pages. Affects pages alignment.
1.103 +*/
1.104 +void CMediaWTCache::SetCacheBasePos(TInt64 aBasePos)
1.105 + {
1.106 + iCacheBasePos = aBasePos;
1.107 + }
1.108 +
1.109 +
1.110 +
1.111 +//---------------------------------------------------------------------------------------------------------------------------------
1.112 +
1.113 +
1.114 +#endif //SL_CACHE_INL
1.115 +
1.116 +
1.117 +
1.118 +