sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Methods, data structures and constants common to Feature Registry Setup EXE
|
sl@0
|
15 |
// and Public API DLL, including private panic method.
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#ifndef FEATREGCMN_H
|
sl@0
|
20 |
#define FEATREGCMN_H
|
sl@0
|
21 |
|
sl@0
|
22 |
#include <e32std.h>
|
sl@0
|
23 |
#include <e32property.h>
|
sl@0
|
24 |
#include <f32file.h>
|
sl@0
|
25 |
#include <featregpan.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
_LIT(KFeatureConfigFile,"_:\\private\\102744CA\\featreg.cfg");
|
sl@0
|
28 |
typedef TBuf<32> TConfigFileName;
|
sl@0
|
29 |
|
sl@0
|
30 |
_LIT(KFeatRegSetupExe, "z:\\sys\\bin\\featregsetup.exe");
|
sl@0
|
31 |
|
sl@0
|
32 |
//match pattern when searching for the file
|
sl@0
|
33 |
//note that for core image the file will be featreg.cfg
|
sl@0
|
34 |
//and for other rofs section it will be in the format featreg.cfg[x-y]
|
sl@0
|
35 |
//whwere x is the rom image id and y is currently set to 0(unused)
|
sl@0
|
36 |
_LIT(KFeatregMatchPattern,"featreg.cfg*");
|
sl@0
|
37 |
_LIT(KFeatregRomPrivatePath,"z:\\private\\102744CA\\");
|
sl@0
|
38 |
|
sl@0
|
39 |
// feature registry data is currently kept in an RProperty with category and key:
|
sl@0
|
40 |
const TUid KFeaturePropCat = { 0x102744CA };
|
sl@0
|
41 |
const TUint KFeaturePropKey = 0;
|
sl@0
|
42 |
// if property with KFeaturePropCat and following key is defined, featregsetup.exe
|
sl@0
|
43 |
// looks for config info in its c: private data cage instead of z: (for tests only):
|
sl@0
|
44 |
const TUint KFeatRegConfigTestKey = 1;
|
sl@0
|
45 |
|
sl@0
|
46 |
/**
|
sl@0
|
47 |
This function will try to find and open all the "featreg.cfg" files from the path specified
|
sl@0
|
48 |
process them in the order of increasing rom image id before copying the aggregate content
|
sl@0
|
49 |
into the buffer aBuf
|
sl@0
|
50 |
*/
|
sl@0
|
51 |
GLREF_C TInt ReadMultipleFeatureFileToBuf(RFs& aFs,const TDesC& aPath,RBuf8& aBuf);
|
sl@0
|
52 |
|
sl@0
|
53 |
/**
|
sl@0
|
54 |
* First block of data in feature config file and resulting binary property:
|
sl@0
|
55 |
* says how many individual feature entries and "default-supported" ranges follow.
|
sl@0
|
56 |
* Config data is invalid if header is not present, or it does not predict size
|
sl@0
|
57 |
* of feature config file/property.
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
class TFeatureHeader
|
sl@0
|
60 |
{
|
sl@0
|
61 |
public:
|
sl@0
|
62 |
TUint32 iTypePrefix; // must be equal to validTypePrefix
|
sl@0
|
63 |
TUint32 iVersionNumber; // zero is the only valid version number
|
sl@0
|
64 |
TUint32 iFeatureEntryCount;
|
sl@0
|
65 |
TUint32 iFeatureRangeCount;
|
sl@0
|
66 |
|
sl@0
|
67 |
inline TUint32 PredictedPropertySize() const;
|
sl@0
|
68 |
inline void SetInvalid();
|
sl@0
|
69 |
inline TBool IsInvalid() const;
|
sl@0
|
70 |
inline TBool IsInvalidOrBadSize(TUint32 aActualPropertySize) const;
|
sl@0
|
71 |
};
|
sl@0
|
72 |
|
sl@0
|
73 |
// First 4 bytes of config file: ASCII f-e-a-t. Stored in TUint32 in little endian, i.e. reverse order
|
sl@0
|
74 |
const TUint32 validTypePrefix = 0x74616566;
|
sl@0
|
75 |
const TUint32 invalidTypePrefix = 0; // must not equal validTypePrefix
|
sl@0
|
76 |
|
sl@0
|
77 |
/**
|
sl@0
|
78 |
* Second block of data in feature config file and resulting binary property:
|
sl@0
|
79 |
* header.iFeatureEntryCount * TFeatureEntry
|
sl@0
|
80 |
* If a feature UID is listed, bits in its status word control the following:
|
sl@0
|
81 |
* - bit 0 (0x1): if set, feature is present, if not, feature is not present
|
sl@0
|
82 |
* - bit 1 (0x2): if set, feature is upgradable in this ROM configuration
|
sl@0
|
83 |
* - bits 2-31: reserved for future use & must be zero
|
sl@0
|
84 |
* Config data is invalid if these are not listed from lowest to highest UID with
|
sl@0
|
85 |
* no repeats.
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
struct TFeatureEntry
|
sl@0
|
88 |
{
|
sl@0
|
89 |
TUint32 iUid;
|
sl@0
|
90 |
TUint32 iInfo;
|
sl@0
|
91 |
};
|
sl@0
|
92 |
|
sl@0
|
93 |
/**
|
sl@0
|
94 |
* Third/last block of data in feature config file and resulting binary property:
|
sl@0
|
95 |
* header.iFeatureRangeCount * TFeatureRange
|
sl@0
|
96 |
* Features with UIDs in these "default-supported" ranges are supported unless
|
sl@0
|
97 |
* they are individually listed in the "entry" block as not supported.
|
sl@0
|
98 |
* Config data is invalid if any ranges have iLowUid higher than iHighUid.
|
sl@0
|
99 |
*/
|
sl@0
|
100 |
struct TFeatureRange
|
sl@0
|
101 |
{
|
sl@0
|
102 |
TUint32 iLowUid;
|
sl@0
|
103 |
TUint32 iHighUid;
|
sl@0
|
104 |
};
|
sl@0
|
105 |
|
sl@0
|
106 |
GLREF_C void Panic(TFeatRegPanic aReason);
|
sl@0
|
107 |
|
sl@0
|
108 |
|
sl@0
|
109 |
// ------------------------------------------------------------------------- //
|
sl@0
|
110 |
// Methods, data structures and constants common to Feature Registry Setup EXE
|
sl@0
|
111 |
// and Public API DLL, including private panic method.
|
sl@0
|
112 |
// ------------------------------------------------------------------------- //
|
sl@0
|
113 |
|
sl@0
|
114 |
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
Construct config file path for the system drive.
|
sl@0
|
117 |
@param aFileName On completion will contain the full path and filename.
|
sl@0
|
118 |
*/
|
sl@0
|
119 |
inline void GetSystemDrivePath(TConfigFileName& aFileName)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
aFileName.Copy(KFeatureConfigFile);
|
sl@0
|
122 |
aFileName[0] = 'A' + static_cast<TInt>(RFs::GetSystemDrive());
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
|
sl@0
|
126 |
|
sl@0
|
127 |
/** returns the total size of the property that is predicted by the counts
|
sl@0
|
128 |
in the header. Confirm !IsInvalid() before using otherwise numerical
|
sl@0
|
129 |
overflow may occur */
|
sl@0
|
130 |
inline TUint32 TFeatureHeader::PredictedPropertySize() const
|
sl@0
|
131 |
{
|
sl@0
|
132 |
return sizeof(TFeatureHeader) +
|
sl@0
|
133 |
+ iFeatureEntryCount * sizeof(TFeatureEntry)
|
sl@0
|
134 |
+ iFeatureRangeCount * sizeof(TFeatureRange);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
/** sets invalid values in the header that API will report as corrupt regardless
|
sl@0
|
138 |
of what data is provided with it */
|
sl@0
|
139 |
inline void TFeatureHeader::SetInvalid()
|
sl@0
|
140 |
{
|
sl@0
|
141 |
iTypePrefix = invalidTypePrefix;
|
sl@0
|
142 |
iVersionNumber = 1; // i.e. not zero
|
sl@0
|
143 |
// note total size of feature property may not exceed these constants,
|
sl@0
|
144 |
// so they are definitely invalid
|
sl@0
|
145 |
iFeatureEntryCount = RProperty::KMaxLargePropertySize + 1;
|
sl@0
|
146 |
iFeatureRangeCount = RProperty::KMaxLargePropertySize + 1;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
/** asks whether the header contains invalid values irrespective of data size
|
sl@0
|
150 |
See also IsInvalidOrBadSize() below */
|
sl@0
|
151 |
inline TBool TFeatureHeader::IsInvalid() const
|
sl@0
|
152 |
{
|
sl@0
|
153 |
// pretty safe to assume RProperty::KMaxLargePropertySize will not
|
sl@0
|
154 |
// ever be large enough to cause overflow problems
|
sl@0
|
155 |
return (iTypePrefix != validTypePrefix)
|
sl@0
|
156 |
|| (iVersionNumber != 0)
|
sl@0
|
157 |
|| (iFeatureEntryCount > RProperty::KMaxLargePropertySize)
|
sl@0
|
158 |
|| (iFeatureRangeCount > RProperty::KMaxLargePropertySize)
|
sl@0
|
159 |
|| (PredictedPropertySize() > RProperty::KMaxLargePropertySize);
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
/** asks whether aActualPropertySize is in the valid range, header is invalid or
|
sl@0
|
163 |
mismatch between property size predicted by the header and that supplied */
|
sl@0
|
164 |
inline TBool TFeatureHeader::IsInvalidOrBadSize(TUint32 aActualPropertySize) const
|
sl@0
|
165 |
{
|
sl@0
|
166 |
return (aActualPropertySize < sizeof(TFeatureHeader))
|
sl@0
|
167 |
|| (aActualPropertySize > RProperty::KMaxLargePropertySize)
|
sl@0
|
168 |
|| IsInvalid()
|
sl@0
|
169 |
|| (PredictedPropertySize() != aActualPropertySize);
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
|
sl@0
|
173 |
#endif
|