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