os/kernelhwsrv/userlibandfileserver/fileserver/sfat/sl_disk.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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\sfat\sl_disk.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    19
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    20
//!!
sl@0
    21
//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
sl@0
    22
//!!
sl@0
    23
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    24
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sl@0
    25
sl@0
    26
#include "sl_disk.h"
sl@0
    27
#include "sl_cache.h"
sl@0
    28
#include "sl_dir_cache.h"
sl@0
    29
sl@0
    30
/**
sl@0
    31
@file
sl@0
    32
*/
sl@0
    33
sl@0
    34
sl@0
    35
//################################################################################################################################
sl@0
    36
//#     CRawDisk implementation
sl@0
    37
//################################################################################################################################
sl@0
    38
sl@0
    39
sl@0
    40
/**
sl@0
    41
    Factory function. Constructs objects of the classes derived from CRawDisk.
sl@0
    42
    
sl@0
    43
    @param  aOwner      reference to the onwning FAT Mount class
sl@0
    44
    @param  aLocDrvCaps local drive capabilities from the media driver
sl@0
    45
    @return pointer to the constructed object. May be NULL on error.
sl@0
    46
*/
sl@0
    47
CRawDisk* CRawDisk::NewL(CFatMountCB& aOwner, const TLocalDriveCaps& aLocDrvCaps)
sl@0
    48
{
sl@0
    49
    __PRINT1(_L("CRawDisk::NewL() drv:%d"), aOwner.DriveNumber());
sl@0
    50
sl@0
    51
    if(aLocDrvCaps.iMediaAtt & KMediaAttVariableSize)
sl@0
    52
    {//-- this is the RAM drive "attribute"
sl@0
    53
        ASSERT((aLocDrvCaps.iDriveAtt & (KDriveAttInternal|KDriveAttLocal)) && aLocDrvCaps.iType == EMediaRam);
sl@0
    54
        if(!aLocDrvCaps.iBaseAddress)
sl@0
    55
        {
sl@0
    56
            ASSERT(0);
sl@0
    57
            return NULL;
sl@0
    58
        }
sl@0
    59
sl@0
    60
        return CRamDisk::NewL(aOwner);
sl@0
    61
    }
sl@0
    62
sl@0
    63
    //-- create CAtaDisk by default
sl@0
    64
    return CAtaDisk::NewL(aOwner);
sl@0
    65
}
sl@0
    66
sl@0
    67
sl@0
    68
CRawDisk::CRawDisk(CFatMountCB& aOwner)
sl@0
    69
    {
sl@0
    70
    iFatMount = &aOwner;
sl@0
    71
    }
sl@0
    72
sl@0
    73
/**
sl@0
    74
    Default implementation. Initialises and re-initialises the object.
sl@0
    75
*/
sl@0
    76
void CRawDisk::InitializeL()
sl@0
    77
    {
sl@0
    78
    ASSERT(iFatMount);
sl@0
    79
    }
sl@0
    80
sl@0
    81
sl@0
    82
TInt CRawDisk::GetLastErrorInfo(TDes8& /*aErrorInfo*/) const
sl@0
    83
    {
sl@0
    84
    return KErrNotSupported;
sl@0
    85
    }
sl@0
    86
sl@0
    87
//################################################################################################################################
sl@0
    88
//##    CAtaDisk class implementation
sl@0
    89
//################################################################################################################################
sl@0
    90
sl@0
    91
CAtaDisk::CAtaDisk(CFatMountCB& aFatMount)
sl@0
    92
         :CRawDisk(aFatMount), iDrive(aFatMount.DriveInterface())
sl@0
    93
    {
sl@0
    94
    }
sl@0
    95
sl@0
    96
CAtaDisk::~CAtaDisk()
sl@0
    97
    {
sl@0
    98
    delete ipDirCache;
sl@0
    99
    delete iUidCache;
sl@0
   100
    
sl@0
   101
    }
sl@0
   102
sl@0
   103
sl@0
   104
