os/kernelhwsrv/userlibandfileserver/fileserver/sfat32/sl_fatcache.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1998-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\sfat\sl_fatcache.inl
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file
sl@0
    20
*/
sl@0
    21
sl@0
    22
#ifndef SL_FAT_CACHE_INL
sl@0
    23
#define SL_FAT_CACHE_INL
sl@0
    24
sl@0
    25
sl@0
    26
sl@0
    27
sl@0
    28
//-----------------------------------------------------------------------------
sl@0
    29
sl@0
    30
TUint32 CFatCacheBase::FatStartPos() const 
sl@0
    31
    {
sl@0
    32
    return iFatStartPos;
sl@0
    33
    }
sl@0
    34
sl@0
    35
TUint32 CFatCacheBase::FatSize() const 
sl@0
    36
    {
sl@0
    37
    return iFatSize;
sl@0
    38
    }
sl@0
    39
sl@0
    40
TFatType CFatCacheBase::FatType() const 
sl@0
    41
    {
sl@0
    42
    return iFatType;
sl@0
    43
    }
sl@0
    44
sl@0
    45
TBool CFatCacheBase::IsDirty() const 
sl@0
    46
    {
sl@0
    47
    return iDirty;
sl@0
    48
    }
sl@0
    49
sl@0
    50
void CFatCacheBase::SetDirty(TBool aDirty) 
sl@0
    51
    {
sl@0
    52
    iDirty = aDirty;
sl@0
    53
    }
sl@0
    54
sl@0
    55
TUint CFatCacheBase::NumFATs() const 
sl@0
    56
    {
sl@0
    57
    return iNumFATs;
sl@0
    58
    }
sl@0
    59
sl@0
    60
TUint CFatCacheBase::FAT_SectorSzLog2() const 
sl@0
    61
    {
sl@0
    62
    return iFatSecSzLog2;
sl@0
    63
    }
sl@0
    64
sl@0
    65
TUint CFatCacheBase::FAT_SectorSz() const 
sl@0
    66
    {
sl@0
    67
    return 1 << iFatSecSzLog2;
sl@0
    68
    }
sl@0
    69
sl@0
    70
TUint CFatCacheBase::FAT_ClusterSzLog2() const 
sl@0
    71
    {
sl@0
    72
    return iFatClustSzLog2;
sl@0
    73
    }
sl@0
    74
    
sl@0
    75
sl@0
    76
//-----------------------------------------------------------------------------
sl@0
    77
sl@0
    78
/** @return number of FAT cache sectors in this fixed cache */
sl@0
    79
TUint32 CFat12Cache::NumSectors() const   
sl@0
    80
    {
sl@0
    81
    return iSectorsInCache;
sl@0
    82
    }
sl@0
    83
sl@0
    84
sl@0
    85
//-----------------------------------------------------------------------------
sl@0
    86
sl@0
    87
sl@0
    88
/** @return Log2(page size in bytes) */
sl@0
    89
TUint CFatPagedCacheBase::PageSizeLog2() const 
sl@0
    90
    {
sl@0
    91
    return iPageSizeLog2;
sl@0
    92
    }
sl@0
    93
sl@0
    94
/** @return page size in bytes */
sl@0
    95
TUint CFatPagedCacheBase::PageSize() const 
sl@0
    96
    {
sl@0
    97
    return Pow2(iPageSizeLog2);
sl@0
    98
    }
sl@0
    99
sl@0
   100
/** @return Log2(size of the logical sector of the page in bytes) */    
sl@0
   101
TUint CFatPagedCacheBase::SectorSizeLog2() const 
sl@0
   102
    {
sl@0
   103
    return iSectorSizeLog2;
sl@0
   104
    }
sl@0
   105
sl@0
   106
/** @return number of the logical sector in the page */
sl@0
   107
TUint CFatPagedCacheBase::SectorsInPage() const 
sl@0
   108
    {
sl@0
   109
    return Pow2(iPageSizeLog2 - iSectorSizeLog2);
sl@0
   110
    }
sl@0
   111
sl@0
   112
sl@0
   113
//-----------------------------------------------------------------------------
sl@0
   114
sl@0
   115
TUint CFat16FixedCache::NumPages() const 
sl@0
   116
    {
sl@0
   117
    return (TUint)iPages.Count();
sl@0
   118
    } 
