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