//-------------------------------------------------------------------------------------
sl@0
   105
sl@0
   106
/**
sl@0
   107
    CAtaDisk factory method.
sl@0
   108
    
sl@0
   109
    @param  aFatMount reference to the owner.
sl@0
   110
    @return pointer to the constructed object.
sl@0
   111
*/
sl@0
   112
CAtaDisk* CAtaDisk::NewL(CFatMountCB& aFatMount)
sl@0
   113
    {
sl@0
   114
    __PRINT1(_L("CAtaDisk::NewL() drv:%d"), aFatMount.DriveNumber());
sl@0
   115
sl@0
   116
    CAtaDisk* pSelf = new (ELeave) CAtaDisk(aFatMount);
sl@0
   117
    
sl@0
   118
    CleanupStack::PushL(pSelf);
sl@0
   119
    
sl@0
   120
    pSelf->ConstructL();
sl@0
   121
    pSelf->InitializeL();
sl@0
   122
    
sl@0
   123
    CleanupStack::Pop();
sl@0
   124
sl@0
   125
    return pSelf;
sl@0
   126
    }
sl@0
   127
sl@0
   128
//-------------------------------------------------------------------------------------
sl@0
   129
sl@0
   130
/** 2nd stage constructor */
sl@0
   131
void CAtaDisk::ConstructL()
sl@0
   132
    {
sl@0
   133
    //===========================  create data WT cache that is primarily used for caching exacutable modules' UIDs
sl@0
   134
    const TUint32 KUidCachePageSzLog2 = 9; //-- 512 bytes in page 
sl@0
   135
    const TUint32 KUidCachePages = 64;     //-- 64 pages; total cache size is 32K 
sl@0
   136
sl@0
   137
    iUidCache = CMediaWTCache::NewL(iDrive, KUidCachePages, KUidCachePageSzLog2);
sl@0
   138
sl@0
   139
sl@0
   140
    //=========================== create directory cache
sl@0
   141
    
sl@0
   142
    //-- Get dir. cache parameters from config. They may be set in estart.txt for a specified drive.
sl@0
   143
    const TUint32 KDirCacheSize = iFatMount->FatConfig().DirCacheSize(); //- Total directory cache size, bytes.
sl@0
   144
    const TUint32 KMaxDirCachePageSzLog2 = iFatMount->FatConfig().DirCacheMaxPageSizeLog2(); //- Log2 of the Max. dir. cache page.
sl@0
   145
sl@0
   146
    __PRINT2(_L("CAtaDisk::ConstructL() Dir Cache config:%d,%d"),KDirCacheSize,KMaxDirCachePageSzLog2);
sl@0
   147
sl@0
   148
    ASSERT(KDirCacheSize >= K1KiloByte && KDirCacheSize <= K1MegaByte);
sl@0
   149
    ASSERT((KMaxDirCachePageSzLog2 >= KDefSectorSzLog2) && (Pow2(KMaxDirCachePageSzLog2) <= KDirCacheSize));
sl@0
   150
sl@0
   151
    //-- calculate the size and number of pages for the dir. cache. 
sl@0
   152
    //-- if the mount's cluster size is less than max. page size from config, the page size will be cluster size.
sl@0
   153
    //-- otherwise it will be the value from config. I.e  the minimal page size is cluster size; the maximal page size is taken from config.
sl@0
   154
    //-- The number of pages depends on total cache size and page size.
sl@0
   155
    const TUint clustSizeLog2 = iFatMount->ClusterSizeLog2(); //-- current FAT cluster size Log2
sl@0
   156
    const TUint32 pageSzLog2 = (clustSizeLog2 <= KMaxDirCachePageSzLog2) ? clustSizeLog2 : KMaxDirCachePageSzLog2;
sl@0
   157
    const TUint32 numPages = KDirCacheSize / (Pow2(pageSzLog2));
sl@0
   158
sl@0
   159
    ASSERT(!ipDirCache);
sl@0
   160
sl@0
   161
#ifdef USE_DP_DIR_CACHE
sl@0
   162
sl@0
   163
    //=========================== create Demand Paging type of the directory cache
sl@0
   164
sl@0
   165
    // initialize cache memory manager as all file systems have mounted by now
sl@0
   166
    if(CCacheMemoryManagerFactory::CacheMemoryManager())
sl@0
   167
        {
sl@0
   168
        // Note: the configuration data of min and max cache size are aligned with the memory size it
sl@0
   169
        //  occupies in kernel as we are using demand paging subsystem for dynamic cache size support. 
sl@0
   170
        //  Therefore, they are refered as 'Mem Size' in following calculation.
sl@0
   171
        //  However, 'Data Size' refers to the logical size of a page, i.e. the actual data size each page
sl@0
   172
        //  contains.
sl@0
   173
        // The constraints we have to consider when setting up the dynamic cache:
sl@0
   174
        //  1. each page's data size is aligned with cluster size, unless cluster size is bigger than
sl@0
   175
        //      the default maximum page size allowed (typically 32 KB).
sl@0
   176
        //  2. if page's data size is smaller than segment size (typically 4 KB), i.e. the unit size of 
sl@0
   177
        //      demand paging subsystem's page management, we will still use up the whole segment for
sl@0
   178
        //      that page.
sl@0
   179
        //  3. the default min and max cache's memory size is pre-defined in  fat_config.cpp file.
sl@0
   180
        //      (see KDef_DynamicDirCacheMin & KDef_DynamicDirCacheMax).
sl@0
   181
sl@0
   182
        // calculate page data size (logical view of page size)
sl@0
   183
        const TUint32 DefMaxCachePageLog2 = iFatMount->FatConfig().DynamicDirCacheMaxPageSizeLog2();
sl@0
   184
        const TUint32 PageDataSizeLog2 = clustSizeLog2 < DefMaxCachePageLog2 ? clustSizeLog2 : DefMaxCachePageLog2;
sl@0
   185
        
sl@0
   186
        // calculate page number, based on memory size we have reserved
sl@0
   187
        const TUint32 SegmentSizeLog2 = CCacheMemoryManagerFactory::CacheMemoryManager()->SegmentSizeInBytesLog2();
sl@0
   188
        const TUint32 PageMemSizeLog2 = PageDataSizeLog2 < SegmentSizeLog2 ? SegmentSizeLog2 : PageDataSizeLog2;
sl@0
   189
        TUint32 CacheSizeMinInPages = iFatMount->FatConfig().DynamicDirCacheSizeMin() >> PageMemSizeLog2;
sl@0
   190
        TUint32 CacheSizeMaxInPages = iFatMount->FatConfig().DynamicDirCacheSizeMax() >> PageMemSizeLog2;
sl@0
   191
sl@0
   192
        // cache memory client is connected via name 
sl@0
   193
        TBuf<0x20> clientName = _L("CACHE_MEM_CLIENT:");
sl@0
   194
        clientName.Append('A'+iFatMount->DriveNumber());
sl@0
   195
sl@0
   196
        TRAPD(err, ipDirCache = CDynamicDirCache::NewL(iDrive, CacheSizeMinInPages, CacheSizeMaxInPages, PageDataSizeLog2, clientName));
sl@0
   197
        if (err == KErrNone)
sl@0
   198
            {
sl@0
   199
            __PRINT4(_L("CDynamicDirCache::NewL(drv:%C, minPageNum:%u, maxPageNum:%u, pageDataSize:%u)\n"), 'A'+iFatMount->DriveNumber(), CacheSizeMinInPages, CacheSizeMaxInPages, 1<<PageDataSizeLog2);
sl@0
   200
            return;
sl@0
   201
            }
sl@0
   202
        }
sl@0
   203
#endif // USE_DP_DIR_CACHE
sl@0
   204
sl@0
   205
    //=========================== create legacy type of the directory cache
sl@0
   206
    ASSERT(!ipDirCache);
sl@0
   207
sl@0
   208
    ipDirCache = CMediaWTCache::NewL(iDrive, numPages, pageSzLog2);
sl@0
   209
    __PRINT3(_L("CDirCache::NewL(drive: %C, NumPages=%d, PageSize=%u)"), 'A'+iFatMount->DriveNumber(), numPages, 1<<pageSzLog2);
sl@0
   210
    
sl@0
   211
    }
