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