All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
To: Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@citrix.com>,
	Tim Deegan <tim@xen.org>,
	xen-devel@lists.xen.org
Subject: [PATCH v2] xen: arm: introduce uImage probe function for Dom0
Date: Wed, 20 Aug 2014 13:04:34 +0300	[thread overview]
Message-ID: <1408529074-20013-1-git-send-email-oleksandr.dmytryshyn@globallogic.com> (raw)

Patch adds a possibility to boot dom0 kernel from uImage.
This is needed to improve boot-time. Comparing to zImage,
uImage is not packed, therefore we can save time needed
to unpack.

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
Changed since v1:
 * fixed commit message
 * added uimage structure definition
 * removed checking of the append device tree

 xen/arch/arm/kernel.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
index d635a7e..20e6884 100644
--- a/xen/arch/arm/kernel.c
+++ b/xen/arch/arm/kernel.c
@@ -16,6 +16,9 @@
 
 #include "kernel.h"
 
+#define UIMAGE32_MAGIC        0x27051956
+#define UIMAGE32_NMLEN        32
+
 #define ZIMAGE32_MAGIC_OFFSET 0x24
 #define ZIMAGE32_START_OFFSET 0x28
 #define ZIMAGE32_END_OFFSET   0x2c
@@ -188,6 +191,64 @@ static void kernel_zimage_load(struct kernel_info *info)
     }
 }
 
+/*
+ * Check if the image is a 32-bit uImage and setup kernel_info
+ */
+static int kernel_uimage32_probe(struct kernel_info *info,
+                                 paddr_t addr, paddr_t size)
+{
+    struct {
+        __be32 magic;   /* Image Header Magic Number */
+        __be32 hcrc;    /* Image Header CRC Checksum */
+        __be32 time;    /* Image Creation Timestamp  */
+        __be32 size;    /* Image Data Size           */
+        __be32 load;    /* Data Load Address         */
+        __be32 ep;      /* Entry Point Address       */
+        __be32 dcrc;    /* Image Data CRC Checksum   */
+        uint8_t os;     /* Operating System          */
+        uint8_t arch;   /* CPU architecture          */
+        uint8_t type;   /* Image Type                */
+        uint8_t comp;   /* Compression Type          */
+        uint8_t name[UIMAGE32_NMLEN]; /* Image Name  */
+    } uimage;
+
+    uint32_t start, len;
+
+    if ( size < sizeof(uimage) )
+        return -EINVAL;
+
+    copy_from_paddr(&uimage, addr, sizeof(uimage));
+
+    if ( be32_to_cpu(uimage.magic) != UIMAGE32_MAGIC )
+        return -EINVAL;
+
+    start = be32_to_cpu(uimage.load);
+    len = be32_to_cpu(uimage.size);
+
+    if ( len > size )
+        return -EINVAL;
+
+    /*
+     * If start is sizeof(zimage) zImage is position independent -- load it
+     * at 32k from start of RAM.
+     */
+    if ( start == 0 )
+        info->zimage.start = info->mem.bank[0].start + 0x8000;
+    else
+        info->zimage.start = start;
+
+    info->zimage.kernel_addr = addr + sizeof(uimage);
+    info->zimage.len = len;
+    info->entry = info->zimage.start;
+    info->load = kernel_zimage_load;
+
+#ifdef CONFIG_ARM_64
+    info->type = DOMAIN_32BIT;
+#endif
+
+    return 0;
+}
+
 #ifdef CONFIG_ARM_64
 /*
  * Check if the image is a 64-bit Image.
@@ -398,6 +459,8 @@ int kernel_probe(struct kernel_info *info)
     rc = kernel_zimage64_probe(info, start, size);
     if (rc < 0)
 #endif
+        rc = kernel_uimage32_probe(info, start, size);
+    if(rc < 0 )
         rc = kernel_zimage32_probe(info, start, size);
     if (rc < 0)
         rc = kernel_elf_probe(info, start, size);
-- 
1.9.1

             reply	other threads:[~2014-08-20 10:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 10:04 Oleksandr Dmytryshyn [this message]
2014-08-20 15:59 ` [PATCH v2] xen: arm: introduce uImage probe function for Dom0 Julien Grall

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=1408529074-20013-1-git-send-email-oleksandr.dmytryshyn@globallogic.com \
    --to=oleksandr.dmytryshyn@globallogic.com \
    --cc=ian.campbell@citrix.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.