sl@0
   212
sl@0
   213
//-------------------------------------------------------------------------------------
sl@0
   214
sl@0
   215
/**
sl@0
   216
    Initialises and re-initialises the object.
sl@0
   217
*/
sl@0
   218
void CAtaDisk::InitializeL()
sl@0
   219
{
sl@0
   220
    CRawDisk::InitializeL();
sl@0
   221
    
sl@0
   222
    //-- there is a little issue here. after formatting FAT mounts's cluster size can change.
sl@0
   223
    //-- dir. cache page size depends on the cluster size. This method doesn't change the dir. cache page size.
sl@0
   224
    //-- At present it is done in CFatMountCB::InitializeL() that deletes this object and then reconstructs it again.
sl@0
   225
sl@0
   226
    //-- invalidate directory cache here
sl@0
   227
    ipDirCache->InvalidateCache();
sl@0
   228
    
sl@0
   229
    TInt64  cacheBasePos;
sl@0
   230
    
sl@0
   231
    if(iFatMount->FatType() == EFat32)
sl@0
   232
        {
sl@0
   233
        //-- this is FAT32, all directories including Root are files and aligned to the cluster heap boundary
sl@0
   234
        //-- set dir. cache base position to the cluster heap boundary
sl@0
   235
        const TUint32 offsetMask = (1 << iFatMount->ClusterSizeLog2() )-1;
sl@0
   236
        cacheBasePos = (iFatMount->ClusterBasePosition() & offsetMask);
sl@0
   237
        }
sl@0
   238
    else
sl@0
   239
        {
sl@0
   240
        //-- this is FAT12/16. Root directory is a separate volume object and has no alignment.
sl@0
   241
        //-- set cache base position to its beginning.
sl@0
   242
        cacheBasePos = iFatMount->StartOfRootDirInBytes();
sl@0
   243
        }
sl@0
   244
sl@0
   245
    ipDirCache->SetCacheBasePos(cacheBasePos);
sl@0
   246
    
sl@0
   247
}
sl@0
   248
