From: Dmitry Voytik <dmitry.voy...@huawei.com>

This patch implements a loader, that can be used to boot a Linux
kernel in a Jailhouse cell on AArch64.

Signed-off-by: Dmitry Voytik <dmitry.voy...@huawei.com>
Signed-off-by: Antonios Motakis <antonios.mota...@huawei.com>
[antonios.mota...@huawei.com:
        - split foundation-v8 configuration to a separate patch
        - small fixes in the linux loader output
        - take kernel and dtb address using cell load command line ]
Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>
---
 inmates/tools/arm64/Makefile       | 19 +++++++++++
 inmates/tools/arm64/linux-loader.c | 66 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+)
 create mode 100644 inmates/tools/arm64/linux-loader.c

diff --git a/inmates/tools/arm64/Makefile b/inmates/tools/arm64/Makefile
index e69de29..4a72277 100644
--- a/inmates/tools/arm64/Makefile
+++ b/inmates/tools/arm64/Makefile
@@ -0,0 +1,19 @@
+#
+# Jailhouse, a Linux-based partitioning hypervisor
+#
+# Copyright (c) Siemens AG, 2013-2015
+#
+# Authors:
+#  Jan Kiszka <jan.kis...@siemens.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+#
+
+include $(INMATES_LIB)/Makefile.lib
+
+INMATES := linux-loader.bin
+
+linux-loader-y := linux-loader.o
+
+$(eval $(call DECLARE_TARGETS,$(INMATES)))
diff --git a/inmates/tools/arm64/linux-loader.c 
b/inmates/tools/arm64/linux-loader.c
new file mode 100644
index 0000000..e8a6cac
--- /dev/null
+++ b/inmates/tools/arm64/linux-loader.c
@@ -0,0 +1,66 @@
+/*
+ * Jailhouse AArch64 support
+ *
+ * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH
+ *
+ * Authors:
+ *  Dmitry Voytik <dmitry.voy...@huawei.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#include <inmate.h>
+
+/* Example memory map:
+ *     0x00000000 - 0x00003fff (16K) this binary
+ *     0x00280000                    Image
+ *     0x0fe00000                    dtb
+ */
+
+#define CMDLINE_BUFFER_SIZE    256
+CMDLINE_BUFFER(CMDLINE_BUFFER_SIZE);
+
+struct arm64_linux_header {
+       u32 code0;              /* Executable code */
+       u32 code1;              /* Executable code */
+       u64 text_offset;        /* Image load offset, little endian */
+       u64 image_size;         /* Effective Image size, little endian */
+       u64 flags;              /* kernel flags, little endian */
+       u64 res2;               /* = 0, reserved */
+       u64 res3;               /* = 0, reserved */
+       u64 res4;               /* = 0, reserved */
+       u32 magic;              /* 0x644d5241 Magic number, little endian,
+                                  "ARM\x64" */
+       u32 res5;               /* reserved (used for PE COFF offset) */
+};
+
+void inmate_main(void)
+{
+       struct arm64_linux_header *kernel;
+       unsigned long dtb;
+       void (*entry)(unsigned long);
+
+       printk("\nJailhouse ARM64 Linux bootloader\n");
+
+       kernel = (void *) cmdline_parse_int("kernel", 0);
+       dtb = cmdline_parse_int("dtb", 0);
+
+       if (!kernel || !dtb) {
+               printk("ERROR: command line parameters kernel and dtb"
+                                                       " are required\n");
+               while(1);
+       }
+
+       entry = (void*)(unsigned long) kernel;
+
+       printk("DTB:        0x%016lx\n", dtb);
+       printk("Image:      0x%016lx\n", kernel);
+       printk("Image size: %lu Bytes\n", kernel->image_size);
+       printk("entry:      0x%016lx\n", entry);
+       if (kernel->magic != 0x644d5241)
+               printk("WARNING: wrong Linux Image header magic: 0x%08x\n",
+                      kernel->magic);
+
+       entry(dtb);
+}
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jailhouse-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to