os/kernelhwsrv/kernel/eka/include/memmodel/epoc/mmubase/kblockmap.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/memmodel/epoc/mmubase/kblockmap.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,129 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\include\memmodel\epoc\mmubase\kblockmap.h
    1.18 +// Kernel-side functionality for processing block maps
    1.19 +// 
    1.20 +// WARNING: This file contains some APIs which are internal and are subject
    1.21 +//          to change without notice. Such APIs should therefore not be used
    1.22 +//          outside the Kernel and Hardware Services package.
    1.23 +//
    1.24 +
    1.25 +#ifndef __KBLOCKMAP_H__
    1.26 +#define __KBLOCKMAP_H__
    1.27 +
    1.28 +#include <e32ldr.h>
    1.29 +#include <e32ldr_private.h>
    1.30 +
    1.31 +/**
    1.32 +The kernel-side representation of a block map.
    1.33 +*/
    1.34 +class TBlockMap
    1.35 +	{
    1.36 +public:
    1.37 +	TBlockMap();
    1.38 +	~TBlockMap();
    1.39 +	
    1.40 +	/**
    1.41 +	Initialise and populate kernel-side representation from a user-side block map
    1.42 +
    1.43 +	@param aBlockMapInfo    	The user-side block map info structure.
    1.44 +	
    1.45 +	@param aBlockMapEntries 	Pointer to a buffer containg the user-side block map entries.
    1.46 +	                            This object takes ownership of the buffer.
    1.47 +	                        
    1.48 +	@param aBlockMapEntriesSize The size of the user-side block map entries in bytes.
    1.49 +
    1.50 +	@param aReadUnitShift       Log2 of the paging device's read unit size.
    1.51 +	
    1.52 +	@param aDataLengthInFile 	The length of the (possibly compressed) code in the file.
    1.53 +	*/
    1.54 +	TInt Initialise(const SBlockMapInfoBase& aBlockMapInfo,
    1.55 +					TBlockMapEntryBase* aBlockMapEntries,
    1.56 +                    TInt aBlockMapEntriesSize,
    1.57 +					TInt aReadUnitShift,
    1.58 +					TInt aDataLengthInFile);
    1.59 +
    1.60 +	/**
    1.61 +	A function supplied to Read that is called to read the actual data.
    1.62 +	
    1.63 +	@param aArg1   		An argument parameter passed to read.
    1.64 +	@param aArg2   		Another argument parameter passed to read.
    1.65 +	@param aBuffer 		The address of the buffer to read the data into.
    1.66 +	@param aBlockNumber The block number to read.
    1.67 +	@param aBlockCount 	The number of blocks to read.
    1.68 +	*/
    1.69 +	typedef TInt (*TReadFunc)(TAny* aArg1, TAny* aArg2, TLinAddr aBuffer, TInt aBlockNumber, TInt aBlockCount);
    1.70 +
    1.71 +	/**
    1.72 +	Read data from the file described by the block map into a buffer.
    1.73 +
    1.74 +	@param aBuffer   	  The buffer into which to read the data.
    1.75 +	@param aPos	   	 	  The offset from the start of the data at which to read.
    1.76 +	@param aLength   	  The length of data to read in bytes.
    1.77 +	@param aReadUnitShift Log2 of the paging device's read unit size.
    1.78 +	@param aReadFunc 	  The function to call to read the blocks of data.
    1.79 +	@param aArg1   		  An argument parameter passed to read.
    1.80 +	@param aArg2   		  Another argument parameter passed to read.
    1.81 +	
    1.82 +	@return The offset into the buffer at which the data starts, or one of the system-wide error
    1.83 +	codes.
    1.84 +	*/
    1.85 +	TInt Read(TLinAddr aBuffer, TInt aPos, TInt aLength, TInt aReadUnitShift, TReadFunc aReadFunc, TAny* aArg1, TAny* aArg2) const;
    1.86 +
    1.87 +	/**
    1.88 +	A contiguous area of media containing (possibly compressed) code.
    1.89 +	*/
    1.90 +	struct SExtent
    1.91 +		{
    1.92 +		TInt iDataOffset;		// position in file from, counting from start of code data
    1.93 +		TUint iBlockNumber;		// block number containg this position
    1.94 +		};
    1.95 +
    1.96 +	inline TInt Count() const;
    1.97 +	inline const SExtent& Extent(TInt aIndex) const;
    1.98 +	inline TInt DataLength() const;
    1.99 +
   1.100 +	/**
   1.101 +	Print out the contents of this object for debugging purposes.
   1.102 +	This method is only implemented in debug builds.
   1.103 +	*/
   1.104 +	void Dump() const;
   1.105 +
   1.106 +private:
   1.107 +	
   1.108 +	TInt FindFirstExtent(TInt aPos) const;
   1.109 +
   1.110 +private:
   1.111 +
   1.112 +	TInt iDataLength;
   1.113 +	TInt iExtentCount;
   1.114 +	SExtent* iExtents;
   1.115 +	};
   1.116 +
   1.117 +inline TInt TBlockMap::Count() const
   1.118 +	{
   1.119 +	return iExtentCount;
   1.120 +	}
   1.121 +
   1.122 +inline const TBlockMap::SExtent& TBlockMap::Extent(TInt aIndex) const
   1.123 +	{
   1.124 +	return iExtents[aIndex];
   1.125 +	}
   1.126 +
   1.127 +inline TInt TBlockMap::DataLength() const
   1.128 +	{
   1.129 +	return iDataLength;
   1.130 +	}
   1.131 +
   1.132 +#endif