sl@0
   249
//-------------------------------------------------------------------------------------
sl@0
   250
sl@0
   251
/**
sl@0
   252
    Read data from the media through LRU data cache cache. 
sl@0
   253
sl@0
   254
    @param  aPos        absolute media position
sl@0
   255
    @param  aLength     how many bytes to read
sl@0
   256
    @param  aDes        data descriptor
sl@0
   257
sl@0
   258
    @leave on error
sl@0
   259
*/
sl@0
   260
void CAtaDisk::ReadCachedL(TInt64 aPos,TInt aLength,TDes8& aDes) const
sl@0
   261
    {
sl@0
   262
    __PRINT3(_L("CAtaDisk::ReadL() pos:%u:%u, len:%u"), I64HIGH(aPos), I64LOW(aPos), aLength);
sl@0
   263
    iUidCache->ReadL(aPos, aLength, aDes);
sl@0
   264
    }
sl@0
   265
sl@0
   266
//-------------------------------------------------------------------------------------
sl@0
   267
sl@0
   268
/**
sl@0
   269
    Write data to the media through LRU data cache
sl@0
   270
sl@0
   271
    @param  aPos        absolute media position
sl@0
   272
    @param  aDes        data descriptor
sl@0
   273
sl@0
   274
    @leave on error
sl@0
   275
*/
sl@0
   276
void CAtaDisk::WriteCachedL(TInt64 aPos, const TDesC8& aDes)
sl@0
   277
    {
sl@0
   278
    __PRINT3(_L("CAtaDisk::WriteL() pos:%u:%u, len:%u"), I64HIGH(aPos), I64LOW(aPos), aDes.Size());
sl@0
   279
    iUidCache->WriteL(aPos, aDes);
sl@0
   280
    }