sl@0
   119
sl@0
   120
//-----------------------------------------------------------------------------
sl@0
   121
sl@0
   122
sl@0
   123
/** @return  the index in the FAT table this page starts from */
sl@0
   124
TUint32 CFatCachePageBase::StartFatIndex() const 
sl@0
   125
    {
sl@0
   126
    return iStartIndexInFAT;
sl@0
   127
    }
sl@0
   128
sl@0
   129
/** @return number of FAT entries in the page */
sl@0
   130
TUint32 CFatCachePageBase::EntriesInPage() const 
sl@0
   131
    {
sl@0
   132
    return iFatEntriesInPage;
sl@0
   133
    }
sl@0
   134
sl@0
   135
/** @return page state */
sl@0
   136
CFatCachePageBase::TState CFatCachePageBase::State() const
sl@0
   137
    {
sl@0
   138
    return iState;
sl@0
   139
    }
sl@0
   140
sl@0
   141
/** sets the state of the page */
sl@0
   142
void CFatCachePageBase::SetState(TState aState)
sl@0
   143
    {
sl@0
   144
    iState = aState;
sl@0
   145
    }
sl@0
   146
sl@0
   147
/** @return ETrue if the page is dirty, i.e. contains non-flushed dirty sectors */
sl@0
   148
TBool CFatCachePageBase::IsDirty() const
sl@0
   149
    {
sl@0
   150
    if(State() == EDirty)
sl@0
   151
        {
sl@0
   152
        ASSERT(iDirtySectors.HasBitsSet());
sl@0
   153
        return ETrue;
sl@0
   154
        }
sl@0
   155
    else
sl@0
   156
        {
sl@0
   157
        ASSERT(!iDirtySectors.HasBitsSet());
sl@0
   158
        return EFalse;
sl@0
   159
        }
sl@0
   160
    }
sl@0
   161
sl@0
   162
/** @return  ETrue if the page data are valid */
sl@0
   163
TBool CFatCachePageBase::IsValid() const
sl@0
   164
    {
sl@0
   165
    return (State() == EClean || State() == EDirty);
sl@0
   166
    }
sl@0
   167
sl@0
   168
/** force the page to the clean state */
sl@0
   169
void CFatCachePageBase::SetClean()
sl@0
   170
    {
sl@0
   171
    iDirtySectors.Clear(); //-- clear dirty sectors bitmap
sl@0
   172
    SetState(EClean);
sl@0
   173
    }
sl@0
   174
sl@0
   175
/** @return page size in bytes */
sl@0
   176
TUint32 CFatCachePageBase::PageSize() const 
sl@0
   177
    {
sl@0
   178
    return iCache.PageSize();
sl@0
   179
    }
sl@0
   180
sl@0
   181
/** @return number of logical sectors in the page */
sl@0
   182
TUint32 CFatCachePageBase::NumSectors() const 
sl@0
   183
    {
sl@0
   184
    return iCache.SectorsInPage();
sl@0
   185
    }
sl@0
   186
sl@0
   187
/** @return ETrue if the entry at aFatIndex belongs to this page */
sl@0
   188
TBool CFatCachePageBase::IsEntryCached(TUint32 aFatIndex) const
sl@0
   189
    {
sl@0
   190
    return (aFatIndex >= iStartIndexInFAT && aFatIndex < iStartIndexInFAT+EntriesInPage());
sl@0
   191
    } 
sl@0
   192
sl@0
   193
sl@0
   194
//---------------------------------------------------------------------------------------------------------------------------------
sl@0
   195
sl@0
   196
sl@0
   197
sl@0
   198
sl@0
   199
sl@0
   200
sl@0
   201
#endif //SL_FAT_CACHE_INL
sl@0
   202
sl@0
   203
sl@0
   204
sl@0
   205
sl@0
   206
sl@0
   207
sl@0
   208
sl@0
   209
sl@0
   210
sl@0
   211
sl@0
   212
sl@0
   213
sl@0
   214
sl@0
   215
sl@0
   216
sl@0
   217
sl@0
   218
sl@0
   219
sl@0
   220
sl@0
   221
sl@0
   222
sl@0
   223
sl@0
   224