williamr@2: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // e32\include\memmodel\epoc\mmubase\kblockmap.h williamr@2: // Kernel-side functionality for processing block maps williamr@2: // williamr@2: // williamr@2: williamr@2: #ifndef __KBLOCKMAP_H__ williamr@2: #define __KBLOCKMAP_H__ williamr@2: williamr@2: #include williamr@2: williamr@2: /** williamr@2: The kernel-side representation of a block map. williamr@2: */ williamr@2: class TBlockMap williamr@2: { williamr@2: public: williamr@2: TBlockMap(); williamr@2: ~TBlockMap(); williamr@2: williamr@2: /** williamr@2: Initialise and populate kernel-side representation from a user-side block map williamr@2: williamr@2: @param aBlockMapInfo The user-side block map info structure. williamr@2: williamr@2: @param aBlockMapEntries Pointer to a buffer containg the user-side block map entries. williamr@2: This object takes ownership of the buffer. williamr@2: williamr@2: @param aBlockMapEntriesSize The size of the user-side block map entries in bytes. williamr@2: williamr@2: @param aReadUnitShift Log2 of the paging device's read unit size. williamr@2: williamr@2: @param aDataLengthInFile The length of the (possibly compressed) code in the file. williamr@2: */ williamr@2: TInt Initialise(const SBlockMapInfoBase& aBlockMapInfo, williamr@2: TBlockMapEntryBase* aBlockMapEntries, williamr@2: TInt aBlockMapEntriesSize, williamr@2: TInt aReadUnitShift, williamr@2: TInt aDataLengthInFile); williamr@2: williamr@2: /** williamr@2: A function supplied to Read that is called to read the actual data. williamr@2: williamr@2: @param aArg1 An argument parameter passed to read. williamr@2: @param aArg2 Another argument parameter passed to read. williamr@2: @param aBuffer The address of the buffer to read the data into. williamr@2: @param aBlockNumber The block number to read. williamr@2: @param aBlockCount The number of blocks to read. williamr@2: */ williamr@2: typedef TInt (*TReadFunc)(TAny* aArg1, TAny* aArg2, TLinAddr aBuffer, TInt aBlockNumber, TInt aBlockCount); williamr@2: williamr@2: /** williamr@2: Read data from the file described by the block map into a buffer. williamr@2: williamr@2: @param aBuffer The buffer into which to read the data. williamr@2: @param aPos The offset from the start of the data at which to read. williamr@2: @param aLength The length of data to read in bytes. williamr@2: @param aReadUnitShift Log2 of the paging device's read unit size. williamr@2: @param aReadFunc The function to call to read the blocks of data. williamr@2: @param aArg1 An argument parameter passed to read. williamr@2: @param aArg2 Another argument parameter passed to read. williamr@2: williamr@2: @return The offset into the buffer at which the data starts, or one of the system-wide error williamr@2: codes. williamr@2: */ williamr@2: TInt Read(TLinAddr aBuffer, TInt aPos, TInt aLength, TInt aReadUnitShift, TReadFunc aReadFunc, TAny* aArg1, TAny* aArg2) const; williamr@2: williamr@2: /** williamr@2: A contiguous area of media containing (possibly compressed) code. williamr@2: */ williamr@2: struct SExtent williamr@2: { williamr@2: TInt iDataOffset; // position in file from, counting from start of code data williamr@2: TUint iBlockNumber; // block number containg this position williamr@2: }; williamr@2: williamr@2: inline TInt Count() const; williamr@2: inline const SExtent& Extent(TInt aIndex) const; williamr@2: inline TInt DataLength() const; williamr@2: williamr@2: /** williamr@2: Print out the contents of this object for debugging purposes. williamr@2: This method is only implemented in debug builds. williamr@2: */ williamr@2: void Dump() const; williamr@2: williamr@2: private: williamr@2: williamr@2: TInt FindFirstExtent(TInt aPos) const; williamr@2: williamr@2: private: williamr@2: williamr@2: TInt iDataLength; williamr@2: TInt iExtentCount; williamr@2: SExtent* iExtents; williamr@2: }; williamr@2: williamr@2: inline TInt TBlockMap::Count() const williamr@2: { williamr@2: return iExtentCount; williamr@2: } williamr@2: williamr@2: inline const TBlockMap::SExtent& TBlockMap::Extent(TInt aIndex) const williamr@2: { williamr@2: return iExtents[aIndex]; williamr@2: } williamr@2: williamr@2: inline TInt TBlockMap::DataLength() const williamr@2: { williamr@2: return iDataLength; williamr@2: } williamr@2: williamr@2: #endif