crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianStructuresLib/MemoryModel/MMUtilities.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     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 SymbianStructuresLib.MemoryModel
       
    88 {
       
    89 	public static class MMUtilities
       
    90 	{
       
    91 		public static TMemoryModelType TypeByAddress( long aAddress )
       
    92 		{
       
    93 			// This is not a very good way of doing this. Should be 
       
    94 			// either a UI option or then something in the symbol file
       
    95 			// that we are reading...
       
    96 			TMemoryModelType ret = TMemoryModelType.EMemoryModelUnknown;
       
    97 			//
       
    98 			if ( aAddress >= 0xc8000000 && aAddress < 0xC8FFFFFF)
       
    99 			{
       
   100 				// Kernel global, Multiple Memory Model
       
   101 				ret = TMemoryModelType.EMemoryModelMultiple;
       
   102 			}
       
   103 			else if ( aAddress >= 0x80000000 && aAddress < 0x8FFFFFFF )
       
   104 			{
       
   105 				// ROM Symbol, Multiple Memory Model
       
   106 				ret = TMemoryModelType.EMemoryModelMultiple;
       
   107 			}
       
   108 			else if ( aAddress >= 0x3C000000 && aAddress < 0x3DFFFFFF )
       
   109 			{
       
   110 				// [1gb] RAM Symbol, Moving Memory Model
       
   111 				ret = TMemoryModelType.EMemoryModelMultiple;
       
   112 			}
       
   113 			else if ( aAddress >= 0x70000000 && aAddress < 0x7FFFFFFF )
       
   114 			{
       
   115 				// [2gb] RAM Symbol, Moving Memory Model
       
   116 				ret = TMemoryModelType.EMemoryModelMultiple;
       
   117 			}
       
   118             else if ( aAddress >= 0xF8000000 && aAddress < 0xFFEFFFFF )
       
   119             {
       
   120                 // ROM Symbol, Moving Memory Model
       
   121                 ret = TMemoryModelType.EMemoryModelMoving;
       
   122             }
       
   123             else if ( aAddress >= 0xF4000000 && aAddress < 0xF7FFFFFF )
       
   124             {
       
   125                 // RAM Symbol, Moving Memory Model
       
   126                 ret = TMemoryModelType.EMemoryModelMoving;
       
   127             }
       
   128             else if ( aAddress >= 0x64000000 && aAddress < 0x64FFFFFF )
       
   129             {
       
   130                 // Kernel global, Moving Memory Model
       
   131                 ret = TMemoryModelType.EMemoryModelMoving;
       
   132             }
       
   133 
       
   134 			return ret;
       
   135 		}
       
   136 
       
   137         public static TMemoryModelRegion RegionByAddress( long aAddress )
       
   138         {
       
   139             TMemoryModelRegion region = TMemoryModelRegion.EMemoryModelRegionUnknown;
       
   140             //
       
   141             TMemoryModelType type = TypeByAddress( aAddress );
       
   142             if ( type != TMemoryModelType.EMemoryModelUnknown )
       
   143             {
       
   144                 region = RegionByAddress( aAddress, type );
       
   145             }
       
   146             //
       
   147             return region;
       
   148         }
       
   149 
       
   150 		public static TMemoryModelRegion RegionByAddress( long aAddress, TMemoryModelType aType )
       
   151 		{
       
   152 			TMemoryModelRegion ret = TMemoryModelRegion.EMemoryModelRegionUnknown;
       
   153 			//
       
   154 			if	( aType == TMemoryModelType.EMemoryModelMoving )
       
   155 			{
       
   156 				#region Moving Memory Model
       
   157 				if	( aAddress >= 0x00000000 && aAddress < 0x003FFFFF )
       
   158 				{
       
   159 					// 00000000-003FFFFF	Unmapped
       
   160 					ret = TMemoryModelRegion.EMemoryModelRegionUnmapped;
       
   161 				}
       
   162 				else if ( aAddress >= 0x00400000 && aAddress < 0x2FFFFFFF )
       
   163 				{
       
   164 					// 00400000-2FFFFFFF	Moving process data
       
   165 					ret = TMemoryModelRegion.EMemoryModelRegionMovingProcessData;
       
   166 				}
       
   167 				else if ( aAddress >= 0x30000000 && aAddress < 0x3FFFFFFF )
       
   168 				{
       
   169 					// 30000000-3FFFFFFF	DLL static data (=phys ram size/2 up to 128M, always ends at 40000000)
       
   170 					ret = TMemoryModelRegion.EMemoryModelRegionDLLStaticData;
       
   171 				}
       
   172 				else if ( aAddress >= 0x40000000 && aAddress < 0x5FFFFFFF )
       
   173 				{
       
   174 					// 40000000-5FFFFFFF	RAM drive
       
   175 					ret = TMemoryModelRegion.EMemoryModelRegionRAMDrive;
       
   176 				}
       
   177 				else if ( aAddress >= 0x60000000 && aAddress < 0x60001FFF )
       
   178 				{
       
   179 					// 60000000-60001FFF	Super page/CPU page
       
   180 					ret = TMemoryModelRegion.EMemoryModelRegionSuperAndCPUPages;
       
   181 				}
       
   182 				else if ( aAddress >= 0x61000000 && aAddress < 0x61003FFF )
       
   183 				{
       
   184 					// 61000000-61003FFF	Page directory (16K)
       
   185 					ret = TMemoryModelRegion.EMemoryModelRegionPageDirectories;
       
   186 				}
       
   187 				else if ( aAddress >= 0x61020000 && aAddress < 0x6103FFFF )
       
   188 				{
       
   189 					// 61020000-6103FFFF	Page table info (4096 * 8bytes = 32K)
       
   190 					ret = TMemoryModelRegion.EMemoryModelRegionPageTableInfo;
       
   191 				}
       
   192 				else if ( aAddress >= 0x61100000 && aAddress < 0x611FFFFF )
       
   193 				{
       
   194 					// 61100000-611FFFFF	Cache flush area
       
   195 					ret = TMemoryModelRegion.EMemoryModelRegionCacheFlushArea;
       
   196 				}
       
   197 				else if ( aAddress >= 0x61200000 && aAddress < 0x612FFFFF )
       
   198 				{
       
   199 					// 61200000-612FFFFF	Alternate cache flush area
       
   200 					ret = TMemoryModelRegion.EMemoryModelRegionCacheFlushAreaAlternate;
       
   201 				}
       
   202 				else if ( aAddress >= 0x62000000 && aAddress < 0x623FFFFF )
       
   203 				{
       
   204 					// 62000000-623FFFFF	Page tables (up to 4096 * 1K)
       
   205 					ret = TMemoryModelRegion.EMemoryModelRegionPageTables;
       
   206 				}
       
   207 				else if ( aAddress >= 0x63000000 && aAddress < 0x63FFFFFF )
       
   208 				{
       
   209 					// 63000000-63FFFFFF	Primary I/O mappings
       
   210 					ret = TMemoryModelRegion.EMemoryModelRegionPrimaryIOMappings;
       
   211 				}
       
   212 				else if ( aAddress >= 0x64000000 && aAddress < 0x64FFFFFF )
       
   213 				{
       
   214 					// 64000000-64FFFFFF	Kernel .data/.bss, initial stack, kernel heap
       
   215 					ret = TMemoryModelRegion.EMemoryModelRegionKernelGlobalsInitialStackKernelHeap;
       
   216 				}
       
   217 				else if ( aAddress >= 0x65000000 && aAddress < 0x655FFFFF )
       
   218 				{
       
   219 					// 65000000-655FFFFF	fixed processes - usually 2 or 3Mb each.
       
   220 					ret = TMemoryModelRegion.EMemoryModelRegionFixedProcesses;
       
   221 				}
       
   222 				else if ( aAddress >= 0x65600000 && aAddress < 0xF1FFFFFF )
       
   223 				{
       
   224 					// 65600000-F1FFFFFF	Kernel section (includes extra I/O mappings)
       
   225 					ret = TMemoryModelRegion.EMemoryModelRegionExtraKernelMappings;
       
   226 				}
       
   227 				else if ( aAddress >= 0xF2000000 && aAddress < 0xF3FFFFFF )
       
   228 				{
       
   229 					// F2000000-F3FFFFFF	Kernel code (RAM size/2)
       
   230 					ret = TMemoryModelRegion.EMemoryModelRegionKernelCode;
       
   231 				}
       
   232 				else if ( aAddress >= 0xF4000000 && aAddress < 0xF7FFFFFF )
       
   233 				{
       
   234 					// F4000000-F7FFFFFF	User code (RAM size)
       
   235 					ret = TMemoryModelRegion.EMemoryModelRegionUserCode;
       
   236 				}
       
   237 				else if ( aAddress >= 0xF8000000 && aAddress < 0xFFEFFFFF )
       
   238 				{
       
   239 					// F8000000-FFEFFFFF	ROM
       
   240 					ret = TMemoryModelRegion.EMemoryModelRegionROM;
       
   241 				}
       
   242 				else if ( aAddress >= 0xFFF00000 && aAddress < 0xFFFFFFFF )
       
   243 				{
       
   244 					// FFF00000-FFFFFFFF	Exception vectors
       
   245 					ret = TMemoryModelRegion.EMemoryModelRegionExceptionVectors;
       
   246 				}
       
   247 				#endregion
       
   248 			}
       
   249 			else if ( aType == TMemoryModelType.EMemoryModelMultiple )
       
   250 			{
       
   251 				#region Multiple Memory Model
       
   252 				if	( aAddress >= 0x00000000 && aAddress < 0x003FFFFF )
       
   253 				{
       
   254 					// 00000000-003FFFFF	Unmapped
       
   255 					ret = TMemoryModelRegion.EMemoryModelRegionUnmapped;
       
   256 				}
       
   257 				else if ( aAddress >= 0x00400000 && aAddress < 0x6FFFFFFF )
       
   258 				{
       
   259 					// Skip overlapping 2gb vs 1gb regions
       
   260 					ret = TMemoryModelRegion.EMemoryModelRegionUnknown;
       
   261 				}
       
   262                 else if ( aAddress >= 0x70000000 && aAddress < 0x7FFFFFFF )
       
   263                 {
       
   264                     // 70000000-7FFFFFFF	RAM Loaded Code
       
   265                     ret = TMemoryModelRegion.EMemoryModelRegionRAMLoadedCode;
       
   266                 }
       
   267                 else if ( aAddress >= 0x80000000 && aAddress < 0x8FFFFFFF )
       
   268 				{
       
   269 					// 80000000-8FFFFFFF	ROM
       
   270 					ret = TMemoryModelRegion.EMemoryModelRegionROM;
       
   271 				}
       
   272 				else if ( aAddress >= 0x90000000 && aAddress < 0x9FFFFFFF )
       
   273 				{
       
   274 					// 90000000-9FFFFFFF	User Global Area
       
   275 					ret = TMemoryModelRegion.EMemoryModelRegionUserGlobalArea;
       
   276 				}
       
   277 				else if ( aAddress >= 0xA0000000 && aAddress < 0xBFFFFFFF )
       
   278 				{
       
   279 					// A0000000-BFFFFFFF	RAM drive
       
   280 					ret = TMemoryModelRegion.EMemoryModelRegionRAMDrive;
       
   281 				}
       
   282 				else if ( aAddress >= 0xC0000000 && aAddress < 0xC0001FFF )
       
   283 				{
       
   284 					// C0000000-C0001FFF	Super page/CPU page
       
   285 					ret = TMemoryModelRegion.EMemoryModelRegionSuperAndCPUPages;
       
   286 				}
       
   287 				else if ( aAddress >= 0xC0040000 && aAddress < 0xC00403FF )
       
   288 				{
       
   289 					// C0040000-C00403FF	ASID info (256 ASIDs)
       
   290 					ret = TMemoryModelRegion.EMemoryModelRegionASIDInfo;
       
   291 				}
       
   292 				else if ( aAddress >= 0xC0080000 && aAddress < 0xC00FFFFF )
       
   293 				{
       
   294 					// C0080000-C00FFFFF	Page table info	
       
   295 					ret = TMemoryModelRegion.EMemoryModelRegionPageTableInfo;
       
   296 				}
       
   297 				else if ( aAddress >= 0xC1000000 && aAddress < 0xC13FFFFF )
       
   298 				{
       
   299 					// C1000000-C13FFFFF	Page directories (up to 256 * 16KB)
       
   300 					ret = TMemoryModelRegion.EMemoryModelRegionPageDirectories;
       
   301 				}
       
   302 				else if ( aAddress >= 0xC2000000 && aAddress < 0xC5FFFFFF )
       
   303 				{
       
   304 					// C2000000-C5FFFFFF	Page tables
       
   305 					ret = TMemoryModelRegion.EMemoryModelRegionPageTables;
       
   306 				}
       
   307 				else if ( aAddress >= 0xC6000000 && aAddress < 0xC6FFFFFF )
       
   308 				{
       
   309 					// C6000000-C6FFFFFF	Primary I/O mappings
       
   310 					ret = TMemoryModelRegion.EMemoryModelRegionPrimaryIOMappings;
       
   311 				}
       
   312 				else if ( aAddress >= 0xC7000000 && aAddress < 0xC7FFFFFF )
       
   313 				{
       
   314 					// C7000000-C7FFFFFF
       
   315 					ret = TMemoryModelRegion.EMemoryModelRegionUnknown;
       
   316 				}
       
   317 				else if ( aAddress >= 0xC8000000 && aAddress < 0xC8FFFFFF )
       
   318 				{
       
   319 					// C8000000-C8FFFFFF	Kernel .data/.bss, initial stack, kernel heap
       
   320 					ret = TMemoryModelRegion.EMemoryModelRegionKernelGlobalsInitialStackKernelHeap;
       
   321 				}
       
   322 				else if ( aAddress >= 0xC9000000 && aAddress < 0xC91FFFFF )
       
   323 				{
       
   324 					// C9000000-C91FFFFF	Kernel stacks
       
   325 					ret = TMemoryModelRegion.EMemoryModelRegionKernelStacks;
       
   326 				}
       
   327 				else if ( aAddress >= 0xC9200000 && aAddress < 0xFFEFFFFF )
       
   328 				{
       
   329 					// C9200000-FFEFFFFF	Extra kernel mappings (I/O, RAM loaded device drivers)
       
   330 					ret = TMemoryModelRegion.EMemoryModelRegionExtraKernelMappings;
       
   331 				}
       
   332 				else if ( aAddress >= 0xFFF00000 && aAddress < 0xFFFFFFFF )
       
   333 				{
       
   334 					// FFF00000-FFFFFFFF	Exception vectors
       
   335 					ret = TMemoryModelRegion.EMemoryModelRegionExceptionVectors;
       
   336 				}
       
   337 				#endregion
       
   338 			}
       
   339 			//
       
   340 			return ret;
       
   341 		}
       
   342 	}
       
   343 }