|
1 /* |
|
2 * Copyright (c) 2003-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 * Name : UdvmMemory.h |
|
16 * Part of : SigComp / UDVM |
|
17 * Interface : |
|
18 * UDVM memory/memory manipulation |
|
19 * Version : 1.0 |
|
20 * |
|
21 */ |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 /** |
|
27 @internalComponent |
|
28 */ |
|
29 |
|
30 |
|
31 #ifndef UDVMMEMORY_H |
|
32 #define UDVMMEMORY_H |
|
33 |
|
34 /** |
|
35 * Universal decompression virtual machine memory |
|
36 * |
|
37 * @lib sigcomp |
|
38 */ |
|
39 |
|
40 class CUdvmMemory : public CBase |
|
41 { |
|
42 public: // Constructors and destructor |
|
43 |
|
44 /** |
|
45 * @param aMemSize UDVM memory size in bytes |
|
46 */ |
|
47 |
|
48 static CUdvmMemory* NewL(TUint aMemSize); |
|
49 |
|
50 static CUdvmMemory* NewLC(TUint aMemSize); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 |
|
56 virtual ~CUdvmMemory(); |
|
57 |
|
58 |
|
59 public: // New functions |
|
60 |
|
61 /** |
|
62 * Write byte to UDVM memory. |
|
63 * Leave if out of memory bounds. |
|
64 * |
|
65 * @pre 0<=aDest<65536 |
|
66 * |
|
67 * @param aDest destination address in UDVM memory |
|
68 * @param aVal value, 8-bit significant |
|
69 * |
|
70 */ |
|
71 |
|
72 void WriteMem8L(TUint aDest, TUint aVal); |
|
73 |
|
74 |
|
75 /** |
|
76 * Write 16-bit word to UDVM memory. |
|
77 * Leave if out of memory bounds. |
|
78 * |
|
79 * @pre 0<=aDest<65536 |
|
80 * |
|
81 * @param aDest destination address in UDVM memory |
|
82 * @param aVal value, 16-bit significant |
|
83 * |
|
84 */ |
|
85 |
|
86 void WriteMem16L(TUint aDest, TUint aVal); |
|
87 |
|
88 |
|
89 /** |
|
90 * Read byte from UDVM memory. |
|
91 * Leave if out of memory bounds. |
|
92 * |
|
93 * @pre 0<=aSrc<65536 |
|
94 * |
|
95 * @param aSrc source address in UDVM memory |
|
96 * |
|
97 * @returns 8-bit value |
|
98 */ |
|
99 |
|
100 TUint8 ReadMem8L(TUint aSrc) const; |
|
101 |
|
102 |
|
103 /** |
|
104 * Read 16-bit word from UDVM memory. |
|
105 * Leave if out of memory bounds. |
|
106 * |
|
107 * @pre 0<=aSrc<65536 |
|
108 * |
|
109 * @param aSrc source address in UDVM memory |
|
110 * |
|
111 * @returns 16-bit value |
|
112 */ |
|
113 |
|
114 TUint16 ReadMem16L(TUint aSrc) const; |
|
115 |
|
116 |
|
117 /** |
|
118 * Set block of UDVM memory to value. |
|
119 * Leave if out of memory bounds. |
|
120 * |
|
121 * @pre 0<=aDest<65536 |
|
122 * |
|
123 * @param aDest destination address in UDVM memory |
|
124 * @param aVal value |
|
125 * @param aSize size of block |
|
126 * |
|
127 */ |
|
128 |
|
129 void SetMemL(TUint aDest, TUint8 aVal, TUint aSize); |
|
130 |
|
131 |
|
132 /** |
|
133 * Copy block of data to UDVM memory. |
|
134 * Leave if out of memory bounds. |
|
135 * |
|
136 * @pre 0<=aDest<65536 |
|
137 * |
|
138 * @param aDest destination address in UDVM memory |
|
139 * @param aSrc source address |
|
140 * @param aSize size of block |
|
141 * |
|
142 */ |
|
143 |
|
144 void CopyToMemL(TUint aDest, const TUint8* aSrc, TUint aSize); |
|
145 |
|
146 |
|
147 /** |
|
148 * Copy block of data from UDVM memory. |
|
149 * Leave if out of memory bounds. |
|
150 * |
|
151 * @pre 0<=aSrc<65536 |
|
152 * |
|
153 * @param aDest destination address |
|
154 * @param aSrc source address in UDVM memory |
|
155 * @param aSize size of block |
|
156 * |
|
157 */ |
|
158 |
|
159 void CopyFromMemL(TUint8* aDest, TUint aSrc, TUint aSize) const; |
|
160 |
|
161 /** |
|
162 * Initialize UDVM memory. |
|
163 * Leave if UDVM memory too small for message. |
|
164 * |
|
165 * @param aMsgSize size of message |
|
166 * |
|
167 */ |
|
168 void InitMemoryL(TUint aMsgSize, TUint aCyclesPerBit); |
|
169 |
|
170 /** |
|
171 * Get pointer to UDVM memory. |
|
172 * |
|
173 * @returns UDVM memory |
|
174 */ |
|
175 TUint8* MemoryPtr(); |
|
176 |
|
177 /** |
|
178 * Get size of UDVM memory |
|
179 * |
|
180 * @returns UDVM memory size |
|
181 */ |
|
182 TUint MemorySize() const; |
|
183 |
|
184 /** |
|
185 * Get size of free UDVM memory |
|
186 * |
|
187 * @returns UDVM free memory size |
|
188 */ |
|
189 TUint FreeMemorySize() const; |
|
190 |
|
191 |
|
192 /** |
|
193 * Check if access to UDVM memory is allowed. |
|
194 * |
|
195 * @param aAddr address of block in UDVM memory |
|
196 * @param aSize size of block that will be accessed. |
|
197 */ |
|
198 void CheckMemAccessL(TUint aAddr, TUint aSize) const; |
|
199 |
|
200 protected: |
|
201 |
|
202 /** |
|
203 * @param aMemSize UDVM memory size |
|
204 * @param aMsgSize sizeof incoming message |
|
205 */ |
|
206 |
|
207 void ConstructL(TUint aMemSize); |
|
208 |
|
209 |
|
210 private: |
|
211 CUdvmMemory(); |
|
212 |
|
213 private: // Data |
|
214 /** size of UDVM memory (up to 65536 bytes) */ |
|
215 TUint iMemSize; |
|
216 |
|
217 /** size of decompression memory */ |
|
218 TUint iFreeMemSize; |
|
219 |
|
220 /** total decompression memory (UDVM and buffered message) */ |
|
221 CArrayFixFlat<TUint8>* iMem; |
|
222 }; |
|
223 |
|
224 #endif |
|
225 |
|
226 // End of File |