2012-05-30 20:13:09 +02:00
|
|
|
/*
|
|
|
|
* \brief Platform specific part of a Genode protection domain
|
|
|
|
* \author Martin Stein
|
|
|
|
* \date 2012-02-12
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2009-2013 Genode Labs GmbH
|
2012-05-30 20:13:09 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
|
|
|
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <base/printf.h>
|
|
|
|
|
|
|
|
/* Core includes */
|
|
|
|
#include <platform.h>
|
|
|
|
#include <platform_thread.h>
|
2013-03-08 11:54:12 +01:00
|
|
|
#include <address_space.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
namespace Kernel
|
|
|
|
{
|
|
|
|
Genode::size_t pd_size();
|
|
|
|
unsigned pd_alignm_log2();
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Genode
|
|
|
|
{
|
|
|
|
class Platform_thread;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Platform specific part of a Genode protection domain
|
|
|
|
*/
|
2013-03-08 11:54:12 +01:00
|
|
|
class Platform_pd : public Address_space
|
2012-05-30 20:13:09 +02:00
|
|
|
{
|
2012-12-19 14:46:48 +01:00
|
|
|
unsigned _id; /* ID of our kernel object */
|
|
|
|
Native_capability _parent; /* our parent interface */
|
2012-05-30 20:13:09 +02:00
|
|
|
Native_thread_id _main_thread; /* the first thread that gets
|
|
|
|
* executed in this PD */
|
2013-02-21 16:52:12 +01:00
|
|
|
char const * _label; /* PD-connection label */
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
2013-02-21 16:52:12 +01:00
|
|
|
Platform_pd(char const *label) : _main_thread(0), _label(label)
|
2012-05-30 20:13:09 +02:00
|
|
|
{
|
|
|
|
/* get some aligned space for the kernel object */
|
|
|
|
void * kernel_pd;
|
|
|
|
Range_allocator * ram = platform()->ram_alloc();
|
|
|
|
assert(ram->alloc_aligned(Kernel::pd_size(), &kernel_pd,
|
2012-11-28 22:50:08 +01:00
|
|
|
Kernel::pd_alignm_log2()).is_ok())
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/* create kernel object */
|
|
|
|
_id = Kernel::new_pd(kernel_pd);
|
|
|
|
assert(_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
~Platform_pd();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bind thread 't' to protection domain
|
|
|
|
*
|
|
|
|
* \return 0 on success or
|
|
|
|
* -1 if failed
|
|
|
|
*/
|
|
|
|
int bind_thread(Platform_thread * t)
|
|
|
|
{
|
|
|
|
/* is this the first and therefore main thread in this PD? */
|
|
|
|
if (!_main_thread)
|
|
|
|
{
|
|
|
|
/* annotate that we've got a main thread from now on */
|
|
|
|
_main_thread = t->id();
|
2013-03-08 11:54:12 +01:00
|
|
|
return t->join_pd(_id, 1, Address_space::weak_ptr());
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
2013-03-08 11:54:12 +01:00
|
|
|
return t->join_pd(_id, 0, Address_space::weak_ptr());
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unbind thread from protection domain
|
|
|
|
*
|
|
|
|
* Free the thread's slot and update thread object.
|
|
|
|
*/
|
|
|
|
void unbind_thread(Platform_thread * t);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assign parent interface to protection domain
|
|
|
|
*/
|
|
|
|
int assign_parent(Native_capability parent)
|
|
|
|
{
|
|
|
|
assert(parent.valid());
|
|
|
|
_parent = parent;
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-08 11:54:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************
|
|
|
|
** Address-space interface **
|
|
|
|
*****************************/
|
|
|
|
|
|
|
|
void flush(addr_t, size_t) { PDBG("not implemented"); }
|
2012-05-30 20:13:09 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */
|
|
|
|
|