sl@0
   281
sl@0
   282
sl@0
   283
//-------------------------------------------------------------------------------------
sl@0
   284
sl@0
   285
/**
sl@0
   286
    Read data from the media directly without any caches.
sl@0
   287
    Mostly used by file IO
sl@0
   288
sl@0
   289
    @param  aPos        absolute media position
sl@0
   290
    @param  aLength     how many bytes to read
sl@0
   291
    @param  aTrg        Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
sl@0
   292
    @param  aMessage    Refrence to server message from request
sl@0
   293
    @param  anOffset    Offset into read data to write
sl@0
   294
sl@0
   295
    @leave on error
sl@0
   296
*/
sl@0
   297
void CAtaDisk::ReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const
sl@0
   298
    {
sl@0
   299
sl@0
   300
    __PRINT4(_L("CAtaDisk::ReadL() pos:%u:%u, len:%u, offset:%u"), I64HIGH(aPos), I64LOW(aPos), aLength, anOffset);
sl@0
   301
    User::LeaveIfError(iDrive.ReadNonCritical(aPos,aLength,aTrg,aMessage,anOffset));
sl@0
   302
    }
sl@0
   303
sl@0
   304
//-------------------------------------------------------------------------------------
sl@0
   305
sl@0
   306
/**
sl@0
   307
    Write data to the media directly without any cached.
sl@0
   308
    Mostly used by file IO
sl@0
   309
sl@0
   310
    This method shall invalidate some data caches to keep them in synch with the media.
sl@0
   311
sl@0
   312
    @param aPos     Media position in bytes
sl@0
   313
    @param aLength  Length in bytes of write
sl@0
   314
    @param aTrg     Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
sl@0
   315
    @param aMessage Refrence to server message from request, contains data
sl@0
   316
    @param anOffset Offset into write data to use in write
sl@0
   317
sl@0
   318
    @leave on error
sl@0
   319
*/
sl@0
   320
void CAtaDisk::WriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset)
sl@0
   321
    {
sl@0
   322
    __PRINT4(_L("CAtaDisk::WriteL() pos:%u:%u, len:%u, offset:%u"), I64HIGH(aPos), I64LOW(aPos), aLength, anOffset);
sl@0
   323
sl@0
   324
    //-- write data to the media directly
sl@0
   325
    User::LeaveIfError(iDrive.WriteNonCritical(aPos,aLength,aSrc,aMessage,anOffset));
sl@0
   326
sl@0
   327
    //-- we need to invalidate UID cache page that corresponds to aPos (if any). This is UID caching specific. UID is stored in the first few bytes of 
sl@0
   328
    //-- the executable module and therefore belongs to one cache page only.
sl@0
   329
    //-- If someone writes to the beginning of the exe module file, corresponding UID cache page will be invalidated and re-read from the media later
sl@0
   330
    iUidCache->InvalidateCachePage(aPos); 
sl@0
   331
sl@0
   332
    //-- invalidate affected(if any) part of the FAT cache in the case if someone used to write data to FAT area, which usually do not happen 
sl@0
   333
    iFatMount->FAT().InvalidateCacheL(aPos,aLength);
sl@0
   334
sl@0
   335
    }
sl@0
   336
sl@0
   337
//-------------------------------------------------------------------------------------
sl@0
   338
sl@0
   339
/** Get information for last disk error */
sl@0
   340
TInt CAtaDisk::GetLastErrorInfo(TDes8& aErrorInfo) const
sl@0
   341
    {
sl@0
   342
    return iDrive.GetLastErrorInfo(aErrorInfo);
sl@0
   343
    }
sl@0
   344
sl@0
   345
sl@0
   346
//-------------------------------------------------------------------------------------
sl@0
   347
/** Invalidate whole UID cache */
sl@0
   348
