From 0c23c22067355c0b3c3660e14507d79915edea7e Mon Sep 17 00:00:00 2001 From: Ola Redell Date: Wed, 15 Nov 2017 13:37:10 +0100 Subject: Initial commit --- COPYING.MIT | 17 ++ README.md | 112 +++++++++++ classes/jailhouse-cell.bbclass | 24 +++ conf/layer.conf | 10 + .../jailhouse/files/0001-ldflags-for-tools.patch | 13 ++ .../jailhouse/files/0002-no-ldflags-in-tools.patch | 13 ++ ...ound-if-changed-problem-in-tools-makefile.patch | 18 ++ .../jailhouse/files/0004-no-kbuild-of-tools.patch | 13 ++ .../jailhouse/files/jailhouse-config-bpi.h | 9 + .../jailhouse/files/plamics-bpi-root.c | 221 +++++++++++++++++++++ recipes-jailhouse/jailhouse/jailhouse-defs.inc | 25 +++ recipes-jailhouse/jailhouse/jailhouse.inc | 71 +++++++ recipes-jailhouse/jailhouse/jailhouse_0.6.bb | 11 + 13 files changed, 557 insertions(+) create mode 100644 COPYING.MIT create mode 100644 README.md create mode 100644 classes/jailhouse-cell.bbclass create mode 100644 conf/layer.conf create mode 100644 recipes-jailhouse/jailhouse/files/0001-ldflags-for-tools.patch create mode 100644 recipes-jailhouse/jailhouse/files/0002-no-ldflags-in-tools.patch create mode 100644 recipes-jailhouse/jailhouse/files/0003-workaround-if-changed-problem-in-tools-makefile.patch create mode 100644 recipes-jailhouse/jailhouse/files/0004-no-kbuild-of-tools.patch create mode 100644 recipes-jailhouse/jailhouse/files/jailhouse-config-bpi.h create mode 100644 recipes-jailhouse/jailhouse/files/plamics-bpi-root.c create mode 100644 recipes-jailhouse/jailhouse/jailhouse-defs.inc create mode 100644 recipes-jailhouse/jailhouse/jailhouse.inc create mode 100644 recipes-jailhouse/jailhouse/jailhouse_0.6.bb diff --git a/COPYING.MIT b/COPYING.MIT new file mode 100644 index 0000000..89de354 --- /dev/null +++ b/COPYING.MIT @@ -0,0 +1,17 @@ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..467a847 --- /dev/null +++ b/README.md @@ -0,0 +1,112 @@ +meta-jailhouse +============== + +This README file contains information on the contents of the +jailhouse layer. + + +Dependencies +============ + +This layer depends on: + + URI: git://git.openembedded.org/bitbake + branch: master + + URI: git://git.openembedded.org/openembedded-core + layers: meta + branch: master + + +Maintainers +=========== + +* Ola Redell +* Anders Törnqvist +* Jonas Weståker + +Please submit any patches against this jailhouse layer to +meta-jailhouse@retotech.se + + +Tested with +=========== + +This layer has been developed for and tested with Bananapi M1 as target. +No other targets have been used thus far. + + +Adding the jailhouse layer to your build +======================================== + +In order to use this layer, you need to make the build system aware of +it. + +Assuming the jailhouse layer exists at the top-level of your +yocto build tree, you can add it to the build system by adding the +location of the jailhouse layer to bblayers.conf, along with any +other layers needed. e.g.: + + BBLAYERS ?= " \ + /path/to/yocto/meta \ + /path/to/yocto/meta-poky \ + /path/to/yocto/meta-yocto-bsp \ + /path/to/yocto/meta-jailhouse \ + " + + +Build Jailhouse using this layer +================================ + +Include the following packages in your image: **jailhouse** and +**kernel-module-jailhouse**. For example, add the following +to your image recipe, or local.conf: + + IMAGE_INSTALL_append = " jailhouse kernel-module-jailhouse" + +The jailhouse inmates and cells are by default +placed under `/usr/share/jailhouse/{inmates,cells}`. These locations +can be adjusted using the variables in jailhouse-dirs.inc. + +The jailhouse build system builds cell configuration (*.cell) files from the +cell descriptions (*.c). To enable cell descriptions being defined in +cell recipes and imported into the jailhouse build, the jailhouse recipe +defines a CELLS variable that lists all recipes that provide cells (and inmates) +for the jailhouse build. Adapt the CELLS variable according to your needs, e.g. + + CELLS_append = " freertos-cell" + +With this declaration, freertos-cell entries will be added both to the +DEPENDS and the RDEPENDS_jailhouse variables, and the jailhouse recipe will +pull cell descriptions from the staging directory before building. + + +Packages produced by a jailhouse.inc based recipe +------------------------------------------------- + +The Jailhouse recipes based on the file jailhouse.inc produce +the follwing packages: + +* **jailhouse**, with the `jailhouse.bin` firmware, the `jailhouse` user +space application, along with all inmate binaries that come with the jailhouse +repo, and all cells for which jailhouse is given configuration att build time. +* **jailhouse-bash-completion**, with file(s) needed for bash completion. +* **jailhouse-dbg**, jailhouse cli sources +* **kernel-module-jailhouse**, with the jailhouse kernel module, jailhouse.ko + + +Build cells and inmates +======================= + +To build jailhouse cell definitions and inmates, inherit the class +`jailhouse-cell.bbclass` into your cell recipe and define your inmate binary, +and your cell configuration file using the variables `INMATE` and `CELLCONFIG` +as follows: + + inherit jailhouse-cell + INMATE = "${S}/freertos-demo.bin" + CELLCONFIG = "${S}/jailhouse-configs/bananapi-freertos-demo.c" + +Using this class and variables ensures that the file designated by the +`CELLCONFIG` variable is pulled into the jailhouse build such that +a corresponding *.cell file is created. diff --git a/classes/jailhouse-cell.bbclass b/classes/jailhouse-cell.bbclass new file mode 100644 index 0000000..ab7b9ce --- /dev/null +++ b/classes/jailhouse-cell.bbclass @@ -0,0 +1,24 @@ +require recipes-jailhouse/jailhouse/jailhouse-defs.inc + +INMATE ?= "" +CELLCONFIG ?= "" + +INMATE_TARGET ?= "${INMATE}" +CELLCONFIG_TARGET ?= "${CELLCONFIG}" + +do_install() { + if [ -n "${CELLCONFIG}" ] + then + install -d ${D}${CELLCONF_DIR} + install ${CELLCONFIG} ${D}${CELLCONF_DIR}/$(basename ${CELLCONFIG_TARGET}) + fi + + if [ -n "${INMATE}" ] + then + install -d ${D}${INMATES_DIR} + install ${INMATE} ${D}${INMATES_DIR}/$(basename ${INMATE_TARGET}) + fi +} + +FILES_${PN}-dev += "${CELLCONF_DIR}" +FILES_${PN} += "${INMATES_DIR}" diff --git a/conf/layer.conf b/conf/layer.conf new file mode 100644 index 0000000..c81174e --- /dev/null +++ b/conf/layer.conf @@ -0,0 +1,10 @@ +# We have a conf and classes directory, add to BBPATH +BBPATH .= ":${LAYERDIR}" + +# We have recipes-* directories, add to BBFILES +BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ + ${LAYERDIR}/recipes-*/*/*.bbappend" + +BBFILE_COLLECTIONS += "jailhouse" +BBFILE_PATTERN_jailhouse = "^${LAYERDIR}/" +BBFILE_PRIORITY_jailhouse = "6" diff --git a/recipes-jailhouse/jailhouse/files/0001-ldflags-for-tools.patch b/recipes-jailhouse/jailhouse/files/0001-ldflags-for-tools.patch new file mode 100644 index 0000000..47b79ed --- /dev/null +++ b/recipes-jailhouse/jailhouse/files/0001-ldflags-for-tools.patch @@ -0,0 +1,13 @@ +diff --git a/tools/Makefile b/tools/Makefile +index 4d91e7a..ecc5503 100644 +--- a/tools/Makefile ++++ b/tools/Makefile +@@ -19,7 +19,7 @@ LINUXINCLUDE := -I$(src)/../driver + KBUILD_CFLAGS := -g -O3 -DLIBEXECDIR=\"$(libexecdir)\" \ + -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Werror \ + -DJAILHOUSE_VERSION=\"$(shell cat $(src)/../VERSION)\" $(EXTRA_CFLAGS) +-LDFLAGS := ++LDFLAGS := $(EXTRA_LDLAGS) + + BINARIES := jailhouse + HELPERS := \ diff --git a/recipes-jailhouse/jailhouse/files/0002-no-ldflags-in-tools.patch b/recipes-jailhouse/jailhouse/files/0002-no-ldflags-in-tools.patch new file mode 100644 index 0000000..e94f69d --- /dev/null +++ b/recipes-jailhouse/jailhouse/files/0002-no-ldflags-in-tools.patch @@ -0,0 +1,13 @@ +diff --git a/tools/Makefile b/tools/Makefile +index 4d91e7a..ecc5503 100644 +--- a/tools/Makefile ++++ b/tools/Makefile +@@ -19,7 +19,7 @@ LINUXINCLUDE := -I$(src)/../driver + KBUILD_CFLAGS := -g -O3 -DLIBEXECDIR=\"$(libexecdir)\" \ + -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Werror \ + -DJAILHOUSE_VERSION=\"$(shell cat $(src)/../VERSION)\" $(EXTRA_CFLAGS) +-LDFLAGS := ++#LDFLAGS := $(EXTRA_LDLAGS) + + BINARIES := jailhouse + HELPERS := \ diff --git a/recipes-jailhouse/jailhouse/files/0003-workaround-if-changed-problem-in-tools-makefile.patch b/recipes-jailhouse/jailhouse/files/0003-workaround-if-changed-problem-in-tools-makefile.patch new file mode 100644 index 0000000..7d02b55 --- /dev/null +++ b/recipes-jailhouse/jailhouse/files/0003-workaround-if-changed-problem-in-tools-makefile.patch @@ -0,0 +1,18 @@ +Index: git/tools/Makefile +=================================================================== +--- git.orig/tools/Makefile ++++ git/tools/Makefile +@@ -55,10 +55,11 @@ endef + targets += jailhouse.o + + $(obj)/jailhouse: $(obj)/jailhouse.o +- $(call if_changed,ld) ++ $(LD) $(LDFLAGS) -o $@ $^ + + $(obj)/jailhouse-config-collect: $(src)/jailhouse-config-create $(src)/jailhouse-config-collect.tmpl +- $(call if_changed,gen_collect) ++ $< -g $@; \ ++ chmod +x $@ + + install-bin: $(BINARIES) $(DESTDIR)$(sbindir) + $(INSTALL_PROGRAM) $^ diff --git a/recipes-jailhouse/jailhouse/files/0004-no-kbuild-of-tools.patch b/recipes-jailhouse/jailhouse/files/0004-no-kbuild-of-tools.patch new file mode 100644 index 0000000..4e0f337 --- /dev/null +++ b/recipes-jailhouse/jailhouse/files/0004-no-kbuild-of-tools.patch @@ -0,0 +1,13 @@ +Index: git/Kbuild +=================================================================== +--- git.orig/Kbuild ++++ git/Kbuild +@@ -11,7 +11,7 @@ + # the COPYING file in the top-level directory. + # + +-subdir-y := driver hypervisor configs inmates tools ++subdir-y := driver hypervisor configs inmates + + subdir-ccflags-y := -Werror + diff --git a/recipes-jailhouse/jailhouse/files/jailhouse-config-bpi.h b/recipes-jailhouse/jailhouse/files/jailhouse-config-bpi.h new file mode 100644 index 0000000..91f651c --- /dev/null +++ b/recipes-jailhouse/jailhouse/files/jailhouse-config-bpi.h @@ -0,0 +1,9 @@ +#define CONFIG_ARM_GIC_V2 1 +#define CONFIG_MACH_SUN7I 1 + +/* Enable error tracing, + * c.f. https://github.com/siemens/jailhouse/blob/master/FAQ.md + * (Redefine macro: + * jailhouse/hypervisor/include/jailhouse/printk.h:trace_error(code)). + */ +#define CONFIG_TRACE_ERROR diff --git a/recipes-jailhouse/jailhouse/files/plamics-bpi-root.c b/recipes-jailhouse/jailhouse/files/plamics-bpi-root.c new file mode 100644 index 0000000..3d7b79f --- /dev/null +++ b/recipes-jailhouse/jailhouse/files/plamics-bpi-root.c @@ -0,0 +1,221 @@ +/* + * Jailhouse, a Linux-based partitioning hypervisor + * + * Test configuration for Banana Pi board (A20 dual-core Cortex-A7, 1G RAM) + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include +#include + +#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0]) + +struct { + struct jailhouse_system header; + __u64 cpus[1]; + struct jailhouse_memory mem_regions[18]; + struct jailhouse_irqchip irqchips[1]; + struct jailhouse_pci_device pci_devices[1]; +} __attribute__((packed)) config = { + .header = { + .signature = JAILHOUSE_SYSTEM_SIGNATURE, + .revision = JAILHOUSE_CONFIG_REVISION, + .hypervisor_memory = { + .phys_start = 0x7c000000, + .size = 0x4000000, + }, + .debug_console = { + .address = 0x01c28000, + .size = 0x1000, + /* .clock_reg = 0x01c2006c, */ + /* .gate_nr = 16 */ + /* .divider = 0x0d, */ + .flags = JAILHOUSE_CON_TYPE_8250 | + JAILHOUSE_CON_FLAG_MMIO, + }, + .platform_info = { + .pci_mmconfig_base = 0x2000000, + .pci_mmconfig_end_bus = 0, + .pci_is_virtual = 1, + .arm = { + .gicd_base = 0x01c81000, + .gicc_base = 0x01c82000, + .gich_base = 0x01c84000, + .gicv_base = 0x01c86000, + .maintenance_irq = 25, + }, + }, + .root_cell = { + .name = "Banana-Pi", + + .cpu_set_size = sizeof(config.cpus), + .num_memory_regions = ARRAY_SIZE(config.mem_regions), + .num_irqchips = ARRAY_SIZE(config.irqchips), + .num_pci_devices = ARRAY_SIZE(config.pci_devices), + + .vpci_irq_base = 108, + }, + }, + + .cpus = { + 0x3, + }, + + .mem_regions = { + /* SPI */ { + .phys_start = 0x01c05000, + .virt_start = 0x01c05000, + .size = 0x00001000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO, + }, + /* MMC */ { + .phys_start = 0x01c0f000, + .virt_start = 0x01c0f000, + .size = 0x00001000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO, + }, + /* USB + PMU1 */ { + .phys_start = 0x01c14000, + .virt_start = 0x01c14000, + .size = 0x00001000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO, + }, + /* SATA */ { + .phys_start = 0x01c18000, + .virt_start = 0x01c18000, + .size = 0x00001000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO, + }, + /* USB + PMU2 */ { + .phys_start = 0x01c1c000, + .virt_start = 0x01c1c000, + .size = 0x00001000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO, + }, + /* CCU */ { + .phys_start = 0x01c20000, + .virt_start = 0x01c20000, + .size = 0x400, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32, + }, + /* Ints */ { + .phys_start = 0x01c20400, + .virt_start = 0x01c20400, + .size = 0x400, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32, + }, + /* GPIO: ports A-G */ { + .phys_start = 0x01c20800, + .virt_start = 0x01c20800, + .size = 0xfc, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32, + }, + /* GPIO: port H */ { + .phys_start = 0x01c208fc, + .virt_start = 0x01c208fc, + .size = 0x24, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32, + }, + /* GPIO: port I */ { + .phys_start = 0x01c20920, + .virt_start = 0x01c20920, + .size = 0x24, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32, + }, + /* GPIO: intr config */ { + .phys_start = 0x01c20a00, + .virt_start = 0x01c20a00, + .size = 0x1c, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32, + }, + /* Timer */ { + .phys_start = 0x01c20c00, + .virt_start = 0x01c20c00, + .size = 0x400, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32, + }, + /* UART0-3 */ { + .phys_start = 0x01c28000, + .virt_start = 0x01c28000, + .size = 0x1000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO, + }, + /* GMAC */ { + .phys_start = 0x01c50000, + .virt_start = 0x01c50000, + .size = 0x00010000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO, + }, + /* HSTIMER */ { + .phys_start = 0x01c60000, + .virt_start = 0x01c60000, + .size = 0x00001000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO, + }, + /* RAM */ { + .phys_start = 0x40000000, + .virt_start = 0x40000000, + .size = 0x3bf00000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_EXECUTE, + }, + /* IVSHMEM shared memory region */ { + .phys_start = 0x7bf00000, + .virt_start = 0x7bf00000, + .size = 0x100000, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE, + }, + /* Framebuffer */ { + .phys_start = 0x7f700000, + .virt_start = 0x7f700000, + .size = 9<<20, + .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE | + JAILHOUSE_MEM_IO, + }, + }, + + .irqchips = { + /* GIC */ { + .address = 0x01c81000, + .pin_base = 32, + .pin_bitmap = { + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff + }, + }, + }, + + .pci_devices = { + { + .type = JAILHOUSE_PCI_TYPE_IVSHMEM, + .bdf = 0x00, + .bar_mask = { + 0xffffff00, 0xffffffff, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, + }, + .shmem_region = 16, + .shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED, + }, + }, +}; diff --git a/recipes-jailhouse/jailhouse/jailhouse-defs.inc b/recipes-jailhouse/jailhouse/jailhouse-defs.inc new file mode 100644 index 0000000..8dd30e3 --- /dev/null +++ b/recipes-jailhouse/jailhouse/jailhouse-defs.inc @@ -0,0 +1,25 @@ +JH_DATADIR ?= "${datadir}/jailhouse" +CELL_DIR ?= "${JH_DATADIR}/cells" +CELLCONF_DIR ?= "${JH_DATADIR}/configs" +INMATES_DIR ?= "${JH_DATADIR}/inmates" + +# Set jailhouse architecture JH_ARCH variable +# +# return value must match one of architectures supported by jailhouse +# +valid_jh_archs = "x86 arm" + +def map_jh_arch(a, d): + import re + + valid_jh_archs = d.getVar('valid_jh_archs', True).split() + + if re.match('(i.86|athlon|x86.64)$', a): return 'x86' + elif re.match('armeb$', a): return 'arm' + elif re.match('aarch64$', a): return 'arm64' + elif re.match('aarch64_be$', a): return 'arm64' + elif a in valid_jh_archs: return a + else: + bb.error("cannot map '%s' to a jailhouse supported architecture" % a) + +export JH_ARCH = "${@map_jh_arch(d.getVar('TARGET_ARCH', True), d)}" diff --git a/recipes-jailhouse/jailhouse/jailhouse.inc b/recipes-jailhouse/jailhouse/jailhouse.inc new file mode 100644 index 0000000..fb6b021 --- /dev/null +++ b/recipes-jailhouse/jailhouse/jailhouse.inc @@ -0,0 +1,71 @@ +SUMMARY = "Jailhouse" +HOMEPAGE = "https://github.com/siemens/jailhouse" +SECTION = "jailhouse" +LICENSE = "GPL-2.0 & BSD-2-Clause" +LIC_FILES_CHKSUM = "file://COPYING;md5=9fa7f895f96bde2d47fd5b7d95b6ba4d \ + file://tools/root-cell-config.c.tmpl;beginline=6;endline=33;md5=2825581c1666c44a17955dc574cfbfb3 \ + file://hypervisor/include/jailhouse/hypercall.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3 \ + file://hypervisor/include/jailhouse/cell-config.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3 \ + file://hypervisor/arch/arm/include/asm/jailhouse_hypercall.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3 \ + file://hypervisor/arch/x86/include/asm/jailhouse_hypercall.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3 \ + file://driver/jailhouse.h;beginline=9;endline=36;md5=2825581c1666c44a17955dc574cfbfb3" + +DEPENDS = "virtual/kernel make-native python-mako-native dtc-native python-mako" + +S ="${WORKDIR}/git" + +require jailhouse-defs.inc +inherit module pythonnative bash-completion + +do_configure() { + if [ -d ${STAGING_DIR_HOST}/${CELLCONF_DIR} ]; + then + cp "${STAGING_DIR_HOST}/${CELLCONF_DIR}/"*.c ${S}/configs/ + fi +} + +USER_SPACE_CFLAGS = '${CFLAGS} -DLIBEXECDIR=\\\"${libexecdir}\\\" \ + -DJAILHOUSE_VERSION=\\\"$JAILHOUSE_VERSION\\\" \ + -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Werror \ + -I../driver' + +TOOLS_SRC_DIR = "${S}/tools" +TOOLS_OBJ_DIR = "${S}/tools" + +do_compile() { + oe_runmake V=1 \ + ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} \ + KDIR=${STAGING_KERNEL_BUILDDIR} + + cd ${TOOLS_SRC_DIR} + export JAILHOUSE_VERSION=$(cat ../VERSION) + oe_runmake V=1 \ + CFLAGS="${USER_SPACE_CFLAGS}" \ + src=${TOOLS_SRC_DIR} obj=${TOOLS_OBJ_DIR} \ + ${TOOLS_OBJ_DIR}/jailhouse-config-collect ${TOOLS_OBJ_DIR}/jailhouse +} + +do_install() { + oe_runmake \ + ARCH=${TARGET_ARCH} \ + CROSS_COMPILE=${TARGET_PREFIX} \ + KDIR=${STAGING_KERNEL_BUILDDIR} \ + DESTDIR=${D} install + + install -d ${D}${CELL_DIR} + install ${B}/configs/*.cell ${D}${CELL_DIR}/ + + install -d ${D}${INMATES_DIR} + install ${B}/inmates/demos/${JH_ARCH}/*.bin ${D}${INMATES_DIR} +} + +PACKAGE_BEFORE_PN = "kernel-module-jailhouse" +FILES_${PN} = "${base_libdir}/firmware ${libexecdir} ${sbindir} ${JH_DATADIR}" + +python __anonymous () { + # Setup DEPENDS and RDEPENDS to included cells" + cells = d.getVar('CELLS', True) or "" + for cell in cells.split(): + d.appendVar('DEPENDS', ' ' + cell) + d.appendVar('RDEPENDS_${PN}', ' ' + cell) +} diff --git a/recipes-jailhouse/jailhouse/jailhouse_0.6.bb b/recipes-jailhouse/jailhouse/jailhouse_0.6.bb new file mode 100644 index 0000000..d0fc7f9 --- /dev/null +++ b/recipes-jailhouse/jailhouse/jailhouse_0.6.bb @@ -0,0 +1,11 @@ +require jailhouse.inc + +SRC_URI = "git://github.com/siemens/jailhouse.git;protocol=git \ + file://0002-no-ldflags-in-tools.patch \ + file://0003-workaround-if-changed-problem-in-tools-makefile.patch \ + file://0004-no-kbuild-of-tools.patch \ + " + +SRCREV = "81528e48763c8dfc10851c49968eb3d053d4b85c" + +CELLS = "freertos-cell freertos-demo1-cell freertos-demo3-cell freertos-ivshmem-demo" -- cgit v1.2.3-54-g00ecf From ba584d2c8b184980c4b9b511e91db468584151b2 Mon Sep 17 00:00:00 2001 From: Ola Redell Date: Wed, 15 Nov 2017 14:46:12 +0100 Subject: updated README with variable information --- README.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 467a847..55db8f1 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,15 @@ Maintainers * Anders Törnqvist * Jonas Weståker -Please submit any patches against this jailhouse layer to -meta-jailhouse@retotech.se +Please submit any patches against this jailhouse layer +via email or https://bitbucket.org/retotech/meta-jailhouse Tested with =========== -This layer has been developed for and tested with Bananapi M1 as target. +* Yocto 2.2 +* This layer has been developed for and tested with Bananapi M1 as target. No other targets have been used thus far. @@ -66,13 +67,14 @@ to your image recipe, or local.conf: The jailhouse inmates and cells are by default placed under `/usr/share/jailhouse/{inmates,cells}`. These locations -can be adjusted using the variables in jailhouse-dirs.inc. +can be adjusted using the variables in **jailhouse-defs.inc**. -The jailhouse build system builds cell configuration (*.cell) files from the -cell descriptions (*.c). To enable cell descriptions being defined in -cell recipes and imported into the jailhouse build, the jailhouse recipe -defines a CELLS variable that lists all recipes that provide cells (and inmates) -for the jailhouse build. Adapt the CELLS variable according to your needs, e.g. +The jailhouse build system builds binary cell configuration (*.cell) files +from cell configuration sources (*.c). To allow cell configurations to be +defined in cell recipes and imported into the jailhouse build, the jailhouse +recipe defines a CELLS variable that lists all recipes that provide cells (and +inmates) for the jailhouse build. Adapt the CELLS variable according to your +needs, e.g. CELLS_append = " freertos-cell" @@ -110,3 +112,38 @@ as follows: Using this class and variables ensures that the file designated by the `CELLCONFIG` variable is pulled into the jailhouse build such that a corresponding *.cell file is created. + + +Important Variables +=================== + +The following variables should be set in jailhouse bbappends and cell recipes + +`CELLCONFIG` The name of the source cell configuration file (.c) that a cell +recipe installs into the sysroot, for the jailhouse recipe to use to create +a binary configuration file. This variable should be set in a cell recipe +using a full path e.g. `CELLCONFIG = "${S}/my/path/cell-config.c"`. +Empty by default. + +`CELLS` A list of cells that should be built with jailhouse. The jailhouse +recipe will get dependencies to all cells listed in this variable and +pull in their cell configuration source files to the build. Empty by default. + +`INMATE` The name of the inmate binary file (.bin) that a cell recipe +produces. This variable should be set in a cell recipe +using a full path e.g. `INMATE = "${B}/freertos-demo.bin"`. +Empty by default. + +The following variables can be left as is + +`JH_DATADIR` Base directory for installed jailhouse cells on target. This +defaults to ${datadir}/jailhouse. + +`CELL_DIR` Target directory into which binary cell configuration files (.cell) +are installed. This defaults to ${JH_DATADIR}/cells. + +`CELLCONF_DIR` Target directory into which the source cell configuration files +(.c) are installed. Defaults to ${JH_DATADIR}/configs. + +`INMATES_DIR` Target directory into which inmate binaries (.bin) are installed. +Defaults to ${JH_DATADIR}/inmates. -- cgit v1.2.3-54-g00ecf