aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2013-01-16 14:50:24 +0100
committerBlue Swirl <blauwirbel@gmail.com>2013-01-19 10:22:41 +0000
commit44687f75434ea938e9d29fdc3696ff4bdc0978fa (patch)
treea35042472ec81aa51898d8863c3f7ec4fe5d6c01 /hw
parent4cad3867b6df2c0826ae508a9fe15dd0b9d8936a (diff)
fw_cfg: New fw_cfg_add_string()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/fw_cfg.c7
-rw-r--r--hw/fw_cfg.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index 0361f684b4..3d6dd5fb3a 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -385,6 +385,13 @@ void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len)
s->entries[arch][key].len = len;
}
+void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value)
+{
+ size_t sz = strlen(value) + 1;
+
+ return fw_cfg_add_bytes(s, key, (uint8_t *)g_memdup(value, sz), sz);
+}
+
void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)
{
uint16_t *copy;
diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h
index 7d32f285c6..c2c57cd2aa 100644
--- a/hw/fw_cfg.h
+++ b/hw/fw_cfg.h
@@ -55,6 +55,7 @@ typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
typedef struct FWCfgState FWCfgState;
void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len);
+void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value);
void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value);
void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value);
void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value);