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