|
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 using System.IO; |
|
19 using System.Text; |
|
20 using System.Collections.Generic; |
|
21 using SymbianUtils; |
|
22 using SymbianUtils.Range; |
|
23 |
|
24 namespace SymbolLib.CodeSegDef |
|
25 { |
|
26 public class CodeSegDefinition : CodeSegResolverEntry |
|
27 { |
|
28 #region Enumerations |
|
29 [Flags] |
|
30 public enum TAttributes |
|
31 { |
|
32 EAttributeNone = 0, |
|
33 EAttributeXIP = 1, |
|
34 EAttributeRAM = 2, |
|
35 } |
|
36 #endregion |
|
37 |
|
38 #region Constructors & destructor |
|
39 public CodeSegDefinition() |
|
40 : this( string.Empty ) |
|
41 { |
|
42 } |
|
43 |
|
44 public CodeSegDefinition( string aFileName ) |
|
45 : this( aFileName, string.Empty ) |
|
46 { |
|
47 } |
|
48 |
|
49 public CodeSegDefinition( string aEnvFileName, string aImageFileName ) |
|
50 : base( aEnvFileName, aImageFileName ) |
|
51 { |
|
52 } |
|
53 #endregion |
|
54 |
|
55 #region Constants |
|
56 public const string KMapFileExtension = ".map"; |
|
57 public const string KSysBinPath = @"\sys\bin\"; |
|
58 public const string KROMBinaryPath = "z:" + KSysBinPath; |
|
59 #endregion |
|
60 |
|
61 #region API |
|
62 #endregion |
|
63 |
|
64 #region Properties |
|
65 public string MapFileName |
|
66 { |
|
67 get |
|
68 { |
|
69 string ret = string.Empty; |
|
70 // |
|
71 if ( !String.IsNullOrEmpty( EnvironmentFileNameAndPath ) ) |
|
72 { |
|
73 ret = EnvironmentFileNameAndPath + KMapFileExtension; |
|
74 } |
|
75 // |
|
76 return ret; |
|
77 } |
|
78 } |
|
79 |
|
80 public bool MapFileExists |
|
81 { |
|
82 get |
|
83 { |
|
84 bool ret = false; |
|
85 // |
|
86 try |
|
87 { |
|
88 string fileName = MapFileName; |
|
89 ret = File.Exists( fileName ); |
|
90 } |
|
91 finally |
|
92 { |
|
93 } |
|
94 // |
|
95 return ret; |
|
96 } |
|
97 } |
|
98 |
|
99 public bool AddressValid |
|
100 { |
|
101 get |
|
102 { |
|
103 bool good = iRange.IsValid; |
|
104 return good; |
|
105 } |
|
106 } |
|
107 |
|
108 public uint AddressStart |
|
109 { |
|
110 get { return (uint) iRange.Min; } |
|
111 set |
|
112 { |
|
113 iRange.UpdateMin( value ); |
|
114 UpdateAttributes(); |
|
115 } |
|
116 } |
|
117 |
|
118 public uint AddressEnd |
|
119 { |
|
120 get { return (uint) iRange.Max; } |
|
121 set |
|
122 { |
|
123 iRange.UpdateMax( value ); |
|
124 UpdateAttributes(); |
|
125 } |
|
126 } |
|
127 |
|
128 public uint Checksum |
|
129 { |
|
130 get { return iChecksum; } |
|
131 set { iChecksum = value; } |
|
132 } |
|
133 |
|
134 public AddressRange AddressRange |
|
135 { |
|
136 get { return iRange; } |
|
137 } |
|
138 |
|
139 public TAttributes Attributes |
|
140 { |
|
141 get { return iAttributes; } |
|
142 } |
|
143 #endregion |
|
144 |
|
145 #region From System.Object |
|
146 public override string ToString() |
|
147 { |
|
148 StringBuilder ret = new StringBuilder(); |
|
149 // |
|
150 ret.Append( iRange.ToString() ); |
|
151 ret.Append( " " ); |
|
152 ret.Append( base.ToString() ); |
|
153 // |
|
154 return ret.ToString(); |
|
155 } |
|
156 #endregion |
|
157 |
|
158 #region Internal methods |
|
159 private void UpdateAttributes() |
|
160 { |
|
161 // Remove XIP/RAM attrib before we work out the type... |
|
162 iAttributes &= ~TAttributes.EAttributeRAM; |
|
163 iAttributes &= ~TAttributes.EAttributeXIP; |
|
164 |
|
165 MemoryModel.TMemoryModelType type = MemoryModel.TypeByAddress( AddressStart ); |
|
166 if ( type != MemoryModel.TMemoryModelType.EMemoryModelUnknown ) |
|
167 { |
|
168 MemoryModel.TMemoryModelRegion region = MemoryModel.RegionByAddress( AddressStart, type ); |
|
169 // |
|
170 if ( region == MemoryModel.TMemoryModelRegion.EMemoryModelRegionROM ) |
|
171 { |
|
172 iAttributes |= TAttributes.EAttributeXIP; |
|
173 } |
|
174 else if ( region == MemoryModel.TMemoryModelRegion.EMemoryModelRegionRAMLoadedCode ) |
|
175 { |
|
176 iAttributes |= TAttributes.EAttributeRAM; |
|
177 } |
|
178 } |
|
179 } |
|
180 #endregion |
|
181 |
|
182 #region Data members |
|
183 private readonly AddressRange iRange = new AddressRange(); |
|
184 private uint iChecksum = 0; |
|
185 private TAttributes iAttributes = TAttributes.EAttributeNone; |
|
186 #endregion |
|
187 } |
|
188 } |