summaryrefslogtreecommitdiffstats
path: root/src/interface/smbios
diff options
context:
space:
mode:
authorMichael Brown2011-03-22 17:56:35 +0100
committerMichael Brown2011-03-22 20:54:58 +0100
commitf5fd4dec3bab362a2ff7844859914e1f191fb905 (patch)
tree607eacef2f79c016a0c3c3031de2bb7d8aa7e331 /src/interface/smbios
parent[forcedeth] Clear the MII link status register on link status changes (diff)
downloadipxe-f5fd4dec3bab362a2ff7844859914e1f191fb905.tar.gz
ipxe-f5fd4dec3bab362a2ff7844859914e1f191fb905.tar.xz
ipxe-f5fd4dec3bab362a2ff7844859914e1f191fb905.zip
[settings] Formalise notion of setting applicability
Expose a function setting_applies() to allow a caller to determine whether or not a particular setting is applicable to a particular settings block. Restrict DHCP-backed settings blocks to accepting only DHCP-based settings. Restrict network device settings blocks to accepting only DHCP-based settings and network device-specific settings such as "mac". Inspired-by: Glenn Brown <glenn@myri.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/smbios')
-rw-r--r--src/interface/smbios/smbios_settings.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c
index bb7c18dd..6594c94b 100644
--- a/src/interface/smbios/smbios_settings.c
+++ b/src/interface/smbios/smbios_settings.c
@@ -64,6 +64,22 @@ FILE_LICENCE ( GPL2_OR_LATER );
( offsetof ( _structure, _field ) << 8 ) )
/**
+ * Check applicability of SMBIOS setting
+ *
+ * @v settings Settings block
+ * @v setting Setting
+ * @ret applies Setting applies within this settings block
+ */
+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 );
+}
+
+/**
* Fetch value of SMBIOS setting
*
* @v settings Settings block, or NULL to search all blocks
@@ -87,8 +103,7 @@ static int smbios_fetch ( struct settings *settings __unused,
tag_type = ( ( setting->tag >> 16 ) & 0xff );
tag_offset = ( ( setting->tag >> 8 ) & 0xff );
tag_len = ( setting->tag & 0xff );
- if ( tag_magic != SMBIOS_TAG_MAGIC )
- return -ENOENT;
+ assert ( tag_magic == SMBIOS_TAG_MAGIC );
/* Find SMBIOS structure */
if ( ( rc = find_smbios_structure ( tag_type, &structure ) ) != 0 )
@@ -119,6 +134,7 @@ static int smbios_fetch ( struct settings *settings __unused,
/** SMBIOS settings operations */
static struct settings_operations smbios_settings_operations = {
+ .applies = smbios_applies,
.fetch = smbios_fetch,
};