sl@0
|
1 |
// Copyright (c) 2008-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 the License "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 |
// Hardware Configuration Respoitory Platform Independent Layer (PIL)
|
sl@0
|
15 |
// Contains the hardware abstraction interface implemented in the variant PSL
|
sl@0
|
16 |
// HCR kernel extension project.
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file hcr_hai.h
|
sl@0
|
21 |
Kernel side definitions for the HCR Symbian Hardware Abstraction
|
sl@0
|
22 |
Interface (SHAI) for variants to implement when creating a HCR.dll binary.
|
sl@0
|
23 |
|
sl@0
|
24 |
@publishedPartner
|
sl@0
|
25 |
@prototype
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
|
sl@0
|
28 |
#ifndef HCR_HAI_H
|
sl@0
|
29 |
#define HCR_HAI_H
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
// -- INCLUDES ----------------------------------------------------------------
|
sl@0
|
33 |
|
sl@0
|
34 |
|
sl@0
|
35 |
#include <e32def.h>
|
sl@0
|
36 |
#include <e32err.h>
|
sl@0
|
37 |
|
sl@0
|
38 |
#include <drivers/hcr.h>
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
// -- CLASSES -----------------------------------------------------------------
|
sl@0
|
42 |
|
sl@0
|
43 |
|
sl@0
|
44 |
/**
|
sl@0
|
45 |
The HCR namespace contains all the types and classes that make up the
|
sl@0
|
46 |
Kernel side Hardware Configuration Repository (HCR).
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
namespace HCR
|
sl@0
|
49 |
{
|
sl@0
|
50 |
/** Constant defined for the first HCR repository format. Used for both
|
sl@0
|
51 |
compiled and file repositories.
|
sl@0
|
52 |
@see SRepositoryBase::iFormatVersion
|
sl@0
|
53 |
*/
|
sl@0
|
54 |
static const TInt KRepositoryFirstVersion = 0x0001;
|
sl@0
|
55 |
|
sl@0
|
56 |
/** Interface class defining the methods variants must implement to provide
|
sl@0
|
57 |
a complete HCR component for the targeted variant.
|
sl@0
|
58 |
The HCR supports three repositories and it is recommended that as few of
|
sl@0
|
59 |
these are employed for a variant to minimise lookup overheads as setting
|
sl@0
|
60 |
override flexibility is provided at the expense of lookup performance.
|
sl@0
|
61 |
*/
|
sl@0
|
62 |
class MVariant
|
sl@0
|
63 |
{
|
sl@0
|
64 |
public:
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
Perform platform specific initialisation of variant HCR object. Invoked
|
sl@0
|
68 |
during HCR kernel extension module initialisation.
|
sl@0
|
69 |
Note: an error code from this method will prevent device startup.
|
sl@0
|
70 |
|
sl@0
|
71 |
@return KErrNone if successful, or any other system wide error code.
|
sl@0
|
72 |
*/
|
sl@0
|
73 |
virtual TInt Initialise() = 0;
|
sl@0
|
74 |
|
sl@0
|
75 |
|
sl@0
|
76 |
/**
|
sl@0
|
77 |
This method returns the address of the compile time setting repository
|
sl@0
|
78 |
built into the variant HCR.dll project/binary. This repository is
|
sl@0
|
79 |
optional and may be absent in which case 0 should be returned in aAddr.
|
sl@0
|
80 |
|
sl@0
|
81 |
@param aAddr out: a pointer to a HCR::SRepositoryCompiled
|
sl@0
|
82 |
@return KErrNone if successful, output parameters valid,
|
sl@0
|
83 |
KErrNotSupported if a compile time repository is not supported,
|
sl@0
|
84 |
Any other system wide error code.
|
sl@0
|
85 |
@see HCR::SRepositoryCompiled
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
virtual TInt GetCompiledRepositoryAddress(TAny* & aAddr) = 0;
|
sl@0
|
88 |
|
sl@0
|
89 |
/**
|
sl@0
|
90 |
This method is called at kernel initialisation and allows the PSL to
|
sl@0
|
91 |
disable the initial lookup of the built-in Core Image file repository.
|
sl@0
|
92 |
The PSL should return ETrue if the device/BSP is not going to support
|
sl@0
|
93 |
this repository.
|
sl@0
|
94 |
|
sl@0
|
95 |
@return ETrue if the PIL should not find the repository in the ROM
|
sl@0
|
96 |
EFalse if the core image repository is to be used/supported
|
sl@0
|
97 |
*/
|
sl@0
|
98 |
virtual TBool IgnoreCoreImgRepository () = 0;
|
sl@0
|
99 |
|
sl@0
|
100 |
/**
|
sl@0
|
101 |
This method returns the address of the override repository that
|
sl@0
|
102 |
provides override values for the variant. Typically this repository
|
sl@0
|
103 |
is held in NAND flash and shadowed in RAM by the OS loader. It is
|
sl@0
|
104 |
a read-only settings repository. This repository is optional and may
|
sl@0
|
105 |
be absent in which case 0 should be returned in aAddr.
|
sl@0
|
106 |
|
sl@0
|
107 |
@param aAddr out: a pointer to a HCR::SRepositoryFile
|
sl@0
|
108 |
@return KErrNone if successful, output parameters valid,
|
sl@0
|
109 |
KErrNotSupported if a compile time repository is not supported,
|
sl@0
|
110 |
Any other system wide error code.
|
sl@0
|
111 |
@see HCR::SRepositoryFile
|
sl@0
|
112 |
*/
|
sl@0
|
113 |
virtual TInt GetOverrideRepositoryAddress(TAny* & aAddr) = 0;
|
sl@0
|
114 |
|
sl@0
|
115 |
};
|
sl@0
|
116 |
|
sl@0
|
117 |
|
sl@0
|
118 |
/** Union that holds one of the supported word-sized setting values
|
sl@0
|
119 |
*/
|
sl@0
|
120 |
union UValueWord
|
sl@0
|
121 |
{
|
sl@0
|
122 |
TInt32 iInt32;
|
sl@0
|
123 |
TInt16 iInt16;
|
sl@0
|
124 |
TInt8 iInt8;
|
sl@0
|
125 |
TBool iBool;
|
sl@0
|
126 |
TUint32 iUInt32;
|
sl@0
|
127 |
TUint16 iUInt16;
|
sl@0
|
128 |
TUint8 iUInt8;
|
sl@0
|
129 |
TLinAddr iAddress;
|
sl@0
|
130 |
};
|
sl@0
|
131 |
|
sl@0
|
132 |
/** Union that holds a pointer to one of the supported large value types
|
sl@0
|
133 |
*/
|
sl@0
|
134 |
union UValueLarge
|
sl@0
|
135 |
{
|
sl@0
|
136 |
TUint8* iData; //!< Array of TUint8 values
|
sl@0
|
137 |
TText8* iString8; //!< Array of TText8 values
|
sl@0
|
138 |
TInt32* iArrayInt32; //!< Array of TInt32 values
|
sl@0
|
139 |
TUint32* iArrayUInt32; //!< Array of TUInt32 values
|
sl@0
|
140 |
TInt64* iInt64; //!< Single TInt64 value
|
sl@0
|
141 |
TUint64* iUInt64; //!< Single TUint64 value
|
sl@0
|
142 |
};
|
sl@0
|
143 |
|
sl@0
|
144 |
/** Type used to hold the offset to a large setting value */
|
sl@0
|
145 |
typedef TInt TValueLargeOffset;
|
sl@0
|
146 |
|
sl@0
|
147 |
/** Union type used to hold either the literal value or a C++ pointer to
|
sl@0
|
148 |
the value. Used in compile time settings.
|
sl@0
|
149 |
*/
|
sl@0
|
150 |
union USettingValueC
|
sl@0
|
151 |
{
|
sl@0
|
152 |
UValueWord iLit;
|
sl@0
|
153 |
UValueLarge iPtr;
|
sl@0
|
154 |
};
|
sl@0
|
155 |
|
sl@0
|
156 |
/** Union type used to hold either the literal value or an offset from the
|
sl@0
|
157 |
start if the setting repository to the setting value. Used in file and RAM
|
sl@0
|
158 |
mapped settings.
|
sl@0
|
159 |
*/
|
sl@0
|
160 |
union USettingValueF
|
sl@0
|
161 |
{
|
sl@0
|
162 |
UValueWord iLit;
|
sl@0
|
163 |
TValueLargeOffset iOffset;
|
sl@0
|
164 |
};
|
sl@0
|
165 |
|
sl@0
|
166 |
/** Metadata flags to describe properties of the settings.
|
sl@0
|
167 |
*/
|
sl@0
|
168 |
enum TSettingProperties
|
sl@0
|
169 |
{
|
sl@0
|
170 |
EPropUndefined = 0x0000, //!< Unknown/not set
|
sl@0
|
171 |
|
sl@0
|
172 |
// Following properties are not yet supported:
|
sl@0
|
173 |
EPropUnintiailised = 0x0001, //!< Setting has no initial value
|
sl@0
|
174 |
EPropModifiable = 0x0002, //!< Setting is set/writable
|
sl@0
|
175 |
EPropPersistent = 0x0004, //!< Setting is non-volatile
|
sl@0
|
176 |
|
sl@0
|
177 |
// Following properties are not yet supported but are envisaged to be
|
sl@0
|
178 |
// implemented to support setting breaks/migration where settings
|
sl@0
|
179 |
// evolve and/or replace each other.
|
sl@0
|
180 |
EPropDeprecated = 0x1000, //!< Setting supported but deprecate, accessed logged
|
sl@0
|
181 |
EPropReplaced = 0x2000, //!< HCR redirected to retrieve value from replacement setting, access logged
|
sl@0
|
182 |
EPropWithdrawn = 0x4000 //!< Setting withdrawn, log & panic if accessed
|
sl@0
|
183 |
};
|
sl@0
|
184 |
|
sl@0
|
185 |
/** Provides base class for setting records. All setting structures start
|
sl@0
|
186 |
with this structure providing common setting attributes such as the
|
sl@0
|
187 |
identifier, type etc.
|
sl@0
|
188 |
*/
|
sl@0
|
189 |
struct SSettingBase
|
sl@0
|
190 |
{
|
sl@0
|
191 |
SSettingId iId; // Always the first member!
|
sl@0
|
192 |
TInt32 iType; //!< @see TSettingType
|
sl@0
|
193 |
TUint16 iFlags; //!< @See TSettingProperties
|
sl@0
|
194 |
TUint16 iLen; //!< Only valid if setting is a large type
|
sl@0
|
195 |
};
|
sl@0
|
196 |
|
sl@0
|
197 |
/** This structure holds a setting defined at compile time within a compile
|
sl@0
|
198 |
time defined repository.
|
sl@0
|
199 |
@see SRepositoryCompiled
|
sl@0
|
200 |
*/
|
sl@0
|
201 |
struct SSettingC // : public SSettingBase
|
sl@0
|
202 |
{
|
sl@0
|
203 |
SSettingBase iName; // Always the first member!
|
sl@0
|
204 |
USettingValueC iValue;
|
sl@0
|
205 |
};
|
sl@0
|
206 |
|
sl@0
|
207 |
/** This structure holds a setting define in a file or memory within a file
|
sl@0
|
208 |
based repository.
|
sl@0
|
209 |
@see SRepositoryFile
|
sl@0
|
210 |
*/
|
sl@0
|
211 |
struct SSettingF // : public SSettingBase
|
sl@0
|
212 |
{
|
sl@0
|
213 |
SSettingBase iName; // Always the first member!
|
sl@0
|
214 |
USettingValueF iValue;
|
sl@0
|
215 |
};
|
sl@0
|
216 |
|
sl@0
|
217 |
|
sl@0
|
218 |
/** Metadata flags to describe the repository type/layout.
|
sl@0
|
219 |
*/
|
sl@0
|
220 |
enum TRepositoryType
|
sl@0
|
221 |
{
|
sl@0
|
222 |
EReposUndefined = 0x00, //!< Unknown
|
sl@0
|
223 |
|
sl@0
|
224 |
EReposCompiled = 'c', //!< Repository is in Compiled layout
|
sl@0
|
225 |
EReposFile = 'f' //!< Repository is in File layout
|
sl@0
|
226 |
};
|
sl@0
|
227 |
|
sl@0
|
228 |
/** Metadata flags to describe repository properties.
|
sl@0
|
229 |
*/
|
sl@0
|
230 |
enum TRepositoryProperties
|
sl@0
|
231 |
{
|
sl@0
|
232 |
EReposClear = 0x0000, //!< Unknown
|
sl@0
|
233 |
EReposReadOnly = 0x0001, //!< Repository is read-only
|
sl@0
|
234 |
EReposNonVolatile = 0x0002 //!< Repository is writable, saved to flash
|
sl@0
|
235 |
};
|
sl@0
|
236 |
|
sl@0
|
237 |
/** Provides base class for setting repositories. All repository structures
|
sl@0
|
238 |
start with this structure providing common repository attributes such as the
|
sl@0
|
239 |
type , size etc.
|
sl@0
|
240 |
*/
|
sl@0
|
241 |
struct SRepositoryBase
|
sl@0
|
242 |
{
|
sl@0
|
243 |
TUint8 iFingerPrint[3]; //!< Fixed value {'H', 'C', 'R'}
|
sl@0
|
244 |
TUint8 iType; //!< @See TRepositoryType
|
sl@0
|
245 |
TInt16 iFormatVersion; //!< Format/layout version number
|
sl@0
|
246 |
TUint16 iFlags; //!< @see TRepositoryProperties
|
sl@0
|
247 |
TInt32 iNumSettings; //!< Number of settings in repository
|
sl@0
|
248 |
};
|
sl@0
|
249 |
|
sl@0
|
250 |
|
sl@0
|
251 |
/** This class is the root object for a compile time defined settings
|
sl@0
|
252 |
repository and is used in the PSL HCR variant object to hold read-only
|
sl@0
|
253 |
compile time settings. This type of repository makes use of pointers to
|
sl@0
|
254 |
structures and arrays as it is compiled.
|
sl@0
|
255 |
*/
|
sl@0
|
256 |
struct SRepositoryCompiled
|
sl@0
|
257 |
{
|
sl@0
|
258 |
SRepositoryBase* iHdr; // Always the first member!
|
sl@0
|
259 |
SSettingC* iOrderedSettingList;
|
sl@0
|
260 |
};
|
sl@0
|
261 |
|
sl@0
|
262 |
|
sl@0
|
263 |
/** Byte type for large setting value data
|
sl@0
|
264 |
*/
|
sl@0
|
265 |
typedef TUint8 TSettingData;
|
sl@0
|
266 |
|
sl@0
|
267 |
/** This class is the root object for a file or memory based settings
|
sl@0
|
268 |
repository. It assumes the repository has a flat contiguous layout and
|
sl@0
|
269 |
employees offsets to data rather then C++ pointers as in compiled
|
sl@0
|
270 |
setting repositories.
|
sl@0
|
271 |
All offsets are relative to the address of &iHdr member.
|
sl@0
|
272 |
The last two members are expected to be present in the file/memory as shown
|
sl@0
|
273 |
although there is no way at type definition time to know the size of these
|
sl@0
|
274 |
members, hence they are commented out and will be accessed in the code
|
sl@0
|
275 |
using memory/file address arithmetic.
|
sl@0
|
276 |
*/
|
sl@0
|
277 |
struct SRepositoryFile
|
sl@0
|
278 |
{
|
sl@0
|
279 |
SRepositoryBase iHdr; // Always the first member!
|
sl@0
|
280 |
TUint32 iLSDfirstByteOffset;
|
sl@0
|
281 |
TUint32 iLSDataSize;
|
sl@0
|
282 |
TUint32 iReserved[3];
|
sl@0
|
283 |
// SSettingF iOrderedSettingList[iNumSettings];
|
sl@0
|
284 |
// TSettingData iLargeSettingsData[iLSDataSize];
|
sl@0
|
285 |
};
|
sl@0
|
286 |
|
sl@0
|
287 |
}
|
sl@0
|
288 |
|
sl@0
|
289 |
|
sl@0
|
290 |
// -- GLOBALS -----------------------------------------------------------------
|
sl@0
|
291 |
|
sl@0
|
292 |
|
sl@0
|
293 |
/**
|
sl@0
|
294 |
Global entry point used by PIL to create the variant HCR object in the PSL
|
sl@0
|
295 |
code.
|
sl@0
|
296 |
|
sl@0
|
297 |
@return Pointer to variant is successfully, 0 otherwise.
|
sl@0
|
298 |
@see HCR::MVariant
|
sl@0
|
299 |
*/
|
sl@0
|
300 |
GLREF_C HCR::MVariant* CreateHCRVariant();
|
sl@0
|
301 |
|
sl@0
|
302 |
|
sl@0
|
303 |
|
sl@0
|
304 |
// -- MACROS ------------------------------------------------------------------
|
sl@0
|
305 |
|
sl@0
|
306 |
|
sl@0
|
307 |
/**
|
sl@0
|
308 |
Global macro for use in defining the finger print field of a
|
sl@0
|
309 |
SRepositoryCompiled.iHdr instance in the PSL compiled repository static data.
|
sl@0
|
310 |
|
sl@0
|
311 |
Macro used in PSL source as the value for the finger print field in a
|
sl@0
|
312 |
compiled repository.
|
sl@0
|
313 |
@see SRepositoryBase::iFingerPrint
|
sl@0
|
314 |
*/
|
sl@0
|
315 |
#define HCR_FINGER_PRINT {'H', 'C', 'R'}
|
sl@0
|
316 |
|
sl@0
|
317 |
/**
|
sl@0
|
318 |
Global macro for use in defining the finger print field of a
|
sl@0
|
319 |
SRepositoryCompiled.iHdr instance in the PSL compiled repository static data.
|
sl@0
|
320 |
|
sl@0
|
321 |
Macro used in PSL source as the value for the finger print field in a
|
sl@0
|
322 |
compiled repository.
|
sl@0
|
323 |
@see SRepositoryBase::iFingerPrint
|
sl@0
|
324 |
*/
|
sl@0
|
325 |
#define HCR_SETTING_COUNT(a) (sizeof(a)/sizeof(SSettingC))
|
sl@0
|
326 |
|
sl@0
|
327 |
/**
|
sl@0
|
328 |
Global macro for use in setting the flags attribute of a SSettingC
|
sl@0
|
329 |
instance in the PSL compiled repository static data.
|
sl@0
|
330 |
|
sl@0
|
331 |
@see HCR::MVariant
|
sl@0
|
332 |
@see HCR::SRepositoryCompiled
|
sl@0
|
333 |
*/
|
sl@0
|
334 |
#define HCR_FLAGS_NONE HCR::EPropUndefined
|
sl@0
|
335 |
|
sl@0
|
336 |
/**
|
sl@0
|
337 |
Global macro for use in setting the length attribute of a SSettingC
|
sl@0
|
338 |
instance in the PSL compiled repository static data.
|
sl@0
|
339 |
|
sl@0
|
340 |
@see HCR::MVariant
|
sl@0
|
341 |
@see HCR::SRepositoryCompiled
|
sl@0
|
342 |
*/
|
sl@0
|
343 |
#define HCR_LEN_NA 0x0000
|
sl@0
|
344 |
|
sl@0
|
345 |
/**
|
sl@0
|
346 |
Global macro for use in defining the actual integer (word) value of a SettingC
|
sl@0
|
347 |
instance in the PSL compiled repository static data. This can be used to
|
sl@0
|
348 |
simplify the setting table for settings with the type flag
|
sl@0
|
349 |
set to one of 0x0000FFFF.
|
sl@0
|
350 |
|
sl@0
|
351 |
@see HCR::MVariant
|
sl@0
|
352 |
@see HCR::SRepositoryCompiled
|
sl@0
|
353 |
*/
|
sl@0
|
354 |
#define HCR_WVALUE(a) static_cast<TInt32>(a)
|
sl@0
|
355 |
|
sl@0
|
356 |
/**
|
sl@0
|
357 |
Global macro for use in assigning the address of a large setting value to an
|
sl@0
|
358 |
instance of a SettingC in the PSL compiled repository static data. This can be
|
sl@0
|
359 |
used to simplify the setting table for settings with the type flag
|
sl@0
|
360 |
set to one of 0xFFFF0000.
|
sl@0
|
361 |
|
sl@0
|
362 |
@see HCR::MVariant
|
sl@0
|
363 |
@see HCR::SRepositoryCompiled
|
sl@0
|
364 |
*/
|
sl@0
|
365 |
#define HCR_LVALUE(a) reinterpret_cast<TInt32>(a)
|
sl@0
|
366 |
|
sl@0
|
367 |
/**
|
sl@0
|
368 |
Global macro used as last entry in a PSL compiled repository static data.
|
sl@0
|
369 |
The main use of this is to avoid the "last entry needs no following comma" issue
|
sl@0
|
370 |
and to aid HCR initial thead testing.
|
sl@0
|
371 |
The Setting (0xffffffff, 0xffffffff) was choosen as it should never appear in
|
sl@0
|
372 |
a real variant as this category UID can not be allocated offically. Testers
|
sl@0
|
373 |
should also be aware of the special use of this setting so as not to use it in
|
sl@0
|
374 |
a file repository.
|
sl@0
|
375 |
|
sl@0
|
376 |
@see HCR::MVariant
|
sl@0
|
377 |
@see HCR::SRepositoryCompiled
|
sl@0
|
378 |
*/
|
sl@0
|
379 |
#define HCR_LAST_SETTING { { { 0xFFFFFFFF, 0xFFFFFFFF}, ETypeUInt32, HCR_FLAGS_NONE, HCR_LEN_NA }, { { 0x4C415354 }}}
|
sl@0
|
380 |
|
sl@0
|
381 |
|
sl@0
|
382 |
#endif // HCR_HAI_H
|