From: "Gabriel L. Somlo" <somlo@cmu.edu>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, gsomlo@gmail.com, kraxel@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] fw_cfg: add fw_cfg_modify_i16 (update) method
Date: Mon, 8 Jun 2015 14:10:44 -0400 [thread overview]
Message-ID: <1433787045-6215-2-git-send-email-somlo@cmu.edu> (raw)
In-Reply-To: <1433787045-6215-1-git-send-email-somlo@cmu.edu>
Allow the ability to modify the value of an existing 16-bit integer
fw_cfg item.
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
---
Couple of thoughts:
1. I'm thinking about pre-emptively creating _i16, _i32, and _i64
versions, but right now (for fixing sparc and ppc) we only need
the _i16 version. What to do ?
2. Part of me wants to find the memory location containing the previous
value and simply overwrite it, but I'll need to somehow ensure the
blob being replaced was of the same size, etc., which could get hairy.
So for now I'm going with the paranoid/safe version which allocates
a new blob and frees the old one.
Thanks,
Gabriel
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,
--
2.1.0
next prev parent reply other threads:[~2015-06-08 18:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-08 18:10 [Qemu-devel] [PATCH 0/2] fw_cfg: *prequel* to cleanup series Gabriel L. Somlo
2015-06-08 18:10 ` Gabriel L. Somlo [this message]
2015-06-08 18:26 ` [Qemu-devel] [PATCH 1/2] fw_cfg: add fw_cfg_modify_i16 (update) method Gabriel L. Somlo
2015-06-09 8:14 ` Gerd Hoffmann
2015-06-08 18:10 ` [Qemu-devel] [PATCH 2/2] fw_cfg: fix FW_CFG_BOOT_DEVICE update on ppc and sparc Gabriel L. Somlo
2015-06-09 8:15 ` [Qemu-devel] [PATCH 0/2] fw_cfg: *prequel* to cleanup series Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433787045-6215-2-git-send-email-somlo@cmu.edu \
--to=somlo@cmu.edu \
--cc=gsomlo@gmail.com \
--cc=kraxel@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).