|
1 // Copyright (c) 2010 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 "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 |
|
15 #ifndef REMOTEFUNCTIONCALL_H_ |
|
16 #define REMOTEFUNCTIONCALL_H_ |
|
17 |
|
18 #include "serializerplatform.h" |
|
19 #include <string.h> |
|
20 class RemoteFunctionCall; |
|
21 |
|
22 class RemoteFunctionCallData |
|
23 { |
|
24 friend class SerializedFunctionCall; |
|
25 friend class RemoteFunctionCall; |
|
26 public: |
|
27 //Simple data copier |
|
28 SER_IMPORT_C static void CopyData( TUint8* aDest, const TUint8* aSource, TInt32 aSize ); |
|
29 SER_IMPORT_C static TInt AlignIndex( TInt aIndex, const TInt32 aAlignment ); |
|
30 |
|
31 public: |
|
32 //Max number of parameters |
|
33 enum |
|
34 { |
|
35 KMaxParameterCount = 34 |
|
36 }; |
|
37 |
|
38 //Operation type |
|
39 enum TOperationType |
|
40 { |
|
41 EOpRequest, |
|
42 EOpRequestWithReply, |
|
43 EOpReply |
|
44 }; |
|
45 |
|
46 //The direction of parameters |
|
47 enum TParamDirection |
|
48 { |
|
49 EIn = 1, |
|
50 EOut = 2, |
|
51 EInOut = 3 |
|
52 }; |
|
53 |
|
54 //Parameters of max 4 bytes of size |
|
55 class TSimpleParam |
|
56 { |
|
57 public: |
|
58 TUint32 Size() const; |
|
59 TInt32 iDataType; |
|
60 TUint32 iData; |
|
61 TInt8 iDataTypeSize; |
|
62 }; |
|
63 |
|
64 //Parameters with arbitrary size |
|
65 class TVectorParam |
|
66 { |
|
67 public: |
|
68 TUint32 Size( TParamDirection aDir, TOperationType aOpType, TInt aIndexToAlign ) const; |
|
69 TInt32 iDataTypeSize; |
|
70 TInt32 iDataType; |
|
71 TUint32 iVectorLength; |
|
72 TUint8* iCallerAddress; |
|
73 const TUint8* iData; |
|
74 TInt8 iDataTypeAlignment; |
|
75 }; |
|
76 |
|
77 //Parameter |
|
78 class TParam |
|
79 { |
|
80 public: |
|
81 enum TType |
|
82 { |
|
83 ESimple, |
|
84 EVector |
|
85 }; |
|
86 |
|
87 TUint32 Size( TOperationType aOpType, TInt aIndexToAlign = 0 ) const; |
|
88 |
|
89 //Data |
|
90 TParamDirection iDir; |
|
91 TParam::TType iType; |
|
92 union |
|
93 { |
|
94 TSimpleParam iSimpleParam; |
|
95 TVectorParam iVectorParam; |
|
96 }; |
|
97 }; |
|
98 |
|
99 //Function call header, common information about function call |
|
100 struct THeader |
|
101 { |
|
102 TInt32 iOpCode; |
|
103 TUint32 iTransactionId; |
|
104 TUint32 iProcessId; |
|
105 TUint32 iThreadId; |
|
106 TInt32 iParameterCount; |
|
107 TInt32 iOpType; |
|
108 TUint32 iReturnValue; |
|
109 TUint32 iApiUid; |
|
110 }; |
|
111 |
|
112 //Identifier for the call sequency |
|
113 SER_IMPORT_C void SetTransactionId( TUint32 aTransactionId ); |
|
114 |
|
115 //Operation type |
|
116 SER_IMPORT_C void SetOperationType( TInt32 aOpType ); |
|
117 |
|
118 //Return value |
|
119 SER_IMPORT_C void SetReturnValue( TUint32 aRetVal ); |
|
120 |
|
121 //General information about function call |
|
122 SER_IMPORT_C const THeader& Header() const; |
|
123 |
|
124 //Parameters |
|
125 SER_IMPORT_C TInt ParameterCount(); |
|
126 |
|
127 //Parameter array |
|
128 SER_IMPORT_C TParam* Parameters(); |
|
129 |
|
130 //Sets thread information for request |
|
131 SER_IMPORT_C void SetThreadInformation( const TUint32 aProcessId, const TUint32 aThreadId ); |
|
132 |
|
133 //Length of serialised function call |
|
134 SER_IMPORT_C TUint32 SerialisedLength() const; |
|
135 |
|
136 //Get pointer to vector data |
|
137 SER_IMPORT_C void GetVectorData( TInt32 aParamType, void** aData, TInt& aSize, TInt aIndex ); |
|
138 |
|
139 //Get parameter value |
|
140 SER_IMPORT_C void GetParamValue( TInt32 aParamType, TUint8* aData, TInt aIndex ); |
|
141 |
|
142 protected: |
|
143 //General information about function call |
|
144 THeader& HeaderData(); |
|
145 |
|
146 //Function information |
|
147 THeader iHeader; |
|
148 |
|
149 //Function parameters |
|
150 TParam iParameters[KMaxParameterCount]; |
|
151 }; |
|
152 |
|
153 //Remote function call |
|
154 // Represents a function call and contains information about |
|
155 // parameters but does not serialize the data |
|
156 class RemoteFunctionCall |
|
157 { |
|
158 public: |
|
159 SER_IMPORT_C RemoteFunctionCall( RemoteFunctionCallData& aData ); |
|
160 |
|
161 //Initialises this object |
|
162 SER_IMPORT_C void Init( TInt32 aOpCode, RemoteFunctionCallData::TOperationType aOpType = RemoteFunctionCallData::EOpRequestWithReply ); |
|
163 |
|
164 SER_IMPORT_C RemoteFunctionCallData& Data(); |
|
165 |
|
166 SER_IMPORT_C TUint32 ReturnValue(); |
|
167 |
|
168 SER_IMPORT_C void SetReturnValue( TUint32 aRetValue ); |
|
169 |
|
170 //Size of type aType |
|
171 virtual TInt GetTypeSize( TInt32 aParamType ) const = 0; |
|
172 |
|
173 //Alignemnt of type aType |
|
174 virtual TInt GetTypeAlignment( TInt32 aParamType ) const = 0; |
|
175 |
|
176 //Alignemnt of type aType |
|
177 virtual TUint32 GetAPIUid() const = 0; |
|
178 |
|
179 protected: |
|
180 SER_IMPORT_C void AppendParam( TInt32 aParamType, const TUint8* aData, RemoteFunctionCallData::TParamDirection aDir = RemoteFunctionCallData::EIn ); |
|
181 SER_IMPORT_C void AppendVector( TInt32 aParamType, TUint32 aLength, const TUint8* aData, RemoteFunctionCallData::TParamDirection aDir = RemoteFunctionCallData::EIn ); |
|
182 SER_IMPORT_C void SetParamData( TInt32 aParamType, const TUint8* aData, TInt aIndex ); |
|
183 SER_IMPORT_C void SetVectorData( TInt32 aParamType, const TUint8* aData, TInt aLength, TInt aIndex ); |
|
184 |
|
185 protected: |
|
186 RemoteFunctionCallData& iData; |
|
187 }; |
|
188 |
|
189 #endif |