0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32\include\drivers\dmasupport.h
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#ifndef DMASUPPORT_H
|
|
19 |
#define DMASUPPORT_H
|
|
20 |
|
|
21 |
#include "plat_priv.h"
|
|
22 |
#include <d32locd.h>
|
|
23 |
|
|
24 |
|
|
25 |
class TLocDrvRequest;
|
|
26 |
|
|
27 |
/**
|
|
28 |
@internalTechnology
|
|
29 |
@prototype
|
|
30 |
|
|
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.
|
|
33 |
*/
|
|
34 |
class DDmaHelper : public DBase
|
|
35 |
{
|
|
36 |
public:
|
|
37 |
|
|
38 |
enum TMemoryType
|
|
39 |
{
|
|
40 |
EUnknown,
|
|
41 |
EFileServerChunk,
|
|
42 |
ESharedChunk,
|
|
43 |
};
|
|
44 |
|
|
45 |
/**
|
|
46 |
Class used to describe a number of contiguous physical pages
|
|
47 |
*/
|
|
48 |
class TPageList
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
TPhysAddr iAddress; // address of page
|
|
52 |
TInt iLength;
|
|
53 |
};
|
|
54 |
|
|
55 |
public:
|
|
56 |
DDmaHelper();
|
|
57 |
~DDmaHelper();
|
|
58 |
|
|
59 |
TInt Construct(TInt aLength, TInt aMediaBlockSize, TInt aDmaAlignment);
|
|
60 |
|
|
61 |
TInt SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress);
|
|
62 |
TInt GetPhysicalAddress(TPhysAddr& aAddr, TInt& aLen);
|
|
63 |
|
|
64 |
#ifdef __DEMAND_PAGING__
|
|
65 |
static TInt GetPhysicalAddress(TLocDrvRequest& aReq, TPhysAddr& aAddr, TInt& aLen);
|
|
66 |
#endif
|
|
67 |
inline TInt PageSize() const { return iPageSize; }
|
|
68 |
|
|
69 |
private:
|
|
70 |
|
|
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);
|
|
75 |
|
|
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;
|
|
81 |
|
|
82 |
inline TBool IsDmaAligned(TLinAddr aAddr);
|
|
83 |
inline TBool IsBlockAligned(TInt64 aPos);
|
|
84 |
inline TInt64 BlockAlign(TInt64 aPos);
|
|
85 |
inline TInt BlockOffset(TInt64 aPos);
|
|
86 |
|
|
87 |
inline TLinAddr LinAddress() const;
|
|
88 |
|
|
89 |
void ResetPageLists();
|
|
90 |
|
|
91 |
TInt UpdateRemoteDescriptorLength(TInt aLength);
|
|
92 |
|
|
93 |
TInt RequestStart();
|
|
94 |
void RequestEnd();
|
|
95 |
void BuildPageList();
|
|
96 |
void ReleasePages(TLinAddr aAddr);
|
|
97 |
|
|
98 |
private:
|
|
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
|
|
102 |
|
|
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
|
|
107 |
|
|
108 |
DThread* iRemoteThread; //
|
|
109 |
DThread* iCurrentThread; //
|
|
110 |
DThread* iOwningThread; // Thread owning remote descriptor, either iRemoteThread or iCurrentThread
|
|
111 |
|
|
112 |
TLocDrvRequest* iReq; // Current TLocDrvRequest
|
|
113 |
|
|
114 |
// The following attributes are copied from the current TLocDrvRequest
|
|
115 |
TInt iReqId;
|
|
116 |
TInt iReqRemoteDesOffset;
|
|
117 |
TInt iReqFlags; //
|
|
118 |
TInt iReqLenClient; // length of data requested by client (unmodified)
|
|
119 |
TInt64 iReqPosClient; // position of data requested by client (unmodified)
|
|
120 |
|
|
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
|
|
125 |
|
|
126 |
TMemoryType iMemoryType;
|
|
127 |
|
|
128 |
/** array of (possibly non-contiguous) pages */
|
|
129 |
TPhysAddr* iPageArray;
|
|
130 |
TInt iPageArrayCount;
|
|
131 |
|
|
132 |
/** list of contiguous pages */
|
|
133 |
TPageList* iPageList;
|
|
134 |
TInt iPageListCount;
|
|
135 |
|
|
136 |
TInt iIndex; // Current memory fragment index
|
|
137 |
|
|
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
|
|
141 |
|
|
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)
|
|
146 |
|
|
147 |
TInt iLockCount; // Prevent 2+ threads accessing this object
|
|
148 |
|
|
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.
|
|
152 |
};
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
#endif // DMASUPPORT_H
|