kernel/eka/include/memmodel/epoc/mmubase/kblockmap.h
changeset 0 a41df078684a
child 6 0173bcd7697c
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.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 // WARNING: This file contains some APIs which are internal and are subject
       
    18 //          to change without notice. Such APIs should therefore not be used
       
    19 //          outside the Kernel and Hardware Services package.
       
    20 //
       
    21 
       
    22 #ifndef __KBLOCKMAP_H__
       
    23 #define __KBLOCKMAP_H__
       
    24 
       
    25 #include <e32ldr.h>
       
    26 
       
    27 /**
       
    28 The kernel-side representation of a block map.
       
    29 */
       
    30 class TBlockMap
       
    31 	{
       
    32 public:
       
    33 	TBlockMap();
       
    34 	~TBlockMap();
       
    35 	
       
    36 	/**
       
    37 	Initialise and populate kernel-side representation from a user-side block map
       
    38 
       
    39 	@param aBlockMapInfo    	The user-side block map info structure.
       
    40 	
       
    41 	@param aBlockMapEntries 	Pointer to a buffer containg the user-side block map entries.
       
    42 	                            This object takes ownership of the buffer.
       
    43 	                        
       
    44 	@param aBlockMapEntriesSize The size of the user-side block map entries in bytes.
       
    45 
       
    46 	@param aReadUnitShift       Log2 of the paging device's read unit size.
       
    47 	
       
    48 	@param aDataLengthInFile 	The length of the (possibly compressed) code in the file.
       
    49 	*/
       
    50 	TInt Initialise(const SBlockMapInfoBase& aBlockMapInfo,
       
    51 					TBlockMapEntryBase* aBlockMapEntries,
       
    52                     TInt aBlockMapEntriesSize,
       
    53 					TInt aReadUnitShift,
       
    54 					TInt aDataLengthInFile);
       
    55 
       
    56 	/**
       
    57 	A function supplied to Read that is called to read the actual data.
       
    58 	
       
    59 	@param aArg1   		An argument parameter passed to read.
       
    60 	@param aArg2   		Another argument parameter passed to read.
       
    61 	@param aBuffer 		The address of the buffer to read the data into.
       
    62 	@param aBlockNumber The block number to read.
       
    63 	@param aBlockCount 	The number of blocks to read.
       
    64 	*/
       
    65 	typedef TInt (*TReadFunc)(TAny* aArg1, TAny* aArg2, TLinAddr aBuffer, TInt aBlockNumber, TInt aBlockCount);
       
    66 
       
    67 	/**
       
    68 	Read data from the file described by the block map into a buffer.
       
    69 
       
    70 	@param aBuffer   	  The buffer into which to read the data.
       
    71 	@param aPos	   	 	  The offset from the start of the data at which to read.
       
    72 	@param aLength   	  The length of data to read in bytes.
       
    73 	@param aReadUnitShift Log2 of the paging device's read unit size.
       
    74 	@param aReadFunc 	  The function to call to read the blocks of data.
       
    75 	@param aArg1   		  An argument parameter passed to read.
       
    76 	@param aArg2   		  Another argument parameter passed to read.
       
    77 	
       
    78 	@return The offset into the buffer at which the data starts, or one of the system-wide error
       
    79 	codes.
       
    80 	*/
       
    81 	TInt Read(TLinAddr aBuffer, TInt aPos, TInt aLength, TInt aReadUnitShift, TReadFunc aReadFunc, TAny* aArg1, TAny* aArg2) const;
       
    82 
       
    83 	/**
       
    84 	A contiguous area of media containing (possibly compressed) code.
       
    85 	*/
       
    86 	struct SExtent
       
    87 		{
       
    88 		TInt iDataOffset;		// position in file from, counting from start of code data
       
    89 		TUint iBlockNumber;		// block number containg this position
       
    90 		};
       
    91 
       
    92 	inline TInt Count() const;
       
    93 	inline const SExtent& Extent(TInt aIndex) const;
       
    94 	inline TInt DataLength() const;
       
    95 
       
    96 	/**
       
    97 	Print out the contents of this object for debugging purposes.
       
    98 	This method is only implemented in debug builds.
       
    99 	*/
       
   100 	void Dump() const;
       
   101 
       
   102 private:
       
   103 	
       
   104 	TInt FindFirstExtent(TInt aPos) const;
       
   105 
       
   106 private:
       
   107 
       
   108 	TInt iDataLength;
       
   109 	TInt iExtentCount;
       
   110 	SExtent* iExtents;
       
   111 	};
       
   112 
       
   113 inline TInt TBlockMap::Count() const
       
   114 	{
       
   115 	return iExtentCount;
       
   116 	}
       
   117 
       
   118 inline const TBlockMap::SExtent& TBlockMap::Extent(TInt aIndex) const
       
   119 	{
       
   120 	return iExtents[aIndex];
       
   121 	}
       
   122 
       
   123 inline TInt TBlockMap::DataLength() const
       
   124 	{
       
   125 	return iDataLength;
       
   126 	}
       
   127 
       
   128 #endif