sl@0
|
1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32\sfat32\inc\sl_cache.inl
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@file
|
sl@0
|
20 |
@internalTechnology
|
sl@0
|
21 |
*/
|
sl@0
|
22 |
|
sl@0
|
23 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
sl@0
|
24 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
sl@0
|
25 |
//!!
|
sl@0
|
26 |
//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
|
sl@0
|
27 |
//!!
|
sl@0
|
28 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
sl@0
|
29 |
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
#ifndef SL_CACHE_INL
|
sl@0
|
33 |
#define SL_CACHE_INL
|
sl@0
|
34 |
|
sl@0
|
35 |
|
sl@0
|
36 |
/**
|
sl@0
|
37 |
@param aPos media linear position
|
sl@0
|
38 |
@return ETrue if the aPos belongs to this page
|
sl@0
|
39 |
*/
|
sl@0
|
40 |
TBool CWTCachePage::PosCached(TInt64 aPos) const
|
sl@0
|
41 |
{
|
sl@0
|
42 |
return (iValid && aPos >= iStartPos && aPos < iStartPos+PageSize());
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
|
sl@0
|
46 |
/**
|
sl@0
|
47 |
Calculate data position within cache page relatively to the page beginning.
|
sl@0
|
48 |
@param aPos media linear position
|
sl@0
|
49 |
@return data offset from the beginning of the page
|
sl@0
|
50 |
*/
|
sl@0
|
51 |
TUint32 CWTCachePage::PosInCachePage(TInt64 aPos) const
|
sl@0
|
52 |
{
|
sl@0
|
53 |
return ((TUint32)aPos - (TUint32)iStartPos) & (PageSize()-1);
|
sl@0
|
54 |
}
|
sl@0
|
55 |
|
sl@0
|
56 |
/**
|
sl@0
|
57 |
Obtain pointer to the data in the cache page by media inear position
|
sl@0
|
58 |
@param aPos media linear position
|
sl@0
|
59 |
@return pointer to the data in page buffer
|
sl@0
|
60 |
*/
|
sl@0
|
61 |
TUint8* CWTCachePage::PtrInCachePage(TInt64 aPos) const
|
sl@0
|
62 |
{
|
sl@0
|
63 |
return (TUint8*)iData.Ptr() + PosInCachePage(aPos);
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
@return cache page size in bytes
|
sl@0
|
68 |
*/
|
sl@0
|
69 |
TUint32 CWTCachePage::PageSize() const
|
sl@0
|
70 |
{
|
sl@0
|
71 |
return iData.Size();
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
//---------------------------------------------------------------------------------------------------------------------------------
|
sl@0
|
75 |
|
sl@0
|
76 |
|
sl@0
|
77 |
/**
|
sl@0
|
78 |
Just helper method to calculate cache page start position by given media pos.
|
sl@0
|
79 |
@param aPos media linear position
|
sl@0
|
80 |
@return rounded-down and aligned position that is the beginning of the cache page
|
sl@0
|
81 |
*/
|
sl@0
|
82 |
TInt64 CMediaWTCache::CalcPageStartPos(TInt64 aPos) const
|
sl@0
|
83 |
{
|
sl@0
|
84 |
ASSERT(aPos >= iCacheBasePos);
|
sl@0
|
85 |
return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
/**
|
sl@0
|
89 |
@return cache page size
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
TUint32 CMediaWTCache::PageSize() const
|
sl@0
|
92 |
{
|
sl@0
|
93 |
return 1<<iPageSizeLog2;
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
|
sl@0
|
97 |
/**
|
sl@0
|
98 |
Set cache base position at aBasePos
|
sl@0
|
99 |
@param aBasePos base position of the cache pages. Affects pages alignment.
|
sl@0
|
100 |
*/
|
sl@0
|
101 |
void CMediaWTCache::SetCacheBasePos(TInt64 aBasePos)
|
sl@0
|
102 |
{
|
sl@0
|
103 |
iCacheBasePos = aBasePos;
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
|
sl@0
|
107 |
|
sl@0
|
108 |
//---------------------------------------------------------------------------------------------------------------------------------
|
sl@0
|
109 |
|
sl@0
|
110 |
|
sl@0
|
111 |
#endif //SL_CACHE_INL
|
sl@0
|
112 |
|
sl@0
|
113 |
|
sl@0
|
114 |
|
sl@0
|
115 |
|