qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Olivia Yin <hong-hua.yin@freescale.com>
To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Cc: Olivia Yin <hong-hua.yin@freescale.com>
Subject: [Qemu-devel] [PATCH 1/5] define image_file_reset and image_blob_reset
Date: Fri, 26 Oct 2012 16:02:02 +0800	[thread overview]
Message-ID: <1351238526-2551-2-git-send-email-hong-hua.yin@freescale.com> (raw)
In-Reply-To: <1351238526-2551-1-git-send-email-hong-hua.yin@freescale.com>

Signed-off-by: Olivia Yin <hong-hua.yin@freescale.com>
---
 hw/loader.c |   39 +++++++++++++++++++++++++++++++++++++++
 hw/loader.h |   18 ++++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/hw/loader.c b/hw/loader.c
index 33acc2f..726c0e7 100644
--- a/hw/loader.c
+++ b/hw/loader.c
@@ -86,6 +86,45 @@ int load_image(const char *filename, uint8_t *addr)
     return size;
 }
 
+void image_file_reset(void *opaque)
+{
+    ImageFile *image = opaque;
+    GError *err = NULL;
+    gboolean res;
+    gchar *content;
+    gsize size;
+
+    if(image->dir) {
+        const char *basename;
+        char fw_file_name[56];
+
+        basename = strrchr(image->name, '/');
+        if (basename) {
+            basename++;
+        } else {
+            basename = image->name;
+        }
+        snprintf(fw_file_name, sizeof(fw_file_name), "%s/%s", image->dir,
+                 basename);
+        image->name = g_strdup(fw_file_name);
+    }
+
+    res = g_file_get_contents(image->name, &content, &size, &err);
+    if (res == FALSE) {
+       error_report("failed to read image file: %s\n", image->name);
+       g_error_free(err);
+    } else {
+       cpu_physical_memory_rw(image->addr, (uint8_t *)content, size, 1);
+       g_free(content);
+    }
+}
+
+void image_blob_reset(void *opaque)
+{
+    ImageBlob *blob = opaque;
+    cpu_physical_memory_rw(blob->addr, blob->data, blob->size, 1);
+}
+
 /* read()-like version */
 ssize_t read_targphys(const char *name,
                       int fd, target_phys_addr_t dst_addr, size_t nbytes)
diff --git a/hw/loader.h b/hw/loader.h
index 6da291e..e9dc4df 100644
--- a/hw/loader.h
+++ b/hw/loader.h
@@ -46,4 +46,22 @@ void do_info_roms(Monitor *mon);
 int rom_add_vga(const char *file);
 int rom_add_option(const char *file, int32_t bootindex);
 
+typedef struct ImageFile ImageFile;
+struct ImageFile {
+    char *name;
+    char *dir;
+    target_phys_addr_t addr;
+};
+
+typedef struct ImageBlob ImageBlob;
+struct ImageBlob {
+    char *name;
+    target_phys_addr_t addr;
+    ssize_t size;
+    uint8_t *data;
+};
+
+void image_blob_reset(void *opaque);
+void image_file_reset(void *opaque);
+
 #endif
-- 
1.7.1

  reply	other threads:[~2012-10-26  8:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26  8:02 [Qemu-devel] [PATCH 0/5] register reset handlers to reload image Olivia Yin
2012-10-26  8:02 ` Olivia Yin [this message]
2012-10-26  8:02   ` [Qemu-devel] [PATCH 2/5] use reset handlers to reload kernel and initrd Olivia Yin
2012-10-26  8:02     ` [Qemu-devel] [PATCH 3/5] replace rom_add_file* with image_file_reset Olivia Yin
2012-10-26  8:02       ` [Qemu-devel] [PATCH 4/5] replaece rom_add_blob* with image_blob_reset Olivia Yin
2012-10-26  8:02         ` [Qemu-devel] [PATCH 5/5] remove rom related functions in loader Olivia Yin
2012-10-26  9:32     ` [Qemu-devel] [PATCH 2/5] use reset handlers to reload kernel and initrd 陳韋任 (Wei-Ren Chen)
2012-10-29  5:12       ` Yin Olivia-R63875
2012-10-26  9:28   ` [Qemu-devel] [PATCH 1/5] define image_file_reset and image_blob_reset 陳韋任 (Wei-Ren Chen)
2012-10-26  9:17 ` [Qemu-devel] [PATCH 0/5] register reset handlers to reload image 陳韋任 (Wei-Ren Chen)

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=1351238526-2551-2-git-send-email-hong-hua.yin@freescale.com \
    --to=hong-hua.yin@freescale.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).