|
1 /* |
|
2 * Copyright (c) 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 using System; |
|
18 |
|
19 #region MOVING MEMORY MODEL |
|
20 // 00000000-003FFFFF Unmapped |
|
21 // 00400000-2FFFFFFF Moving process data |
|
22 // 30000000-3FFFFFFF DLL static data (=phys ram size/2 up to 128M, always ends at 40000000) |
|
23 // 40000000-5FFFFFFF RAM drive |
|
24 // 60000000-60001FFF Super page/CPU page |
|
25 // 61000000-61003FFF Page directory (16K) |
|
26 // 61020000-6103FFFF Page table info (4096 * 8bytes = 32K) |
|
27 // 61100000-611FFFFF Cache flush area |
|
28 // 61200000-612FFFFF Alternate cache flush area |
|
29 // 62000000-623FFFFF Page tables (up to 4096 * 1K) |
|
30 // 63000000-63FFFFFF Primary I/O mappings |
|
31 // 64000000-64FFFFFF Kernel .data/.bss, initial stack, kernel heap |
|
32 // 65000000-655FFFFF fixed processes - usually 2 or 3Mb each. |
|
33 // 65600000-F1FFFFFF Kernel section (includes extra I/O mappings) |
|
34 // F2000000-F3FFFFFF Kernel code (RAM size/2) |
|
35 // F4000000-F7FFFFFF User code (RAM size) |
|
36 // F8000000-FFEFFFFF ROM |
|
37 // FFF00000-FFFFFFFF Exception vectors |
|
38 #endregion |
|
39 #region MULTIPLE MEMORY MODEL |
|
40 // Linear address map (1Gb configuration): |
|
41 // 00000000-003FFFFF Unmapped |
|
42 // 00400000-1FFFFFFF Local data |
|
43 // 20000000-3BFFFFFF Shared data |
|
44 // 3C000000-3DFFFFFF RAM loaded code (=phys ram size up to 256M) |
|
45 // 3E000000-3FFFFFFF DLL static data (=phys ram size/2 up to 128M) |
|
46 // 40000000-7FFFFFFF Unused |
|
47 // |
|
48 // 80000000-8FFFFFFF ROM |
|
49 // 90000000-9FFFFFFF User Global Area |
|
50 // A0000000-BFFFFFFF RAM drive |
|
51 // C0000000-C0001FFF Super page/CPU page |
|
52 // C0040000-C00403FF ASID info (256 ASIDs) |
|
53 // C0080000-C00FFFFF Page table info |
|
54 // C1000000-C13FFFFF Page directories (up to 256 * 16KB) |
|
55 // C2000000-C5FFFFFF Page tables |
|
56 // C6000000-C6FFFFFF Primary I/O mappings |
|
57 // C7000000-C7FFFFFF |
|
58 // C8000000-C8FFFFFF Kernel .data/.bss, initial stack, kernel heap |
|
59 // C9000000-C91FFFFF Kernel stacks |
|
60 // C9200000-FFEFFFFF Extra kernel mappings (I/O, RAM loaded device drivers) |
|
61 // FFF00000-FFFFFFFF Exception vectors |
|
62 // |
|
63 // |
|
64 // Linear address map (2Gb configuration): |
|
65 // 00000000-003FFFFF Unmapped |
|
66 // 00400000-37FFFFFF Local data |
|
67 // 38000000-3FFFFFFF DLL static data (=phys ram size/2 up to 128M) |
|
68 // 40000000-6FFFFFFF Shared data |
|
69 // 70000000-7FFFFFFF RAM loaded code (=phys ram size up to 256M) |
|
70 // |
|
71 // 80000000-8FFFFFFF ROM |
|
72 // 90000000-9FFFFFFF User Global Area |
|
73 // A0000000-BFFFFFFF RAM drive |
|
74 // C0000000-C0001FFF Super page/CPU page |
|
75 // C0040000-C00403FF ASID info (256 ASIDs) |
|
76 // C0080000-C00FFFFF Page table info |
|
77 // C1000000-C13FFFFF Page directories (up to 256 * 16KB) |
|
78 // C2000000-C5FFFFFF Page tables |
|
79 // C6000000-C6FFFFFF Primary I/O mappings |
|
80 // C7000000-C7FFFFFF |
|
81 // C8000000-C8FFFFFF Kernel .data/.bss, initial stack, kernel heap |
|
82 // C9000000-C91FFFFF Kernel stacks |
|
83 // C9200000-FFEFFFFF Extra kernel mappings (I/O, RAM loaded device drivers) |
|
84 // FFF00000-FFFFFFFF Exception vectors |
|
85 #endregion |
|
86 |
|
87 namespace SymbianUtils |
|
88 { |
|
89 public static class MemoryModel |
|
90 { |
|
91 #region Enumerations |
|
92 public enum TMemoryModelType |
|
93 { |
|
94 EMemoryModelUnknown = -1, |
|
95 EMemoryModelMoving = 0, |
|
96 EMemoryModelMultiple |
|
97 } |
|
98 |
|
99 public enum TMemoryModelRegion |
|
100 { |
|
101 // Common |
|
102 EMemoryModelRegionUnmapped = 0, |
|
103 EMemoryModelRegionDLLStaticData, |
|
104 EMemoryModelRegionRAMLoadedCode, |
|
105 EMemoryModelRegionROM, |
|
106 EMemoryModelRegionUserGlobalArea, |
|
107 EMemoryModelRegionRAMDrive, |
|
108 EMemoryModelRegionSuperAndCPUPages, |
|
109 EMemoryModelRegionPageTableInfo, |
|
110 EMemoryModelRegionPageDirectories, |
|
111 EMemoryModelRegionPageTables, |
|
112 EMemoryModelRegionPrimaryIOMappings, |
|
113 EMemoryModelRegionUnknown, |
|
114 EMemoryModelRegionKernelGlobalsInitialStackKernelHeap, |
|
115 EMemoryModelRegionExtraKernelMappings, |
|
116 EMemoryModelRegionExceptionVectors, |
|
117 |
|
118 // Moving |
|
119 EMemoryModelRegionMovingProcessData, |
|
120 EMemoryModelRegionCacheFlushArea, |
|
121 EMemoryModelRegionCacheFlushAreaAlternate, |
|
122 EMemoryModelRegionKernelCode, |
|
123 EMemoryModelRegionFixedProcesses, |
|
124 EMemoryModelRegionUserCode, |
|
125 |
|
126 // Multiple |
|
127 EMemoryModelRegionSharedData, |
|
128 EMemoryModelRegionLocalData, |
|
129 EMemoryModelRegionASIDInfo, |
|
130 EMemoryModelRegionKernelStacks, |
|
131 } |
|
132 #endregion |
|
133 |
|
134 #region API |
|
135 public static TMemoryModelType TypeByAddress( long aAddress ) |
|
136 { |
|
137 // This is not a very good way of doing this. Should be |
|
138 // either a UI option or then something in the symbol file |
|
139 // that we are reading... |
|
140 TMemoryModelType ret = TMemoryModelType.EMemoryModelUnknown; |
|
141 // |
|
142 if ( aAddress >= 0xc8000000 && aAddress < 0xC8FFFFFF) |
|
143 { |
|
144 // Kernel global, Multiple Memory Model |
|
145 ret = TMemoryModelType.EMemoryModelMultiple; |
|
146 } |
|
147 else if ( aAddress >= 0x80000000 && aAddress < 0x8FFFFFFF ) |
|
148 { |
|
149 // ROM Symbol, Multiple Memory Model |
|
150 ret = TMemoryModelType.EMemoryModelMultiple; |
|
151 } |
|
152 else if ( aAddress >= 0x3C000000 && aAddress < 0x3DFFFFFF ) |
|
153 { |
|
154 // [1gb] RAM Symbol, Moving Memory Model |
|
155 ret = TMemoryModelType.EMemoryModelMultiple; |
|
156 } |
|
157 else if ( aAddress >= 0x70000000 && aAddress < 0x7FFFFFFF ) |
|
158 { |
|
159 // [2gb] RAM Symbol, Moving Memory Model |
|
160 ret = TMemoryModelType.EMemoryModelMultiple; |
|
161 } |
|
162 else if ( aAddress >= 0xF8000000 && aAddress < 0xFFEFFFFF ) |
|
163 { |
|
164 // ROM Symbol, Moving Memory Model |
|
165 ret = TMemoryModelType.EMemoryModelMoving; |
|
166 } |
|
167 else if ( aAddress >= 0xF4000000 && aAddress < 0xF7FFFFFF ) |
|
168 { |
|
169 // RAM Symbol, Moving Memory Model |
|
170 ret = TMemoryModelType.EMemoryModelMoving; |
|
171 } |
|
172 else if ( aAddress >= 0x64000000 && aAddress < 0x64FFFFFF ) |
|
173 { |
|
174 // Kernel global, Moving Memory Model |
|
175 ret = TMemoryModelType.EMemoryModelMoving; |
|
176 } |
|
177 |
|
178 return ret; |
|
179 } |
|
180 |
|
181 public static TMemoryModelRegion RegionByAddress( long aAddress, TMemoryModelType aType ) |
|
182 { |
|
183 TMemoryModelRegion ret = TMemoryModelRegion.EMemoryModelRegionUnknown; |
|
184 // |
|
185 if ( aType == TMemoryModelType.EMemoryModelMoving ) |
|
186 { |
|
187 #region Moving Memory Model |
|
188 if ( aAddress >= 0x00000000 && aAddress < 0x003FFFFF ) |
|
189 { |
|
190 // 00000000-003FFFFF Unmapped |
|
191 ret = TMemoryModelRegion.EMemoryModelRegionUnmapped; |
|
192 } |
|
193 else if ( aAddress >= 0x00400000 && aAddress < 0x2FFFFFFF ) |
|
194 { |
|
195 // 00400000-2FFFFFFF Moving process data |
|
196 ret = TMemoryModelRegion.EMemoryModelRegionMovingProcessData; |
|
197 } |
|
198 else if ( aAddress >= 0x30000000 && aAddress < 0x3FFFFFFF ) |
|
199 { |
|
200 // 30000000-3FFFFFFF DLL static data (=phys ram size/2 up to 128M, always ends at 40000000) |
|
201 ret = TMemoryModelRegion.EMemoryModelRegionDLLStaticData; |
|
202 } |
|
203 else if ( aAddress >= 0x40000000 && aAddress < 0x5FFFFFFF ) |
|
204 { |
|
205 // 40000000-5FFFFFFF RAM drive |
|
206 ret = TMemoryModelRegion.EMemoryModelRegionRAMDrive; |
|
207 } |
|
208 else if ( aAddress >= 0x60000000 && aAddress < 0x60001FFF ) |
|
209 { |
|
210 // 60000000-60001FFF Super page/CPU page |
|
211 ret = TMemoryModelRegion.EMemoryModelRegionSuperAndCPUPages; |
|
212 } |
|
213 else if ( aAddress >= 0x61000000 && aAddress < 0x61003FFF ) |
|
214 { |
|
215 // 61000000-61003FFF Page directory (16K) |
|
216 ret = TMemoryModelRegion.EMemoryModelRegionPageDirectories; |
|
217 } |
|
218 else if ( aAddress >= 0x61020000 && aAddress < 0x6103FFFF ) |
|
219 { |
|
220 // 61020000-6103FFFF Page table info (4096 * 8bytes = 32K) |
|
221 ret = TMemoryModelRegion.EMemoryModelRegionPageTableInfo; |
|
222 } |
|
223 else if ( aAddress >= 0x61100000 && aAddress < 0x611FFFFF ) |
|
224 { |
|
225 // 61100000-611FFFFF Cache flush area |
|
226 ret = TMemoryModelRegion.EMemoryModelRegionCacheFlushArea; |
|
227 } |
|
228 else if ( aAddress >= 0x61200000 && aAddress < 0x612FFFFF ) |
|
229 { |
|
230 // 61200000-612FFFFF Alternate cache flush area |
|
231 ret = TMemoryModelRegion.EMemoryModelRegionCacheFlushAreaAlternate; |
|
232 } |
|
233 else if ( aAddress >= 0x62000000 && aAddress < 0x623FFFFF ) |
|
234 { |
|
235 // 62000000-623FFFFF Page tables (up to 4096 * 1K) |
|
236 ret = TMemoryModelRegion.EMemoryModelRegionPageTables; |
|
237 } |
|
238 else if ( aAddress >= 0x63000000 && aAddress < 0x63FFFFFF ) |
|
239 { |
|
240 // 63000000-63FFFFFF Primary I/O mappings |
|
241 ret = TMemoryModelRegion.EMemoryModelRegionPrimaryIOMappings; |
|
242 } |
|
243 else if ( aAddress >= 0x64000000 && aAddress < 0x64FFFFFF ) |
|
244 { |
|
245 // 64000000-64FFFFFF Kernel .data/.bss, initial stack, kernel heap |
|
246 ret = TMemoryModelRegion.EMemoryModelRegionKernelGlobalsInitialStackKernelHeap; |
|
247 } |
|
248 else if ( aAddress >= 0x65000000 && aAddress < 0x655FFFFF ) |
|
249 { |
|
250 // 65000000-655FFFFF fixed processes - usually 2 or 3Mb each. |
|
251 ret = TMemoryModelRegion.EMemoryModelRegionFixedProcesses; |
|
252 } |
|
253 else if ( aAddress >= 0x65600000 && aAddress < 0xF1FFFFFF ) |
|
254 { |
|
255 // 65600000-F1FFFFFF Kernel section (includes extra I/O mappings) |
|
256 ret = TMemoryModelRegion.EMemoryModelRegionExtraKernelMappings; |
|
257 } |
|
258 else if ( aAddress >= 0xF2000000 && aAddress < 0xF3FFFFFF ) |
|
259 { |
|
260 // F2000000-F3FFFFFF Kernel code (RAM size/2) |
|
261 ret = TMemoryModelRegion.EMemoryModelRegionKernelCode; |
|
262 } |
|
263 else if ( aAddress >= 0xF4000000 && aAddress < 0xF7FFFFFF ) |
|
264 { |
|
265 // F4000000-F7FFFFFF User code (RAM size) |
|
266 ret = TMemoryModelRegion.EMemoryModelRegionUserCode; |
|
267 } |
|
268 else if ( aAddress >= 0xF8000000 && aAddress < 0xFFEFFFFF ) |
|
269 { |
|
270 // F8000000-FFEFFFFF ROM |
|
271 ret = TMemoryModelRegion.EMemoryModelRegionROM; |
|
272 } |
|
273 else if ( aAddress >= 0xFFF00000 && aAddress < 0xFFFFFFFF ) |
|
274 { |
|
275 // FFF00000-FFFFFFFF Exception vectors |
|
276 ret = TMemoryModelRegion.EMemoryModelRegionExceptionVectors; |
|
277 } |
|
278 #endregion |
|
279 } |
|
280 else if ( aType == TMemoryModelType.EMemoryModelMultiple ) |
|
281 { |
|
282 #region Multiple Memory Model |
|
283 if ( aAddress >= 0x00000000 && aAddress < 0x003FFFFF ) |
|
284 { |
|
285 // 00000000-003FFFFF Unmapped |
|
286 ret = TMemoryModelRegion.EMemoryModelRegionUnmapped; |
|
287 } |
|
288 else if ( aAddress >= 0x00400000 && aAddress < 0x6FFFFFFF ) |
|
289 { |
|
290 // Skip overlapping 2gb vs 1gb regions |
|
291 ret = TMemoryModelRegion.EMemoryModelRegionUnknown; |
|
292 } |
|
293 else if ( aAddress >= 0x70000000 && aAddress < 0x7FFFFFFF ) |
|
294 { |
|
295 // 70000000-7FFFFFFF RAM Loaded Code |
|
296 ret = TMemoryModelRegion.EMemoryModelRegionRAMLoadedCode; |
|
297 } |
|
298 else if ( aAddress >= 0x80000000 && aAddress < 0x8FFFFFFF ) |
|
299 { |
|
300 // 80000000-8FFFFFFF ROM |
|
301 ret = TMemoryModelRegion.EMemoryModelRegionROM; |
|
302 } |
|
303 else if ( aAddress >= 0x90000000 && aAddress < 0x9FFFFFFF ) |
|
304 { |
|
305 // 90000000-9FFFFFFF User Global Area |
|
306 ret = TMemoryModelRegion.EMemoryModelRegionUserGlobalArea; |
|
307 } |
|
308 else if ( aAddress >= 0xA0000000 && aAddress < 0xBFFFFFFF ) |
|
309 { |
|
310 // A0000000-BFFFFFFF RAM drive |
|
311 ret = TMemoryModelRegion.EMemoryModelRegionRAMDrive; |
|
312 } |
|
313 else if ( aAddress >= 0xC0000000 && aAddress < 0xC0001FFF ) |
|
314 { |
|
315 // C0000000-C0001FFF Super page/CPU page |
|
316 ret = TMemoryModelRegion.EMemoryModelRegionSuperAndCPUPages; |
|
317 } |
|
318 else if ( aAddress >= 0xC0040000 && aAddress < 0xC00403FF ) |
|
319 { |
|
320 // C0040000-C00403FF ASID info (256 ASIDs) |
|
321 ret = TMemoryModelRegion.EMemoryModelRegionASIDInfo; |
|
322 } |
|
323 else if ( aAddress >= 0xC0080000 && aAddress < 0xC00FFFFF ) |
|
324 { |
|
325 // C0080000-C00FFFFF Page table info |
|
326 ret = TMemoryModelRegion.EMemoryModelRegionPageTableInfo; |
|
327 } |
|
328 else if ( aAddress >= 0xC1000000 && aAddress < 0xC13FFFFF ) |
|
329 { |
|
330 // C1000000-C13FFFFF Page directories (up to 256 * 16KB) |
|
331 ret = TMemoryModelRegion.EMemoryModelRegionPageDirectories; |
|
332 } |
|
333 else if ( aAddress >= 0xC2000000 && aAddress < 0xC5FFFFFF ) |
|
334 { |
|
335 // C2000000-C5FFFFFF Page tables |
|
336 ret = TMemoryModelRegion.EMemoryModelRegionPageTables; |
|
337 } |
|
338 else if ( aAddress >= 0xC6000000 && aAddress < 0xC6FFFFFF ) |
|
339 { |
|
340 // C6000000-C6FFFFFF Primary I/O mappings |
|
341 ret = TMemoryModelRegion.EMemoryModelRegionPrimaryIOMappings; |
|
342 } |
|
343 else if ( aAddress >= 0xC7000000 && aAddress < 0xC7FFFFFF ) |
|
344 { |
|
345 // C7000000-C7FFFFFF |
|
346 ret = TMemoryModelRegion.EMemoryModelRegionUnknown; |
|
347 } |
|
348 else if ( aAddress >= 0xC8000000 && aAddress < 0xC8FFFFFF ) |
|
349 { |
|
350 // C8000000-C8FFFFFF Kernel .data/.bss, initial stack, kernel heap |
|
351 ret = TMemoryModelRegion.EMemoryModelRegionKernelGlobalsInitialStackKernelHeap; |
|
352 } |
|
353 else if ( aAddress >= 0xC9000000 && aAddress < 0xC91FFFFF ) |
|
354 { |
|
355 // C9000000-C91FFFFF Kernel stacks |
|
356 ret = TMemoryModelRegion.EMemoryModelRegionKernelStacks; |
|
357 } |
|
358 else if ( aAddress >= 0xC9200000 && aAddress < 0xFFEFFFFF ) |
|
359 { |
|
360 // C9200000-FFEFFFFF Extra kernel mappings (I/O, RAM loaded device drivers) |
|
361 ret = TMemoryModelRegion.EMemoryModelRegionExtraKernelMappings; |
|
362 } |
|
363 else if ( aAddress >= 0xFFF00000 && aAddress < 0xFFFFFFFF ) |
|
364 { |
|
365 // FFF00000-FFFFFFFF Exception vectors |
|
366 ret = TMemoryModelRegion.EMemoryModelRegionExceptionVectors; |
|
367 } |
|
368 #endregion |
|
369 } |
|
370 // |
|
371 return ret; |
|
372 } |
|
373 #endregion |
|
374 } |
|
375 } |