diff -r 000000000000 -r a41df078684a kernel/eka/include/memmodel/epoc/mmubase/ramalloc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kernel/eka/include/memmodel/epoc/mmubase/ramalloc.h Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,213 @@ +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32\include\memmodel\epoc\mmubase\ramalloc.h +// +// + +/** + @file + @internalComponent +*/ + +#ifndef __RAMALLOC_H__ +#define __RAMALLOC_H__ +#include + +// RAM information block passed from bootstrap to kernel. +// Consists of two consecutive lists of SRamBank structures, each terminated by +// a bank with iSize=0. +// The first list specifies all available blocks of RAM in the system. +// The second list specifies any blocks of RAM which are reserved and not +// available for general allocation. This should not include RAM mapped by the +// bootstrap - this will be discovered when the initial page mappings are +// analysed. +struct SRamInfo + { + SRamBank iBanks[1]; // extend for multiple banks +// SRamBank iReservedBlocks[1]; + }; + +/** The number of types of pages that can't be moved or discarded +*/ +const TInt KPageImmovable = EPageMovable; + +/** The lowest enum from TZonePageType that DRamAllocater will allocate +*/ +const TUint KPageTypeAllocBase = EPageFixed; + +/** Element 0 of SZone::iBma is the bit map of all allocated pages +regardless of type. +*/ +const TUint KBmaAllPages = 0; + +/** The maximum number of freeable contiguous pages that can be found by +DRamAllocator::FindFreeableContiguousPages and RamCacheBase::AllocFreeContiguousPages. +*/ +const TUint KMaxFreeableContiguousPages = 16; + + +/** Structure to store the information on a zone. +*/ +struct SZone + { + TBitMapAllocator* iBma[EPageTypes]; /**< Pointers to bit map allocators for each type of page*/ + TPhysAddr iPhysBase; /**< physical base address of this zone*/ + TPhysAddr iPhysEnd; /**< physical end address of this zone*/ + TUint32 iPhysPages; /**< the total no. of pages that are in this zone*/ + TUint32 iAllocPages[EPageTypes]; /**< number of pages allocated of each type*/ + TUint32 iFreePages; /**< number of pages free*/ + SDblQueLink iPrefLink; /**< The link of this zone into the preference ordered list*/ + TUint iPrefRank; /**< The rank of this zone in the preference ordered list.*/ + TUint iId; /**< the ID of the zone*/ + TUint iFlags; /**< bit flags for this zone, all flags masked KRamZoneFlagInvalid are + for use by the kernel only*/ + TUint8 iPref; /**< the preference of the zone, lower preference zones are used first*/ + }; + +/** The different stages of a general defragmentation*/ +enum TGenDefragStage + { + EGenDefragStage0, /**< This stage should discard any pages needed to + allow the required movable pages to fit into the + RAM zones to be in use after the general defrag.*/ + EGenDefragStage1, /**< This stage should reduce the number of RAM + zones in use to the minmum required.*/ + EGenDefragStage2, /**< This stage clears space in most preferable RAM + zones for fixed page allocations by placing movable + and discardable pages in the least preferable RAM + zones in use.*/ + EGenDefragStageEnd, + }; + +// forward declare +struct SPageInfo; + +class DRamAllocator : public DBase + { +private: + /** Used with NextAllocZone to specify which order to run through the zones + */ + enum TZoneSearchState + { + EZoneSearchPref, + EZoneSearchAddr, + EZoneSearchEnd, + }; + + enum TPanic + { + EDoNotUse=0, + EDoMarkPagesAllocated1=1, + EAllocRamPagesInconsistent=2, + EZonesTooNumerousOrFew=3, /**