]> Git Repo - qemu.git/commitdiff
loader: Add load_image_size() to replace load_image()
authorBenjamin Herrenschmidt <[email protected]>
Mon, 21 Jul 2014 03:02:03 +0000 (13:02 +1000)
committerAlexander Graf <[email protected]>
Mon, 8 Sep 2014 10:50:48 +0000 (12:50 +0200)
A subsequent patch to ppc/spapr needs to load the RTAS blob into
qemu memory rather than target memory (so it can later be copied
into the right spot at machine reset time).

I would use load_image() but it is marked deprecated because it
doesn't take a buffer size as argument, so let's add load_image_size()
that does.

Signed-off-by: Benjamin Herrenschmidt <[email protected]>
[aik: fixed errors from checkpatch.pl]
Signed-off-by: Alexey Kardashevskiy <[email protected]>
Signed-off-by: Alexander Graf <[email protected]>
hw/core/loader.c
include/hw/loader.h

index 193f0f8400471d265a547b7533051ecb787d0712..597b117db3009f6c7e90ee967115d7f02d08535a 100644 (file)
@@ -89,6 +89,27 @@ int load_image(const char *filename, uint8_t *addr)
     return size;
 }
 
+/* return the size or -1 if error */
+ssize_t load_image_size(const char *filename, void *addr, size_t size)
+{
+    int fd;
+    ssize_t actsize;
+
+    fd = open(filename, O_RDONLY | O_BINARY);
+    if (fd < 0) {
+        return -1;
+    }
+
+    actsize = read(fd, addr, size);
+    if (actsize < 0) {
+        close(fd);
+        return -1;
+    }
+    close(fd);
+
+    return actsize;
+}
+
 /* read()-like version */
 ssize_t read_targphys(const char *name,
                       int fd, hwaddr dst_addr, size_t nbytes)
index 00c9117ee08a148742c4294b07b0facb713897fd..9190387b8e5cd32604adba271ba3ec91824d701e 100644 (file)
@@ -13,6 +13,7 @@
  */
 int get_image_size(const char *filename);
 int load_image(const char *filename, uint8_t *addr); /* deprecated */
+ssize_t load_image_size(const char *filename, void *addr, size_t size);
 int load_image_targphys(const char *filename, hwaddr,
                         uint64_t max_sz);
 int load_image_gzipped(const char *filename, hwaddr addr, uint64_t max_sz);
This page took 0.027919 seconds and 4 git commands to generate.