|
@@ -2247,29 +2247,8 @@ struct setting priority_setting __setting ( SETTING_MISC ) = {
|
2247
|
2247
|
******************************************************************************
|
2248
|
2248
|
*/
|
2249
|
2249
|
|
2250
|
|
-/** A built-in setting operation */
|
2251
|
|
-struct builtin_setting_operation {
|
2252
|
|
- /** Setting */
|
2253
|
|
- struct setting *setting;
|
2254
|
|
- /** Fetch setting value
|
2255
|
|
- *
|
2256
|
|
- * @v data Buffer to fill with setting data
|
2257
|
|
- * @v len Length of buffer
|
2258
|
|
- * @ret len Length of setting data, or negative error
|
2259
|
|
- */
|
2260
|
|
- int ( * fetch ) ( void *data, size_t len );
|
2261
|
|
-};
|
2262
|
|
-
|
2263
|
2250
|
/** Built-in setting scope */
|
2264
|
|
-static struct settings_scope builtin_scope;
|
2265
|
|
-
|
2266
|
|
-/** Error number setting */
|
2267
|
|
-struct setting errno_setting __setting ( SETTING_MISC ) = {
|
2268
|
|
- .name = "errno",
|
2269
|
|
- .description = "Last error",
|
2270
|
|
- .type = &setting_type_uint32,
|
2271
|
|
- .scope = &builtin_scope,
|
2272
|
|
-};
|
|
2251
|
+struct settings_scope builtin_scope;
|
2273
|
2252
|
|
2274
|
2253
|
/**
|
2275
|
2254
|
* Fetch error number setting
|
|
@@ -2289,14 +2268,20 @@ static int errno_fetch ( void *data, size_t len ) {
|
2289
|
2268
|
return sizeof ( content );
|
2290
|
2269
|
}
|
2291
|
2270
|
|
2292
|
|
-/** Build architecture setting */
|
2293
|
|
-struct setting buildarch_setting __setting ( SETTING_MISC ) = {
|
2294
|
|
- .name = "buildarch",
|
2295
|
|
- .description = "Build architecture",
|
2296
|
|
- .type = &setting_type_string,
|
|
2271
|
+/** Error number setting */
|
|
2272
|
+struct setting errno_setting __setting ( SETTING_MISC ) = {
|
|
2273
|
+ .name = "errno",
|
|
2274
|
+ .description = "Last error",
|
|
2275
|
+ .type = &setting_type_uint32,
|
2297
|
2276
|
.scope = &builtin_scope,
|
2298
|
2277
|
};
|
2299
|
2278
|
|
|
2279
|
+/** Error number built-in setting */
|
|
2280
|
+struct builtin_setting errno_builtin_setting __builtin_setting = {
|
|
2281
|
+ .setting = &errno_setting,
|
|
2282
|
+ .fetch = errno_fetch,
|
|
2283
|
+};
|
|
2284
|
+
|
2300
|
2285
|
/**
|
2301
|
2286
|
* Fetch build architecture setting
|
2302
|
2287
|
*
|
|
@@ -2311,14 +2296,20 @@ static int buildarch_fetch ( void *data, size_t len ) {
|
2311
|
2296
|
return ( sizeof ( buildarch ) - 1 /* NUL */ );
|
2312
|
2297
|
}
|
2313
|
2298
|
|
2314
|
|
-/** Platform setting */
|
2315
|
|
-struct setting platform_setting __setting ( SETTING_MISC ) = {
|
2316
|
|
- .name = "platform",
|
2317
|
|
- .description = "Platform",
|
|
2299
|
+/** Build architecture setting */
|
|
2300
|
+struct setting buildarch_setting __setting ( SETTING_MISC ) = {
|
|
2301
|
+ .name = "buildarch",
|
|
2302
|
+ .description = "Build architecture",
|
2318
|
2303
|
.type = &setting_type_string,
|
2319
|
2304
|
.scope = &builtin_scope,
|
2320
|
2305
|
};
|
2321
|
2306
|
|
|
2307
|
+/** Build architecture built-in setting */
|
|
2308
|
+struct builtin_setting buildarch_builtin_setting __builtin_setting = {
|
|
2309
|
+ .setting = &buildarch_setting,
|
|
2310
|
+ .fetch = buildarch_fetch,
|
|
2311
|
+};
|
|
2312
|
+
|
2322
|
2313
|
/**
|
2323
|
2314
|
* Fetch platform setting
|
2324
|
2315
|
*
|
|
@@ -2333,14 +2324,20 @@ static int platform_fetch ( void *data, size_t len ) {
|
2333
|
2324
|
return ( sizeof ( platform ) - 1 /* NUL */ );
|
2334
|
2325
|
}
|
2335
|
2326
|
|
2336
|
|
-/** Version setting */
|
2337
|
|
-struct setting version_setting __setting ( SETTING_MISC ) = {
|
2338
|
|
- .name = "version",
|
2339
|
|
- .description = "Version",
|
|
2327
|
+/** Platform setting */
|
|
2328
|
+struct setting platform_setting __setting ( SETTING_MISC ) = {
|
|
2329
|
+ .name = "platform",
|
|
2330
|
+ .description = "Platform",
|
2340
|
2331
|
.type = &setting_type_string,
|
2341
|
2332
|
.scope = &builtin_scope,
|
2342
|
2333
|
};
|
2343
|
2334
|
|
|
2335
|
+/** Platform built-in setting */
|
|
2336
|
+struct builtin_setting platform_builtin_setting __builtin_setting = {
|
|
2337
|
+ .setting = &platform_setting,
|
|
2338
|
+ .fetch = platform_fetch,
|
|
2339
|
+};
|
|
2340
|
+
|
2344
|
2341
|
/**
|
2345
|
2342
|
* Fetch version setting
|
2346
|
2343
|
*
|
|
@@ -2353,12 +2350,18 @@ static int version_fetch ( void *data, size_t len ) {
|
2353
|
2350
|
return ( strlen ( product_version ) );
|
2354
|
2351
|
}
|
2355
|
2352
|
|
2356
|
|
-/** List of built-in setting operations */
|
2357
|
|
-static struct builtin_setting_operation builtin_setting_operations[] = {
|
2358
|
|
- { &errno_setting, errno_fetch },
|
2359
|
|
- { &buildarch_setting, buildarch_fetch },
|
2360
|
|
- { &platform_setting, platform_fetch },
|
2361
|
|
- { &version_setting, version_fetch },
|
|
2353
|
+/** Version setting */
|
|
2354
|
+struct setting version_setting __setting ( SETTING_MISC ) = {
|
|
2355
|
+ .name = "version",
|
|
2356
|
+ .description = "Version",
|
|
2357
|
+ .type = &setting_type_string,
|
|
2358
|
+ .scope = &builtin_scope,
|
|
2359
|
+};
|
|
2360
|
+
|
|
2361
|
+/** Version built-in setting */
|
|
2362
|
+struct builtin_setting version_builtin_setting __builtin_setting = {
|
|
2363
|
+ .setting = &version_setting,
|
|
2364
|
+ .fetch = version_fetch,
|
2362
|
2365
|
};
|
2363
|
2366
|
|
2364
|
2367
|
/**
|
|
@@ -2373,12 +2376,9 @@ static struct builtin_setting_operation builtin_setting_operations[] = {
|
2373
|
2376
|
static int builtin_fetch ( struct settings *settings __unused,
|
2374
|
2377
|
struct setting *setting,
|
2375
|
2378
|
void *data, size_t len ) {
|
2376
|
|
- struct builtin_setting_operation *builtin;
|
2377
|
|
- unsigned int i;
|
|
2379
|
+ struct builtin_setting *builtin;
|
2378
|
2380
|
|
2379
|
|
- for ( i = 0 ; i < ( sizeof ( builtin_setting_operations ) /
|
2380
|
|
- sizeof ( builtin_setting_operations[0] ) ) ; i++ ) {
|
2381
|
|
- builtin = &builtin_setting_operations[i];
|
|
2381
|
+ for_each_table_entry ( builtin, BUILTIN_SETTINGS ) {
|
2382
|
2382
|
if ( setting_cmp ( setting, builtin->setting ) == 0 )
|
2383
|
2383
|
return builtin->fetch ( data, len );
|
2384
|
2384
|
}
|