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