diff options
author | Michael Brown | 2013-05-01 18:20:39 +0200 |
---|---|---|
committer | Michael Brown | 2013-05-01 20:52:12 +0200 |
commit | 15d2f947f51a0ea72e9938f5648fd5133950ecdb (patch) | |
tree | f53d0e87063b2c2972c3602ad8962332b3756a72 /src/interface/smbios | |
parent | [realtek] Defer packets when no transmit descriptors are available (diff) | |
download | ipxe-15d2f947f51a0ea72e9938f5648fd5133950ecdb.tar.gz ipxe-15d2f947f51a0ea72e9938f5648fd5133950ecdb.tar.xz ipxe-15d2f947f51a0ea72e9938f5648fd5133950ecdb.zip |
[settings] Eliminate settings "tag magic"
Create an explicit concept of "settings scope" and eliminate the magic
values used for numerical setting tags.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/smbios')
-rw-r--r-- | src/interface/smbios/smbios_settings.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index 663da968..7b2efcd7 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -27,15 +27,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <ipxe/uuid.h> #include <ipxe/smbios.h> -/** SMBIOS settings tag magic number */ -#define SMBIOS_TAG_MAGIC 0x5B /* "SmBios" */ - -/** - * Construct SMBIOS empty tag - * - * @ret tag SMBIOS setting tag - */ -#define SMBIOS_EMPTY_TAG ( SMBIOS_TAG_MAGIC << 24 ) +/** SMBIOS settings scope */ +static struct settings_scope smbios_settings_scope; /** * Construct SMBIOS raw-data tag @@ -46,8 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); * @ret tag SMBIOS setting tag */ #define SMBIOS_RAW_TAG( _type, _structure, _field ) \ - ( ( SMBIOS_TAG_MAGIC << 24 ) | \ - ( (_type) << 16 ) | \ + ( ( (_type) << 16 ) | \ ( offsetof ( _structure, _field ) << 8 ) | \ ( sizeof ( ( ( _structure * ) 0 )->_field ) ) ) @@ -60,8 +52,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); * @ret tag SMBIOS setting tag */ #define SMBIOS_STRING_TAG( _type, _structure, _field ) \ - ( ( SMBIOS_TAG_MAGIC << 24 ) | \ - ( (_type) << 16 ) | \ + ( ( (_type) << 16 ) | \ ( offsetof ( _structure, _field ) << 8 ) ) /** @@ -73,11 +64,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); */ static int smbios_applies ( struct settings *settings __unused, struct setting *setting ) { - unsigned int tag_magic; - /* Check tag magic */ - tag_magic = ( setting->tag >> 24 ); - return ( tag_magic == SMBIOS_TAG_MAGIC ); + return ( setting->scope == &smbios_settings_scope ); } /** @@ -93,18 +81,15 @@ static int smbios_fetch ( struct settings *settings __unused, struct setting *setting, void *data, size_t len ) { struct smbios_structure structure; - unsigned int tag_magic; unsigned int tag_type; unsigned int tag_offset; unsigned int tag_len; int rc; /* Split tag into type, offset and length */ - tag_magic = ( setting->tag >> 24 ); tag_type = ( ( setting->tag >> 16 ) & 0xff ); tag_offset = ( ( setting->tag >> 8 ) & 0xff ); tag_len = ( setting->tag & 0xff ); - assert ( tag_magic == SMBIOS_TAG_MAGIC ); /* Find SMBIOS structure */ if ( ( rc = find_smbios_structure ( tag_type, &structure ) ) != 0 ) @@ -170,10 +155,10 @@ static struct settings_operations smbios_settings_operations = { /** SMBIOS settings */ static struct settings smbios_settings = { .refcnt = NULL, - .tag_magic = SMBIOS_EMPTY_TAG, .siblings = LIST_HEAD_INIT ( smbios_settings.siblings ), .children = LIST_HEAD_INIT ( smbios_settings.children ), .op = &smbios_settings_operations, + .default_scope = &smbios_settings_scope, }; /** Initialise SMBIOS settings */ @@ -200,6 +185,7 @@ struct setting uuid_setting __setting ( SETTING_HOST ) = { .tag = SMBIOS_RAW_TAG ( SMBIOS_TYPE_SYSTEM_INFORMATION, struct smbios_system_information, uuid ), .type = &setting_type_uuid, + .scope = &smbios_settings_scope, }; /** Other SMBIOS named settings */ @@ -211,6 +197,7 @@ struct setting smbios_named_settings[] __setting ( SETTING_HOST_EXTRA ) = { struct smbios_system_information, manufacturer ), .type = &setting_type_string, + .scope = &smbios_settings_scope, }, { .name = "product", @@ -219,6 +206,7 @@ struct setting smbios_named_settings[] __setting ( SETTING_HOST_EXTRA ) = { struct smbios_system_information, product ), .type = &setting_type_string, + .scope = &smbios_settings_scope, }, { .name = "serial", @@ -227,6 +215,7 @@ struct setting smbios_named_settings[] __setting ( SETTING_HOST_EXTRA ) = { struct smbios_system_information, serial ), .type = &setting_type_string, + .scope = &smbios_settings_scope, }, { .name = "asset", @@ -235,5 +224,6 @@ struct setting smbios_named_settings[] __setting ( SETTING_HOST_EXTRA ) = { struct smbios_enclosure_information, asset_tag ), .type = &setting_type_string, + .scope = &smbios_settings_scope, }, }; |