void CAtaDisk::InvalidateUidCache()
sl@0
   349
{
sl@0
   350
    ASSERT(iUidCache);
sl@0
   351
    iUidCache->InvalidateCache();
sl@0
   352
}
sl@0
   353
sl@0
   354
/** 
sl@0
   355
    Invalidate the UID cache page that has aPos cached.
sl@0
   356
    This method doesn't pay attention to the length of the block being invalidated because
sl@0
   357
    UID lives in the very beginning of the exe module and always fits into a single page
sl@0
   358
*/
sl@0
   359
void CAtaDisk::InvalidateUidCachePage(TUint64 aPos)
sl@0
   360
{
sl@0
   361
    ASSERT(iUidCache);
sl@0
   362
    iUidCache->InvalidateCachePage(aPos);
sl@0
   363
}
sl@0
   364
sl@0
   365
sl@0
   366
//################################################################################################################################
sl@0
   367
//##    CRamDisk class implementation
sl@0
   368
//################################################################################################################################
sl@0
   369
sl@0
   370
sl@0
   371
/**
sl@0
   372
    CRamDisk factory method.
sl@0
   373
    
sl@0
   374
    @param  aFatMount reference to the owner.
sl@0
   375
    @return pointer to the constructed object.
sl@0
   376
*/
sl@0
   377
CRamDisk* CRamDisk::NewL(CFatMountCB& aFatMount)
sl@0
   378
    {
sl@0
   379
    __PRINT1(_L("CRamDisk::NewL() drv:%d"), aFatMount.DriveNumber());
sl@0
   380
    CRamDisk* pSelf = new(ELeave)CRamDisk(aFatMount);
sl@0
   381
sl@0
   382
    CleanupStack::PushL(pSelf);
sl@0
   383
  
sl@0
   384
    pSelf->InitializeL();
sl@0
   385
    
sl@0
   386
    CleanupStack::Pop();
sl@0
   387
sl@0
   388
    return pSelf;
sl@0
   389
    }
sl@0
   390
sl@0
   391
CRamDisk::CRamDisk(CFatMountCB& aFatMount)
sl@0
   392
         :CRawDisk(aFatMount)
sl@0
   393
    {
sl@0
   394
    }
sl@0
   395
sl@0
   396
//-------------------------------------------------------------------------------------
sl@0
   397
sl@0
   398
/**
sl@0
   399
    Initialises and re-initialises the object.
sl@0
   400
*/
sl@0
   401
void CRamDisk::InitializeL()
sl@0
   402
{
sl@0
   403
    CRawDisk::InitializeL();
sl@0
   404
sl@0
   405
    //-- set the RAM disk base
sl@0
   406
    TLocalDriveCapsV2 caps;
sl@0
   407
    TPckg<TLocalDriveCapsV2> capsPckg(caps);
sl@0
   408
    User::LeaveIfError(iFatMount->LocalDrive()->Caps(capsPckg));
sl@0
   409
  
sl@0
   410
    ASSERT(caps.iMediaAtt & KMediaAttVariableSize);
sl@0
   411
    
sl@0
   412
    //-- set RAM disk base
sl@0
   413
    iRamDiskBase = caps.iBaseAddress; 
sl@0
   414
    ASSERT(iRamDiskBase);
sl@0
   415
}
sl@0
   416
sl@0
   417
sl@0
   418
sl@0
   419
/** @return the start address of the Ram Drive in low memory */
sl@0
   420
TUint8* CRamDisk::RamDiskBase() const
sl@0
   421
    {
sl@0
   422
    return iRamDiskBase;
sl@0
   423
    }
sl@0
   424
sl@0
   425
//-------------------------------------------------------------------------------------
sl@0
   426
//
sl@0
   427
// Read aLength of data from the disk
sl@0
   428
//
sl@0
   429
