Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\include\drivers\dmasupport.h
21 #include "plat_priv.h"
31 Class used for read / write requests to the local media subsystem to gain access
32 to physical memory address to make use of DMA without the need of an intermediate buffer.
34 class DDmaHelper : public DBase
46 Class used to describe a number of contiguous physical pages
51 TPhysAddr iAddress; // address of page
59 TInt Construct(TInt aLength, TInt aMediaBlockSize, TInt aDmaAlignment);
61 TInt SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress);
62 TInt GetPhysicalAddress(TPhysAddr& aAddr, TInt& aLen);
64 #ifdef __DEMAND_PAGING__
65 static TInt GetPhysicalAddress(TLocDrvRequest& aReq, TPhysAddr& aAddr, TInt& aLen);
67 inline TInt PageSize() const { return iPageSize; }
71 static inline TInt PageSizeLog2();
72 static inline TBool IsPageAligned(TLinAddr aAddr);
73 static inline TLinAddr PageAlign(TLinAddr aAddr);
74 static inline TLinAddr PageOffset(TLinAddr aAddr);
76 inline TInt MaxFragLength() const;
77 inline void SetFragLength(TInt aLength);
78 inline TInt FragLength() const;
79 inline TInt LengthRemaining() const;
80 inline TUint32 LengthConsumed() const;
82 inline TBool IsDmaAligned(TLinAddr aAddr);
83 inline TBool IsBlockAligned(TInt64 aPos);
84 inline TInt64 BlockAlign(TInt64 aPos);
85 inline TInt BlockOffset(TInt64 aPos);
87 inline TLinAddr LinAddress() const;
89 void ResetPageLists();
91 TInt UpdateRemoteDescriptorLength(TInt aLength);
96 void ReleasePages(TLinAddr aAddr);
99 TInt iMediaBlockSize; // Minimum transfer size (bytes) for the media.
100 TInt64 iMediaBlockSizeMask; // iMediaBlockSize - 1
101 TInt iDmaAlignment; // DMA Alignment req for media's DMA controller i.e. word alignment
103 static TInt iPageSize; // Memory page size in bytes (e.g. 4096 Bytes)
104 static TInt iPageSizeLog2; // Log2 of page size (e.g. 4096 -> 12)
105 static TInt iPageSizeMsk; // Mask of page size (e.g. 4096-1 -> 4095)
106 TInt iMaxPages; // Maximum number of pages that can be stored by this object
108 DThread* iRemoteThread; //
109 DThread* iCurrentThread; //
110 DThread* iOwningThread; // Thread owning remote descriptor, either iRemoteThread or iCurrentThread
112 TLocDrvRequest* iReq; // Current TLocDrvRequest
114 // The following attributes are copied from the current TLocDrvRequest
116 TInt iReqRemoteDesOffset;
118 TInt iReqLenClient; // length of data requested by client (unmodified)
119 TInt64 iReqPosClient; // position of data requested by client (unmodified)
121 TLinAddr iLinAddressUser; // linear address of client buffer in user process
122 TLinAddr iLinAddressKernel; // linear address of client buffer in kernel process
123 TInt iFragLen; // length of data to be read into physical pages (possibly < a multiple of the page-size)
124 TInt iFragLenRemaining; // length of data to be read left in this fragment
126 TMemoryType iMemoryType;
128 /** array of (possibly non-contiguous) pages */
129 TPhysAddr* iPageArray;
130 TInt iPageArrayCount;
132 /** list of contiguous pages */
133 TPageList* iPageList;
136 TInt iIndex; // Current memory fragment index
138 /** Represents the current read/write position in terms of an offset
139 from the start of the caller's linear address */
140 TInt iLenConsumed; // Offset from start of client buffer
142 DChunk* iChunk; // Shared chunk object in use
143 TInt iChunkOffset; // Offset within shared chunk
144 TUint32 iMapAttr; // mmu mapping attributes for the Shared chunk or pinned physical memory.
145 TUint32 iPhysAddr; // Physical Address of chunk (if contiguous)
147 TInt iLockCount; // Prevent 2+ threads accessing this object
149 TBool iPhysPinningAvailable; // True if physical memory pinning Kernel interface is available
150 TUint iPageColour; // Mapping colour of the first page in iPageArray.
151 TPhysicalPinObject* iPhysicalPinObject; // Physical pinning object.
156 #endif // DMASUPPORT_H