|
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.Collections.Generic; |
|
19 using System.Text; |
|
20 using System.IO; |
|
21 using SymbianStructuresLib.Version; |
|
22 |
|
23 namespace SymbianImageLib.ROM.Structures |
|
24 { |
|
25 internal class TRomHeader |
|
26 { |
|
27 #region Constructors |
|
28 #endregion |
|
29 |
|
30 #region API |
|
31 public void Read( BinaryReader aReader ) |
|
32 { |
|
33 aReader.BaseStream.Read( iJump, 0, iJump.Length ); |
|
34 iRestartVector = aReader.ReadUInt32(); |
|
35 iTime = aReader.ReadInt64(); |
|
36 iTimeHi = aReader.ReadUInt32(); |
|
37 iRomBase = aReader.ReadUInt32(); |
|
38 iRomSize = aReader.ReadUInt32(); |
|
39 |
|
40 iRomRootDirectoryList = aReader.ReadUInt32(); |
|
41 iKernDataAddress = aReader.ReadUInt32(); |
|
42 iKernelLimit = aReader.ReadUInt32(); |
|
43 iPrimaryFile = aReader.ReadUInt32(); |
|
44 iSecondaryFile = aReader.ReadUInt32(); |
|
45 iCheckSum = aReader.ReadUInt32(); |
|
46 |
|
47 // Print the checksum to aid debugging |
|
48 System.Diagnostics.Debug.WriteLine( string.Format( "[SIHeaderROM] checksum: 0x{0:x8}", iCheckSum ) ); |
|
49 |
|
50 iHardware = aReader.ReadUInt32(); |
|
51 |
|
52 iLanguage = aReader.ReadInt64(); |
|
53 |
|
54 iKernelConfigFlags = aReader.ReadUInt32(); |
|
55 iRomExceptionSearchTable = aReader.ReadUInt32(); |
|
56 iRomHeaderSize = aReader.ReadUInt32(); |
|
57 iRomSectionHeader = aReader.ReadUInt32(); |
|
58 |
|
59 iTotalSvDataSize = aReader.ReadInt32(); |
|
60 |
|
61 iVariantFile = aReader.ReadUInt32(); |
|
62 iExtensionFile = aReader.ReadUInt32(); |
|
63 iRelocInfo = aReader.ReadUInt32(); |
|
64 iOldTraceMask = aReader.ReadUInt32(); |
|
65 iUserDataAddress = aReader.ReadUInt32(); |
|
66 iTotalUserDataSize = aReader.ReadUInt32(); |
|
67 iDebugPort = aReader.ReadUInt32(); |
|
68 |
|
69 iVersion.Read( aReader ); |
|
70 |
|
71 iCompressionType = aReader.ReadUInt32(); |
|
72 iCompressedSize = aReader.ReadUInt32(); |
|
73 iUncompressedSize = aReader.ReadUInt32(); |
|
74 |
|
75 ReadUintArray( aReader, iDisabledCapabilities ); |
|
76 ReadUintArray( aReader, iTraceMask ); |
|
77 ReadUintArray( aReader, iInitialBTraceFilter ); |
|
78 |
|
79 iInitialBTraceBuffer = aReader.ReadInt32(); |
|
80 iInitialBTraceMode = aReader.ReadInt32(); |
|
81 iPageableRomStart = aReader.ReadInt32(); |
|
82 iPageableRomSize = aReader.ReadInt32(); |
|
83 iRomPageIndex = aReader.ReadInt32(); |
|
84 |
|
85 iDemandPagingConfig.Read( aReader ); |
|
86 |
|
87 ReadUintArray( aReader, iSpare ); |
|
88 } |
|
89 #endregion |
|
90 |
|
91 #region Properties |
|
92 public uint Size |
|
93 { |
|
94 get |
|
95 { |
|
96 return iRomHeaderSize; |
|
97 } |
|
98 } |
|
99 |
|
100 public uint RomBaseAddress |
|
101 { |
|
102 get { return iRomBase; } |
|
103 } |
|
104 |
|
105 public uint CompressedSize |
|
106 { |
|
107 get { return iCompressedSize; } |
|
108 } |
|
109 |
|
110 public uint UncompressedSize |
|
111 { |
|
112 get { return iUncompressedSize; } |
|
113 } |
|
114 |
|
115 public uint CompressionType |
|
116 { |
|
117 get { return iCompressionType; } |
|
118 } |
|
119 |
|
120 public int PageableRomStart |
|
121 { |
|
122 get { return iPageableRomStart; } |
|
123 } |
|
124 |
|
125 public int PageableRomSize |
|
126 { |
|
127 get { return iPageableRomSize; } |
|
128 } |
|
129 |
|
130 public uint RomPageIndex |
|
131 { |
|
132 get |
|
133 { |
|
134 return (uint) iRomPageIndex; |
|
135 } |
|
136 } |
|
137 #endregion |
|
138 |
|
139 #region Internal constants |
|
140 private const int KNumTraceMask = 8; |
|
141 #endregion |
|
142 |
|
143 #region Internal methods |
|
144 private void ReadUintArray( BinaryReader aReader, uint[] aArray ) |
|
145 { |
|
146 for ( int i = 0; i < aArray.Length; i++ ) |
|
147 { |
|
148 byte[] b = aReader.ReadBytes( 4 ); |
|
149 uint val = 0; |
|
150 // |
|
151 val += (uint) ( b[ 0 ] ); |
|
152 val += (uint) ( b[ 1 ] << 08 ); |
|
153 val += (uint) ( b[ 2 ] << 16 ); |
|
154 val += (uint) ( b[ 3 ] << 24 ); |
|
155 // |
|
156 aArray[ i ] = val; |
|
157 } |
|
158 } |
|
159 #endregion |
|
160 |
|
161 #region Data members |
|
162 private byte[] iJump = new byte[ 124 ]; |
|
163 private uint iRestartVector; |
|
164 private long iTime; |
|
165 private uint iTimeHi; |
|
166 |
|
167 // Default to the old moving memory model base address. |
|
168 private uint iRomBase = 0xf8000000; |
|
169 private uint iRomSize; |
|
170 private uint iRomRootDirectoryList; |
|
171 private uint iKernDataAddress; |
|
172 private uint iKernelLimit; |
|
173 private uint iPrimaryFile; |
|
174 private uint iSecondaryFile; |
|
175 private uint iCheckSum; |
|
176 private uint iHardware; |
|
177 private long iLanguage; |
|
178 private uint iKernelConfigFlags; |
|
179 private uint iRomExceptionSearchTable; |
|
180 private uint iRomHeaderSize; |
|
181 private uint iRomSectionHeader; |
|
182 private int iTotalSvDataSize; |
|
183 private uint iVariantFile; |
|
184 private uint iExtensionFile; |
|
185 private uint iRelocInfo; |
|
186 private uint iOldTraceMask; |
|
187 private uint iUserDataAddress; |
|
188 private uint iTotalUserDataSize; |
|
189 private uint iDebugPort; |
|
190 private TVersion iVersion = new TVersion(); |
|
191 private uint iCompressionType; |
|
192 private uint iCompressedSize; |
|
193 private uint iUncompressedSize; |
|
194 private uint[] iDisabledCapabilities = new uint[ 2 ]; |
|
195 private uint[] iTraceMask = new uint[ KNumTraceMask ]; |
|
196 private uint[] iInitialBTraceFilter = new uint[ 8 ]; |
|
197 private int iInitialBTraceBuffer; |
|
198 private int iInitialBTraceMode; |
|
199 private int iPageableRomStart; |
|
200 private int iPageableRomSize; |
|
201 private int iRomPageIndex; |
|
202 private SDemandPagingConfig iDemandPagingConfig = new SDemandPagingConfig(); |
|
203 private uint[] iSpare = new uint[ 40 ]; |
|
204 #endregion |
|
205 } |
|
206 } |