2012-10-02 14:27:32 +02:00
|
|
|
/*
|
|
|
|
* \brief Platform implementations specific for base-hw and VEA9X4
|
|
|
|
* \author Martin Stein
|
|
|
|
* \date 2012-04-27
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2012-2013 Genode Labs GmbH
|
2012-10-02 14:27:32 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
2013-11-27 16:32:12 +01:00
|
|
|
#include <drivers/trustzone.h>
|
|
|
|
|
2012-12-10 13:55:19 +01:00
|
|
|
/* core includes */
|
|
|
|
#include <board.h>
|
2014-07-15 14:51:27 +02:00
|
|
|
#include <cpu.h>
|
2012-10-02 14:27:32 +02:00
|
|
|
#include <platform.h>
|
2014-07-09 12:03:17 +02:00
|
|
|
#include <pic.h>
|
2014-07-03 13:39:42 +02:00
|
|
|
#include <trustzone.h>
|
|
|
|
#include <pic.h>
|
2012-10-02 14:27:32 +02:00
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
|
2014-07-03 13:39:42 +02:00
|
|
|
/* monitor exception vector address */
|
|
|
|
extern int _mon_kernel_entry;
|
|
|
|
|
|
|
|
|
|
|
|
void Kernel::init_trustzone(Pic * pic)
|
|
|
|
{
|
|
|
|
/* check for compatibility */
|
2014-10-10 16:13:52 +02:00
|
|
|
if (NR_OF_CPUS > 1) {
|
2014-07-03 13:39:42 +02:00
|
|
|
PERR("trustzone not supported with multiprocessing");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* set exception vector entry */
|
2014-07-15 14:51:27 +02:00
|
|
|
Cpu::mon_exception_entry_at((Genode::addr_t)&_mon_kernel_entry);
|
2014-07-03 13:39:42 +02:00
|
|
|
|
|
|
|
/* enable coprocessor access for TZ VMs */
|
2014-07-15 14:51:27 +02:00
|
|
|
Cpu::allow_coprocessor_nonsecure();
|
2014-07-03 13:39:42 +02:00
|
|
|
|
|
|
|
/* set unsecure IRQs */
|
|
|
|
pic->unsecure(35); //Timer 2/3
|
|
|
|
pic->unsecure(36); //RTC
|
|
|
|
pic->unsecure(37); //UART0
|
|
|
|
pic->unsecure(41); //MCI0
|
|
|
|
pic->unsecure(42); //MCI1
|
|
|
|
pic->unsecure(43); //AACI
|
|
|
|
pic->unsecure(44); //KMI0
|
|
|
|
pic->unsecure(45); //KMI1
|
|
|
|
pic->unsecure(47); //ETHERNET
|
|
|
|
pic->unsecure(48); //USB
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-30 13:56:57 +01:00
|
|
|
Native_region * Platform::_ram_regions(unsigned const i)
|
2012-10-02 14:27:32 +02:00
|
|
|
{
|
|
|
|
static Native_region _regions[] =
|
|
|
|
{
|
2013-11-27 16:32:12 +01:00
|
|
|
{ Trustzone::SECURE_RAM_BASE, Trustzone::SECURE_RAM_SIZE },
|
2012-10-02 14:27:32 +02:00
|
|
|
};
|
|
|
|
return i < sizeof(_regions)/sizeof(_regions[0]) ? &_regions[i] : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Native_region * Platform::_mmio_regions(unsigned const i)
|
|
|
|
{
|
|
|
|
static Native_region _regions[] =
|
|
|
|
{
|
2012-12-10 13:55:19 +01:00
|
|
|
{ Board::MMIO_0_BASE, Board::MMIO_0_SIZE },
|
|
|
|
{ Board::MMIO_1_BASE, Board::MMIO_1_SIZE },
|
2013-11-27 16:32:12 +01:00
|
|
|
{ Trustzone::NONSECURE_RAM_BASE, Trustzone::NONSECURE_RAM_SIZE },
|
2012-10-02 14:27:32 +02:00
|
|
|
};
|
|
|
|
return i < sizeof(_regions)/sizeof(_regions[0]) ? &_regions[i] : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Native_region * Platform::_core_only_mmio_regions(unsigned const i)
|
|
|
|
{
|
|
|
|
static Native_region _regions[] =
|
|
|
|
{
|
|
|
|
/* Core timer and PIC */
|
2012-12-10 13:55:19 +01:00
|
|
|
{ Board::CORTEX_A9_PRIVATE_MEM_BASE,
|
|
|
|
Board::CORTEX_A9_PRIVATE_MEM_SIZE },
|
2012-10-02 14:27:32 +02:00
|
|
|
|
|
|
|
/* Core UART */
|
2013-11-27 16:32:12 +01:00
|
|
|
{ Board::PL011_0_MMIO_BASE, Board::PL011_0_MMIO_SIZE },
|
2012-10-02 14:27:32 +02:00
|
|
|
};
|
|
|
|
return i < sizeof(_regions)/sizeof(_regions[0]) ? &_regions[i] : 0;
|
|
|
|
}
|
2013-11-05 11:08:05 +01:00
|
|
|
|
|
|
|
|
2014-07-15 14:51:27 +02:00
|
|
|
Cpu::User_context::User_context() { cpsr = Psr::init_user_with_trustzone(); }
|