2012-05-30 20:13:09 +02:00
|
|
|
/*
|
2013-11-14 17:29:34 +01:00
|
|
|
* \brief Basic Genode types
|
2012-05-30 20:13:09 +02:00
|
|
|
* \author Martin Stein
|
|
|
|
* \date 2012-01-02
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2012-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.
|
|
|
|
*/
|
|
|
|
|
2013-11-14 13:29:47 +01:00
|
|
|
#ifndef _BASE__NATIVE_TYPES_H_
|
|
|
|
#define _BASE__NATIVE_TYPES_H_
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/* Genode includes */
|
2013-11-14 17:29:34 +01:00
|
|
|
#include <kernel/interface.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
#include <base/native_capability.h>
|
2012-08-29 14:42:56 +02:00
|
|
|
#include <base/stdint.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
namespace Genode
|
|
|
|
{
|
|
|
|
class Platform_thread;
|
2012-12-10 13:55:19 +01:00
|
|
|
class Tlb;
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2013-02-25 21:18:26 +01:00
|
|
|
typedef unsigned Native_thread_id;
|
|
|
|
|
|
|
|
struct Native_thread
|
|
|
|
{
|
2013-11-19 15:13:24 +01:00
|
|
|
Platform_thread * platform_thread;
|
|
|
|
Native_thread_id thread_id;
|
2013-02-25 21:18:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef int Native_connection_state;
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/* FIXME needs to be MMU dependent */
|
|
|
|
enum { MIN_MAPPING_SIZE_LOG2 = 12 };
|
|
|
|
|
|
|
|
/**
|
2013-11-19 15:13:24 +01:00
|
|
|
* Return kernel thread-name of the caller
|
2012-05-30 20:13:09 +02:00
|
|
|
*/
|
2013-11-19 15:13:24 +01:00
|
|
|
Native_thread_id thread_get_my_native_id();
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/**
|
2013-11-19 15:13:24 +01:00
|
|
|
* Return an invalid kernel thread-name
|
2012-05-30 20:13:09 +02:00
|
|
|
*/
|
|
|
|
inline Native_thread_id thread_invalid_id() { return 0; }
|
|
|
|
|
2013-10-17 16:07:47 +02:00
|
|
|
/**
|
|
|
|
* Message that is communicated between user threads
|
|
|
|
*/
|
2013-11-21 12:04:21 +01:00
|
|
|
struct Ipc_msg
|
2013-10-17 16:07:47 +02:00
|
|
|
{
|
|
|
|
size_t size;
|
|
|
|
uint8_t data[];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-11-19 15:13:24 +01:00
|
|
|
* Message that is communicated from a thread creator to the new thread
|
2013-10-17 16:07:47 +02:00
|
|
|
*/
|
2013-11-19 15:13:24 +01:00
|
|
|
class Startup_msg;
|
2013-10-07 16:01:03 +02:00
|
|
|
|
2013-11-19 15:13:24 +01:00
|
|
|
/**
|
|
|
|
* Memory region that is exclusive to every thread and known by the kernel
|
|
|
|
*/
|
|
|
|
struct Native_utcb;
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
struct Cap_dst_policy
|
|
|
|
{
|
|
|
|
typedef Native_thread_id Dst;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validate capability destination
|
|
|
|
*/
|
|
|
|
static bool valid(Dst pt) { return pt != 0; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get invalid capability destination
|
|
|
|
*/
|
|
|
|
static Dst invalid() { return 0; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy capability 'src' to a given memory destination 'dst'
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
copy(void * dst, Native_capability_tpl<Cap_dst_policy> * src);
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef Native_capability_tpl<Cap_dst_policy> Native_capability;
|
|
|
|
|
|
|
|
/**
|
2013-11-19 15:13:24 +01:00
|
|
|
* Coherent address region
|
2012-05-30 20:13:09 +02:00
|
|
|
*/
|
|
|
|
struct Native_region
|
|
|
|
{
|
|
|
|
addr_t base;
|
|
|
|
size_t size;
|
|
|
|
};
|
2012-08-29 14:42:56 +02:00
|
|
|
|
|
|
|
struct Native_config
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Thread-context area configuration.
|
|
|
|
*/
|
|
|
|
static addr_t context_area_virtual_base() { return 0x40000000UL; }
|
|
|
|
static addr_t context_area_virtual_size() { return 0x10000000UL; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Size of virtual address region holding the context of one thread
|
|
|
|
*/
|
|
|
|
static addr_t context_virtual_size() { return 0x00100000UL; }
|
|
|
|
};
|
2012-11-21 15:20:21 +01:00
|
|
|
|
|
|
|
struct Native_pd_args { };
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
|
|
|
|
2013-11-21 12:04:21 +01:00
|
|
|
class Genode::Startup_msg
|
2013-11-19 15:13:24 +01:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
Native_thread_id _thread_id;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set-up valid startup message
|
|
|
|
*
|
|
|
|
* \param thread_id kernel name of the thread that is started
|
|
|
|
*/
|
2013-11-21 12:04:21 +01:00
|
|
|
void init(Native_thread_id const thread_id) { _thread_id = thread_id; }
|
2013-11-19 15:13:24 +01:00
|
|
|
|
2013-11-21 12:04:21 +01:00
|
|
|
|
|
|
|
/***************
|
|
|
|
** Accessors **
|
|
|
|
***************/
|
|
|
|
|
|
|
|
Native_thread_id thread_id() const { return _thread_id; }
|
2013-11-19 15:13:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Genode::Native_utcb
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
uint8_t data[1 << MIN_MAPPING_SIZE_LOG2];
|
|
|
|
Ipc_msg ipc_msg;
|
|
|
|
Startup_msg startup_msg;
|
|
|
|
};
|
|
|
|
|
2013-11-21 11:35:33 +01:00
|
|
|
void call_await_request_msg(void * & buf_base, size_t & buf_size)
|
2013-11-19 15:13:24 +01:00
|
|
|
{
|
|
|
|
buf_base = base();
|
|
|
|
buf_size = size();
|
|
|
|
}
|
|
|
|
|
2013-11-21 11:35:33 +01:00
|
|
|
void call_send_request_msg(void * & msg_base, size_t & msg_size,
|
|
|
|
void * & buf_base, size_t & buf_size)
|
2013-11-19 15:13:24 +01:00
|
|
|
{
|
|
|
|
msg_base = ipc_msg_base();
|
|
|
|
msg_size = ipc_msg_size();
|
|
|
|
buf_base = base();
|
|
|
|
buf_size = size();
|
|
|
|
}
|
|
|
|
|
2013-11-21 11:35:33 +01:00
|
|
|
void call_send_reply_msg(void * & msg_base, size_t & msg_size)
|
2013-11-19 15:13:24 +01:00
|
|
|
{
|
|
|
|
msg_base = ipc_msg_base();
|
|
|
|
msg_size = ipc_msg_size();
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t size() { return sizeof(data) / sizeof(data[0]); }
|
|
|
|
void * base() { return &data; }
|
|
|
|
addr_t top() { return (addr_t)base() + size(); }
|
|
|
|
void * ipc_msg_base() { return &ipc_msg; }
|
|
|
|
size_t ipc_msg_size() { return ipc_msg_header_size() + ipc_msg.size; }
|
|
|
|
size_t ipc_msg_max_size() { return top() - (addr_t)&ipc_msg; }
|
|
|
|
size_t ipc_msg_header_size() { return (addr_t)ipc_msg.data - (addr_t)&ipc_msg; }
|
|
|
|
};
|
|
|
|
|
2013-11-14 13:29:47 +01:00
|
|
|
#endif /* _BASE__NATIVE_TYPES_H_ */
|
2012-05-30 20:13:09 +02:00
|
|
|
|