author | Zheng Shen <zheng.shen@nokia.com> |
Tue, 17 Aug 2010 15:31:16 +0800 | |
changeset 626 | ac03b93ca9c4 |
parent 607 | 378360dbbdba |
child 647 | 53d1ab72f5bc |
permissions | -rw-r--r-- |
606 | 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 |
* @internalComponent * @released |
|
16 |
* OBY file reader and processing class Definition. |
|
17 |
* |
|
18 |
*/ |
|
19 |
||
20 |
||
21 |
#ifndef __R_OBEY_H__ |
|
22 |
#define __R_OBEY_H__ |
|
23 |
||
24 |
#define __REFERENCE_CAPABILITY_NAMES__ |
|
25 |
||
26 |
#include <stdio.h> |
|
27 |
#include <e32capability.h> |
|
28 |
#include <kernel/kernboot.h> |
|
29 |
#include "fatdefines.h" |
|
30 |
||
31 |
#include <vector> |
|
32 |
#include <map> |
|
33 |
#include <fstream> |
|
34 |
||
35 |
using namespace std; |
|
36 |
// |
|
37 |
const TUint32 KNumWords=16; |
|
38 |
// |
|
39 |
const TInt KDefaultRomSize=0x400000; |
|
40 |
const TInt KDefaultRomAlign=0x10; |
|
41 |
// |
|
42 |
typedef vector<string> StringVector ; |
|
43 |
typedef map<string, StringVector> KeywordMap; |
|
44 |
||
45 |
enum EKeyword |
|
46 |
{ |
|
47 |
EKeywordNone=0, // backwards compatibility, but now ignored |
|
48 |
EKeywordFile, |
|
49 |
EKeywordData, |
|
50 |
EKeywordDir, |
|
51 |
EKeywordRofsName, |
|
52 |
EKeywordExtensionRofs, |
|
53 |
EKeywordCoreRofsName, |
|
54 |
EKeywordRomSize, |
|
55 |
EKeywordAlias, |
|
56 |
EKeywordHide, |
|
57 |
EKeywordRename, |
|
58 |
EKeywordRofsSize, |
|
59 |
EKeywordRofsChecksum, |
|
60 |
EKeywordVersion, |
|
61 |
EKeywordTime, |
|
62 |
EKeywordRomChecksum, |
|
63 |
EKeywordTrace, |
|
64 |
EKeywordCoreImage, |
|
65 |
EKeywordRofsAutoSize, |
|
66 |
EKeywordFileCompress, |
|
67 |
EKeywordFileUncompress, |
|
68 |
EKeywordHideV2, |
|
69 |
EKeywordPatchDllData, |
|
70 |
EKeywordPagingOverride, |
|
71 |
EKeywordCodePagingOverride, |
|
72 |
EKeywordDataPagingOverride, |
|
73 |
// Added to support data drive images. |
|
74 |
EKeywordDataImageName, |
|
75 |
EKeywordDataImageFileSystem, |
|
76 |
EKeywordDataImageSize, |
|
77 |
EKeywordDataImageVolume, |
|
78 |
EKeywordDataImageSectorSize, |
|
626
ac03b93ca9c4
ROM Tools 12.3.4 + RCOMP 8.4.2
Zheng Shen <zheng.shen@nokia.com>
parents:
607
diff
changeset
|
79 |
EKeywordDataImageClusterSize, |
606 | 80 |
EKeywordDataImageNoOfFats, |
81 |
EKeywordSmrImageName, |
|
82 |
EKeywordSmrFileData, |
|
83 |
EKeywordSmrFormatVersion, |
|
84 |
EKeywordSmrFlags, |
|
85 |
EKeywordSmrUID |
|
86 |
||
87 |
}; |
|
88 |
||
89 |
enum EFileAttribute { |
|
90 |
EAttributeAtt, |
|
91 |
EAttributeAttExtra, |
|
92 |
// EAttributeCompress, |
|
93 |
EAttributeStack, |
|
94 |
EAttributeFixed, |
|
95 |
EAttributePriority, |
|
96 |
EAttributeUid1, |
|
97 |
EAttributeUid2, |
|
98 |
EAttributeUid3, |
|
99 |
EAttributeHeapMin, |
|
100 |
EAttributeHeapMax, |
|
101 |
EAttributeCapability, |
|
102 |
EAttributeUnpaged, |
|
103 |
EAttributePaged, |
|
104 |
EAttributeUnpagedCode, |
|
105 |
EAttributePagedCode, |
|
106 |
EAttributeUnpagedData, |
|
107 |
EAttributePagedData, |
|
108 |
}; |
|
109 |
||
110 |
#include "r_romnode.h" |
|
111 |
#include "r_rofs.h" |
|
112 |
||
113 |
class MRofsImage; |
|
114 |
||
115 |
struct ObeyFileKeyword |
|
116 |
{ |
|
117 |
const char* iKeyword; |
|
118 |
size_t iKeywordLength; |
|
119 |
TInt iPass; |
|
120 |
TInt iNumArgs; // -ve means >= number |
|
121 |
enum EKeyword iKeywordEnum; |
|
122 |
const char* iHelpText; |
|
123 |
}; |
|
124 |
||
125 |
struct FileAttributeKeyword |
|
126 |
{ |
|
127 |
const char* iKeyword; |
|
128 |
size_t iKeywordLength; |
|
129 |
TInt iIsFileAttribute; |
|
130 |
TInt iNumArgs; |
|
131 |
enum EFileAttribute iAttributeEnum; |
|
132 |
const char* iHelpText; |
|
133 |
}; |
|
134 |
||
135 |
class ObeyFileReader |
|
136 |
{ |
|
137 |
public: |
|
138 |
ObeyFileReader(const char *aFileName); |
|
139 |
~ObeyFileReader(); |
|
140 |
||
141 |
static void KeywordHelp(); |
|
142 |
||
143 |
TBool Open(); |
|
144 |
void Mark(); |
|
145 |
void MarkNext(); |
|
146 |
void Rewind(); |
|
147 |
||
148 |
TInt NextLine(TInt aPass, enum EKeyword& aKeyword); |
|
149 |
TInt NextAttribute(TInt& aIndex, TInt aHasFile, enum EFileAttribute& aKeyword, char*& aArg); |
|
150 |
||
151 |
char* DupWord(TInt aIndex) const; // allocate copy of nth word |
|
152 |
TInt Count() const { return iNumWords;} // number of words on current line |
|
153 |
const char* Word(TInt aIndex) const { return iWord[aIndex]; } // return nth word as char* |
|
154 |
const char* Suffix() const { return iSuffix; } // return unmatched suffix of word[0] |
|
155 |
TInt CurrentLine() const { return iCurrentLine;} // number of words on current line |
|
156 |
const char* GetCurrentObeyStatement() const {return iCurrentObeyStatement;} // return current obey statement |
|
157 |
||
158 |
void ProcessTime(TInt64& aTime); |
|
159 |
static void TimeNow(TInt64& aTime); |
|
160 |
private: |
|
161 |
TInt ReadAndParseLine(); |
|
162 |
TInt Parse(); |
|
163 |
inline static TBool IsGap(char ch) { |
|
164 |
return (ch==' ' || ch=='=' || ch=='\t'); |
|
165 |
} |
|
166 |
||
167 |
static const ObeyFileKeyword iKeywords[]; |
|
168 |
static const FileAttributeKeyword iAttributeKeywords[]; |
|
169 |
static TInt64 iTimeNow; |
|
170 |
||
171 |
private: |
|
172 |
TInt iCurrentLine; |
|
173 |
StringVector iLines ; |
|
174 |
string iFileName; |
|
175 |
TInt iNumWords; |
|
176 |
char* iLine; |
|
177 |
TInt iMarkLine ; |
|
178 |
char* iCurrentObeyStatement; |
|
179 |
char iSuffix[80]; |
|
180 |
char* iWord[KNumWords]; |
|
181 |
}; |
|
182 |
||
183 |
class CPatchDataProcessor; |
|
184 |
// Configurable FAT attributes |
|
185 |
||
186 |
||
187 |
class CObeyFile |
|
188 |
{ |
|
189 |
public: |
|
190 |
char* iRomFileName; |
|
191 |
char* iExtensionRofsName; |
|
192 |
char* iKernelRofsName; |
|
193 |
TInt iRomSize; |
|
194 |
TVersion iVersion; |
|
195 |
TUint32 iCheckSum; |
|
196 |
TInt iNumberOfFiles; |
|
197 |
TInt64 iTime; |
|
198 |
TRomNode* iRootDirectory; |
|
199 |
TInt iNumberOfDataFiles; |
|
200 |
// Added to support Data Drive Images. |
|
201 |
char* iDriveFileName; |
|
202 |
char* iDriveFileFormat; |
|
203 |
ConfigurableFatAttributes iConfigurableFatAttributes; |
|
204 |
||
205 |
private: |
|
206 |
ObeyFileReader& iReader; |
|
207 |
TInt iMissingFiles; |
|
208 |
TRomNode* iLastExecutable; |
|
209 |
||
210 |
TRomBuilderEntry* iFirstFile; |
|
211 |
TRomBuilderEntry** iNextFilePtrPtr; |
|
212 |
TRomBuilderEntry* iCurrentFile; |
|
213 |
KeywordMap iKeyValues; |
|
214 |
||
215 |
public: |
|
216 |
CObeyFile(ObeyFileReader& aReader); |
|
217 |
~CObeyFile(); |
|
218 |
void Release(); |
|
219 |
TInt ProcessRofs(); |
|
220 |
TInt ProcessExtensionRofs(MRofsImage* info); |
|
221 |
TInt ProcessDataDrive(); // Process the data drive obey file. |
|
222 |
TRomBuilderEntry *FirstFile(); |
|
223 |
TRomBuilderEntry *NextFile(); |
|
224 |
char* ProcessCoreImage() const; |
|
225 |
void SkipToExtension(); |
|
226 |
TBool AutoSize() const {return iAutoSize ;} |
|
227 |
TUint32 AutoPageSize() const {return iAutoPageSize;} |
|
228 |
TBool Process(); |
|
229 |
||
230 |
StringVector getValues(const string& aKey); |
|
231 |
||
232 |
private: |
|
233 |
TBool ProcessFile(TInt aAlign, enum EKeyword aKeyword); |
|
234 |
TBool ProcessDriveFile(enum EKeyword aKeyword); |
|
235 |
TBool ProcessRenaming(enum EKeyword aKeyword); |
|
236 |
TBool ProcessKeyword(enum EKeyword aKeyword); |
|
237 |
TBool ProcessDriveKeyword(enum EKeyword aKeyword); |
|
238 |
void ProcessExtensionKeyword(enum EKeyword aKeyword); |
|
239 |
TInt ParseFileAttributes(TRomNode* aNode, TRomBuilderEntry* aFile, enum EKeyword aKeyword); |
|
240 |
TInt ParseSection(); |
|
241 |
TBool ParsePatchDllData(); |
|
242 |
TBool GotKeyVariables(); |
|
243 |
TBool GotKeyDriveVariables(); // To check the data drive mandatory variables. |
|
244 |
TBool GotExtensionVariables(MRofsImage* aRom); |
|
245 |
void AddFile(TRomBuilderEntry* aFile); |
|
246 |
||
247 |
TInt SetStackSize(TRomNode* aNode, const char *aStr); |
|
248 |
TInt SetHeapSizeMin(TRomNode* aNode, const char *aStr); |
|
249 |
TInt SetHeapSizeMax(TRomNode* aNode, const char *aStr); |
|
250 |
TInt SetCapability(TRomNode* aNode, const char *aStr); |
|
251 |
TInt SetUid1(TRomNode* aNode, const char *aStr); |
|
252 |
TInt SetUid2(TRomNode* aNode, const char *aStr); |
|
253 |
TInt SetUid3(TRomNode* aNode, const char *aStr); |
|
254 |
TInt SetPriority(TRomNode* aNode, const char *aStr); |
|
255 |
||
256 |
static TBool GetNextBitOfFileName(char*& epocEndPtr); |
|
257 |
static const char *IsValidFilePath(const char *aPath); |
|
258 |
static const char* IsValidDirPath(const char* aPath); |
|
259 |
||
260 |
TBool iAutoSize; |
|
261 |
TUint32 iAutoPageSize; |
|
262 |
TBool iPagingOverrideParsed; |
|
263 |
TBool iCodePagingOverrideParsed; |
|
264 |
TBool iDataPagingOverrideParsed; |
|
265 |
public: |
|
266 |
CPatchDataProcessor* iPatchData; |
|
267 |
void SplitPatchDataStatement(StringVector& aPatchDataTokens); |
|
268 |
}; |
|
269 |
||
270 |
||
271 |
#endif |