void CRamDisk::ReadCachedL(TInt64 aPos,TInt aLength,TDes8& aDes) const
sl@0
   430
    {
sl@0
   431
    
sl@0
   432
    __PRINT3(_L("CRamDisk::ReadL Base 0x%x Pos 0x%x, Len %d"),RamDiskBase(),I64LOW(aPos),aLength);
sl@0
   433
    __ASSERT_ALWAYS((aPos+aLength<=I64INT(iFatMount->Size())) && (aLength>=0),User::Leave(KErrCorrupt));
sl@0
   434
    Mem::Copy((TUint8*)aDes.Ptr(),RamDiskBase()+I64LOW(aPos),aLength);
sl@0
   435
    aDes.SetLength(aLength);
sl@0
   436
    }
sl@0
   437
sl@0
   438
//-------------------------------------------------------------------------------------
sl@0
   439
//
sl@0
   440
// Write aLength of data to the disk
sl@0
   441
//
sl@0
   442
void CRamDisk::WriteCachedL(TInt64 aPos,const TDesC8& aDes)
sl@0
   443
    {
sl@0
   444
sl@0
   445
    __PRINT3(_L("CRamDisk::WriteL Base 0x%x Pos 0x%x, Len %d"),RamDiskBase(),aPos,aDes.Length());
sl@0
   446
    __ASSERT_ALWAYS(aPos+aDes.Length()<=I64INT(iFatMount->Size()),User::Leave(KErrCorrupt));
sl@0
   447
    Mem::Copy(RamDiskBase()+I64LOW(aPos),(TUint8*)aDes.Ptr(),aDes.Length());
sl@0
   448
    }
sl@0
   449
    
sl@0
   450
sl@0
   451
//-------------------------------------------------------------------------------------
sl@0
   452
//
sl@0
   453
// Read from ramDrive into thread relative descriptor
sl@0
   454
//
sl@0
   455
void CRamDisk::ReadL(TInt64 aPos,TInt aLength,const TAny* /*aTrg*/,const RMessagePtr2 &aMessage,TInt anOffset) const
sl@0
   456
    {
sl@0
   457
    __PRINT2(_L("CRamDisk::ReadL TAny* Pos 0x%x, Len %d"),aPos,aLength);
sl@0
   458
    __ASSERT_ALWAYS((aPos+aLength<=I64INT(iFatMount->Size())) && (aLength>=0),User::Leave(KErrCorrupt));
sl@0
   459
    TUint8* pos=RamDiskBase()+I64LOW(aPos);
sl@0
   460
    TPtrC8 buf(pos,aLength);
sl@0
   461
    aMessage.WriteL(0,buf,anOffset);
sl@0
   462
    }
sl@0
   463
sl@0
   464
//-------------------------------------------------------------------------------------
sl@0
   465
//
sl@0
   466
// Write from thread relative descriptor into ramDrive
sl@0
   467
//
sl@0
   468
void CRamDisk::WriteL(TInt64 aPos,TInt aLength,const TAny* /*aSrc*/,const RMessagePtr2 &aMessage,TInt anOffset)
sl@0
   469
    {
sl@0
   470
    __PRINT2(_L("CRamDisk::WriteL TAny* Pos 0x%x, Len %d"),aPos,aLength);
sl@0
   471
    __ASSERT_ALWAYS(aPos+aLength<=I64INT(iFatMount->Size()),User::Leave(KErrCorrupt));
sl@0
   472
    TUint8* pos=RamDiskBase()+I64LOW(aPos);
sl@0
   473
    TPtr8 buf(pos,aLength);
sl@0
   474
    aMessage.ReadL(0,buf,anOffset);
sl@0
   475
    }
sl@0
   476
sl@0
   477
sl@0
   478
sl@0
   479
sl@0
   480
sl@0
   481
sl@0
   482
sl@0
   483
sl@0
   484
sl@0
   485
sl@0
   486
sl@0
   487
sl@0
   488
sl@0
   489
sl@0
   490
sl@0
   491
sl@0
   492
sl@0
   493
sl@0
   494
sl@0
   495
sl@0
   496
sl@0
   497
sl@0
   498
sl@0
   499
sl@0
   500
sl@0
   501
sl@0
   502