summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorAndrii Anisov <andrii_anisov@epam.com>2020-08-06 12:42:47 +0300
committerTom Rini <trini@konsulko.com>2020-08-14 15:18:27 -0400
commit770a8eef3e27a5dc16e286cafa1a58e9201c9721 (patch)
tree16da67f0db3866775e5d78602e2e8d656ba16001 /board
parent365d88ac7ef562daedded3dacb922bd92ccc72cc (diff)
board: Introduce xenguest_arm64 board
Introduce a minimal Xen guest board running as a virtual machine under Xen Project's hypervisor [1], [2]. Part of the code is ported from Xen mini-os and also uses work initially done by different authors from NXP: please see relevant files for their copyrights. [1] https://xenbits.xen.org [2] https://wiki.xenproject.org/ Signed-off-by: Andrii Anisov <andrii_anisov@epam.com> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Diffstat (limited to 'board')
-rw-r--r--board/xen/xenguest_arm64/Kconfig12
-rw-r--r--board/xen/xenguest_arm64/MAINTAINERS7
-rw-r--r--board/xen/xenguest_arm64/Makefile5
-rw-r--r--board/xen/xenguest_arm64/xenguest_arm64.c152
4 files changed, 176 insertions, 0 deletions
diff --git a/board/xen/xenguest_arm64/Kconfig b/board/xen/xenguest_arm64/Kconfig
new file mode 100644
index 0000000000..cc131ed5b9
--- /dev/null
+++ b/board/xen/xenguest_arm64/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_XENGUEST_ARM64
+
+config SYS_BOARD
+ default "xenguest_arm64"
+
+config SYS_VENDOR
+ default "xen"
+
+config SYS_CONFIG_NAME
+ default "xenguest_arm64"
+
+endif
diff --git a/board/xen/xenguest_arm64/MAINTAINERS b/board/xen/xenguest_arm64/MAINTAINERS
new file mode 100644
index 0000000000..787e9e0d0e
--- /dev/null
+++ b/board/xen/xenguest_arm64/MAINTAINERS
@@ -0,0 +1,7 @@
+XEN GUEST FOR ARM64
+M: Andrii Anisov <andrii_anisov@epam.com>
+S: Maintained
+F: board/xen/xenguest_arm64/
+F: doc/board/xen/
+F: include/configs/xenguest_arm64.h
+F: configs/xenguest_arm64_defconfig
diff --git a/board/xen/xenguest_arm64/Makefile b/board/xen/xenguest_arm64/Makefile
new file mode 100644
index 0000000000..1cf87a728f
--- /dev/null
+++ b/board/xen/xenguest_arm64/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2020 EPAM Systems Inc.
+
+obj-y := xenguest_arm64.o
diff --git a/board/xen/xenguest_arm64/xenguest_arm64.c b/board/xen/xenguest_arm64/xenguest_arm64.c
new file mode 100644
index 0000000000..1d1e229085
--- /dev/null
+++ b/board/xen/xenguest_arm64/xenguest_arm64.c
@@ -0,0 +1,152 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) 2013
+ * David Feng <fenghua@phytium.com.cn>
+ * Sharma Bhupesh <bhupesh.sharma@freescale.com>
+ *
+ * (C) 2020 EPAM Systems Inc
+ */
+
+#include <common.h>
+#include <cpu_func.h>
+#include <dm.h>
+#include <errno.h>
+#include <malloc.h>
+
+#include <asm/io.h>
+#include <asm/armv8/mmu.h>
+#include <asm/xen.h>
+#include <asm/xen/hypercall.h>
+
+#include <linux/compiler.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+ return 0;
+}
+
+/*
+ * Use fdt provided by Xen: according to
+ * https://www.kernel.org/doc/Documentation/arm64/booting.txt
+ * x0 is the physical address of the device tree blob (dtb) in system RAM.
+ * This is stored in rom_pointer during low level init.
+ */
+void *board_fdt_blob_setup(void)
+{
+ if (fdt_magic(rom_pointer[0]) != FDT_MAGIC)
+ return NULL;
+ return (void *)rom_pointer[0];
+}
+
+#define MAX_MEM_MAP_REGIONS 5
+static struct mm_region xen_mem_map[MAX_MEM_MAP_REGIONS];
+struct mm_region *mem_map = xen_mem_map;
+
+static int get_next_memory_node(const void *blob, int mem)
+{
+ do {
+ mem = fdt_node_offset_by_prop_value(blob, mem,
+ "device_type", "memory", 7);
+ } while (!fdtdec_get_is_enabled(blob, mem));
+
+ return mem;
+}
+
+static int setup_mem_map(void)
+{
+ int i, ret, mem, reg = 0;
+ struct fdt_resource res;
+ const void *blob = gd->fdt_blob;
+
+ mem = get_next_memory_node(blob, -1);
+ if (mem < 0) {
+ printf("%s: Missing /memory node\n", __func__);
+ return -EINVAL;
+ }
+
+ for (i = 0; i < MAX_MEM_MAP_REGIONS; i++) {
+ ret = fdt_get_resource(blob, mem, "reg", reg++, &res);
+ if (ret == -FDT_ERR_NOTFOUND) {
+ reg = 0;
+ mem = get_next_memory_node(blob, mem);
+ if (mem == -FDT_ERR_NOTFOUND)
+ break;
+
+ ret = fdt_get_resource(blob, mem, "reg", reg++, &res);
+ if (ret == -FDT_ERR_NOTFOUND)
+ break;
+ }
+ if (ret != 0) {
+ printf("No reg property for memory node\n");
+ return -EINVAL;
+ }
+
+ xen_mem_map[i].virt = (phys_addr_t)res.start;
+ xen_mem_map[i].phys = (phys_addr_t)res.start;
+ xen_mem_map[i].size = (phys_size_t)(res.end - res.start + 1);
+ xen_mem_map[i].attrs = (PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE);
+ }
+ return 0;
+}
+
+void enable_caches(void)
+{
+ /* Re-setup the memory map as BSS gets cleared after relocation. */
+ setup_mem_map();
+ icache_enable();
+ dcache_enable();
+}
+
+/* Read memory settings from the Xen provided device tree. */
+int dram_init(void)
+{
+ int ret;
+
+ ret = fdtdec_setup_mem_size_base();
+ if (ret < 0)
+ return ret;
+ /* Setup memory map, so MMU page table size can be estimated. */
+ return setup_mem_map();
+}
+
+int dram_init_banksize(void)
+{
+ return fdtdec_setup_memory_banksize();
+}
+
+/*
+ * Board specific reset that is system reset.
+ */
+void reset_cpu(ulong addr)
+{
+}
+
+int ft_system_setup(void *blob, struct bd_info *bd)
+{
+ return 0;
+}
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+ return 0;
+}
+
+int board_early_init_f(void)
+{
+ return 0;
+}
+
+int print_cpuinfo(void)
+{
+ printf("Xen virtual CPU\n");
+ return 0;
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return NULL;
+}
+