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