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