|
1 /* |
|
2 * Copyright (c) 1995-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 the License "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 |
|
18 |
|
19 #define __REFERENCE_CAPABILITY_NAMES__ |
|
20 |
|
21 #include "e32image.h" |
|
22 #include <e32std.h> |
|
23 #include <e32std_private.h> |
|
24 #include <e32ver.h> |
|
25 #include <e32rom.h> |
|
26 #include <stdlib.h> |
|
27 #include <u32std.h> |
|
28 |
|
29 #include "r_rom.h" |
|
30 #include "r_global.h" |
|
31 #include "r_obey.h" |
|
32 #include "h_utl.h" |
|
33 |
|
34 inline char* RomToActualAddress(TLinAddr aRomAddr) |
|
35 { return (char*)(aRomAddr+TheRomMem-TheRomLinearAddress); } |
|
36 |
|
37 // |
|
38 void TRomLoaderHeader::SetUp(CObeyFile *aObey) |
|
39 // |
|
40 // Fill in the TRomLoaderHeader - this is used by the ROM loader / programmer. |
|
41 // |
|
42 { |
|
43 |
|
44 if (CPU==ECpuX86) |
|
45 _snprintf((char *)r.name,24,"%-16.16s%2x%2x%4x","EPOC486 ROM",aObey->iVersion.iMajor,aObey->iVersion.iMinor,aObey->iVersion.iBuild); |
|
46 else if (CPU==ECpuArmV4) |
|
47 _snprintf((char *)r.name,24,"%-16.16s%2x%2x%4x","EPOCARM4ROM",aObey->iVersion.iMajor,aObey->iVersion.iMinor,aObey->iVersion.iBuild); |
|
48 else if (CPU==ECpuArmV5) |
|
49 _snprintf((char *)r.name,24,"%-16.16s%2x%2x%4x","EPOCARM5ROM",aObey->iVersion.iMajor,aObey->iVersion.iMinor,aObey->iVersion.iBuild); |
|
50 else if (CPU==ECpuMCore) |
|
51 _snprintf((char *)r.name,24,"%-16.16s%2x%2x%4x","EPOCMCORROM",aObey->iVersion.iMajor,aObey->iVersion.iMinor,aObey->iVersion.iBuild); |
|
52 else |
|
53 _snprintf((char *)r.name,24,"%-16.16s%2x%2x%4x","EPOCUNKNOWN",aObey->iVersion.iMajor,aObey->iVersion.iMinor,aObey->iVersion.iBuild); |
|
54 r.romSize = aObey->iRomSize; |
|
55 r.wrapSize = KRomWrapperSize; |
|
56 for (TUint i=0; i<KFillSize; i++) |
|
57 filler[i] = 0; |
|
58 } |
|
59 // |
|
60 void ImpTRomHeader::SetUp(CObeyFile *aObey) |
|
61 // |
|
62 // Fill in the TRomHeader - this is used by the bootstrap and kernel. |
|
63 // |
|
64 { |
|
65 |
|
66 iVersion = aObey->iVersion; |
|
67 iTime = aObey->iTime; |
|
68 iTimeHi = (TUint32)(aObey->iTime>>32); |
|
69 iRomBase = aObey->iRomLinearBase; |
|
70 iRomSize = aObey->iRomSize; |
|
71 |
|
72 iKernDataAddress = aObey->iKernDataRunAddress; |
|
73 iKernelLimit = aObey->iKernelLimit; |
|
74 iPrimaryFile = TheRomHeader->iPrimaryFile; |
|
75 iSecondaryFile = TheRomHeader->iSecondaryFile; |
|
76 iLanguage=aObey->iLanguage; |
|
77 iHardware=aObey->iHardware; |
|
78 iRomHeaderSize=KRomHeaderSize; |
|
79 iRomSectionHeader=aObey->iSectionStart; |
|
80 TUint j; |
|
81 for (j=0; j<(TUint)KNumTraceMaskWords; j++) |
|
82 iTraceMask[j]=aObey->iTraceMask[j]; |
|
83 for (j=0; j<sizeof(iInitialBTraceFilter)/sizeof(TUint32); j++) |
|
84 iInitialBTraceFilter[j]=aObey->iInitialBTraceFilter[j]; |
|
85 iInitialBTraceMode = aObey->iInitialBTraceMode; |
|
86 iInitialBTraceBuffer = aObey->iInitialBTraceBuffer; |
|
87 iDebugPort=aObey->iDebugPort; |
|
88 iKernelConfigFlags=aObey->iKernelConfigFlags; |
|
89 for(TInt i=0; i<SCapabilitySet::ENCapW; i++) |
|
90 iDisabledCapabilities[i]=aObey->iPlatSecDisabledCaps[i]; |
|
91 } |
|
92 |
|
93 void ImpTRomHeader::CheckSum(TUint32 aTargetValue) |
|
94 { |
|
95 iCheckSum=0; |
|
96 iCheckSum=aTargetValue-(HMem::CheckSum((TUint *)(TRomHeader *)this, iRomSize)); |
|
97 } |
|
98 |
|
99 |
|
100 void DisplayExceptionTable(TLinAddr aRomExcTab) |
|
101 { |
|
102 Print(ELog,"Rom Exception Search Table Address: %08x\n",aRomExcTab); |
|
103 TRomExceptionSearchTable* pT=(TRomExceptionSearchTable*)RomToActualAddress(aRomExcTab); |
|
104 Print(ELog,"Rom Exception Search Table contains %d entries:\n",pT->iNumEntries); |
|
105 |
|
106 Print(ELog,"CodeAddr\tCd + Data\tidx size\tNum Ents\t Shorts \n"); |
|
107 Print(ELog,"========\t=========\t========\t========\t========\n"); |
|
108 TInt i; |
|
109 for (i=0; i<pT->iNumEntries; i++) |
|
110 { |
|
111 TRomImageHeader* pE = (TRomImageHeader *)RomToActualAddress(pT->iEntries[i]); |
|
112 TRomImageHeader* pH = pE - 1; |
|
113 const TExceptionDescriptor* pX = (const TExceptionDescriptor*)RomToActualAddress(pH->iExceptionDescriptor); |
|
114 if (!pX) |
|
115 continue; |
|
116 TUint32 indexTableSize = (char *)pX->iExIdxLimit - (char *)pX->iExIdxBase; |
|
117 struct IndexTableEntry { TUint32 aPc; TInt aVal; }; |
|
118 struct IndexTableEntry* aExIdxBase = (struct IndexTableEntry *)RomToActualAddress(pX->iExIdxBase); |
|
119 struct IndexTableEntry* aExIdxLimit = (struct IndexTableEntry *)RomToActualAddress(pX->iExIdxLimit); |
|
120 TUint32 numIndexTableEntries = aExIdxLimit - aExIdxBase; |
|
121 TUint32 numShortEntries = 0; |
|
122 // Short entries have top bit set. |
|
123 for(; aExIdxBase < aExIdxLimit; aExIdxBase++) |
|
124 if (aExIdxBase->aVal == 1 || aExIdxBase->aVal < 0) |
|
125 numShortEntries++; |
|
126 |
|
127 Print(ELog,"%08x\t%08d\t%08d\t%08d\t%08d\n", |
|
128 pT->iEntries[i], |
|
129 pH->iCodeSize+pH->iDataSize, |
|
130 indexTableSize, |
|
131 numIndexTableEntries, |
|
132 numShortEntries); |
|
133 } |
|
134 Print(ELog,"\nROM EST fencepost = %08x\n", pT->iEntries[pT->iNumEntries]); |
|
135 } |
|
136 |
|
137 |
|
138 // |
|
139 void ImpTRomHeader::Display() |
|
140 // |
|
141 // Display info from ROM header |
|
142 // |
|
143 { |
|
144 TInt i; |
|
145 |
|
146 Print(ELog,"\n\nDevelopment configuration settings:\n"); |
|
147 TUint j; |
|
148 for (j=0; j<(TUint)KNumTraceMaskWords; j++) |
|
149 Print(ELog,"TraceMask[%d]: %08x\n",j, iTraceMask[j]); |
|
150 for (j=0; j<sizeof(iInitialBTraceFilter)/sizeof(TUint32); j++) |
|
151 Print(ELog,"BTrace[%d]: %08x\n",j, iInitialBTraceFilter[j]); |
|
152 Print(ELog,"BTraceMode: %08x\n",iInitialBTraceMode); |
|
153 Print(ELog,"BTraceBuffer: %08x\n",iInitialBTraceBuffer); |
|
154 Print(ELog,"DebugPort: %08x\n",iDebugPort); |
|
155 Print(ELog,"KernelConfigFlags: %08x\n",iKernelConfigFlags); |
|
156 Print(ELog,"PlatSecDiagnostics: %s\n",iKernelConfigFlags&EKernelConfigPlatSecDiagnostics ? "ON":"OFF"); |
|
157 Print(ELog,"PlatSecEnforcement: %s\n",iKernelConfigFlags&EKernelConfigPlatSecEnforcement ? "ON":"OFF"); |
|
158 Print(ELog,"PlatSecProcessIsolation: %s\n",iKernelConfigFlags&EKernelConfigPlatSecProcessIsolation ? "ON":"OFF"); |
|
159 Print(ELog,"PlatSecEnforceSysBin: %s\n",iKernelConfigFlags&EKernelConfigPlatSecEnforceSysBin ? "ON":"OFF"); |
|
160 const char* pagingPolicy =0; |
|
161 switch(iKernelConfigFlags&EKernelConfigCodePagingPolicyMask) |
|
162 { |
|
163 case EKernelConfigCodePagingPolicyNoPaging: |
|
164 pagingPolicy = "NoPaging"; |
|
165 break; |
|
166 case EKernelConfigCodePagingPolicyAlwaysPage: |
|
167 pagingPolicy = "AlwaysPage"; |
|
168 break; |
|
169 case EKernelConfigCodePagingPolicyDefaultUnpaged: |
|
170 pagingPolicy = "DefaultUnpaged"; |
|
171 break; |
|
172 case EKernelConfigCodePagingPolicyDefaultPaged: |
|
173 pagingPolicy = "DefaultPaged"; |
|
174 break; |
|
175 } |
|
176 Print(ELog,"CodePagingPolicy: %s\n",pagingPolicy); |
|
177 switch(iKernelConfigFlags&EKernelConfigDataPagingPolicyMask) |
|
178 { |
|
179 case EKernelConfigDataPagingPolicyNoPaging: |
|
180 pagingPolicy = "NoPaging"; |
|
181 break; |
|
182 case EKernelConfigDataPagingPolicyAlwaysPage: |
|
183 pagingPolicy = "AlwaysPage"; |
|
184 break; |
|
185 case EKernelConfigDataPagingPolicyDefaultUnpaged: |
|
186 pagingPolicy = "DefaultUnpaged"; |
|
187 break; |
|
188 case EKernelConfigDataPagingPolicyDefaultPaged: |
|
189 pagingPolicy = "DefaultPaged"; |
|
190 break; |
|
191 } |
|
192 Print(ELog,"DataPagingPolicy: %s\n",pagingPolicy); |
|
193 Print(ELog,"PlatSecDisabledCaps: "); |
|
194 TBool all=ETrue; |
|
195 TBool none=ETrue; |
|
196 for(i=0; i<ECapability_Limit; i++) |
|
197 if(CapabilityNames[i]) |
|
198 { |
|
199 if(iDisabledCapabilities[i>>5] & (1<<(i&31))) |
|
200 none = EFalse; |
|
201 else |
|
202 all = EFalse; |
|
203 } |
|
204 if(none) |
|
205 Print(ELog,"NONE"); |
|
206 else if(all) |
|
207 Print(ELog,"ALL"); |
|
208 else |
|
209 for(i=0; i<ECapability_Limit; i++) |
|
210 if(iDisabledCapabilities[i>>5] & (1<<(i&31))) |
|
211 Print(ELog,"%s ",CapabilityNames[i]); |
|
212 Print(ELog,"\n"); |
|
213 |
|
214 Print(ELog,"\n\nRom details:\n"); |
|
215 Print(ELog,"Version %d.%02d(%03d)\n", iVersion.iMajor, iVersion.iMinor, iVersion.iBuild); |
|
216 Print(ELog,"Hardware version: %08x\n",iHardware); |
|
217 Print(ELog,"Language Support: %08x%08x\n",TUint32(iLanguage>>32),TUint32(iLanguage)); |
|
218 Print(ELog,"Linear base address: %08x\n",iRomBase); |
|
219 Print(ELog,"Size: %08x\n",iRomSize); |
|
220 Print(ELog,"Root directory list: %08x\n",iRomRootDirectoryList); |
|
221 Print(ELog,"Kernel data address: %08x\n",iKernDataAddress); |
|
222 Print(ELog,"Kernel limit: %08x\n",iKernelLimit); |
|
223 Print(ELog,"Primary file address: %08x\n",iPrimaryFile); |
|
224 Print(ELog,"Secondary file address: %08x\n",iSecondaryFile); |
|
225 Print(ELog,"First variant address: %08x\n",iVariantFile); |
|
226 Print(ELog,"First extension address: %08x\n",iExtensionFile); |
|
227 Print(ELog,"Pageable ROM offset: %08x\n",iPageableRomStart); |
|
228 Print(ELog,"Pageable ROM size: %08x\n",iPageableRomSize); |
|
229 Print(ELog,"ROM page index offset: %08x\n",iRomPageIndex); |
|
230 Print(ELog,"Demand Paging Config: minPages=%d maxPages=%d ageRatio=%d spare[0..2]=%d,%d,%d \n",iDemandPagingConfig.iMinPages,iDemandPagingConfig.iMaxPages,iDemandPagingConfig.iYoungOldRatio,iDemandPagingConfig.iSpare[0],iDemandPagingConfig.iSpare[1],iDemandPagingConfig.iSpare[2]); |
|
231 Print(ELog,"Checksum word: %08x\n",iCheckSum); |
|
232 Print(ELog,"TotalSvDataSize: %08x\n",iTotalSvDataSize); |
|
233 Print(ELog,"User data address: %08x\n",iUserDataAddress); |
|
234 Print(ELog,"TotalUserDataSize: %08x\n",iTotalUserDataSize); |
|
235 Print(ELog,"Relocation Info Address: %08x\n",iRelocInfo); |
|
236 if(iRelocInfo) |
|
237 { |
|
238 TReloc* reloc=(TReloc*)RomToActualAddress(iRelocInfo); |
|
239 while(reloc->iLength) |
|
240 { |
|
241 Print(ELog," Src %08x Dest %08x Length %08x\n", |
|
242 reloc->iSrc, reloc->iDest, reloc->iLength); |
|
243 reloc++; |
|
244 } |
|
245 } |
|
246 |
|
247 TRomRootDirectoryList* pR=(TRomRootDirectoryList*)RomToActualAddress(iRomRootDirectoryList); |
|
248 Print(ELog,"\nRoot directories:\n"); |
|
249 for (i=0; i<pR->iNumRootDirs; i++) |
|
250 { |
|
251 Print(ELog,"Directory %2d %08x %08x\n",i,pR->iRootDir[i].iHardwareVariant,pR->iRootDir[i].iAddressLin); |
|
252 } |
|
253 if (iRomExceptionSearchTable) |
|
254 { |
|
255 if(!iPageableRomSize) // Don't do this for Paged ROMs because of page compression |
|
256 DisplayExceptionTable(iRomExceptionSearchTable); |
|
257 } |
|
258 } |
|
259 // |
|
260 |
|
261 void E32Rom::FinaliseSectionHeader() |
|
262 // |
|
263 // Fill in the section header |
|
264 // |
|
265 { |
|
266 |
|
267 if (iHeader->iRomSectionHeader) |
|
268 { |
|
269 // Set up the section header |
|
270 TRomSectionHeader *header=(TRomSectionHeader *)RomToActualAddress(iHeader->iRomSectionHeader); |
|
271 header->iVersion=iHeader->iVersion; |
|
272 header->iTime=iHeader->iTime; |
|
273 header->iLanguage=iHeader->iLanguage; |
|
274 header->iCheckSum=0; |
|
275 header->iCheckSum=0-HMem::CheckSum((TUint *)header, iHeader->iRomSize-(iHeader->iRomSectionHeader-iHeader->iRomBase)); |
|
276 } |
|
277 } |
|
278 |
|
279 // |
|
280 void E32Rom::FinaliseExtensionHeader(MRomImage* aKernelRom) |
|
281 { |
|
282 TExtensionRomHeader* header = (TExtensionRomHeader*)iHeader; |
|
283 |
|
284 header->iVersion = iObey->iVersion; |
|
285 header->iTime = iObey->iTime; |
|
286 header->iRomBase = iObey->iRomLinearBase; |
|
287 header->iRomSize = iObey->iRomSize; |
|
288 |
|
289 header->iKernelVersion = aKernelRom->Version(); |
|
290 header->iKernelTime = aKernelRom->Time(); |
|
291 header->iKernelCheckSum = aKernelRom->CheckSum(); |
|
292 |
|
293 header->iCheckSum=0; |
|
294 header->iCheckSum=0-HMem::CheckSum((TUint *)header, iObey->iRomSize); |
|
295 } |
|
296 |
|
297 void E32Rom::DisplayExtensionHeader() |
|
298 // |
|
299 // Display info from extension ROM header |
|
300 // |
|
301 { |
|
302 |
|
303 TExtensionRomHeader* header = (TExtensionRomHeader*)iHeader; |
|
304 |
|
305 TVersion version = header->iVersion; |
|
306 Print(ELog,"\n\nExtension Rom details:\n"); |
|
307 Print(ELog,"Version %d.%02d(%03d) ", version.iMajor, version.iMinor, version.iBuild); |
|
308 version = header->iKernelVersion; |
|
309 Print(ELog,"(Kernel %d.%02d(%03d))\n", version.iMajor, version.iMinor, version.iBuild); |
|
310 Print(ELog,"Linear base address: %08x\n",header->iRomBase); |
|
311 Print(ELog,"Size: %08x\n",header->iRomSize); |
|
312 Print(ELog,"Root directory list: %08x\n",header->iRomRootDirectoryList); |
|
313 Print(ELog,"Checksum word: %08x (Kernel %08x)\n",header->iCheckSum, header->iKernelCheckSum); |
|
314 Print(ELog,"Exception Search Table: %08x\n", header->iRomExceptionSearchTable); |
|
315 |
|
316 if (header->iRomExceptionSearchTable) |
|
317 { |
|
318 DisplayExceptionTable(header->iRomExceptionSearchTable); |
|
319 } |
|
320 |
|
321 TRomRootDirectoryList* pR=(TRomRootDirectoryList*)RomToActualAddress(header->iRomRootDirectoryList); |
|
322 Print(ELog,"\nRoot directories:\n"); |
|
323 TInt i; |
|
324 for (i=0; i<pR->iNumRootDirs; i++) |
|
325 { |
|
326 Print(ELog,"Directory %2d %08x %08x\n",i,pR->iRootDir[i].iHardwareVariant,pR->iRootDir[i].iAddressLin); |
|
327 } |
|
328 Print(ELog, "\n"); |
|
329 } |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |