epoc32/include/memmodel/epoc/mmubase/kblockmap.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // 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
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32\include\memmodel\epoc\mmubase\kblockmap.h
       
    15 // Kernel-side functionality for processing block maps
       
    16 // 
       
    17 //
       
    18 
       
    19 #ifndef __KBLOCKMAP_H__
       
    20 #define __KBLOCKMAP_H__
       
    21 
       
    22 #include <e32ldr.h>
       
    23 
       
    24 /**
       
    25 The kernel-side representation of a block map.
       
    26 */
       
    27 class TBlockMap
       
    28 	{
       
    29 public:
       
    30 	TBlockMap();
       
    31 	~TBlockMap();
       
    32 	
       
    33 	/**
       
    34 	Initialise and populate kernel-side representation from a user-side block map
       
    35 
       
    36 	@param aBlockMapInfo    	The user-side block map info structure.
       
    37 	
       
    38 	@param aBlockMapEntries 	Pointer to a buffer containg the user-side block map entries.
       
    39 	                            This object takes ownership of the buffer.
       
    40 	                        
       
    41 	@param aBlockMapEntriesSize The size of the user-side block map entries in bytes.
       
    42 
       
    43 	@param aReadUnitShift       Log2 of the paging device's read unit size.
       
    44 	
       
    45 	@param aDataLengthInFile 	The length of the (possibly compressed) code in the file.
       
    46 	*/
       
    47 	TInt Initialise(const SBlockMapInfoBase& aBlockMapInfo,
       
    48 					TBlockMapEntryBase* aBlockMapEntries,
       
    49                     TInt aBlockMapEntriesSize,
       
    50 					TInt aReadUnitShift,
       
    51 					TInt aDataLengthInFile);
       
    52 
       
    53 	/**
       
    54 	A function supplied to Read that is called to read the actual data.
       
    55 	
       
    56 	@param aArg1   		An argument parameter passed to read.
       
    57 	@param aArg2   		Another argument parameter passed to read.
       
    58 	@param aBuffer 		The address of the buffer to read the data into.
       
    59 	@param aBlockNumber The block number to read.
       
    60 	@param aBlockCount 	The number of blocks to read.
       
    61 	*/
       
    62 	typedef TInt (*TReadFunc)(TAny* aArg1, TAny* aArg2, TLinAddr aBuffer, TInt aBlockNumber, TInt aBlockCount);
       
    63 
       
    64 	/**
       
    65 	Read data from the file described by the block map into a buffer.
       
    66 
       
    67 	@param aBuffer   	  The buffer into which to read the data.
       
    68 	@param aPos	   	 	  The offset from the start of the data at which to read.
       
    69 	@param aLength   	  The length of data to read in bytes.
       
    70 	@param aReadUnitShift Log2 of the paging device's read unit size.
       
    71 	@param aReadFunc 	  The function to call to read the blocks of data.
       
    72 	@param aArg1   		  An argument parameter passed to read.
       
    73 	@param aArg2   		  Another argument parameter passed to read.
       
    74 	
       
    75 	@return The offset into the buffer at which the data starts, or one of the system-wide error
       
    76 	codes.
       
    77 	*/
       
    78 	TInt Read(TLinAddr aBuffer, TInt aPos, TInt aLength, TInt aReadUnitShift, TReadFunc aReadFunc, TAny* aArg1, TAny* aArg2) const;
       
    79 
       
    80 	/**
       
    81 	A contiguous area of media containing (possibly compressed) code.
       
    82 	*/
       
    83 	struct SExtent
       
    84 		{
       
    85 		TInt iDataOffset;		// position in file from, counting from start of code data
       
    86 		TUint iBlockNumber;		// block number containg this position
       
    87 		};
       
    88 
       
    89 	inline TInt Count() const;
       
    90 	inline const SExtent& Extent(TInt aIndex) const;
       
    91 	inline TInt DataLength() const;
       
    92 
       
    93 	/**
       
    94 	Print out the contents of this object for debugging purposes.
       
    95 	This method is only implemented in debug builds.
       
    96 	*/
       
    97 	void Dump() const;
       
    98 
       
    99 private:
       
   100 	
       
   101 	TInt FindFirstExtent(TInt aPos) const;
       
   102 
       
   103 private:
       
   104 
       
   105 	TInt iDataLength;
       
   106 	TInt iExtentCount;
       
   107 	SExtent* iExtents;
       
   108 	};
       
   109 
       
   110 inline TInt TBlockMap::Count() const
       
   111 	{
       
   112 	return iExtentCount;
       
   113 	}
       
   114 
       
   115 inline const TBlockMap::SExtent& TBlockMap::Extent(TInt aIndex) const
       
   116 	{
       
   117 	return iExtents[aIndex];
       
   118 	}
       
   119 
       
   120 inline TInt TBlockMap::DataLength() const
       
   121 	{
       
   122 	return iDataLength;
       
   123 	}
       
   124 
       
   125 #endif