userlibandfileserver/fileserver/sfat32/inc/sl_fatcache32.inl
author Tom Cosgrove <tom.cosgrove@nokia.com>
Fri, 28 May 2010 16:29:07 +0100
changeset 30 8aab599e3476
parent 0 a41df078684a
permissions -rw-r--r--
Fix for bug 2283 (RVCT 4.0 support is missing from PDK 3.0.h) Have multiple extension sections in the bld.inf, one for each version of the compiler. The RVCT version building the tools will build the runtime libraries for its version, but make sure we extract all the other versions from zip archives. Also add the archive for RVCT4.

// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// f32\sfat32\inc\sl_facache32.h
// FAT32 various cache classes definition
// 
//

/**
 @file
 @internalTechnology
*/

#ifndef SL_FAT_CACHE_32_INL
#define SL_FAT_CACHE_32_INL


//-----------------------------------------------------------------------------


void CFatBitCache::SetState(CFatBitCache::TState aState) 
    {
    iState = aState;
    }

/**
    Converts FAT index to the corresponding bit array bit number (or FAT cache sector number).
    @param  aFatIndex index in the FAT 
    @return corresponding index in the FAT bit array
*/
TUint32 CFatBitCache::FatIndexToCacheSectorNumber(TUint32 aFatIndex) const
    {
    ASSERT(aFatIndex >= KFatFirstSearchCluster);
    return (aFatIndex >> iFatIdxToSecCoeff);
    }

/**
    Converts FAT32 cache sector number to the FAT32 entry index (in the beginning of this cache sector)
    @param  aCacheSecNum index in the FAT bit array (or FAT cache sector number)
    @return corresponding index in the FAT 

*/
TUint32 CFatBitCache::CacheSectorNumberToFatIndex(TUint32 aCacheSecNum) const
    {
    ASSERT(aCacheSecNum < iBitCache.Size());
    return (aCacheSecNum << iFatIdxToSecCoeff);
    }

/** @return state of the cache*/
CFatBitCache::TState CFatBitCache::State() const 
    {
    return iState;
    }

/** 
    @return ETrue if the cache can be used, i.e. is fully populated
*/
TBool CFatBitCache::UsableState() const
    {
    return State() == EPopulated;
    }


/**
    @return ETrue if the FAT cache sector number "aFatSectorNum" is marked as having at least one free FAT entry.
    N.B. The cache must be in consistent state, i.e. fully populated.
*/
TBool CFatBitCache::FatSectorHasFreeEntry(TUint32 aFatSectorNum) const
    {
    ASSERT(UsableState());
    return iBitCache[aFatSectorNum];
    }

/**
    Mark FAT cache sector number "aFatSectorNum" is as having/not having free FAT entry.
    N.B. The cache must be in consistent state, i.e. fully populated.

    @param  aFatSectorNum FAT32 cache sector number [index in a bit vector] 
    @param  aHasFreeEntry ETrue  if we want to mark this sector as having free FAT entries; 
                          EFalse if we want to mark this sector as NOT having free FAT entries; 
*/
void CFatBitCache::SetFreeEntryInFatSector(TUint32 aFatSectorNum, TBool aHasFreeEntry)
    {
    ASSERT(UsableState());
    iBitCache.SetBitVal(aFatSectorNum, aHasFreeEntry);
    }


#endif //SL_FAT_CACHE_32_INL