tz_vmm: support USB-Armory board

For the USB-Armory, we use a newer version of Linux (3.18) as for the
i.MX53-QSB. The main difference is, that the newer Linux uses a DTB instead of
ATAGs.

Fixes #1422
This commit is contained in:
Martin Stein 2015-02-25 00:02:36 +01:00 committed by Christian Helmuth
parent be392b3bf9
commit 9737b5d966
10 changed files with 152 additions and 35 deletions

View File

@ -28,8 +28,8 @@ namespace Trustzone
*/
SECURE_RAM_BASE = Genode::Board_base::RAM0_BASE,
SECURE_RAM_SIZE = 256 * 1024 * 1024,
NONSECURE_RAM_BASE = Genode::Board_base::RAM1_BASE,
NONSECURE_RAM_SIZE = Genode::Board_base::RAM1_SIZE,
NONSECURE_RAM_BASE = Genode::Board_base::RAM0_BASE + SECURE_RAM_SIZE,
NONSECURE_RAM_SIZE = 256 * 1024 * 1024,
};
}

View File

@ -1,6 +1,7 @@
#
# \brief Virtual-machine monitor demo
# \author Stefan Kalkowski
# \author Martin Stein
# \date 2012-06-25
#
@ -35,8 +36,38 @@ install_config {
</config>
}
set init_uri "http://genode.org/files/images/imx53_qsb/initrd.gz"
set linux_uri "http://genode.org/files/images/imx53_qsb/linux_trustzone.bin"
set init_uri "http://genode.org/files/images/imx53_qsb/initrd.gz"
if {[have_spec hw_usb_armory]} {
#
# This Linux and DTB were build with this toolchain:
#
# ! http://releases.linaro.org/14.09/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.9-2014.09_linux.tar.xz
#
# From this sources:
#
# ! https://github.com/m-stein/linux/tree/usb_armory_genode_tz_vmm
#
# With the following commands:
#
# ! make ARCH=arm CROSS_COMPILE=$GCC/bin/arm-none-eabi- imx_v53_usb_armory_defconfig
# ! make ARCH=arm CROSS_COMPILE=$GCC/bin/arm-none-eabi- zImage LOADADDR=0x80008000
# ! make ARCH=arm CROSS_COMPILE=$GCC/bin/arm-none-eabi- dtbs
#
# Then 'arch/arm/boot/zImage' can be used as 'linux' and
# 'arch/arm/boot/dts/imx53-qsb.dtb' can be used as 'dtb'.
#
set linux_uri "https://github.com/m-stein/genode_binaries/raw/master/tz_vmm/imx53/linux"
set dtb_uri "https://github.com/m-stein/genode_binaries/raw/master/tz_vmm/imx53/dtb"
if {![file exists bin/dtb]} {
puts "Download device tree ..."
exec >& /dev/null wget -c -O bin/dtb $dtb_uri
}
exec >& /dev/null wget -O bin/dtb.md5 $dtb_uri.md5
} elseif {[have_spec hw_imx53_qsb_tz]} {
set linux_uri "http://genode.org/files/images/imx53_qsb/linux_trustzone.bin"
}
if {![file exists bin/initrd.gz]} {
puts "Download initramfs ..."
@ -49,11 +80,14 @@ if {![file exists bin/linux]} {
exec >& /dev/null wget -O bin/initrd.gz.md5 $init_uri.md5
exec >& /dev/null wget -O bin/linux.md5 $linux_uri.md5
cd bin
if {[have_spec hw_usb_armory]} { exec md5sum -c dtb.md5 }
exec md5sum -c initrd.gz.md5
exec md5sum -c linux.md5
cd ..
build_boot_image "core init tz_vmm linux initrd.gz"
set boot_modules { core init tz_vmm linux initrd.gz }
lappend_if [have_spec hw_usb_armory] boot_modules dtb
build_boot_image [join $boot_modules " "]
#
# Execute test case
@ -64,8 +98,8 @@ set serial_id [output_spawn_id]
# Wait for network to settle down
send -i $serial_id "sleep 5\n"
send -i $serial_id "wget http://genode.org/\n"
run_genode_until "Connecting to genode.org" 10 $serial_id
run_genode_until {.*\/ #.*} 30 $serial_id
exec rm bin/initrd.gz bin/initrd.gz.md5 bin/linux bin/linux.md5
if {[have_spec hw_usb_armory]} { exec rm bin/dtb bin/dtb.md5 }

View File

@ -21,7 +21,6 @@
/* local includes */
#include <vm.h>
#include <atag.h>
#include <m4if.h>
using namespace Genode;

View File

@ -0,0 +1,9 @@
TARGET = tz_vmm
REQUIRES += trustzone platform_imx53
LIBS = base
SRC_CC = main.cc
INC_DIR += $(PRG_DIR) \
$(PRG_DIR)/../include \
$(PRG_DIR)/../imx53
vpath main.cc $(PRG_DIR)/../imx53

View File

@ -1,5 +0,0 @@
TARGET = tz_vmm
REQUIRES = trustzone platform_imx53
LIBS = base
SRC_CC = main.cc
INC_DIR += $(PRG_DIR) $(PRG_DIR)/../include

View File

@ -0,0 +1,3 @@
REQUIRES = hw_imx53_qsb
include $(PRG_DIR)/../imx53/target.inc

View File

@ -0,0 +1,43 @@
/*
* \brief Virtual Machine implementation using device trees
* \author Stefan Kalkowski
* \date 2015-02-27
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#include <vm_base.h>
#include <atag.h>
class Vm : public Vm_base
{
private:
enum { ATAG_OFFSET = 0x100 };
Genode::addr_t _load_board_info()
{
Atag tag((void*)(_ram.local() + ATAG_OFFSET));
tag.setup_mem_tag(_ram.base(), _ram.size());
tag.setup_cmdline_tag(_cmdline);
tag.setup_initrd2_tag(_ram.base() + INITRD_OFFSET, _initrd_cap.size());
if (_board_rev)
tag.setup_rev_tag(_board_rev);
tag.setup_end_tag();
return ATAG_OFFSET;
}
public:
Vm(const char *kernel, const char *initrd, const char *cmdline,
Genode::addr_t ram_base, Genode::size_t ram_size,
Genode::addr_t kernel_offset, unsigned long mach_type,
unsigned long board_rev = 0)
: Vm_base(kernel, initrd, cmdline, ram_base, ram_size,
kernel_offset, mach_type, board_rev) {}
};

View File

@ -23,16 +23,12 @@
/* local includes */
#include <mmu.h>
#include <atag.h>
class Vm {
class Vm_base {
private:
protected:
enum {
ATAG_OFFSET = 0x100,
INITRD_OFFSET = 0x1000000,
};
enum { INITRD_OFFSET = 0x1000000, };
Genode::Vm_connection _vm_con;
Genode::Rom_connection _kernel_rom;
@ -68,23 +64,14 @@ class Vm {
env()->rm_session()->detach((void*)addr);
}
void _prepare_atag()
{
Atag tag((void*)(_ram.local() + ATAG_OFFSET));
tag.setup_mem_tag(_ram.base(), _ram.size());
tag.setup_cmdline_tag(_cmdline);
tag.setup_initrd2_tag(_ram.base() + INITRD_OFFSET, _initrd_cap.size());
if (_board_rev)
tag.setup_rev_tag(_board_rev);
tag.setup_end_tag();
}
virtual Genode::addr_t _load_board_info() = 0;
public:
Vm(const char *kernel, const char *initrd, const char *cmdline,
Genode::addr_t ram_base, Genode::size_t ram_size,
Genode::addr_t kernel_offset, unsigned long mach_type,
unsigned long board_rev = 0)
Vm_base(const char *kernel, const char *initrd, const char *cmdline,
Genode::addr_t ram_base, Genode::size_t ram_size,
Genode::addr_t kernel_offset, unsigned long mach_type,
unsigned long board_rev = 0)
: _kernel_rom(kernel),
_initrd_rom(initrd),
_kernel_cap(_kernel_rom.dataspace()),
@ -102,10 +89,10 @@ class Vm {
Genode::memset((void*)_state, 0, sizeof(Genode::Vm_state));
_load_kernel();
_load_initrd();
_prepare_atag();
_state->cpsr = 0x93; /* SVC mode and IRQs disabled */
_state->r0 = 0;
_state->r1 = _mach_type;
_state->r2 = _ram.base() + ATAG_OFFSET; /* ATAG addr */
_state->r2 = _ram.base() + _load_board_info(); /* board info addr */
}
void sig_handler(Genode::Signal_context_capability sig_cap) {

View File

@ -0,0 +1,3 @@
REQUIRES = hw_usb_armory
include $(PRG_DIR)/../imx53/target.inc

View File

@ -0,0 +1,44 @@
/*
* \brief Virtual Machine implementation using device trees
* \author Stefan Kalkowski
* \date 2015-02-27
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#include <vm_base.h>
class Vm : public Genode::Rom_connection,
public Genode::Dataspace_client,
public Vm_base
{
private:
enum { DTB_OFFSET = 0x2000000 };
Genode::addr_t _load_board_info()
{
using namespace Genode;
addr_t addr = env()->rm_session()->attach(*this);
memcpy((void*)(_ram.local() + DTB_OFFSET), (void*)addr, size());
env()->rm_session()->detach((void*)addr);
return DTB_OFFSET;
}
public:
Vm(const char *kernel, const char *initrd, const char *cmdline,
Genode::addr_t ram_base, Genode::size_t ram_size,
Genode::addr_t kernel_offset, unsigned long mach_type,
unsigned long board_rev = 0)
: Genode::Rom_connection("dtb"),
Genode::Dataspace_client(dataspace()),
Vm_base(kernel, initrd, cmdline, ram_base, ram_size,
kernel_offset, mach_type, board_rev) {}
};