userlibandfileserver/fileserver/sfat/sl_dir_cache.inl
changeset 15 4122176ea935
parent 0 a41df078684a
equal deleted inserted replaced
0:a41df078684a 15:4122176ea935
    18 /**
    18 /**
    19  @file
    19  @file
    20  @internalTechnology
    20  @internalTechnology
    21 */
    21 */
    22 
    22 
       
    23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    25 //!!
       
    26 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
       
    27 //!!
       
    28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    29 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    30 
       
    31 
    23 #ifndef SL_DIR_CACHE_INL
    32 #ifndef SL_DIR_CACHE_INL
    24 #define SL_DIR_CACHE_INL
    33 #define SL_DIR_CACHE_INL
    25 
    34 
    26 #include "sl_dir_cache.h"
    35 #include "sl_dir_cache.h"
    27 
    36 
    28 /**
    37 /**
    29 Get function of TDynamicDirCachePage.
    38 Get function of TDynamicDirCachePage.
    30 @return	TInt64	the starting media address of the page content.
    39 @return TInt64  the starting media address of the page content.
    31 */
    40 */
    32 TInt64 TDynamicDirCachePage::StartPos()	const
    41 TInt64 TDynamicDirCachePage::StartPos() const
    33 	{
    42     {
    34 	return iStartMedPos;
    43     return iStartMedPos;
    35 	}
    44     }
    36 
    45 
    37 /**
    46 /**
    38 Get function of TDynamicDirCachePage.
    47 Get function of TDynamicDirCachePage.
    39 @return	TUint8*	the starting ram content of the page content.
    48 @return TUint8* the starting ram content of the page content.
    40 */
    49 */
    41 TUint8*	TDynamicDirCachePage::StartPtr() const
    50 TUint8* TDynamicDirCachePage::StartPtr() const
    42 	{
    51     {
    43 	return iStartRamAddr;
    52     return iStartRamAddr;
    44 	}
    53     }
    45 
    54 
    46 /**
    55 /**
    47 Set function of TDynamicDirCachePage.
    56 Set function of TDynamicDirCachePage.
    48 @param	aPtr	starting RAM Ptr that holds the cache page data.
    57 @param  aPtr    starting RAM Ptr that holds the cache page data.
    49 */
    58 */
    50 void TDynamicDirCachePage::SetStartPtr(TUint8* aPtr)
    59 void TDynamicDirCachePage::SetStartPtr(TUint8* aPtr)
    51 	{
    60     {
    52 	iStartRamAddr = aPtr;
    61     iStartRamAddr = aPtr;
    53 	}
    62     }
    54 
    63 
    55 /**
    64 /**
    56 Set function of TDynamicDirCachePage.
    65 Set function of TDynamicDirCachePage.
    57 @param	aIsValid	boolean value to set validity of the page content.
    66 @param  aIsValid    boolean value to set validity of the page content.
    58 */
    67 */
    59 void TDynamicDirCachePage::SetValid(TBool aIsValid)
    68 void TDynamicDirCachePage::SetValid(TBool aIsValid)
    60 	{
    69     {
    61 	iValid = aIsValid;
    70     iValid = aIsValid;
    62 	}
    71     }
    63 
    72 
    64 /**
    73 /**
    65 Get	function of TDynamicDirCachePage.
    74 Get function of TDynamicDirCachePage.
    66 @return TBool	boolean value that indicates validity of the page content.
    75 @return TBool   boolean value that indicates validity of the page content.
    67 */
    76 */
    68 TBool TDynamicDirCachePage::IsValid() const
    77 TBool TDynamicDirCachePage::IsValid() const
    69 	{
    78     {
    70 	return iValid;
    79     return iValid;
    71 	}
    80     }
    72 
    81 
    73 /**
    82 /**
    74 Set	function of TDynamicDirCachePage.
    83 Set function of TDynamicDirCachePage.
    75 @param	aLocked	flag that sets if the page is locked or not.
    84 @param  aLocked flag that sets if the page is locked or not.
    76 */
    85 */
    77 void TDynamicDirCachePage::SetLocked(TBool aLocked)
    86 void TDynamicDirCachePage::SetLocked(TBool aLocked)
    78 	{
    87     {
    79 	iLocked = aLocked;
    88     iLocked = aLocked;
    80 	}
    89     }
    81 
    90 
    82 /**
    91 /**
    83 Get	function of TDynamicDirCachePage.
    92 Get function of TDynamicDirCachePage.
    84 @return TBool	boolean value that indicates if the page is locked.
    93 @return TBool   boolean value that indicates if the page is locked.
    85 */
    94 */
    86 TBool TDynamicDirCachePage::IsLocked() const
    95 TBool TDynamicDirCachePage::IsLocked() const
    87 	{
    96     {
    88 	return iLocked;
    97     return iLocked;
    89 	}
    98     }
    90 
    99 
    91 /**
   100 /**
    92 Set	function of TDynamicDirCachePage.
   101 Set function of TDynamicDirCachePage.
    93 @param	aType	set page type: EUnknown, ELocked, EUnlocked or EActivePage.
   102 @param  aType   set page type: EUnknown, ELocked, EUnlocked or EActivePage.
    94 */
   103 */
    95 void TDynamicDirCachePage::SetPageType(TDynamicDirCachePage::TPageType aType)
   104 void TDynamicDirCachePage::SetPageType(TDynamicDirCachePage::TPageType aType)
    96 	{
   105     {
    97 	iType = aType;
   106     iType = aType;
    98 	}
   107     }
    99 
   108 
   100 /**
   109 /**
   101 Get	function of TDynamicDirCachePage.
   110 Get function of TDynamicDirCachePage.
   102 @return	TPageType	get page type: EUnknown, ELocked, EUnlocked or EActivePage.
   111 @return TPageType   get page type: EUnknown, ELocked, EUnlocked or EActivePage.
   103 */
   112 */
   104 TDynamicDirCachePage::TPageType TDynamicDirCachePage::PageType()
   113 TDynamicDirCachePage::TPageType TDynamicDirCachePage::PageType()
   105 	{
   114     {
   106 	return iType;
   115     return iType;
   107 	}
   116     }
   108 
   117 
   109 /**
   118 /**
   110 Get	function of TDynamicDirCachePage.
   119 Get function of TDynamicDirCachePage.
   111 @return	TUint32	page size in bytes.
   120 @return TUint32 page size in bytes.
   112 */
   121 */
   113 TUint32	TDynamicDirCachePage::PageSizeInBytes() const
   122 TUint32 TDynamicDirCachePage::PageSizeInBytes() const
   114 	{
   123     {
   115 	return 1 << iOwnerCache->PageSizeInBytesLog2();
   124     return 1 << iOwnerCache->PageSizeInBytesLog2();
   116 	}
   125     }
   117 
   126 
   118 /**
   127 /**
   119 Deque the page from its queue.
   128 Deque the page from its queue.
   120 @see	TDblQueLink::Deque()
   129 @see    TDblQueLink::Deque()
   121 */
   130 */
   122 void TDynamicDirCachePage::Deque()
   131 void TDynamicDirCachePage::Deque()
   123 	{
   132     {
   124 	iLink.Deque();
   133     iLink.Deque();
   125 	}
   134     }
   126 
   135 
   127 /**
   136 /**
   128 Get	function of TDynamicDirCachePage.
   137 Get function of TDynamicDirCachePage.
   129 @return	TUint32	page size in segments.
   138 @return TUint32 page size in segments.
   130 */
   139 */
   131 TUint32	TDynamicDirCachePage::PageSizeInSegs() const
   140 TUint32 TDynamicDirCachePage::PageSizeInSegs() const
   132 	{
   141     {
   133 	return iOwnerCache->PageSizeInSegs();
   142     return iOwnerCache->PageSizeInSegs();
   134 	}
   143     }
   135 
   144 
   136 /**
   145 /**
   137 Interpret the media address into ram address.
   146 Interpret the media address into ram address.
   138 @param	aPos	the media address to be interpreted
   147 @param  aPos    the media address to be interpreted
   139 @return	TUint8*	the ram content pointer that contains that media content.
   148 @return TUint8* the ram content pointer that contains that media content.
   140 */
   149 */
   141 TUint8*	TDynamicDirCachePage::PtrInPage(TInt64 aPos) const
   150 TUint8* TDynamicDirCachePage::PtrInPage(TInt64 aPos) const
   142 	{
   151     {
   143     ASSERT(PosCachedInPage(aPos));
   152     ASSERT(PosCachedInPage(aPos));
   144     return iStartRamAddr + (((TUint32)aPos - (TUint32)iStartMedPos) & (PageSizeInBytes() - 1));
   153     return iStartRamAddr + (((TUint32)aPos - (TUint32)iStartMedPos) & (PageSizeInBytes() - 1));
   145 	}
   154     }
   146 
   155 
   147 /**
   156 /**
   148 Query function, to check if the media address is contained in the page.
   157 Query function, to check if the media address is contained in the page.
   149 @param	aPos	the media address to be queried.
   158 @param  aPos    the media address to be queried.
   150 @return	TBool	ETrue if the media address is cached in the page, otherwise EFalse.
   159 @return TBool   ETrue if the media address is cached in the page, otherwise EFalse.
   151 */
   160 */
   152 TBool TDynamicDirCachePage::PosCachedInPage(TInt64 aPos) const
   161 TBool TDynamicDirCachePage::PosCachedInPage(TInt64 aPos) const
   153     {
   162     {
   154     return (aPos >= iStartMedPos && aPos < iStartMedPos + PageSizeInBytes());
   163     return (aPos >= iStartMedPos && aPos < iStartMedPos + PageSizeInBytes());
   155     }
   164     }
   156 
   165 
   157 /**
   166 /**
   158 Reset the media address to 0, invalidate page content.
   167 Reset the media address to 0, invalidate page content.
   159 */
   168 */
   160 void TDynamicDirCachePage::ResetPos()
   169 void TDynamicDirCachePage::ResetPos()
   161 	{
   170     {
   162 	iStartMedPos = 0;
   171     iStartMedPos = 0;
   163 	SetValid(EFalse);
   172     SetValid(EFalse);
   164 	}
   173     }
   165 
   174 
   166 /**
   175 /**
   167 Set page starting media address, invalidate page content.
   176 Set page starting media address, invalidate page content.
   168 @param	aPos	the new media address to be set.
   177 @param  aPos    the new media address to be set.
   169 */
   178 */
   170 void TDynamicDirCachePage::SetPos(TInt64 aPos)
   179 void TDynamicDirCachePage::SetPos(TInt64 aPos)
   171 	{
   180     {
   172 	iStartMedPos = aPos;
   181     iStartMedPos = aPos;
   173 	SetValid(EFalse);
   182     SetValid(EFalse);
   174 	return;
   183     return;
   175 	}
   184     }
   176 
   185 
   177 
   186 
   178 //========================================================================
   187 //========================================================================
   179 /**
   188 /**
   180 Calculate the page starting media address, aligned with page size.
   189 Calculate the page starting media address, aligned with page size.
   181 @param	aPos	the media address to be aligned.
   190 @param  aPos    the media address to be aligned.
   182 @return	TInt64	the aligned media address.
   191 @return TInt64  the aligned media address.
   183 */
   192 */
   184 TInt64 CDynamicDirCache::CalcPageStartPos(TInt64 aPos) const
   193 TInt64 CDynamicDirCache::CalcPageStartPos(TInt64 aPos) const
   185 	{
   194     {
   186     ASSERT(aPos >= iCacheBasePos);
   195     ASSERT(aPos >= iCacheBasePos);
   187     return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
   196     return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
   188 	}
   197     }
   189 
   198 
   190 /**
   199 /**
   191 Check if the cache has reached its limited page number.
   200 Check if the cache has reached its limited page number.
   192 @return	TBool	ETrue if cache is full, otherwise EFalse.
   201 @return TBool   ETrue if cache is full, otherwise EFalse.
   193 */
   202 */
   194 TBool CDynamicDirCache::CacheIsFull() const
   203 TBool CDynamicDirCache::CacheIsFull() const
   195 	{
   204     {
   196 	// active page, locked page and unlocked page
   205     // active page, locked page and unlocked page
   197 	return (iLockedQCount + iUnlockedQCount + 1 >= iMaxSizeInPages);
   206     return (iLockedQCount + iUnlockedQCount + 1 >= iMaxSizeInPages);
   198 	}
   207     }
   199 
   208 
   200 /**
   209 /**
   201 Return the maximum allowed page number of the cache.
   210 Return the maximum allowed page number of the cache.
   202 */
   211 */
   203 TUint32 CDynamicDirCache::MaxCacheSizeInPages() const
   212 TUint32 CDynamicDirCache::MaxCacheSizeInPages() const
   204 	{
   213     {
   205 	return iMaxSizeInPages;
   214     return iMaxSizeInPages;
   206 	}
   215     }
   207 
   216 
   208 #endif //SL_DIR_CACHE_INL
   217 #endif //SL_DIR_CACHE_INL
   209 
   218