From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2Id7-0004r5-9G for qemu-devel@nongnu.org; Tue, 09 Jun 2015 08:27:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2Id1-0004BY-SX for qemu-devel@nongnu.org; Tue, 09 Jun 2015 08:27:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2Id1-0004BQ-NR for qemu-devel@nongnu.org; Tue, 09 Jun 2015 08:27:39 -0400 From: Gerd Hoffmann Date: Tue, 9 Jun 2015 14:27:29 +0200 Message-Id: <1433852855-4323-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1433852855-4323-1-git-send-email-kraxel@redhat.com> References: <1433852855-4323-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL v2 2/8] fw_cfg: add fw_cfg_modify_i16 (update) method List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Gabriel L. Somlo" , Gerd Hoffmann From: "Gabriel L. Somlo" Allow the ability to modify the value of an existing 16-bit integer fw_cfg item. Signed-off-by: Gabriel Somlo Signed-off-by: Gerd Hoffmann --- hw/nvram/fw_cfg.c | 10 ++++++++++ include/hw/nvram/fw_cfg.h | 1 + 2 files changed, 11 insertions(+) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 68eff77..08b5cc3 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -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; diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 6d8a8ac..bc6c4a0 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -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, -- 1.8.3.1