navienginebsp/naviengine_assp/pci/chunkman.h
changeset 0 5de814552237
equal deleted inserted replaced
-1:000000000000 0:5de814552237
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CHUNKMAN_H__
       
    21 #define __CHUNKMAN_H__
       
    22 
       
    23 #include <e32cmn.h>
       
    24 
       
    25 class TAddressAllocator;
       
    26 class DPlatChunkHw;
       
    27 class DChunk;
       
    28 class TChunkCreateInfo;
       
    29 class DMutex;
       
    30 
       
    31 
       
    32 /**
       
    33 Responsible for allocating and deallocating chunks which
       
    34 are accessible from the PCI bus.
       
    35 
       
    36 At present there can be only 1 chunk associated with each BAR.
       
    37 It would be possible to access more than one chunk per BAR, providing
       
    38 the chunks were physically contiguous with each other,
       
    39 */
       
    40 class TChunkManager
       
    41 	{
       
    42 public:
       
    43 	TChunkManager(TMappingManager& aMapMan);
       
    44 	~TChunkManager();
       
    45 	TInt AddChunk(DPlatChunkHw*& aChunk, TInt& aSize, TUint aAttributes, TUint32& aPciAddress);
       
    46 	TInt RemoveChunk(DPlatChunkHw* aChunk);
       
    47 
       
    48 	TInt AddChunk(DChunk*& aChunk, TChunkCreateInfo& aAttributes, TUint aOffset, TUint& aSize, TUint32& aPciAddress);
       
    49 	void RemoveChunk(TUint32 aPhysicalAddress);
       
    50 
       
    51 private:
       
    52 	/**
       
    53 	Used to keep a record of an allocated chunk
       
    54 	*/
       
    55 	struct TChunkRecord
       
    56 		{
       
    57 		TChunkRecord(DPlatChunkHw* aChunk, TInt32 aSize);
       
    58 		static TBool ChunkComparator(const TChunkRecord& aKeyRecord, const TChunkRecord& aRecord);
       
    59 
       
    60 		DPlatChunkHw* iChunk;
       
    61 		// DPlayChunkHw do not know the size which has been allocated to them.
       
    62 		TInt32 iSize;
       
    63 		};
       
    64 
       
    65 	/**
       
    66 	Used to keep a record of a shared chunk
       
    67 	*/
       
    68 	struct TSCRecord
       
    69 		{
       
    70 		TSCRecord(DChunk* aChunk, TUint32 aPhysAddr);
       
    71 		static TBool ChunkComparator(const TSCRecord& aKeyRecord, const TSCRecord& aRecord);
       
    72 
       
    73 		DChunk* iChunk;
       
    74 		TUint32 iPhysAddr; //we need to remember this as it allows PCI mapping to be freed
       
    75 		TBool iMapped; //says whether this chunk is mapped into PCI
       
    76 		TInt32 iSize;
       
    77 		};
       
    78 
       
    79 	TInt DoAddChunk(DPlatChunkHw*& aChunk, TInt aSize, TUint aAttributes, TUint32& aPciAddress);
       
    80 	TInt CreateChunk(DPlatChunkHw*& aChunk, TInt& aSize, TUint aAttributes);
       
    81 	TInt DeleteChunk(DPlatChunkHw* aChunk, TInt aSize);
       
    82 
       
    83 	TInt DoAddChunk(DChunk*& aChunk, TChunkCreateInfo& aAttributes, TUint aOffset, TUint& aSize, TUint32& aPciAddress);
       
    84 	TInt CreateChunk(DChunk*& aChunk, TChunkCreateInfo& aAttributes, TUint aOffset, TUint& aSize, TSCRecord& aRecord);
       
    85 
       
    86 	typedef DPlatChunkHw* DPlatChunkHwP;
       
    87 
       
    88 	TMappingManager& iMapMan;
       
    89 
       
    90 	RArray<TChunkRecord> iChunks;
       
    91 	RArray<TSCRecord> iSharedChunks;
       
    92 	DMutex* iMutex;
       
    93 
       
    94 
       
    95 	};
       
    96 #endif // __CHUNKMAN_H__