]> git.proxmox.com Git - mirror_qemu.git/commitdiff
fw_cfg: add fw_cfg_modify_i16 (update) method
authorGabriel L. Somlo <somlo@cmu.edu>
Mon, 8 Jun 2015 18:10:44 +0000 (14:10 -0400)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 10 Jun 2015 06:00:37 +0000 (08:00 +0200)
Allow the ability to modify the value of an existing 16-bit integer
fw_cfg item.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/nvram/fw_cfg.c
include/hw/nvram/fw_cfg.h

index 68eff77983c532b833d7c04a66740a0d8b3884d5..08b5cc3ecc587a6028faa94ceb758e36f1964aa6 100644 (file)
@@ -484,6 +484,16 @@ void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)
     fw_cfg_add_bytes(s, key, copy, sizeof(value));
 }
 
+void fw_cfg_modify_i16(FWCfgState *s, uint16_t key, uint16_t value)
+{
+    uint16_t *copy, *old;
+
+    copy = g_malloc(sizeof(value));
+    *copy = cpu_to_le16(value);
+    old = fw_cfg_modify_bytes_read(s, key, copy, sizeof(value));
+    g_free(old);
+}
+
 void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value)
 {
     uint32_t *copy;
index 6d8a8ac564f578e04fe9e3d271fed5c151e20db0..bc6c4a03c98b705eb6ae1a79af9a524ffedba9cb 100644 (file)
@@ -67,6 +67,7 @@ typedef void (*FWCfgReadCallback)(void *opaque, uint32_t offset);
 void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_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_modify_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);
 void fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,