diff --git a/base-hw/include/platform/vea9x4/drivers/trustzone.h b/base-hw/include/platform/vea9x4/drivers/trustzone.h new file mode 100644 index 0000000000..257fea807f --- /dev/null +++ b/base-hw/include/platform/vea9x4/drivers/trustzone.h @@ -0,0 +1,33 @@ +/* + * \brief TrustZone specific definitions for the Versatile Express board + * \author Stefan Kalkowski + * \date 2013-11-15 + */ + +/* + * Copyright (C) 2013 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. + */ + +#ifndef _INCLUDE__PLATFORM__VEA9X4__DRIVERS__TRUSTZONE_H_ +#define _INCLUDE__PLATFORM__VEA9X4__DRIVERS__TRUSTZONE_H_ + +/* Genode includes */ +#include + +namespace Trustzone +{ + enum { + VM_STATE_SIZE = 1 << 20, + SECURE_RAM_BASE = Genode::Board_base::RAM_3_BASE, + SECURE_RAM_SIZE = Genode::Board_base::RAM_3_SIZE - VM_STATE_SIZE, + VM_STATE_BASE = SECURE_RAM_BASE + SECURE_RAM_SIZE, + NONSECURE_RAM_BASE = Genode::Board_base::RAM_1_BASE, + NONSECURE_RAM_SIZE = 0x40000000, + }; +} + +#endif /* _INCLUDE__PLATFORM__VEA9X4__DRIVERS__TRUSTZONE_H_ */ + diff --git a/base-hw/src/core/vea9x4/tlb.h b/base-hw/src/core/vea9x4/no_trustzone/tlb.h similarity index 100% rename from base-hw/src/core/vea9x4/tlb.h rename to base-hw/src/core/vea9x4/no_trustzone/tlb.h diff --git a/base-hw/src/core/vea9x4/trustzone/platform_services.cc b/base-hw/src/core/vea9x4/trustzone/platform_services.cc index c4ebe04f27..870a1e2ca8 100644 --- a/base-hw/src/core/vea9x4/trustzone/platform_services.cc +++ b/base-hw/src/core/vea9x4/trustzone/platform_services.cc @@ -13,6 +13,7 @@ /* Genode includes */ #include +#include /* Core includes */ #include @@ -29,7 +30,15 @@ void Genode::platform_add_local_services(Genode::Rpc_entrypoint *ep, { using namespace Genode; - static Vm_root vm_root(ep, sh, platform()->ram_alloc()); + /* + * We use an extra portion of RAM for the VM state, + * so we can map it non-cached to core instead of normal, cached RAM. + * In future, when core only maps memory on demand, this extra allocator, + * can be eliminated. + */ + static Synchronized_range_allocator vm_alloc(0); + vm_alloc.add_range(Trustzone::VM_STATE_BASE, Trustzone::VM_STATE_SIZE); + static Vm_root vm_root(ep, sh, &vm_alloc); static Local_service vm_ls(Vm_session::service_name(), &vm_root); ls->insert(&vm_ls); } diff --git a/base-hw/src/core/vea9x4/trustzone/platform_support.cc b/base-hw/src/core/vea9x4/trustzone/platform_support.cc index c793573971..1cfd9a0939 100644 --- a/base-hw/src/core/vea9x4/trustzone/platform_support.cc +++ b/base-hw/src/core/vea9x4/trustzone/platform_support.cc @@ -11,6 +11,8 @@ * under the terms of the GNU General Public License version 2. */ +#include + /* core includes */ #include #include @@ -60,7 +62,7 @@ Native_region * Platform::_ram_regions(unsigned const i) { static Native_region _regions[] = { - { Board::RAM_3_BASE, Board::RAM_3_SIZE } + { Trustzone::SECURE_RAM_BASE, Trustzone::SECURE_RAM_SIZE }, }; return i < sizeof(_regions)/sizeof(_regions[0]) ? &_regions[i] : 0; } @@ -72,9 +74,7 @@ Native_region * Platform::_mmio_regions(unsigned const i) { { Board::MMIO_0_BASE, Board::MMIO_0_SIZE }, { Board::MMIO_1_BASE, Board::MMIO_1_SIZE }, - { 0x60000000, 0x40000000 }, - { Board::TZASC_MMIO_BASE, Board::TZASC_MMIO_SIZE }, - { Board::TZPC_MMIO_BASE, Board::TZPC_MMIO_SIZE }, + { Trustzone::NONSECURE_RAM_BASE, Trustzone::NONSECURE_RAM_SIZE }, }; return i < sizeof(_regions)/sizeof(_regions[0]) ? &_regions[i] : 0; } @@ -89,7 +89,10 @@ Native_region * Platform::_core_only_mmio_regions(unsigned const i) Board::CORTEX_A9_PRIVATE_MEM_SIZE }, /* Core UART */ - { Board::PL011_0_MMIO_BASE, Board::PL011_0_MMIO_SIZE } + { Board::PL011_0_MMIO_BASE, Board::PL011_0_MMIO_SIZE }, + + /* vm state memory */ + { Trustzone::VM_STATE_BASE, Trustzone::VM_STATE_SIZE }, }; return i < sizeof(_regions)/sizeof(_regions[0]) ? &_regions[i] : 0; } diff --git a/base-hw/src/core/vea9x4/trustzone/tlb.h b/base-hw/src/core/vea9x4/trustzone/tlb.h new file mode 100644 index 0000000000..c5ec6b3a3d --- /dev/null +++ b/base-hw/src/core/vea9x4/trustzone/tlb.h @@ -0,0 +1,51 @@ +/* + * \brief Translation lookaside buffer + * \author Martin Stein + * \author Stefan Kalkowski + * \date 2012-04-23 + */ + +/* + * Copyright (C) 2012-2013 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. + */ + +#ifndef _VEA9X4__TLB_H_ +#define _VEA9X4__TLB_H_ + +#include + +/* core includes */ +#include +#include + +namespace Genode +{ + struct Page_flags : Arm::Page_flags { }; + + class Tlb : public Arm_v7::Section_table { }; + + /** + * Translation lookaside buffer of core + */ + class Core_tlb : public Tlb + { + public: + + /** + * Constructor - ensures that core never gets a pagefault + */ + Core_tlb() + { + map_core_area(Trustzone::SECURE_RAM_BASE, Trustzone::SECURE_RAM_SIZE, 0); + map_core_area(Board::MMIO_0_BASE, Board::MMIO_0_SIZE, 1); + map_core_area(Board::MMIO_1_BASE, Board::MMIO_1_SIZE, 1); + map_core_area(Trustzone::VM_STATE_BASE, Trustzone::VM_STATE_SIZE, 1); + } + }; +} + +#endif /* _VEA9X4__TLB_H_ */ +