os/kernelhwsrv/kerneltest/e32test/buffer/t_tbma.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-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
// e32test\buffer\t_tbma.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef __T_TBMA_H__
sl@0
    19
#define __T_TBMA_H__
sl@0
    20
sl@0
    21
#include <e32test.h>
sl@0
    22
#include <e32atomics.h>
sl@0
    23
sl@0
    24
#define TBMA_FAULT()	TBmaFault(__LINE__)
sl@0
    25
#define __ALLOC(x)		User::Alloc(x)
sl@0
    26
sl@0
    27
extern void TBmaFault(TInt aLine);
sl@0
    28
sl@0
    29
extern RTest test;
sl@0
    30
sl@0
    31
// Copied from klib.h
sl@0
    32
class TBitMapAllocator
sl@0
    33
	{
sl@0
    34
public:
sl@0
    35
	IMPORT_C static TBitMapAllocator* New(TInt aSize, TBool aState);
sl@0
    36
	IMPORT_C TBitMapAllocator(TInt aSize, TBool aState);
sl@0
    37
	inline TInt Avail() const {return iAvail;}
sl@0
    38
	IMPORT_C TInt Alloc();
sl@0
    39
	IMPORT_C void Free(TInt aPos);
sl@0
    40
	IMPORT_C void Alloc(TInt aStart, TInt aLength);
sl@0
    41
	IMPORT_C void Free(TInt aStart, TInt aLength);
sl@0
    42
	IMPORT_C void SelectiveFree(TInt aStart, TInt aLength);
sl@0
    43
	IMPORT_C TBool NotFree(TInt aStart, TInt aLength) const;
sl@0
    44
	IMPORT_C TBool NotAllocated(TInt aStart, TInt aLength) const;
sl@0
    45
	IMPORT_C TInt AllocList(TInt aLength, TInt* aList);
sl@0
    46
	IMPORT_C TInt AllocConsecutive(TInt aLength, TBool aBestFit) const;
sl@0
    47
	IMPORT_C TInt AllocAligned(TInt aLength, TInt aAlign, TInt aBase, TBool aBestFit) const;
sl@0
    48
	IMPORT_C TInt AllocAligned(TInt aLength, TInt aAlign, TInt aBase, TBool aBestFit, TInt& aCarry, TInt& aRunLength) const;
sl@0
    49
	IMPORT_C TInt AllocAligned(TInt aLength, TInt aAlign, TInt aBase, TBool aBestFit, TInt& aCarry, TInt& aRunLength, TUint aOffset) const;
sl@0
    50
	IMPORT_C void CopyAlignedRange(const TBitMapAllocator* aA, TInt aFirst, TInt aLen);
sl@0
    51
public:
sl@0
    52
	TInt iAvail;			/**< @internalComponent */
sl@0
    53
	TUint32* iCheckFirst;	/**< @internalComponent */
sl@0
    54
	TInt iSize;				/**< @internalComponent */
sl@0
    55
	TUint32 iMap[1];		/**< @internalComponent */	// extend
sl@0
    56
	};
sl@0
    57
sl@0
    58
class TBmaList
sl@0
    59
	{
sl@0
    60
public:
sl@0
    61
	static TBmaList* New(TInt aNumBmas);
sl@0
    62
	static TBmaList* New(const TBitMapAllocator& aBma, TInt aNumSplits, VA_LIST aList);
sl@0
    63
	TBmaList();
sl@0
    64
	~TBmaList();
sl@0
    65
	TInt AllocConsecutiveFF(TInt aLength);
sl@0
    66
	TInt AllocConsecutiveBF(TInt aLength);
sl@0
    67
	TInt AllocAlignedFF(TInt aLength, TInt aAlign);
sl@0
    68
	TInt AllocAlignedBF(TInt aLength, TInt aAlign);
sl@0
    69
public:
sl@0
    70
	TInt iNumBmas;
sl@0
    71
	TBitMapAllocator** iBmaList;
sl@0
    72
	TInt* iBaseList;
sl@0
    73
	};
sl@0
    74
sl@0
    75
struct SRange
sl@0
    76
	{
sl@0
    77
	TInt iBase;
sl@0
    78
	TInt iLength;
sl@0
    79
	};
sl@0
    80
sl@0
    81
#endif