base: remove dependency from deprecated APIs
This patch adjusts the implementation of the base library and core such that the code no longer relies on deprecated APIs except for very few cases, mainly to keep those deprecated APIs in tact for now. The most prominent changes are: - Removing the use of base/printf.h - Removing of the log backend for printf. The 'Console' with the format-string parser is still there along with 'snprintf.h' because the latter is still used at a few places, most prominently the 'Connection' classes. - Removing the notion of a RAM session, which does not exist in Genode anymore. Still the types were preserved (by typedefs to PD session) to keep up compatibility. But this transition should come to an end now. - Slight rennovation of core's tracing service, e.g., the use of an Attached_dataspace as the Argument_buffer. - Reducing the reliance on global accessors like deprecated_env() or core_env(). Still there is a longish way to go to eliminate all such calls. A useful pattern (or at least a stop-gap solution) is to pass the 'Env' to the individual compilation units via init functions. - Avoiding the use of the old 'Child_policy::resolve_session_request' interface that returned a 'Service' instead of a 'Route'. Issue #1987
This commit is contained in:
parent
c629a92aa2
commit
aa66b5d62f
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/capability.h>
|
#include <base/capability.h>
|
||||||
#include <base/printf.h>
|
|
||||||
#include <util/misc_math.h>
|
#include <util/misc_math.h>
|
||||||
|
|
||||||
/* core includes */
|
/* core includes */
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/capability_data.h>
|
#include <base/internal/capability_data.h>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <cpu_thread/client.h>
|
#include <cpu_thread/client.h>
|
||||||
#include <foc/native_capability.h>
|
#include <foc/native_capability.h>
|
||||||
#include <foc_native_cpu/client.h>
|
#include <foc_native_cpu/client.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/stack.h>
|
#include <base/internal/stack.h>
|
||||||
|
|
|
@ -35,7 +35,7 @@ Main::Main(Env &env)
|
||||||
enum { COUNT = 1000 };
|
enum { COUNT = 1000 };
|
||||||
|
|
||||||
Cap_index* idx = cap_idx_alloc().alloc_range(COUNT);
|
Cap_index* idx = cap_idx_alloc().alloc_range(COUNT);
|
||||||
Fiasco::l4_cap_idx_t tid = Capability_space::kcap(env.ram_session_cap());
|
Fiasco::l4_cap_idx_t tid = Capability_space::kcap(env.pd_session_cap());
|
||||||
|
|
||||||
/* try the first 1000 local name IDs */
|
/* try the first 1000 local name IDs */
|
||||||
for (int local_name = 0; local_name < COUNT; local_name++, idx++) {
|
for (int local_name = 0; local_name < COUNT; local_name++, idx++) {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <hw/assert.h>
|
#include <hw/assert.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
Genode::Env_deprecated * Genode::env_deprecated()
|
Genode::Env_deprecated * Genode::env_deprecated()
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ class Bootstrap::Platform
|
||||||
|
|
||||||
Ram_allocator()
|
Ram_allocator()
|
||||||
: Genode::Allocator_avl_base(&_slab, sizeof(Base::Block)),
|
: Genode::Allocator_avl_base(&_slab, sizeof(Base::Block)),
|
||||||
_slab(this, (Genode::Slab_block*)&_first_slab) {}
|
_slab(this, (Block *)&_first_slab) {}
|
||||||
|
|
||||||
void * alloc_aligned(size_t size, unsigned align);
|
void * alloc_aligned(size_t size, unsigned align);
|
||||||
bool alloc(size_t size, void **out_addr) override;
|
bool alloc(size_t size, void **out_addr) override;
|
||||||
|
|
|
@ -47,7 +47,7 @@ Platform_thread::~Platform_thread()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free UTCB */
|
/* free UTCB */
|
||||||
core_env().ram_session()->free(_utcb);
|
core_env().pd_session()->free(_utcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ Platform_thread::Platform_thread(size_t const quota,
|
||||||
_kobj(true, _priority(virt_prio), quota, _label.string())
|
_kobj(true, _priority(virt_prio), quota, _label.string())
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
_utcb = core_env().ram_session()->alloc(sizeof(Native_utcb), CACHED);
|
_utcb = core_env().pd_session()->alloc(sizeof(Native_utcb), CACHED);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
error("failed to allocate UTCB");
|
error("failed to allocate UTCB");
|
||||||
throw Out_of_ram();
|
throw Out_of_ram();
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _CORE__PLATFORM_THREAD_H_
|
#define _CORE__PLATFORM_THREAD_H_
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <ram_session/ram_session.h>
|
#include <base/ram_allocator.h>
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
namespace Genode { Rm_session *env_stack_area_rm_session(); }
|
|
||||||
|
|
||||||
namespace Hw { extern Untyped_capability _main_thread_cap; }
|
namespace Hw { extern Untyped_capability _main_thread_cap; }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,6 @@ using namespace Genode;
|
||||||
void Genode::init_signal_transmitter(Env &) { }
|
void Genode::init_signal_transmitter(Env &) { }
|
||||||
|
|
||||||
|
|
||||||
void Signal_context::submit(unsigned) { Genode::error("not implemented"); }
|
|
||||||
|
|
||||||
|
|
||||||
void Signal_transmitter::submit(unsigned cnt)
|
void Signal_transmitter::submit(unsigned cnt)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <base/sleep.h>
|
#include <base/sleep.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <cpu_thread/client.h>
|
#include <cpu_thread/client.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/stack_allocator.h>
|
#include <base/internal/stack_allocator.h>
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct Sync::Connection : public Genode::Connection<Session>,
|
||||||
public Genode::Rpc_client<Session>
|
public Genode::Rpc_client<Session>
|
||||||
{
|
{
|
||||||
explicit Connection(Genode::Env &env)
|
explicit Connection(Genode::Env &env)
|
||||||
: Genode::Connection<Session>(env, session("ram_quota=4K")),
|
: Genode::Connection<Session>(env, session(env.parent(), "ram_quota=4K")),
|
||||||
Genode::Rpc_client<Session>(cap()) { }
|
Genode::Rpc_client<Session>(cap()) { }
|
||||||
|
|
||||||
void threshold(unsigned threshold) override { call<Rpc_threshold>(threshold); }
|
void threshold(unsigned threshold) override { call<Rpc_threshold>(threshold); }
|
||||||
|
|
|
@ -64,7 +64,7 @@ grep_output {\[init -\> test-lx_hybrid_ctors\]}
|
||||||
|
|
||||||
compare_output_to {
|
compare_output_to {
|
||||||
[init -> test-lx_hybrid_ctors] Global static constructor of host library called.
|
[init -> test-lx_hybrid_ctors] Global static constructor of host library called.
|
||||||
[init -> test-lx_hybrid_ctors] Global static constructor of Genode application called
|
[init -> test-lx_hybrid_ctors] Global static constructor of Genode application called.
|
||||||
[init -> test-lx_hybrid_ctors] --- lx_hybrid global static constructor test ---
|
[init -> test-lx_hybrid_ctors] --- lx_hybrid global static constructor test ---
|
||||||
[init -> test-lx_hybrid_ctors] --- returning from main ---
|
[init -> test-lx_hybrid_ctors] --- returning from main ---
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/signal.h>
|
#include <base/signal.h>
|
||||||
|
#include <cpu_session/cpu_session.h> /* for 'Thread_capability' type */
|
||||||
#include <pager/capability.h>
|
#include <pager/capability.h>
|
||||||
#include <thread/capability.h>
|
|
||||||
|
|
||||||
/* core-local includes */
|
/* core-local includes */
|
||||||
#include <rpc_cap_factory.h>
|
#include <rpc_cap_factory.h>
|
||||||
|
|
|
@ -49,6 +49,8 @@ static inline Genode::Socket_pair create_server_socket_pair(long id)
|
||||||
{
|
{
|
||||||
Genode::Socket_pair socket_pair;
|
Genode::Socket_pair socket_pair;
|
||||||
|
|
||||||
|
using Genode::raw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Main thread uses 'Ipc_server' for 'sleep_forever()' only. No need for
|
* Main thread uses 'Ipc_server' for 'sleep_forever()' only. No need for
|
||||||
* binding.
|
* binding.
|
||||||
|
@ -63,7 +65,7 @@ static inline Genode::Socket_pair create_server_socket_pair(long id)
|
||||||
*/
|
*/
|
||||||
socket_pair.server_sd = lx_socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
socket_pair.server_sd = lx_socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||||
if (socket_pair.server_sd < 0) {
|
if (socket_pair.server_sd < 0) {
|
||||||
PRAW("Error: Could not create server-side socket (ret=%d)", socket_pair.server_sd);
|
raw("Error: Could not create server-side socket (ret=", socket_pair.server_sd, ")");
|
||||||
class Server_socket_failed { };
|
class Server_socket_failed { };
|
||||||
throw Server_socket_failed();
|
throw Server_socket_failed();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +75,7 @@ static inline Genode::Socket_pair create_server_socket_pair(long id)
|
||||||
|
|
||||||
int const bind_ret = lx_bind(socket_pair.server_sd, (sockaddr *)&addr, sizeof(addr));
|
int const bind_ret = lx_bind(socket_pair.server_sd, (sockaddr *)&addr, sizeof(addr));
|
||||||
if (bind_ret < 0) {
|
if (bind_ret < 0) {
|
||||||
PRAW("Error: Could not bind server socket (ret=%d)", bind_ret);
|
raw("Error: Could not bind server socket (ret=", bind_ret, ")");
|
||||||
class Bind_failed { };
|
class Bind_failed { };
|
||||||
throw Bind_failed();
|
throw Bind_failed();
|
||||||
}
|
}
|
||||||
|
@ -83,14 +85,14 @@ static inline Genode::Socket_pair create_server_socket_pair(long id)
|
||||||
*/
|
*/
|
||||||
socket_pair.client_sd = lx_socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
socket_pair.client_sd = lx_socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||||
if (socket_pair.client_sd < 0) {
|
if (socket_pair.client_sd < 0) {
|
||||||
PRAW("Error: Could not create client-side socket (ret=%d)", socket_pair.client_sd);
|
raw("Error: Could not create client-side socket (ret=", socket_pair.client_sd, ")");
|
||||||
class Client_socket_failed { };
|
class Client_socket_failed { };
|
||||||
throw Client_socket_failed();
|
throw Client_socket_failed();
|
||||||
}
|
}
|
||||||
|
|
||||||
int const conn_ret = lx_connect(socket_pair.client_sd, (sockaddr *)&addr, sizeof(addr));
|
int const conn_ret = lx_connect(socket_pair.client_sd, (sockaddr *)&addr, sizeof(addr));
|
||||||
if (conn_ret < 0) {
|
if (conn_ret < 0) {
|
||||||
PRAW("Error: Could not connect client-side socket (ret=%d)", conn_ret);
|
raw("Error: Could not connect client-side socket (ret=", conn_ret, ")");
|
||||||
class Connect_failed { };
|
class Connect_failed { };
|
||||||
throw Connect_failed();
|
throw Connect_failed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <rm_session/rm_session.h>
|
#include <rm_session/rm_session.h>
|
||||||
#include <ram_session/ram_session.h>
|
#include <base/ram_allocator.h>
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
|
|
|
@ -33,7 +33,8 @@ struct Genode::Local_pd_session : Expanding_pd_session_client
|
||||||
Region_map_mmap _stack_area { true, stack_area_virtual_size() };
|
Region_map_mmap _stack_area { true, stack_area_virtual_size() };
|
||||||
Region_map_mmap _linker_area { true, Pd_session::LINKER_AREA_SIZE };
|
Region_map_mmap _linker_area { true, Pd_session::LINKER_AREA_SIZE };
|
||||||
|
|
||||||
Local_pd_session(Pd_session_capability pd) : Expanding_pd_session_client(pd) { }
|
Local_pd_session(Parent &parent, Pd_session_capability pd)
|
||||||
|
: Expanding_pd_session_client(parent, pd) { }
|
||||||
|
|
||||||
Capability<Region_map> address_space()
|
Capability<Region_map> address_space()
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,29 +55,30 @@ class Genode::Platform_env_base : public Env_deprecated
|
||||||
* in 'Platform_env_base' because the procedure differs between
|
* in 'Platform_env_base' because the procedure differs between
|
||||||
* core and non-core components.
|
* core and non-core components.
|
||||||
*/
|
*/
|
||||||
Local_pd_session _local_pd_session { _pd_session_cap };
|
Local_pd_session _local_pd_session;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Platform_env_base(Cpu_session_capability cpu_cap,
|
Platform_env_base(Parent &parent,
|
||||||
|
Cpu_session_capability cpu_cap,
|
||||||
Pd_session_capability pd_cap)
|
Pd_session_capability pd_cap)
|
||||||
:
|
:
|
||||||
_cpu_session_cap(cpu_cap),
|
_cpu_session_cap(cpu_cap),
|
||||||
_cpu_session_client(cpu_cap, Parent::Env::cpu()),
|
_cpu_session_client(parent, cpu_cap, Parent::Env::cpu()),
|
||||||
_region_map_mmap(false),
|
_region_map_mmap(false),
|
||||||
_pd_session_cap(pd_cap),
|
_pd_session_cap(pd_cap),
|
||||||
_local_pd_session(_pd_session_cap)
|
_local_pd_session(parent, _pd_session_cap)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used by 'Core_env'
|
* Constructor used by 'Core_env'
|
||||||
*/
|
*/
|
||||||
Platform_env_base()
|
Platform_env_base(Parent &parent)
|
||||||
:
|
:
|
||||||
Platform_env_base(Cpu_session_capability(), Pd_session_capability())
|
Platform_env_base(parent, Cpu_session_capability(), Pd_session_capability())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,8 +86,6 @@ class Genode::Platform_env_base : public Env_deprecated
|
||||||
** Env_deprecated interface **
|
** Env_deprecated interface **
|
||||||
******************************/
|
******************************/
|
||||||
|
|
||||||
Ram_session *ram_session() override { return &_local_pd_session; }
|
|
||||||
Ram_session_capability ram_session_cap() override { return _pd_session_cap; }
|
|
||||||
Region_map *rm_session() override { return &_region_map_mmap; }
|
Region_map *rm_session() override { return &_region_map_mmap; }
|
||||||
Cpu_session *cpu_session() override { return &_cpu_session_client; }
|
Cpu_session *cpu_session() override { return &_cpu_session_client; }
|
||||||
Cpu_session_capability cpu_session_cap() override { return _cpu_session_cap; }
|
Cpu_session_capability cpu_session_cap() override { return _cpu_session_cap; }
|
||||||
|
@ -134,8 +133,9 @@ class Genode::Platform_env : public Platform_env_base
|
||||||
** Env_deprecated interface **
|
** Env_deprecated interface **
|
||||||
******************************/
|
******************************/
|
||||||
|
|
||||||
Parent *parent() override { return &_parent(); }
|
Parent *parent() override { return &_parent(); }
|
||||||
Heap *heap() override { return &_heap; }
|
Allocator *heap() override { return &_heap; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _INCLUDE__BASE__INTERNAL__PLATFORM_ENV_H_ */
|
#endif /* _INCLUDE__BASE__INTERNAL__PLATFORM_ENV_H_ */
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <region_map/region_map.h>
|
#include <region_map/region_map.h>
|
||||||
#include <dataspace/client.h>
|
#include <dataspace/client.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/local_capability.h>
|
#include <base/internal/local_capability.h>
|
||||||
|
|
|
@ -160,7 +160,7 @@ static int lookup_tid_by_client_socket(int sd)
|
||||||
|
|
||||||
unsigned tid = 0;
|
unsigned tid = 0;
|
||||||
if (Genode::ascii_to(name.sun_path + prefix_len.len, tid) == 0) {
|
if (Genode::ascii_to(name.sun_path + prefix_len.len, tid) == 0) {
|
||||||
PRAW("Error: could not parse tid number");
|
raw("Error: could not parse tid number");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return tid;
|
return tid;
|
||||||
|
@ -354,7 +354,8 @@ static inline void lx_reply(int reply_socket, Rpc_exception_code exception_code,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
PRAW("[%d] lx_sendmsg failed with %d in lx_reply() reply_socket=%d", lx_gettid(), ret, reply_socket);
|
raw("[", lx_gettid, "] lx_sendmsg failed with ", ret, " "
|
||||||
|
"in lx_reply() reply_socket=", reply_socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -388,7 +389,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
|
||||||
|
|
||||||
int ret = lx_socketpair(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0, sd);
|
int ret = lx_socketpair(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0, sd);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
PRAW("[%d] lx_socketpair failed with %d", lx_getpid(), ret);
|
raw("[", lx_gettid(), "] lx_socketpair failed with ", ret);
|
||||||
throw Genode::Ipc_error();
|
throw Genode::Ipc_error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -438,7 +439,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
|
||||||
throw Genode::Blocking_canceled();
|
throw Genode::Blocking_canceled();
|
||||||
|
|
||||||
if (recv_ret < 0) {
|
if (recv_ret < 0) {
|
||||||
PRAW("[%d] lx_recvmsg failed with %d in lx_call()", lx_getpid(), recv_ret);
|
raw("[", lx_getpid(), "] lx_recvmsg failed with ", recv_ret, " in lx_call()");
|
||||||
throw Genode::Ipc_error();
|
throw Genode::Ipc_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,8 +497,8 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
PRAW("lx_recvmsg failed with %d in ipc_reply_wait, sd=%d",
|
raw("lx_recvmsg failed with ", ret, " in ipc_reply_wait, sd=",
|
||||||
ret, native_thread.socket_pair.server_sd);
|
native_thread.socket_pair.server_sd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,8 +529,8 @@ Ipc_server::Ipc_server()
|
||||||
Native_thread &native_thread = Thread::myself()->native_thread();
|
Native_thread &native_thread = Thread::myself()->native_thread();
|
||||||
|
|
||||||
if (native_thread.is_ipc_server) {
|
if (native_thread.is_ipc_server) {
|
||||||
PRAW("[%d] unexpected multiple instantiation of Ipc_server by one thread",
|
Genode::raw("[", lx_gettid(), "] "
|
||||||
lx_gettid());
|
" unexpected multiple instantiation of Ipc_server by one thread");
|
||||||
struct Ipc_server_multiple_instance { };
|
struct Ipc_server_multiple_instance { };
|
||||||
throw Ipc_server_multiple_instance();
|
throw Ipc_server_multiple_instance();
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,14 +154,15 @@ Local_parent &Platform_env::_parent()
|
||||||
|
|
||||||
Platform_env::Platform_env()
|
Platform_env::Platform_env()
|
||||||
:
|
:
|
||||||
Platform_env_base(static_cap_cast<Cpu_session>(_parent().session_cap(Parent::Env::cpu())),
|
Platform_env_base(_parent(),
|
||||||
|
static_cap_cast<Cpu_session>(_parent().session_cap(Parent::Env::cpu())),
|
||||||
static_cap_cast<Pd_session> (_parent().session_cap(Parent::Env::pd()))),
|
static_cap_cast<Pd_session> (_parent().session_cap(Parent::Env::pd()))),
|
||||||
_heap(Platform_env_base::ram_session(), Platform_env_base::rm_session())
|
_heap(Platform_env_base::pd_session(), Platform_env_base::rm_session())
|
||||||
{
|
{
|
||||||
_attach_stack_area();
|
_attach_stack_area();
|
||||||
|
|
||||||
env_stack_area_region_map = &_local_pd_session._stack_area;
|
env_stack_area_region_map = &_local_pd_session._stack_area;
|
||||||
env_stack_area_ram_allocator = ram_session();
|
env_stack_area_ram_allocator = Platform_env_base::pd_session();
|
||||||
|
|
||||||
/* register TID and PID of the main thread at core */
|
/* register TID and PID of the main thread at core */
|
||||||
Linux_native_cpu_client native_cpu(cpu_session()->native_cpu());
|
Linux_native_cpu_client native_cpu(cpu_session()->native_cpu());
|
||||||
|
|
|
@ -41,13 +41,13 @@ Region_map_client::attach(Dataspace_capability ds, size_t size,
|
||||||
Region_map::Local_addr local_addr,
|
Region_map::Local_addr local_addr,
|
||||||
bool executable, bool writeable)
|
bool executable, bool writeable)
|
||||||
{
|
{
|
||||||
return _local(*this)->attach(ds, size, offset, use_local_addr,
|
return _local(rpc_cap())->attach(ds, size, offset, use_local_addr,
|
||||||
local_addr, executable, writeable);
|
local_addr, executable, writeable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Region_map_client::detach(Local_addr local_addr) {
|
void Region_map_client::detach(Local_addr local_addr) {
|
||||||
return _local(*this)->detach(local_addr); }
|
return _local(rpc_cap())->detach(local_addr); }
|
||||||
|
|
||||||
|
|
||||||
void Region_map_client::fault_handler(Signal_context_capability /*handler*/)
|
void Region_map_client::fault_handler(Signal_context_capability /*handler*/)
|
||||||
|
@ -61,9 +61,9 @@ void Region_map_client::fault_handler(Signal_context_capability /*handler*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Region_map::State Region_map_client::state() { return _local(*this)->state(); }
|
Region_map::State Region_map_client::state() { return _local(rpc_cap())->state(); }
|
||||||
|
|
||||||
|
|
||||||
Dataspace_capability Region_map_client::dataspace() {
|
Dataspace_capability Region_map_client::dataspace() {
|
||||||
return _local(*this) ? _local(*this)->dataspace() : Dataspace_capability(); }
|
return _local(rpc_cap()) ? _local(rpc_cap())->dataspace() : Dataspace_capability(); }
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ Rm_session_client::Rm_session_client(Capability<Rm_session> session)
|
||||||
|
|
||||||
|
|
||||||
Capability<Region_map> Rm_session_client::create(size_t size) {
|
Capability<Region_map> Rm_session_client::create(size_t size) {
|
||||||
return _local(*this)->create(size); }
|
return _local(rpc_cap())->create(size); }
|
||||||
|
|
||||||
|
|
||||||
void Rm_session_client::destroy(Capability<Region_map> cap) {
|
void Rm_session_client::destroy(Capability<Region_map> cap) {
|
||||||
_local(*this)->destroy(cap); }
|
_local(rpc_cap())->destroy(cap); }
|
||||||
|
|
|
@ -32,20 +32,6 @@ char **lx_environ;
|
||||||
*/
|
*/
|
||||||
int main_thread_futex_counter __attribute__((aligned(sizeof(addr_t))));
|
int main_thread_futex_counter __attribute__((aligned(sizeof(addr_t))));
|
||||||
|
|
||||||
/**
|
|
||||||
* Genode console hook
|
|
||||||
*/
|
|
||||||
extern "C" int stdout_write(char const *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Core lacks the hook, so provide a base-linux specific weak implementation
|
|
||||||
*/
|
|
||||||
extern "C" __attribute__((weak)) int stdout_write(char const *s)
|
|
||||||
{
|
|
||||||
raw(s);
|
|
||||||
return Genode::strlen(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal handler for exceptions like segmentation faults
|
* Signal handler for exceptions like segmentation faults
|
||||||
*/
|
*/
|
||||||
|
@ -62,17 +48,7 @@ void exception_signal_handler(int signum)
|
||||||
default: /* unexpected signal */ return;
|
default: /* unexpected signal */ return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
raw(reason, " (signum=", signum, "), see Linux kernel log for details");
|
||||||
* We can't use Genode::printf() as the exception may have occurred in the
|
|
||||||
* Genode console library itself, which uses a mutex. Therefore, we use
|
|
||||||
* Genode::snprintf() and call the console hook directly to minimize
|
|
||||||
* overlaps with other code paths.
|
|
||||||
*/
|
|
||||||
static char msg[128];
|
|
||||||
snprintf(msg, sizeof(msg),
|
|
||||||
ESC_ERR "%s (signum=%d), see Linux kernel log for details" ESC_END "\n",
|
|
||||||
reason, signum);
|
|
||||||
stdout_write(msg);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We reset the signal handler to SIG_DFL and trigger exception again,
|
* We reset the signal handler to SIG_DFL and trigger exception again,
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <linux_native_cpu/client.h>
|
#include <linux_native_cpu/client.h>
|
||||||
#include <cpu_thread/client.h>
|
#include <cpu_thread/client.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/stack.h>
|
#include <base/internal/stack.h>
|
||||||
|
|
|
@ -86,8 +86,16 @@ namespace Genode {
|
||||||
* This function is normally provided by the cxx library, which is not
|
* This function is normally provided by the cxx library, which is not
|
||||||
* used for lx_hybrid programs. For lx_hybrid programs, the exception
|
* used for lx_hybrid programs. For lx_hybrid programs, the exception
|
||||||
* handling is initialized by the host system's regular startup code.
|
* handling is initialized by the host system's regular startup code.
|
||||||
|
*
|
||||||
|
* However, we conveniently use this function to get hold of the
|
||||||
|
* component's environment and initialize the default log output.
|
||||||
*/
|
*/
|
||||||
void init_exception_handling(Env &env) { _env_ptr = &env; }
|
void init_exception_handling(Env &env)
|
||||||
|
{
|
||||||
|
_env_ptr = &env;
|
||||||
|
|
||||||
|
init_log(env.parent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <base/printf.h>
|
|
||||||
#include <base/snprintf.h>
|
#include <base/snprintf.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
/* Linux includes */
|
/* Linux includes */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ struct Testapp_testclass
|
||||||
{
|
{
|
||||||
Testapp_testclass()
|
Testapp_testclass()
|
||||||
{
|
{
|
||||||
Genode::log("Global static constructor of Genode application called");
|
printf("[init -> test-lx_hybrid_ctors] Global static constructor of Genode application called.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void dummy() { }
|
void dummy() { }
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#define _CORE__INCLUDE__PLATFORM_THREAD_H_
|
#define _CORE__INCLUDE__PLATFORM_THREAD_H_
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <thread/capability.h>
|
|
||||||
#include <base/thread_state.h>
|
#include <base/thread_state.h>
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
#include <nova_native_cpu/nova_native_cpu.h>
|
#include <nova_native_cpu/nova_native_cpu.h>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <util/retry.h>
|
#include <util/retry.h>
|
||||||
#include <base/rpc_server.h>
|
#include <base/rpc_server.h>
|
||||||
#include <pd_session/client.h>
|
#include <pd_session/client.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/globals.h>
|
#include <base/internal/globals.h>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <session/session.h>
|
#include <session/session.h>
|
||||||
#include <cpu_thread/client.h>
|
#include <cpu_thread/client.h>
|
||||||
#include <nova_native_cpu/client.h>
|
#include <nova_native_cpu/client.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/stack.h>
|
#include <base/internal/stack.h>
|
||||||
|
|
|
@ -645,7 +645,7 @@ Main::Main(Env &env) : env(env)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Attached_rom_dataspace config(env, "config");
|
Attached_rom_dataspace config(env, "config");
|
||||||
config.xml().attribute("check_pat").value(&check_pat);
|
config.xml().attribute("check_pat").value(check_pat);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
Genode::error("no check_pat attribute found");
|
Genode::error("no check_pat attribute found");
|
||||||
env.parent().exit(-__LINE__);
|
env.parent().exit(-__LINE__);
|
||||||
|
|
|
@ -12,9 +12,6 @@
|
||||||
* under the terms of the GNU Affero General Public License version 3.
|
* under the terms of the GNU Affero General Public License version 3.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Genode includes */
|
|
||||||
#include <base/attached_rom_dataspace.h>
|
|
||||||
|
|
||||||
/* NOVA includes */
|
/* NOVA includes */
|
||||||
#include <nova/native_thread.h>
|
#include <nova/native_thread.h>
|
||||||
|
|
||||||
|
@ -25,17 +22,6 @@ using namespace Genode;
|
||||||
using namespace Nova;
|
using namespace Nova;
|
||||||
|
|
||||||
|
|
||||||
Timer::Time_source::Time_source(Env &env) : Threaded_time_source(env)
|
|
||||||
{
|
|
||||||
/* read out the tsc frequency once */
|
|
||||||
Attached_rom_dataspace const platform_info { env, "platform_info" };
|
|
||||||
Xml_node const hardware = platform_info.xml().sub_node("hardware");
|
|
||||||
hardware.sub_node("tsc").attribute("freq_khz").value(&_tsc_khz);
|
|
||||||
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Timer::Time_source::schedule_timeout(Microseconds duration,
|
void Timer::Time_source::schedule_timeout(Microseconds duration,
|
||||||
Timeout_handler &handler)
|
Timeout_handler &handler)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <trace/timestamp.h>
|
#include <trace/timestamp.h>
|
||||||
|
#include <base/attached_rom_dataspace.h>
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include <threaded_time_source.h>
|
#include <threaded_time_source.h>
|
||||||
|
@ -28,9 +29,24 @@ class Timer::Time_source : public Threaded_time_source
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/* read the tsc frequency from platform info */
|
||||||
|
static unsigned long _obtain_tsc_khz(Genode::Env &env)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Genode::Attached_rom_dataspace info { env, "platform_info"};
|
||||||
|
|
||||||
|
return info.xml()
|
||||||
|
.sub_node("hardware")
|
||||||
|
.sub_node("tsc")
|
||||||
|
.attribute_value("freq_khz", 0UL);
|
||||||
|
} catch (...) { }
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Genode::addr_t _sem { ~0UL };
|
Genode::addr_t _sem { ~0UL };
|
||||||
unsigned long _timeout_us { 0 };
|
unsigned long _timeout_us { 0 };
|
||||||
unsigned long _tsc_khz { 0 };
|
unsigned long const _tsc_khz;
|
||||||
Duration _curr_time { Microseconds(0) };
|
Duration _curr_time { Microseconds(0) };
|
||||||
Genode::Trace::Timestamp _tsc_start { Genode::Trace::timestamp() };
|
Genode::Trace::Timestamp _tsc_start { Genode::Trace::timestamp() };
|
||||||
Genode::Trace::Timestamp _tsc_last { _tsc_start };
|
Genode::Trace::Timestamp _tsc_last { _tsc_start };
|
||||||
|
@ -52,8 +68,12 @@ class Timer::Time_source : public Threaded_time_source
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Time_source(Genode::Env &env);
|
Time_source(Genode::Env &env)
|
||||||
|
:
|
||||||
|
Threaded_time_source(env), _tsc_khz(_obtain_tsc_khz(env))
|
||||||
|
{
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
** Genode::Time_source **
|
** Genode::Time_source **
|
||||||
|
|
|
@ -91,12 +91,13 @@ int Platform::bi_add_phys_mem(Okl4::bi_name_t pool, Okl4::uintptr_t base,
|
||||||
static char init_slab_block_rom[get_page_size()];
|
static char init_slab_block_rom[get_page_size()];
|
||||||
static char init_slab_block_thread[get_page_size()];
|
static char init_slab_block_thread[get_page_size()];
|
||||||
|
|
||||||
|
|
||||||
Platform::Platform()
|
Platform::Platform()
|
||||||
:
|
:
|
||||||
_io_mem_alloc(&core_mem_alloc()), _io_port_alloc(&core_mem_alloc()),
|
_io_mem_alloc(&core_mem_alloc()), _io_port_alloc(&core_mem_alloc()),
|
||||||
_irq_alloc(&core_mem_alloc()),
|
_irq_alloc(&core_mem_alloc()),
|
||||||
_rom_slab(&core_mem_alloc(), (Slab_block *)&init_slab_block_rom),
|
_rom_slab(&core_mem_alloc(), &init_slab_block_rom),
|
||||||
_thread_slab(core_mem_alloc(), (Slab_block *)&init_slab_block_thread)
|
_thread_slab(core_mem_alloc(), &init_slab_block_thread)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We must be single-threaded at this stage and so this is safe.
|
* We must be single-threaded at this stage and so this is safe.
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
#ifndef _CORE__INCLUDE__MAP_LOCAL_H_
|
#ifndef _CORE__INCLUDE__MAP_LOCAL_H_
|
||||||
#define _CORE__INCLUDE__MAP_LOCAL_H_
|
#define _CORE__INCLUDE__MAP_LOCAL_H_
|
||||||
|
|
||||||
#include <base/printf.h>
|
|
||||||
|
|
||||||
/* core includes */
|
/* core includes */
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
|
|
@ -283,7 +283,7 @@ void Platform::_init_rom_modules()
|
||||||
*/
|
*/
|
||||||
static long slab_block[4096];
|
static long slab_block[4096];
|
||||||
static Tslab<Rom_module, sizeof(slab_block)>
|
static Tslab<Rom_module, sizeof(slab_block)>
|
||||||
rom_module_slab(core_mem_alloc(), (Genode::Slab_block *)slab_block);
|
rom_module_slab(core_mem_alloc(), &slab_block);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate unused range of phys CNode address space where to make the
|
* Allocate unused range of phys CNode address space where to make the
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct Genode::Env : Interface
|
||||||
* The RAM allocator is backed with the RAM budget of the component's PD
|
* The RAM allocator is backed with the RAM budget of the component's PD
|
||||||
* session. This budget can be used to allocate RAM dataspaces.
|
* session. This budget can be used to allocate RAM dataspaces.
|
||||||
*/
|
*/
|
||||||
virtual Ram_session &ram() = 0;
|
virtual Ram_session &ram() { return pd(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CPU session of the component
|
* CPU session of the component
|
||||||
|
@ -68,7 +68,7 @@ struct Genode::Env : Interface
|
||||||
* \deprecated the RAM session has become part of the PD session
|
* \deprecated the RAM session has become part of the PD session
|
||||||
* \noapi
|
* \noapi
|
||||||
*/
|
*/
|
||||||
virtual Ram_session_capability ram_session_cap() = 0;
|
virtual Ram_session_capability ram_session_cap() { return pd_session_cap(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the CPU-session capability of the component
|
* Return the CPU-session capability of the component
|
||||||
|
|
|
@ -75,8 +75,8 @@ struct Genode::Env_deprecated : Interface
|
||||||
* available to the component. This budget can be used to allocate
|
* available to the component. This budget can be used to allocate
|
||||||
* RAM dataspaces.
|
* RAM dataspaces.
|
||||||
*/
|
*/
|
||||||
virtual Ram_session *ram_session() = 0;
|
virtual Ram_session *ram_session() { return pd_session(); }
|
||||||
virtual Ram_session_capability ram_session_cap() = 0;
|
virtual Ram_session_capability ram_session_cap() { return pd_session_cap(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CPU session of the component
|
* CPU session of the component
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
SRC_CC += log_console.cc default_log.cc
|
SRC_CC += default_log.cc
|
||||||
SRC_CC += env_deprecated.cc stack_area.cc env_reinit.cc main_thread_cap.cc
|
SRC_CC += env_deprecated.cc stack_area.cc env_reinit.cc main_thread_cap.cc
|
||||||
SRC_CC += rpc_cap_alloc.cc heartbeat.cc
|
SRC_CC += rpc_cap_alloc.cc heartbeat.cc
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,9 @@ int Cpu_session_component::ref_account(Cpu_session_capability ref_cap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Cpu_session_component::Cpu_session_component(Rpc_entrypoint &session_ep,
|
Cpu_session_component::Cpu_session_component(Ram_allocator &ram,
|
||||||
|
Region_map &local_rm,
|
||||||
|
Rpc_entrypoint &session_ep,
|
||||||
Rpc_entrypoint &thread_ep,
|
Rpc_entrypoint &thread_ep,
|
||||||
Pager_entrypoint &pager_ep,
|
Pager_entrypoint &pager_ep,
|
||||||
Allocator &md_alloc,
|
Allocator &md_alloc,
|
||||||
|
@ -257,7 +259,9 @@ Cpu_session_component::Cpu_session_component(Rpc_entrypoint &session_ep,
|
||||||
/* map affinity to a location within the physical affinity space */
|
/* map affinity to a location within the physical affinity space */
|
||||||
_location(affinity.scale_to(platform().affinity_space())),
|
_location(affinity.scale_to(platform().affinity_space())),
|
||||||
|
|
||||||
_trace_sources(trace_sources), _quota(quota), _ref(0),
|
_trace_sources(trace_sources),
|
||||||
|
_trace_control_area(ram, local_rm),
|
||||||
|
_quota(quota), _ref(0),
|
||||||
_native_cpu(*this, args)
|
_native_cpu(*this, args)
|
||||||
{
|
{
|
||||||
Arg a = Arg_string::find_arg(args, "priority");
|
Arg a = Arg_string::find_arg(args, "priority");
|
||||||
|
|
|
@ -41,4 +41,4 @@ Genode::Log &Genode::Log::log()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Genode::init_log() { };
|
void Genode::init_log(Parent &) { };
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/globals.h>
|
#include <base/internal/globals.h>
|
||||||
|
@ -91,8 +92,6 @@ class Genode::Core_env : public Env_deprecated, Noncopyable
|
||||||
******************************/
|
******************************/
|
||||||
|
|
||||||
Parent *parent() override { return nullptr; }
|
Parent *parent() override { return nullptr; }
|
||||||
Ram_session *ram_session() override { return &_pd_session; }
|
|
||||||
Ram_session_capability ram_session_cap() override { return _pd_session.cap(); }
|
|
||||||
Region_map *rm_session() override { return &_region_map; }
|
Region_map *rm_session() override { return &_region_map; }
|
||||||
Pd_session *pd_session() override { return &_pd_session; }
|
Pd_session *pd_session() override { return &_pd_session; }
|
||||||
Allocator *heap() override { ASSERT_NEVER_CALLED; }
|
Allocator *heap() override { ASSERT_NEVER_CALLED; }
|
||||||
|
|
|
@ -26,6 +26,8 @@ namespace Genode {
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Ram_allocator &_ram;
|
||||||
|
Region_map &_local_rm;
|
||||||
Rpc_entrypoint &_thread_ep;
|
Rpc_entrypoint &_thread_ep;
|
||||||
Pager_entrypoint &_pager_ep;
|
Pager_entrypoint &_pager_ep;
|
||||||
Allocator &_md_alloc;
|
Allocator &_md_alloc;
|
||||||
|
@ -44,6 +46,7 @@ namespace Genode {
|
||||||
|
|
||||||
return new (md_alloc())
|
return new (md_alloc())
|
||||||
Cpu_session_component(
|
Cpu_session_component(
|
||||||
|
_ram, _local_rm,
|
||||||
*Root_component<Cpu_session_component>::ep(),
|
*Root_component<Cpu_session_component>::ep(),
|
||||||
_thread_ep, _pager_ep, _md_alloc, _trace_sources,
|
_thread_ep, _pager_ep, _md_alloc, _trace_sources,
|
||||||
args, affinity, 0);
|
args, affinity, 0);
|
||||||
|
@ -64,13 +67,16 @@ namespace Genode {
|
||||||
* \param thread_ep entry point for managing threads
|
* \param thread_ep entry point for managing threads
|
||||||
* \param md_alloc meta data allocator to be used by root component
|
* \param md_alloc meta data allocator to be used by root component
|
||||||
*/
|
*/
|
||||||
Cpu_root(Rpc_entrypoint &session_ep,
|
Cpu_root(Ram_allocator &ram,
|
||||||
|
Region_map &local_rm,
|
||||||
|
Rpc_entrypoint &session_ep,
|
||||||
Rpc_entrypoint &thread_ep,
|
Rpc_entrypoint &thread_ep,
|
||||||
Pager_entrypoint &pager_ep,
|
Pager_entrypoint &pager_ep,
|
||||||
Allocator &md_alloc,
|
Allocator &md_alloc,
|
||||||
Trace::Source_registry &trace_sources)
|
Trace::Source_registry &trace_sources)
|
||||||
:
|
:
|
||||||
Root_component<Cpu_session_component>(&session_ep, &md_alloc),
|
Root_component<Cpu_session_component>(&session_ep, &md_alloc),
|
||||||
|
_ram(ram), _local_rm(local_rm),
|
||||||
_thread_ep(thread_ep), _pager_ep(pager_ep),
|
_thread_ep(thread_ep), _pager_ep(pager_ep),
|
||||||
_md_alloc(md_alloc), _trace_sources(trace_sources)
|
_md_alloc(md_alloc), _trace_sources(trace_sources)
|
||||||
{ }
|
{ }
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Genode::Cpu_session_component : public Rpc_object<Cpu_session>,
|
||||||
Affinity::Location _location; /* CPU affinity of this
|
Affinity::Location _location; /* CPU affinity of this
|
||||||
session */
|
session */
|
||||||
Trace::Source_registry &_trace_sources;
|
Trace::Source_registry &_trace_sources;
|
||||||
Trace::Control_area _trace_control_area { };
|
Trace::Control_area _trace_control_area;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Members for quota accounting
|
* Members for quota accounting
|
||||||
|
@ -139,7 +139,9 @@ class Genode::Cpu_session_component : public Rpc_object<Cpu_session>,
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Cpu_session_component(Rpc_entrypoint &session_ep,
|
Cpu_session_component(Ram_allocator &ram,
|
||||||
|
Region_map &local_rm,
|
||||||
|
Rpc_entrypoint &session_ep,
|
||||||
Rpc_entrypoint &thread_ep,
|
Rpc_entrypoint &thread_ep,
|
||||||
Pager_entrypoint &pager_ep,
|
Pager_entrypoint &pager_ep,
|
||||||
Allocator &md_alloc,
|
Allocator &md_alloc,
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#define _CORE__INCLUDE__PLATFORM_GENERIC_H_
|
#define _CORE__INCLUDE__PLATFORM_GENERIC_H_
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <thread/capability.h>
|
|
||||||
#include <base/allocator.h>
|
#include <base/allocator.h>
|
||||||
#include <base/affinity.h>
|
#include <base/affinity.h>
|
||||||
|
|
||||||
|
|
|
@ -31,18 +31,20 @@ class Genode::Trace::Control_area
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Ram_allocator &_ram;
|
||||||
|
Region_map &_rm;
|
||||||
Ram_dataspace_capability _ds;
|
Ram_dataspace_capability _ds;
|
||||||
Trace::Control *_local_base;
|
Trace::Control *_local_base;
|
||||||
|
|
||||||
static Ram_dataspace_capability _try_alloc(size_t size)
|
static Ram_dataspace_capability _try_alloc(Ram_allocator &ram, size_t size)
|
||||||
{
|
{
|
||||||
try { return env_deprecated()->ram_session()->alloc(size); }
|
try { return ram.alloc(size); }
|
||||||
catch (...) { return Ram_dataspace_capability(); }
|
catch (...) { return Ram_dataspace_capability(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
static Trace::Control *_try_attach(Dataspace_capability ds)
|
static Trace::Control *_try_attach(Region_map &rm, Dataspace_capability ds)
|
||||||
{
|
{
|
||||||
try { return env_deprecated()->rm_session()->attach(ds); }
|
try { return rm.attach(ds); }
|
||||||
catch (...) { return nullptr; }
|
catch (...) { return nullptr; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,16 +61,17 @@ class Genode::Trace::Control_area
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Control_area()
|
Control_area(Ram_allocator &ram, Region_map &rm)
|
||||||
:
|
:
|
||||||
_ds(_try_alloc(SIZE)),
|
_ram(ram), _rm(rm),
|
||||||
_local_base(_try_attach(_ds))
|
_ds(_try_alloc(ram, SIZE)),
|
||||||
|
_local_base(_try_attach(rm, _ds))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
~Control_area()
|
~Control_area()
|
||||||
{
|
{
|
||||||
if (_local_base) env_deprecated()->rm_session()->detach(_local_base);
|
if (_local_base) _rm.detach(_local_base);
|
||||||
if (_ds.valid()) env_deprecated()->ram_session()->free(_ds);
|
if (_ds.valid()) _ram.free(_ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dataspace_capability dataspace() const { return _ds; }
|
Dataspace_capability dataspace() const { return _ds; }
|
||||||
|
|
|
@ -27,6 +27,8 @@ class Genode::Trace::Root : public Genode::Root_component<Session_component>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Ram_allocator &_ram;
|
||||||
|
Region_map &_local_rm;
|
||||||
Source_registry &_sources;
|
Source_registry &_sources;
|
||||||
Policy_registry &_policies;
|
Policy_registry &_policies;
|
||||||
|
|
||||||
|
@ -42,8 +44,9 @@ class Genode::Trace::Root : public Genode::Root_component<Session_component>
|
||||||
throw Service_denied();
|
throw Service_denied();
|
||||||
|
|
||||||
return new (md_alloc())
|
return new (md_alloc())
|
||||||
Session_component(*md_alloc(), ram_quota, arg_buffer_size,
|
Session_component(_ram, _local_rm, *md_alloc(), ram_quota,
|
||||||
parent_levels, label_from_args(args).string(), _sources, _policies);
|
arg_buffer_size, parent_levels,
|
||||||
|
label_from_args(args).string(), _sources, _policies);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _upgrade_session(Session_component *s, const char *args) override
|
void _upgrade_session(Session_component *s, const char *args) override
|
||||||
|
@ -57,16 +60,14 @@ class Genode::Trace::Root : public Genode::Root_component<Session_component>
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* \param session_ep entry point for managing session objects
|
* \param session_ep entry point for managing session objects
|
||||||
* \param md_alloc meta data allocator used by root component
|
|
||||||
* \param ram_quota RAM for tracing purposes of this session
|
|
||||||
* \param arg_buffer_size session argument-buffer size
|
|
||||||
*/
|
*/
|
||||||
Root(Rpc_entrypoint &session_ep, Allocator &md_alloc,
|
Root(Ram_allocator &ram, Region_map &local_rm,
|
||||||
|
Rpc_entrypoint &session_ep, Allocator &md_alloc,
|
||||||
Source_registry &sources, Policy_registry &policies)
|
Source_registry &sources, Policy_registry &policies)
|
||||||
:
|
:
|
||||||
Root_component<Session_component>(&session_ep, &md_alloc),
|
Root_component<Session_component>(&session_ep, &md_alloc),
|
||||||
_sources(sources), _policies(policies)
|
_ram(ram), _local_rm(local_rm), _sources(sources), _policies(policies)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <base/allocator_guard.h>
|
#include <base/allocator_guard.h>
|
||||||
#include <base/rpc_server.h>
|
#include <base/rpc_server.h>
|
||||||
#include <base/tslab.h>
|
#include <base/tslab.h>
|
||||||
|
#include <base/attached_ram_dataspace.h>
|
||||||
#include <trace_session/trace_session.h>
|
#include <trace_session/trace_session.h>
|
||||||
|
|
||||||
/* core-local includes */
|
/* core-local includes */
|
||||||
|
@ -35,7 +36,8 @@ class Genode::Trace::Session_component
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Ram_session &_ram;
|
Ram_allocator &_ram;
|
||||||
|
Region_map &_local_rm;
|
||||||
Allocator_guard _md_alloc;
|
Allocator_guard _md_alloc;
|
||||||
Tslab<Trace::Subject, 4096> _subjects_slab;
|
Tslab<Trace::Subject, 4096> _subjects_slab;
|
||||||
Tslab<Trace::Policy, 4096> _policies_slab;
|
Tslab<Trace::Policy, 4096> _policies_slab;
|
||||||
|
@ -45,48 +47,18 @@ class Genode::Trace::Session_component
|
||||||
Policy_registry &_policies;
|
Policy_registry &_policies;
|
||||||
Subject_registry _subjects;
|
Subject_registry _subjects;
|
||||||
unsigned _policy_cnt { 0 };
|
unsigned _policy_cnt { 0 };
|
||||||
|
Attached_ram_dataspace _argument_buffer;
|
||||||
class Argument_buffer
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Noncopyable
|
|
||||||
*/
|
|
||||||
Argument_buffer(Argument_buffer const &);
|
|
||||||
Argument_buffer &operator = (Argument_buffer const &);
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Ram_session &ram;
|
|
||||||
Ram_dataspace_capability ds;
|
|
||||||
char *base;
|
|
||||||
size_t size;
|
|
||||||
|
|
||||||
Argument_buffer(Ram_session &ram, size_t size)
|
|
||||||
:
|
|
||||||
ram(ram),
|
|
||||||
ds(ram.alloc(size)),
|
|
||||||
base(env_deprecated()->rm_session()->attach(ds)),
|
|
||||||
size(ram.dataspace_size(ds))
|
|
||||||
{ }
|
|
||||||
|
|
||||||
~Argument_buffer()
|
|
||||||
{
|
|
||||||
env_deprecated()->rm_session()->detach(base);
|
|
||||||
ram.free(ds);
|
|
||||||
}
|
|
||||||
} _argument_buffer;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Session_component(Allocator &md_alloc, size_t ram_quota,
|
Session_component(Ram_allocator &ram, Region_map &local_rm,
|
||||||
size_t arg_buffer_size, unsigned parent_levels,
|
Allocator &md_alloc, size_t ram_quota,
|
||||||
char const *label, Source_registry &sources,
|
size_t arg_buffer_size, unsigned parent_levels,
|
||||||
Policy_registry &policies);
|
char const *label, Source_registry &sources,
|
||||||
|
Policy_registry &policies);
|
||||||
|
|
||||||
~Session_component();
|
~Session_component();
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Genode::Trace::Subject
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Ram_session *_ram_ptr { nullptr };
|
Ram_allocator *_ram_ptr { nullptr };
|
||||||
size_t _size { 0 };
|
size_t _size { 0 };
|
||||||
Ram_dataspace_capability _ds { };
|
Ram_dataspace_capability _ds { };
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class Genode::Trace::Subject
|
||||||
* \return true on success, false on the attempt to call setup
|
* \return true on success, false on the attempt to call setup
|
||||||
* twice.
|
* twice.
|
||||||
*/
|
*/
|
||||||
bool setup(Ram_session &ram, size_t size)
|
bool setup(Ram_allocator &ram, size_t size)
|
||||||
{
|
{
|
||||||
if (_size)
|
if (_size)
|
||||||
return false;
|
return false;
|
||||||
|
@ -97,8 +97,8 @@ class Genode::Trace::Subject
|
||||||
/**
|
/**
|
||||||
* Clone dataspace into newly allocated dataspace
|
* Clone dataspace into newly allocated dataspace
|
||||||
*/
|
*/
|
||||||
bool setup(Ram_session &ram, Dataspace_capability &from_ds,
|
bool setup(Ram_allocator &ram, Region_map &local_rm,
|
||||||
size_t size)
|
Dataspace_capability &from_ds, size_t size)
|
||||||
{
|
{
|
||||||
if (!from_ds.valid())
|
if (!from_ds.valid())
|
||||||
return false;
|
return false;
|
||||||
|
@ -108,13 +108,13 @@ class Genode::Trace::Subject
|
||||||
_ds = ram.alloc(_size);
|
_ds = ram.alloc(_size);
|
||||||
|
|
||||||
/* copy content */
|
/* copy content */
|
||||||
void *src = env_deprecated()->rm_session()->attach(from_ds),
|
void *src = local_rm.attach(from_ds),
|
||||||
*dst = env_deprecated()->rm_session()->attach(_ds);
|
*dst = local_rm.attach(_ds);
|
||||||
|
|
||||||
memcpy(dst, src, _size);
|
memcpy(dst, src, _size);
|
||||||
|
|
||||||
env_deprecated()->rm_session()->detach(src);
|
local_rm.detach(src);
|
||||||
env_deprecated()->rm_session()->detach(dst);
|
local_rm.detach(dst);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -196,12 +196,13 @@ class Genode::Trace::Subject
|
||||||
* \throw Traced_by_other_session
|
* \throw Traced_by_other_session
|
||||||
*/
|
*/
|
||||||
void trace(Policy_id policy_id, Dataspace_capability policy_ds,
|
void trace(Policy_id policy_id, Dataspace_capability policy_ds,
|
||||||
size_t policy_size, Ram_session &ram, size_t size)
|
size_t policy_size, Ram_allocator &ram,
|
||||||
|
Region_map &local_rm, size_t size)
|
||||||
{
|
{
|
||||||
_policy_id = policy_id;
|
_policy_id = policy_id;
|
||||||
|
|
||||||
if (!_buffer.setup(ram, size)
|
if (!_buffer.setup(ram, size)
|
||||||
|| !_policy.setup(ram, policy_ds, policy_size))
|
|| !_policy.setup(ram, local_rm, policy_ds, policy_size))
|
||||||
throw Already_traced();
|
throw Already_traced();
|
||||||
|
|
||||||
/* inform trace source about the new buffer */
|
/* inform trace source about the new buffer */
|
||||||
|
@ -288,7 +289,7 @@ class Genode::Trace::Subject_registry
|
||||||
typedef List<Subject> Subjects;
|
typedef List<Subject> Subjects;
|
||||||
|
|
||||||
Allocator &_md_alloc;
|
Allocator &_md_alloc;
|
||||||
Ram_session &_ram;
|
Ram_allocator &_ram;
|
||||||
Source_registry &_sources;
|
Source_registry &_sources;
|
||||||
unsigned _id_cnt { 0 };
|
unsigned _id_cnt { 0 };
|
||||||
Lock _lock { };
|
Lock _lock { };
|
||||||
|
@ -372,10 +373,10 @@ class Genode::Trace::Subject_registry
|
||||||
*
|
*
|
||||||
* \param md_alloc meta-data allocator used for allocating 'Subject'
|
* \param md_alloc meta-data allocator used for allocating 'Subject'
|
||||||
* objects.
|
* objects.
|
||||||
* \param ram RAM session used for the allocation of trace
|
* \param ram allocator used for the allocation of trace
|
||||||
* buffers and policy dataspaces.
|
* buffers and policy dataspaces.
|
||||||
*/
|
*/
|
||||||
Subject_registry(Allocator &md_alloc, Ram_session &ram,
|
Subject_registry(Allocator &md_alloc, Ram_allocator &ram,
|
||||||
Source_registry &sources)
|
Source_registry &sources)
|
||||||
:
|
:
|
||||||
_md_alloc(md_alloc), _ram(ram), _sources(sources)
|
_md_alloc(md_alloc), _ram(ram), _sources(sources)
|
||||||
|
|
|
@ -145,8 +145,8 @@ class Core_child : public Child_policy
|
||||||
|
|
||||||
Name name() const { return "init"; }
|
Name name() const { return "init"; }
|
||||||
|
|
||||||
Service &resolve_session_request(Service::Name const &name,
|
Route resolve_session_request(Service::Name const &name,
|
||||||
Session_state::Args const &) override
|
Session_label const &label) override
|
||||||
{
|
{
|
||||||
Service *service = nullptr;
|
Service *service = nullptr;
|
||||||
_services.for_each([&] (Service &s) {
|
_services.for_each([&] (Service &s) {
|
||||||
|
@ -156,7 +156,9 @@ class Core_child : public Child_policy
|
||||||
if (!service)
|
if (!service)
|
||||||
throw Service_denied();
|
throw Service_denied();
|
||||||
|
|
||||||
return *service;
|
return Route { .service = *service,
|
||||||
|
.label = label,
|
||||||
|
.diag = Session::Diag() };
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(Pd_session &session, Capability<Pd_session> cap) override
|
void init(Pd_session &session, Capability<Pd_session> cap) override
|
||||||
|
@ -172,11 +174,8 @@ class Core_child : public Child_policy
|
||||||
_core_cpu.transfer_quota(cap, Cpu_session::quota_lim_upscale(100, 100));
|
_core_cpu.transfer_quota(cap, Cpu_session::quota_lim_upscale(100, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
Pd_session &ref_pd() { return _core_pd; }
|
Pd_session &ref_pd() override { return _core_pd; }
|
||||||
Pd_session_capability ref_pd_cap() const { return _core_pd_cap; }
|
Pd_session_capability ref_pd_cap() const override { return _core_pd_cap; }
|
||||||
|
|
||||||
Ram_session &ref_ram() { return _core_pd; }
|
|
||||||
Ram_session_capability ref_ram_cap() const { return _core_pd_cap; }
|
|
||||||
|
|
||||||
size_t session_alloc_batch_size() const override { return 128; }
|
size_t session_alloc_batch_size() const override { return 128; }
|
||||||
};
|
};
|
||||||
|
@ -254,8 +253,8 @@ int main()
|
||||||
|
|
||||||
static Rom_root rom_root (ep, ep, platform().rom_fs(), sliced_heap);
|
static Rom_root rom_root (ep, ep, platform().rom_fs(), sliced_heap);
|
||||||
static Rm_root rm_root (ep, sliced_heap, pager_ep);
|
static Rm_root rm_root (ep, sliced_heap, pager_ep);
|
||||||
static Cpu_root cpu_root (ep, ep, pager_ep, sliced_heap,
|
static Cpu_root cpu_root (core_ram_alloc, local_rm, ep, ep, pager_ep,
|
||||||
Trace::sources());
|
sliced_heap, Trace::sources());
|
||||||
static Pd_root pd_root (ep, core_env().signal_ep(), pager_ep,
|
static Pd_root pd_root (ep, core_env().signal_ep(), pager_ep,
|
||||||
platform().ram_alloc(),
|
platform().ram_alloc(),
|
||||||
local_rm, sliced_heap,
|
local_rm, sliced_heap,
|
||||||
|
@ -265,7 +264,8 @@ int main()
|
||||||
platform().ram_alloc(), sliced_heap);
|
platform().ram_alloc(), sliced_heap);
|
||||||
static Irq_root irq_root (*core_env().pd_session(),
|
static Irq_root irq_root (*core_env().pd_session(),
|
||||||
platform().irq_alloc(), sliced_heap);
|
platform().irq_alloc(), sliced_heap);
|
||||||
static Trace::Root trace_root (ep, sliced_heap, Trace::sources(), trace_policies);
|
static Trace::Root trace_root (core_ram_alloc, local_rm, ep, sliced_heap,
|
||||||
|
Trace::sources(), trace_policies);
|
||||||
|
|
||||||
static Core_service<Rom_session_component> rom_service (services, rom_root);
|
static Core_service<Rom_session_component> rom_service (services, rom_root);
|
||||||
static Core_service<Rm_session_component> rm_service (services, rm_root);
|
static Core_service<Rm_session_component> rm_service (services, rm_root);
|
||||||
|
@ -300,7 +300,7 @@ int main()
|
||||||
|
|
||||||
/* CPU session representing core */
|
/* CPU session representing core */
|
||||||
static Cpu_session_component
|
static Cpu_session_component
|
||||||
core_cpu(ep, ep, pager_ep, sliced_heap, Trace::sources(),
|
core_cpu(core_ram_alloc, local_rm, ep, ep, pager_ep, sliced_heap, Trace::sources(),
|
||||||
"label=\"core\"", Affinity(), Cpu_session::QUOTA_LIMIT);
|
"label=\"core\"", Affinity(), Cpu_session::QUOTA_LIMIT);
|
||||||
Cpu_session_capability core_cpu_cap = ep.manage(&core_cpu);
|
Cpu_session_capability core_cpu_cap = ep.manage(&core_cpu);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ using namespace Genode::Trace;
|
||||||
|
|
||||||
Dataspace_capability Session_component::dataspace()
|
Dataspace_capability Session_component::dataspace()
|
||||||
{
|
{
|
||||||
return _argument_buffer.ds;
|
return _argument_buffer.cap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,14 +31,14 @@ size_t Session_component::subjects()
|
||||||
{
|
{
|
||||||
_subjects.import_new_sources(_sources);
|
_subjects.import_new_sources(_sources);
|
||||||
|
|
||||||
return _subjects.subjects((Subject_id *)_argument_buffer.base,
|
return _subjects.subjects(_argument_buffer.local_addr<Subject_id>(),
|
||||||
_argument_buffer.size/sizeof(Subject_id));
|
_argument_buffer.size()/sizeof(Subject_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Policy_id Session_component::alloc_policy(size_t size)
|
Policy_id Session_component::alloc_policy(size_t size)
|
||||||
{
|
{
|
||||||
if (size > _argument_buffer.size)
|
if (size > _argument_buffer.size())
|
||||||
throw Policy_too_large();
|
throw Policy_too_large();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -92,7 +92,7 @@ void Session_component::trace(Subject_id subject_id, Policy_id policy_id,
|
||||||
try {
|
try {
|
||||||
Trace::Subject &subject = _subjects.lookup_by_id(subject_id);
|
Trace::Subject &subject = _subjects.lookup_by_id(subject_id);
|
||||||
subject.trace(policy_id, _policies.dataspace(*this, policy_id),
|
subject.trace(policy_id, _policies.dataspace(*this, policy_id),
|
||||||
policy_size, _ram, buffer_size);
|
policy_size, _ram, _local_rm, buffer_size);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
/* revert withdrawal or quota */
|
/* revert withdrawal or quota */
|
||||||
_md_alloc.upgrade(required_ram);
|
_md_alloc.upgrade(required_ram);
|
||||||
|
@ -139,12 +139,13 @@ void Session_component::free(Subject_id subject_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Session_component::Session_component(Allocator &md_alloc, size_t ram_quota,
|
Session_component::Session_component(Ram_allocator &ram, Region_map &local_rm,
|
||||||
|
Allocator &md_alloc, size_t ram_quota,
|
||||||
size_t arg_buffer_size, unsigned parent_levels,
|
size_t arg_buffer_size, unsigned parent_levels,
|
||||||
char const *label, Source_registry &sources,
|
char const *label, Source_registry &sources,
|
||||||
Policy_registry &policies)
|
Policy_registry &policies)
|
||||||
:
|
:
|
||||||
_ram(*env_deprecated()->ram_session()),
|
_ram(ram), _local_rm(local_rm),
|
||||||
_md_alloc(&md_alloc, ram_quota),
|
_md_alloc(&md_alloc, ram_quota),
|
||||||
_subjects_slab(&_md_alloc),
|
_subjects_slab(&_md_alloc),
|
||||||
_policies_slab(&_md_alloc),
|
_policies_slab(&_md_alloc),
|
||||||
|
@ -153,9 +154,9 @@ Session_component::Session_component(Allocator &md_alloc, size_t ram_quota,
|
||||||
_sources(sources),
|
_sources(sources),
|
||||||
_policies(policies),
|
_policies(policies),
|
||||||
_subjects(_subjects_slab, _ram, _sources),
|
_subjects(_subjects_slab, _ram, _sources),
|
||||||
_argument_buffer(_ram, arg_buffer_size)
|
_argument_buffer(_ram, local_rm, arg_buffer_size)
|
||||||
{
|
{
|
||||||
_md_alloc.withdraw(_argument_buffer.size);
|
_md_alloc.withdraw(_argument_buffer.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@ namespace Genode { struct Attached_stack_area; }
|
||||||
|
|
||||||
struct Genode::Attached_stack_area : Expanding_region_map_client
|
struct Genode::Attached_stack_area : Expanding_region_map_client
|
||||||
{
|
{
|
||||||
Attached_stack_area(Parent &, Pd_session_capability pd)
|
Attached_stack_area(Parent &parent, Pd_session_capability pd)
|
||||||
:
|
:
|
||||||
Expanding_region_map_client(pd, Pd_session_client(pd).stack_area(),
|
Expanding_region_map_client(parent, pd, Pd_session_client(pd).stack_area(),
|
||||||
Parent::Env::pd())
|
Parent::Env::pd())
|
||||||
{
|
{
|
||||||
Region_map_client address_space(Pd_session_client(pd).address_space());
|
Region_map_client address_space(Pd_session_client(pd).address_space());
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace Genode { struct Expanding_cpu_session_client; }
|
||||||
|
|
||||||
struct Genode::Expanding_cpu_session_client : Upgradeable_client<Genode::Cpu_session_client>
|
struct Genode::Expanding_cpu_session_client : Upgradeable_client<Genode::Cpu_session_client>
|
||||||
{
|
{
|
||||||
Expanding_cpu_session_client(Genode::Cpu_session_capability cap, Parent::Client::Id id)
|
Expanding_cpu_session_client(Parent &parent, Genode::Cpu_session_capability cap, Parent::Client::Id id)
|
||||||
:
|
:
|
||||||
/*
|
/*
|
||||||
* We need to upcast the capability because on some platforms (i.e.,
|
* We need to upcast the capability because on some platforms (i.e.,
|
||||||
|
@ -35,7 +35,7 @@ struct Genode::Expanding_cpu_session_client : Upgradeable_client<Genode::Cpu_ses
|
||||||
* interface ('Nova_cpu_session').
|
* interface ('Nova_cpu_session').
|
||||||
*/
|
*/
|
||||||
Upgradeable_client<Genode::Cpu_session_client>
|
Upgradeable_client<Genode::Cpu_session_client>
|
||||||
(static_cap_cast<Genode::Cpu_session_client::Rpc_interface>(cap), id)
|
(parent, static_cap_cast<Genode::Cpu_session_client::Rpc_interface>(cap), id)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Thread_capability
|
Thread_capability
|
||||||
|
|
|
@ -23,19 +23,20 @@ namespace Genode { class Expanding_pd_session_client; }
|
||||||
|
|
||||||
struct Genode::Expanding_pd_session_client : Pd_session_client
|
struct Genode::Expanding_pd_session_client : Pd_session_client
|
||||||
{
|
{
|
||||||
|
Parent &_parent;
|
||||||
|
|
||||||
void _request_ram_from_parent(size_t amount)
|
void _request_ram_from_parent(size_t amount)
|
||||||
{
|
{
|
||||||
Parent &parent = *env_deprecated()->parent();
|
_parent.resource_request(String<128>("ram_quota=", amount).string());
|
||||||
parent.resource_request(String<128>("ram_quota=", amount).string());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _request_caps_from_parent(size_t amount)
|
void _request_caps_from_parent(size_t amount)
|
||||||
{
|
{
|
||||||
Parent &parent = *env_deprecated()->parent();
|
_parent.resource_request(String<128>("cap_quota=", amount).string());
|
||||||
parent.resource_request(String<128>("cap_quota=", amount).string());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Expanding_pd_session_client(Pd_session_capability cap) : Pd_session_client(cap) { }
|
Expanding_pd_session_client(Parent &parent, Pd_session_capability cap)
|
||||||
|
: Pd_session_client(cap), _parent(parent) { }
|
||||||
|
|
||||||
Ram_dataspace_capability alloc(size_t size, Cache_attribute cached = UNCACHED) override
|
Ram_dataspace_capability alloc(size_t size, Cache_attribute cached = UNCACHED) override
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,9 +29,10 @@ struct Genode::Expanding_region_map_client : Region_map_client
|
||||||
{
|
{
|
||||||
Upgradeable_client<Genode::Pd_session_client> _pd_client;
|
Upgradeable_client<Genode::Pd_session_client> _pd_client;
|
||||||
|
|
||||||
Expanding_region_map_client(Pd_session_capability pd, Capability<Region_map> rm,
|
Expanding_region_map_client(Parent &parent, Pd_session_capability pd,
|
||||||
|
Capability<Region_map> rm,
|
||||||
Parent::Client::Id pd_id)
|
Parent::Client::Id pd_id)
|
||||||
: Region_map_client(rm), _pd_client(pd, pd_id) { }
|
: Region_map_client(rm), _pd_client(parent, pd, pd_id) { }
|
||||||
|
|
||||||
Local_addr attach(Dataspace_capability ds, size_t size, off_t offset,
|
Local_addr attach(Dataspace_capability ds, size_t size, off_t offset,
|
||||||
bool use_local_addr, Local_addr local_addr,
|
bool use_local_addr, Local_addr local_addr,
|
||||||
|
|
|
@ -35,7 +35,9 @@ namespace Genode {
|
||||||
void init_ldso_phdr(Env &);
|
void init_ldso_phdr(Env &);
|
||||||
void init_signal_thread(Env &);
|
void init_signal_thread(Env &);
|
||||||
void init_root_proxy(Env &);
|
void init_root_proxy(Env &);
|
||||||
void init_log();
|
void init_tracing(Env &);
|
||||||
|
void init_log(Parent &);
|
||||||
|
void init_exit(Parent &);
|
||||||
void init_parent_resource_requests(Env &);
|
void init_parent_resource_requests(Env &);
|
||||||
void init_heartbeat_monitoring(Env &);
|
void init_heartbeat_monitoring(Env &);
|
||||||
void deinit_heartbeat_monitoring();
|
void deinit_heartbeat_monitoring();
|
||||||
|
@ -50,4 +52,6 @@ namespace Genode {
|
||||||
Env &internal_env();
|
Env &internal_env();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void genode_exit(int);
|
||||||
|
|
||||||
#endif /* _INCLUDE__BASE__INTERNAL__GLOBALS_H_ */
|
#endif /* _INCLUDE__BASE__INTERNAL__GLOBALS_H_ */
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/heap.h>
|
#include <base/heap.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/globals.h>
|
#include <base/internal/globals.h>
|
||||||
|
@ -62,10 +63,10 @@ class Genode::Platform_env : public Platform_env_base
|
||||||
|
|
||||||
Resources(Parent &parent)
|
Resources(Parent &parent)
|
||||||
:
|
:
|
||||||
pd (request<Pd_session> (parent, Parent::Env::pd())),
|
pd (parent, request<Pd_session> (parent, Parent::Env::pd())),
|
||||||
cpu(request<Cpu_session>(parent, Parent::Env::cpu()),
|
cpu(parent, request<Cpu_session>(parent, Parent::Env::cpu()),
|
||||||
Parent::Env::cpu()),
|
Parent::Env::cpu()),
|
||||||
rm(pd, pd.address_space(), Parent::Env::pd())
|
rm(parent, pd.rpc_cap(), pd.address_space(), Parent::Env::pd())
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ class Genode::Platform_env : public Platform_env_base
|
||||||
* because the 'Local_parent' performs a dynamic memory allocation
|
* because the 'Local_parent' performs a dynamic memory allocation
|
||||||
* due to the creation of the stack area's sub-RM session.
|
* due to the creation of the stack area's sub-RM session.
|
||||||
*/
|
*/
|
||||||
Attached_stack_area _stack_area { _parent_client, _resources.pd };
|
Attached_stack_area _stack_area { _parent_client, _resources.pd.rpc_cap() };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -107,13 +108,11 @@ class Genode::Platform_env : public Platform_env_base
|
||||||
******************************/
|
******************************/
|
||||||
|
|
||||||
Parent *parent() override { return &_parent_client; }
|
Parent *parent() override { return &_parent_client; }
|
||||||
Ram_session *ram_session() override { return &_resources.pd; }
|
|
||||||
Ram_session_capability ram_session_cap() override { return _resources.pd; }
|
|
||||||
Cpu_session *cpu_session() override { return &_resources.cpu; }
|
Cpu_session *cpu_session() override { return &_resources.cpu; }
|
||||||
Cpu_session_capability cpu_session_cap() override { return _resources.cpu; }
|
Cpu_session_capability cpu_session_cap() override { return _resources.cpu.rpc_cap(); }
|
||||||
Region_map *rm_session() override { return &_resources.rm; }
|
|
||||||
Pd_session *pd_session() override { return &_resources.pd; }
|
Pd_session *pd_session() override { return &_resources.pd; }
|
||||||
Pd_session_capability pd_session_cap() override { return _resources.pd; }
|
Pd_session_capability pd_session_cap() override { return _resources.pd.rpc_cap(); }
|
||||||
|
Region_map *rm_session() override { return &_resources.rm; }
|
||||||
Allocator *heap() override { return &_heap; }
|
Allocator *heap() override { return &_heap; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
#include <cpu/consts.h>
|
#include <cpu/consts.h>
|
||||||
#include <ram_session/ram_session.h> /* for 'Ram_dataspace_capability' type */
|
|
||||||
#include <cpu_session/cpu_session.h> /* for 'Cpu_session::Name' type */
|
#include <cpu_session/cpu_session.h> /* for 'Cpu_session::Name' type */
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
|
|
|
@ -28,19 +28,20 @@ struct Genode::Upgradeable_client : CLIENT
|
||||||
{
|
{
|
||||||
typedef Genode::Capability<typename CLIENT::Rpc_interface> Capability;
|
typedef Genode::Capability<typename CLIENT::Rpc_interface> Capability;
|
||||||
|
|
||||||
|
Parent &_parent;
|
||||||
Parent::Client::Id _id;
|
Parent::Client::Id _id;
|
||||||
|
|
||||||
Upgradeable_client(Capability cap, Parent::Client::Id id)
|
Upgradeable_client(Parent &parent, Capability cap, Parent::Client::Id id)
|
||||||
: CLIENT(cap), _id(id) { }
|
: CLIENT(cap), _parent(parent), _id(id) { }
|
||||||
|
|
||||||
void upgrade_ram(size_t quota)
|
void upgrade_ram(size_t quota)
|
||||||
{
|
{
|
||||||
env_deprecated()->parent()->upgrade(_id, String<64>("ram_quota=", quota).string());
|
_parent.upgrade(_id, String<64>("ram_quota=", quota).string());
|
||||||
}
|
}
|
||||||
|
|
||||||
void upgrade_caps(size_t quota)
|
void upgrade_caps(size_t quota)
|
||||||
{
|
{
|
||||||
env_deprecated()->parent()->upgrade(_id, String<64>("cap_quota=", quota).string());
|
_parent.upgrade(_id, String<64>("cap_quota=", quota).string());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -221,8 +221,8 @@ Session_capability Child::session(Parent::Client::Id id,
|
||||||
Ram_transfer::Remote_account ref_ram_account { _policy.ref_pd(), _policy.ref_pd_cap() };
|
Ram_transfer::Remote_account ref_ram_account { _policy.ref_pd(), _policy.ref_pd_cap() };
|
||||||
Cap_transfer::Remote_account ref_cap_account { _policy.ref_pd(), _policy.ref_pd_cap() };
|
Cap_transfer::Remote_account ref_cap_account { _policy.ref_pd(), _policy.ref_pd_cap() };
|
||||||
|
|
||||||
Ram_transfer::Remote_account ram_account { ram(), ram_session_cap() };
|
Ram_transfer::Remote_account ram_account { pd(), pd_session_cap() };
|
||||||
Cap_transfer::Remote_account cap_account { pd(), pd_session_cap() };
|
Cap_transfer::Remote_account cap_account { pd(), pd_session_cap() };
|
||||||
|
|
||||||
/* transfer the quota donation from the child's account to ourself */
|
/* transfer the quota donation from the child's account to ourself */
|
||||||
Ram_transfer ram_donation_from_child(ram_quota, ram_account, ref_ram_account);
|
Ram_transfer ram_donation_from_child(ram_quota, ram_account, ref_ram_account);
|
||||||
|
@ -364,8 +364,8 @@ Parent::Upgrade_result Child::upgrade(Client::Id id, Parent::Upgrade_args const
|
||||||
Ram_transfer::Remote_account ref_ram_account { _policy.ref_pd(), _policy.ref_pd_cap() };
|
Ram_transfer::Remote_account ref_ram_account { _policy.ref_pd(), _policy.ref_pd_cap() };
|
||||||
Cap_transfer::Remote_account ref_cap_account { _policy.ref_pd(), _policy.ref_pd_cap() };
|
Cap_transfer::Remote_account ref_cap_account { _policy.ref_pd(), _policy.ref_pd_cap() };
|
||||||
|
|
||||||
Ram_transfer::Remote_account ram_account { ram(), pd_session_cap() };
|
Ram_transfer::Remote_account ram_account { pd(), pd_session_cap() };
|
||||||
Cap_transfer::Remote_account cap_account { pd(), pd_session_cap() };
|
Cap_transfer::Remote_account cap_account { pd(), pd_session_cap() };
|
||||||
|
|
||||||
/* transfer quota from client to ourself */
|
/* transfer quota from client to ourself */
|
||||||
Ram_transfer ram_donation_from_child(ram_quota, ram_account, ref_ram_account);
|
Ram_transfer ram_donation_from_child(ram_quota, ram_account, ref_ram_account);
|
||||||
|
@ -416,7 +416,7 @@ void Child::_revert_quota_and_destroy(Session_state &session)
|
||||||
{
|
{
|
||||||
Ram_transfer::Remote_account ref_ram_account(_policy.ref_pd(), _policy.ref_pd_cap());
|
Ram_transfer::Remote_account ref_ram_account(_policy.ref_pd(), _policy.ref_pd_cap());
|
||||||
Ram_transfer::Account &service_ram_account = session.service();
|
Ram_transfer::Account &service_ram_account = session.service();
|
||||||
Ram_transfer::Remote_account child_ram_account(ram(), pd_session_cap());
|
Ram_transfer::Remote_account child_ram_account(pd(), pd_session_cap());
|
||||||
|
|
||||||
Cap_transfer::Remote_account ref_cap_account(_policy.ref_pd(), _policy.ref_pd_cap());
|
Cap_transfer::Remote_account ref_cap_account(_policy.ref_pd(), _policy.ref_pd_cap());
|
||||||
Cap_transfer::Account &service_cap_account = session.service();
|
Cap_transfer::Account &service_cap_account = session.service();
|
||||||
|
|
|
@ -26,7 +26,7 @@ using namespace Genode;
|
||||||
|
|
||||||
Child::Process::Loaded_executable::Loaded_executable(Type type,
|
Child::Process::Loaded_executable::Loaded_executable(Type type,
|
||||||
Dataspace_capability ldso_ds,
|
Dataspace_capability ldso_ds,
|
||||||
Pd_session &pd,
|
Ram_session &ram,
|
||||||
Region_map &local_rm,
|
Region_map &local_rm,
|
||||||
Region_map &remote_rm,
|
Region_map &remote_rm,
|
||||||
Parent_capability parent_cap)
|
Parent_capability parent_cap)
|
||||||
|
@ -84,7 +84,7 @@ Child::Process::Loaded_executable::Loaded_executable(Type type,
|
||||||
|
|
||||||
/* alloc dataspace */
|
/* alloc dataspace */
|
||||||
Dataspace_capability ds_cap;
|
Dataspace_capability ds_cap;
|
||||||
try { ds_cap = pd.alloc(size); }
|
try { ds_cap = ram.alloc(size); }
|
||||||
catch (Out_of_ram) {
|
catch (Out_of_ram) {
|
||||||
error("allocation of read-write segment failed"); throw; };
|
error("allocation of read-write segment failed"); throw; };
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <base/connection.h>
|
#include <base/connection.h>
|
||||||
#include <base/service.h>
|
#include <base/service.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/globals.h>
|
#include <base/internal/globals.h>
|
||||||
|
@ -73,17 +74,11 @@ namespace {
|
||||||
Env(Genode::Entrypoint &ep) : _ep(ep) { env_ptr = this; }
|
Env(Genode::Entrypoint &ep) : _ep(ep) { env_ptr = this; }
|
||||||
|
|
||||||
Genode::Parent &parent() override { return _parent; }
|
Genode::Parent &parent() override { return _parent; }
|
||||||
Genode::Ram_session &ram() override { return *Genode::env_deprecated()->ram_session(); }
|
|
||||||
Genode::Cpu_session &cpu() override { return *Genode::env_deprecated()->cpu_session(); }
|
Genode::Cpu_session &cpu() override { return *Genode::env_deprecated()->cpu_session(); }
|
||||||
Genode::Region_map &rm() override { return *Genode::env_deprecated()->rm_session(); }
|
Genode::Region_map &rm() override { return *Genode::env_deprecated()->rm_session(); }
|
||||||
Genode::Pd_session &pd() override { return *Genode::env_deprecated()->pd_session(); }
|
Genode::Pd_session &pd() override { return *Genode::env_deprecated()->pd_session(); }
|
||||||
Genode::Entrypoint &ep() override { return _ep; }
|
Genode::Entrypoint &ep() override { return _ep; }
|
||||||
|
|
||||||
Genode::Ram_session_capability ram_session_cap() override
|
|
||||||
{
|
|
||||||
return Genode::env_deprecated()->ram_session_cap();
|
|
||||||
}
|
|
||||||
|
|
||||||
Genode::Cpu_session_capability cpu_session_cap() override
|
Genode::Cpu_session_capability cpu_session_cap() override
|
||||||
{
|
{
|
||||||
return Genode::env_deprecated()->cpu_session_cap();
|
return Genode::env_deprecated()->cpu_session_cap();
|
||||||
|
@ -171,7 +166,7 @@ namespace {
|
||||||
cap_quota = Cap_quota { cap_quota.value + 4 }; }
|
cap_quota = Cap_quota { cap_quota.value + 4 }; }
|
||||||
|
|
||||||
catch (Out_of_ram) {
|
catch (Out_of_ram) {
|
||||||
if (ram_quota.value > ram().avail_ram().value) {
|
if (ram_quota.value > pd().avail_ram().value) {
|
||||||
Parent::Resource_args args(String<64>("ram_quota=", ram_quota));
|
Parent::Resource_args args(String<64>("ram_quota=", ram_quota));
|
||||||
_parent.resource_request(args);
|
_parent.resource_request(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
|
#include <util/construct_at.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <log_session/log_session.h>
|
|
||||||
#include <base/buffered_output.h>
|
#include <base/buffered_output.h>
|
||||||
|
#include <base/sleep.h>
|
||||||
|
#include <log_session/client.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/globals.h>
|
#include <base/internal/globals.h>
|
||||||
|
@ -23,32 +25,68 @@
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
|
||||||
static Log *log_ptr;
|
namespace {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton back end for writing messages to the component's log session
|
||||||
|
*/
|
||||||
|
struct Back_end : Noncopyable
|
||||||
|
{
|
||||||
|
Log_session_client _client;
|
||||||
|
|
||||||
|
static Session_capability _cap(Parent &parent) {
|
||||||
|
return parent.session_cap(Parent::Env::log()); }
|
||||||
|
|
||||||
|
Back_end(Parent &parent)
|
||||||
|
: _client(reinterpret_cap_cast<Log_session>(_cap(parent))) { }
|
||||||
|
|
||||||
|
void write(char const *string) { (void)_client.write(string); }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static Back_end *back_end_ptr;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton instance of the 'Log' interface
|
||||||
|
*/
|
||||||
|
static Log *log_ptr;
|
||||||
|
|
||||||
Log &Log::log()
|
Log &Log::log()
|
||||||
{
|
{
|
||||||
/*
|
if (log_ptr)
|
||||||
* Ensure the log is initialized before use. This is only needed for
|
return *log_ptr;
|
||||||
* components that do not initialize the log explicitly in the startup
|
|
||||||
* code, i.e., Linux hybrid components.
|
|
||||||
*/
|
|
||||||
Genode::init_log();
|
|
||||||
|
|
||||||
return *log_ptr;
|
raw("Error: Missing call of init_log");
|
||||||
|
sleep_forever();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" int stdout_write(const char *s);
|
/**
|
||||||
|
* Hook for support the 'fork' implementation of the noux libc backend
|
||||||
|
*/
|
||||||
|
extern "C" void stdout_reconnect(Parent &parent)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* We cannot use a 'Reconstructible' because we have to skip
|
||||||
|
* the object destruction inside a freshly forked process.
|
||||||
|
* Otherwise, the attempt to destruct the capability contained
|
||||||
|
* in the 'Log' object would result in an inconsistent ref counter
|
||||||
|
* of the respective capability-space element.
|
||||||
|
*/
|
||||||
|
construct_at<Back_end>(back_end_ptr, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Genode::init_log()
|
void Genode::init_log(Parent &parent)
|
||||||
{
|
{
|
||||||
/* ignore subsequent calls */
|
/* ignore subsequent calls */
|
||||||
if (log_ptr)
|
if (log_ptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct Write_fn { void operator () (char const *s) { stdout_write(s); } };
|
back_end_ptr = unmanaged_singleton<Back_end>(parent);
|
||||||
|
|
||||||
|
struct Write_fn { void operator () (char const *s) { back_end_ptr->write(s); } };
|
||||||
|
|
||||||
typedef Buffered_output<Log_session::MAX_STRING_LEN, Write_fn>
|
typedef Buffered_output<Log_session::MAX_STRING_LEN, Write_fn>
|
||||||
Buffered_log_output;
|
Buffered_log_output;
|
||||||
|
|
|
@ -15,14 +15,9 @@
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/entrypoint.h>
|
#include <base/entrypoint.h>
|
||||||
#include <base/component.h>
|
#include <base/component.h>
|
||||||
|
|
||||||
#include <cpu/atomic.h>
|
#include <cpu/atomic.h>
|
||||||
|
|
||||||
#define INCLUDED_BY_ENTRYPOINT_CC /* prevent "deprecated" warning */
|
|
||||||
#include <cap_session/connection.h>
|
|
||||||
#undef INCLUDED_BY_ENTRYPOINT_CC
|
|
||||||
|
|
||||||
#include <util/retry.h>
|
#include <util/retry.h>
|
||||||
|
#include <base/rpc_client.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/globals.h>
|
#include <base/internal/globals.h>
|
||||||
|
@ -284,6 +279,7 @@ namespace {
|
||||||
|
|
||||||
Genode::call_global_static_constructors();
|
Genode::call_global_static_constructors();
|
||||||
Genode::init_signal_transmitter(env);
|
Genode::init_signal_transmitter(env);
|
||||||
|
Genode::init_tracing(env);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now, as signaling is available, initialize the asynchronous
|
* Now, as signaling is available, initialize the asynchronous
|
||||||
|
@ -296,6 +292,11 @@ namespace {
|
||||||
Component::construct(env);
|
Component::construct(env);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void invoke_constructor_at_entrypoint(Capability<Constructor> cap)
|
||||||
|
{
|
||||||
|
cap.call<Constructor::Rpc_construct>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,16 +316,15 @@ Entrypoint::Entrypoint(Env &env)
|
||||||
*/
|
*/
|
||||||
Constructor_component constructor(env);
|
Constructor_component constructor(env);
|
||||||
|
|
||||||
Capability<Constructor> constructor_cap =
|
_env.ep().manage(constructor);
|
||||||
_rpc_ep->manage(&constructor);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
constructor_cap.call<Constructor::Rpc_construct>();
|
invoke_constructor_at_entrypoint(constructor.cap());
|
||||||
} catch (Blocking_canceled) {
|
} catch (Blocking_canceled) {
|
||||||
warning("blocking canceled in entrypoint constructor");
|
warning("blocking canceled in entrypoint constructor");
|
||||||
}
|
}
|
||||||
|
|
||||||
_rpc_ep->dissolve(&constructor);
|
_env.ep().dissolve(constructor);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The calling initial thread becomes the signal proxy thread for this
|
* The calling initial thread becomes the signal proxy thread for this
|
||||||
|
|
|
@ -1,144 +0,0 @@
|
||||||
/*
|
|
||||||
* \brief Printf backend for the LOG interface
|
|
||||||
* \author Norman Feske
|
|
||||||
* \date 2006-09-15
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2006-2017 Genode Labs GmbH
|
|
||||||
*
|
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
|
||||||
* under the terms of the GNU Affero General Public License version 3.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <log_session/connection.h>
|
|
||||||
#include <base/printf.h>
|
|
||||||
#include <base/console.h>
|
|
||||||
#include <base/lock.h>
|
|
||||||
#include <base/env.h>
|
|
||||||
#include <base/internal/unmanaged_singleton.h>
|
|
||||||
|
|
||||||
using namespace Genode;
|
|
||||||
|
|
||||||
class Log_console : public Console
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
enum { _BUF_SIZE = Log_session::MAX_STRING_LEN };
|
|
||||||
|
|
||||||
|
|
||||||
struct Log : Log_session_client
|
|
||||||
{
|
|
||||||
Session_capability _cap() {
|
|
||||||
return env_deprecated()->parent()->session_cap(Parent::Env::log()); }
|
|
||||||
|
|
||||||
Log() : Log_session_client(reinterpret_cap_cast<Log_session>(_cap()))
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
Log _log { };
|
|
||||||
|
|
||||||
char _buf[_BUF_SIZE] { };
|
|
||||||
unsigned _num_chars = 0;
|
|
||||||
Lock _lock { };
|
|
||||||
|
|
||||||
void _flush()
|
|
||||||
{
|
|
||||||
/* null-terminate string */
|
|
||||||
_buf[_num_chars] = 0;
|
|
||||||
_log.write(_buf);
|
|
||||||
|
|
||||||
/* restart with empty buffer */
|
|
||||||
_num_chars = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
void _out_char(char c)
|
|
||||||
{
|
|
||||||
/* ensure enough buffer space for complete escape sequence */
|
|
||||||
if ((c == 27) && (_num_chars + 8 > _BUF_SIZE)) _flush();
|
|
||||||
|
|
||||||
_buf[_num_chars++] = c;
|
|
||||||
|
|
||||||
/* flush immediately on line break */
|
|
||||||
if (c == '\n' || _num_chars >= sizeof(_buf) - 1)
|
|
||||||
_flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
Log_console() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Console interface
|
|
||||||
*/
|
|
||||||
void vprintf(const char *format, va_list list)
|
|
||||||
{
|
|
||||||
Lock::Guard lock_guard(_lock);
|
|
||||||
Console::vprintf(format, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return LOG session interface
|
|
||||||
*/
|
|
||||||
Log_session &log_session() { return _log; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Re-establish LOG session
|
|
||||||
*/
|
|
||||||
void reconnect()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* We cannot use a 'Reconstructible' because we have to skip
|
|
||||||
* the object destruction inside a freshly forked process.
|
|
||||||
* Otherwise, the attempt to destruct the capability contained
|
|
||||||
* in the 'Log' object would result in an inconsistent ref counter
|
|
||||||
* of the respective capability-space element.
|
|
||||||
*/
|
|
||||||
construct_at<Log>(&_log);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* In the presence of a libC, we use the libC's full printf implementation and
|
|
||||||
* use the 'Log_console' as backend.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static Log_console *stdout_log_console() { return unmanaged_singleton<Log_console>(); }
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook for supporting libc back ends for stdio
|
|
||||||
*/
|
|
||||||
extern "C" int stdout_write(const char *s)
|
|
||||||
{
|
|
||||||
return stdout_log_console()->log_session().write(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook for support the 'fork' implementation of the noux libc backend
|
|
||||||
*/
|
|
||||||
extern "C" void stdout_reconnect() { stdout_log_console()->reconnect(); }
|
|
||||||
|
|
||||||
|
|
||||||
void Genode::printf(const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list list;
|
|
||||||
va_start(list, format);
|
|
||||||
|
|
||||||
vprintf(format, list);
|
|
||||||
|
|
||||||
va_end(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Genode::vprintf(const char *format, va_list list)
|
|
||||||
{
|
|
||||||
stdout_log_console()->vprintf(format, list);
|
|
||||||
}
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <util/retry.h>
|
#include <util/retry.h>
|
||||||
#include <base/rpc_server.h>
|
#include <base/rpc_server.h>
|
||||||
#include <pd_session/client.h>
|
#include <pd_session/client.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <base/sleep.h>
|
#include <base/sleep.h>
|
||||||
#include <base/trace/events.h>
|
#include <base/trace/events.h>
|
||||||
#include <util/reconstructible.h>
|
#include <util/reconstructible.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/globals.h>
|
#include <base/internal/globals.h>
|
||||||
|
@ -182,31 +183,6 @@ Genode::Signal_context_registry *signal_context_registry()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************
|
|
||||||
** Signal context **
|
|
||||||
********************/
|
|
||||||
|
|
||||||
void Signal_context::submit(unsigned num)
|
|
||||||
{
|
|
||||||
if (!_receiver) {
|
|
||||||
warning("signal context with no receiver");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!signal_context_registry()->test_and_lock(this)) {
|
|
||||||
warning("encountered dead signal context");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* construct and locally submit signal object */
|
|
||||||
Signal::Data signal(this, num);
|
|
||||||
_receiver->local_submit(signal);
|
|
||||||
|
|
||||||
/* free context lock that was taken by 'test_and_lock' */
|
|
||||||
_lock.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
** Signal receiver **
|
** Signal receiver **
|
||||||
*********************/
|
*********************/
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/signal.h>
|
#include <base/signal.h>
|
||||||
#include <base/trace/events.h>
|
#include <base/trace/events.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/sleep.h>
|
#include <base/sleep.h>
|
||||||
#include <base/snprintf.h>
|
#include <base/snprintf.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/stack_allocator.h>
|
#include <base/internal/stack_allocator.h>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <base/sleep.h>
|
#include <base/sleep.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <cpu_thread/client.h>
|
#include <cpu_thread/client.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/stack.h>
|
#include <base/internal/stack.h>
|
||||||
|
|
|
@ -27,6 +27,19 @@ using namespace Genode;
|
||||||
|
|
||||||
namespace Genode { bool inhibit_tracing = true; /* cleared by '_main' */ }
|
namespace Genode { bool inhibit_tracing = true; /* cleared by '_main' */ }
|
||||||
|
|
||||||
|
static Env *_env_ptr;
|
||||||
|
|
||||||
|
namespace Genode { void init_tracing(Env &env) { _env_ptr = &env; } }
|
||||||
|
|
||||||
|
static Env &_env()
|
||||||
|
{
|
||||||
|
if (_env_ptr)
|
||||||
|
return *_env_ptr;
|
||||||
|
|
||||||
|
struct Missing_call_of_init_tracing { };
|
||||||
|
throw Missing_call_of_init_tracing();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
** Trace::Logger **
|
** Trace::Logger **
|
||||||
|
@ -47,13 +60,13 @@ bool Trace::Logger::_evaluate_control()
|
||||||
|
|
||||||
/* unload policy */
|
/* unload policy */
|
||||||
if (policy_module) {
|
if (policy_module) {
|
||||||
env_deprecated()->rm_session()->detach(policy_module);
|
_env().rm().detach(policy_module);
|
||||||
policy_module = 0;
|
policy_module = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unmap trace buffer */
|
/* unmap trace buffer */
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
env_deprecated()->rm_session()->detach(buffer);
|
_env().rm().detach(buffer);
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +106,8 @@ bool Trace::Logger::_evaluate_control()
|
||||||
EXECUTABLE = true
|
EXECUTABLE = true
|
||||||
};
|
};
|
||||||
|
|
||||||
Genode::Region_map * const rm = env_deprecated()->rm_session();
|
policy_module = _env().rm().attach(policy_ds, MAX_SIZE, NO_OFFSET,
|
||||||
policy_module = rm->attach(policy_ds, MAX_SIZE, NO_OFFSET,
|
ANY_LOCAL_ADDR, nullptr, EXECUTABLE);
|
||||||
ANY_LOCAL_ADDR, nullptr, EXECUTABLE);
|
|
||||||
|
|
||||||
/* relocate function pointers of policy callback table */
|
/* relocate function pointers of policy callback table */
|
||||||
for (unsigned i = 0; i < sizeof(Trace::Policy_module)/sizeof(void *); i++) {
|
for (unsigned i = 0; i < sizeof(Trace::Policy_module)/sizeof(void *); i++) {
|
||||||
|
@ -118,7 +130,7 @@ bool Trace::Logger::_evaluate_control()
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
buffer = env_deprecated()->rm_session()->attach(buffer_ds);
|
buffer = _env().rm().attach(buffer_ds);
|
||||||
buffer->init(Dataspace_client(buffer_ds).size());
|
buffer->init(Dataspace_client(buffer_ds).size());
|
||||||
} catch (...) { }
|
} catch (...) { }
|
||||||
|
|
||||||
|
@ -170,10 +182,10 @@ Trace::Logger::Logger() { }
|
||||||
/**
|
/**
|
||||||
* return logger instance for the main thread **
|
* return logger instance for the main thread **
|
||||||
*/
|
*/
|
||||||
static Trace::Logger *main_trace_logger()
|
static Trace::Logger &main_trace_logger()
|
||||||
{
|
{
|
||||||
static Trace::Logger logger;
|
static Trace::Logger logger;
|
||||||
return &logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,38 +195,36 @@ static Trace::Control *main_trace_control;
|
||||||
Trace::Logger *Thread::_logger()
|
Trace::Logger *Thread::_logger()
|
||||||
{
|
{
|
||||||
if (inhibit_tracing)
|
if (inhibit_tracing)
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
Thread * const myself = Thread::myself();
|
Thread * const myself = Thread::myself();
|
||||||
|
|
||||||
Trace::Logger * const logger = myself ? &myself->_trace_logger
|
Trace::Logger &logger = myself ? myself->_trace_logger
|
||||||
: main_trace_logger();
|
: main_trace_logger();
|
||||||
|
|
||||||
/* logger is already being initialized */
|
/* logger is already being initialized */
|
||||||
if (logger->init_pending())
|
if (logger.init_pending())
|
||||||
return logger;
|
return &logger;
|
||||||
|
|
||||||
/* lazily initialize trace object */
|
/* lazily initialize trace object */
|
||||||
if (!logger->initialized()) {
|
if (!logger.initialized()) {
|
||||||
logger->init_pending(true);
|
logger.init_pending(true);
|
||||||
|
|
||||||
Thread_capability thread_cap = myself ? myself->_thread_cap
|
Thread_capability thread_cap = myself ? myself->_thread_cap
|
||||||
: env_deprecated()->parent()->main_thread_cap();
|
: _env().parent().main_thread_cap();
|
||||||
|
|
||||||
Genode::Cpu_session *cpu = myself ? myself->_cpu_session
|
Cpu_session &cpu = myself ? *myself->_cpu_session : _env().cpu();
|
||||||
: env_deprecated()->cpu_session();
|
|
||||||
if (!cpu) cpu = env_deprecated()->cpu_session();
|
|
||||||
|
|
||||||
if (!myself)
|
if (!myself)
|
||||||
if (!main_trace_control) {
|
if (!main_trace_control) {
|
||||||
Dataspace_capability ds = env_deprecated()->cpu_session()->trace_control();
|
Dataspace_capability ds = _env().cpu().trace_control();
|
||||||
if (ds.valid())
|
if (ds.valid())
|
||||||
main_trace_control = env_deprecated()->rm_session()->attach(ds);
|
main_trace_control = _env().rm().attach(ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger->init(thread_cap, cpu,
|
logger.init(thread_cap, &cpu,
|
||||||
myself ? myself->_trace_control : main_trace_control);
|
myself ? myself->_trace_control : main_trace_control);
|
||||||
}
|
}
|
||||||
|
|
||||||
return logger;
|
return &logger;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <base/stdint.h>
|
#include <base/stdint.h>
|
||||||
#include <base/sleep.h>
|
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
|
|
||||||
|
@ -119,9 +118,8 @@ extern "C" void *abort(void)
|
||||||
|
|
||||||
/* Notify the parent of failure */
|
/* Notify the parent of failure */
|
||||||
if (name != "main")
|
if (name != "main")
|
||||||
Genode::env_deprecated()->parent()->exit(1);
|
genode_exit(1);
|
||||||
|
|
||||||
Genode::sleep_forever();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/sleep.h>
|
#include <base/sleep.h>
|
||||||
#include <base/log.h>
|
|
||||||
#include <base/component.h>
|
#include <base/component.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* platform-specific local helper functions */
|
/* platform-specific local helper functions */
|
||||||
#include <base/internal/parent_cap.h>
|
#include <base/internal/parent_cap.h>
|
||||||
|
@ -173,6 +173,12 @@ void genode___cxa_finalize(void *dso)
|
||||||
|
|
||||||
extern "C" void __cxa_finalize(void *dso);
|
extern "C" void __cxa_finalize(void *dso);
|
||||||
|
|
||||||
|
static Genode::Parent *_parent_ptr;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Genode { void init_exit(Parent &parent) { _parent_ptr = &parent; } }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminate the process.
|
* Terminate the process.
|
||||||
*/
|
*/
|
||||||
|
@ -186,7 +192,8 @@ void genode_exit(int status)
|
||||||
for (func = &_dtors_start; func != &_dtors_end; (*func++)());
|
for (func = &_dtors_start; func != &_dtors_end; (*func++)());
|
||||||
|
|
||||||
/* inform parent about the exit status */
|
/* inform parent about the exit status */
|
||||||
Genode::env_deprecated()->parent()->exit(status);
|
if (_parent_ptr)
|
||||||
|
_parent_ptr->exit(status);
|
||||||
|
|
||||||
/* wait for destruction by the parent */
|
/* wait for destruction by the parent */
|
||||||
Genode::sleep_forever();
|
Genode::sleep_forever();
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <util/construct_at.h>
|
#include <util/construct_at.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
|
#include <deprecated/env.h>
|
||||||
|
|
||||||
/* base-internal includes */
|
/* base-internal includes */
|
||||||
#include <base/internal/globals.h>
|
#include <base/internal/globals.h>
|
||||||
|
@ -98,7 +99,8 @@ extern "C" void init_main_thread()
|
||||||
* destructor won't be registered for the atexit routine.
|
* destructor won't be registered for the atexit routine.
|
||||||
*/
|
*/
|
||||||
(void*)env_deprecated();
|
(void*)env_deprecated();
|
||||||
init_log();
|
init_log(*env_deprecated()->parent());
|
||||||
|
init_exit(*env_deprecated()->parent());
|
||||||
|
|
||||||
/* create a thread object for the main thread */
|
/* create a thread object for the main thread */
|
||||||
main_thread();
|
main_thread();
|
||||||
|
|
|
@ -175,6 +175,19 @@ class Test_child_policy : public Child_policy
|
||||||
Signal_context_capability const _fault_handler_sigh;
|
Signal_context_capability const _fault_handler_sigh;
|
||||||
Signal_context_capability const _fault_handler_stack_sigh;
|
Signal_context_capability const _fault_handler_stack_sigh;
|
||||||
|
|
||||||
|
Service &_matching_service(Service::Name const &name)
|
||||||
|
{
|
||||||
|
Service *service = nullptr;
|
||||||
|
_parent_services.for_each([&] (Service &s) {
|
||||||
|
if (!service && name == s.name())
|
||||||
|
service = &s; });
|
||||||
|
|
||||||
|
if (!service)
|
||||||
|
throw Service_denied();
|
||||||
|
|
||||||
|
return *service;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,18 +229,12 @@ class Test_child_policy : public Child_policy
|
||||||
stack_area.fault_handler(_fault_handler_stack_sigh);
|
stack_area.fault_handler(_fault_handler_stack_sigh);
|
||||||
}
|
}
|
||||||
|
|
||||||
Service &resolve_session_request(Service::Name const &service_name,
|
Route resolve_session_request(Service::Name const &name,
|
||||||
Session_state::Args const &) override
|
Session_label const &label) override
|
||||||
{
|
{
|
||||||
Service *service = nullptr;
|
return Route { .service = _matching_service(name),
|
||||||
_parent_services.for_each([&] (Service &s) {
|
.label = label,
|
||||||
if (!service && service_name == s.name())
|
.diag = Session::Diag() };
|
||||||
service = &s; });
|
|
||||||
|
|
||||||
if (!service)
|
|
||||||
throw Service_denied();
|
|
||||||
|
|
||||||
return *service;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -252,19 +259,19 @@ struct Main_parent
|
||||||
{
|
{
|
||||||
Allocator &alloc;
|
Allocator &alloc;
|
||||||
|
|
||||||
Parent_services(Allocator &alloc) : alloc(alloc)
|
Parent_services(Env &env, Allocator &alloc) : alloc(alloc)
|
||||||
{
|
{
|
||||||
static const char *names[] = {
|
static const char *names[] = {
|
||||||
"PD", "CPU", "ROM", "LOG", 0 };
|
"PD", "CPU", "ROM", "LOG", 0 };
|
||||||
for (unsigned i = 0; names[i]; i++)
|
for (unsigned i = 0; names[i]; i++)
|
||||||
new (alloc) Test_child_policy::Parent_service(*this, names[i]);
|
new (alloc) Test_child_policy::Parent_service(*this, env, names[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Parent_services()
|
~Parent_services()
|
||||||
{
|
{
|
||||||
for_each([&] (Test_child_policy::Parent_service &s) { destroy(alloc, &s); });
|
for_each([&] (Test_child_policy::Parent_service &s) { destroy(alloc, &s); });
|
||||||
}
|
}
|
||||||
} _parent_services { _heap };
|
} _parent_services { _env, _heap };
|
||||||
|
|
||||||
/* create child */
|
/* create child */
|
||||||
Test_child_policy _child_policy { _env, _parent_services, _fault_handler,
|
Test_child_policy _child_policy { _env, _parent_services, _fault_handler,
|
||||||
|
|
|
@ -41,7 +41,6 @@ struct workqueue_struct *tasklet_wq;
|
||||||
|
|
||||||
void breakpoint() { Genode::log("BREAK"); }
|
void breakpoint() { Genode::log("BREAK"); }
|
||||||
|
|
||||||
extern "C" int stdout_write(const char *);
|
|
||||||
|
|
||||||
static void run_linux(void *s)
|
static void run_linux(void *s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,6 @@ struct workqueue_struct *tasklet_wq;
|
||||||
|
|
||||||
void breakpoint() { Genode::log("BREAK"); }
|
void breakpoint() { Genode::log("BREAK"); }
|
||||||
|
|
||||||
extern "C" int stdout_write(const char *);
|
|
||||||
|
|
||||||
static void run_linux(void *s)
|
static void run_linux(void *s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
* version 2.
|
* version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Genode includes */
|
||||||
|
#include <base/log.h>
|
||||||
|
#include <util/string.h>
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include <lx_emul.h>
|
#include <lx_emul.h>
|
||||||
|
|
||||||
|
@ -20,8 +24,6 @@ namespace Lx {
|
||||||
class Format_command;
|
class Format_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int stdout_write(const char *s);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format string command representation
|
* Format string command representation
|
||||||
|
@ -192,7 +194,7 @@ class Lx::Console
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_buf[_idx] = 0;
|
_buf[_idx] = 0;
|
||||||
stdout_write(_buf);
|
Genode::log(Genode::Cstring(_buf));
|
||||||
_idx = 0;
|
_idx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <base/printf.h>
|
#include <base/log.h>
|
||||||
extern "C" void print_num(int num) {
|
extern "C" void print_num(int num) {
|
||||||
Genode::printf("Number from rust: %d \n",num);
|
Genode::log("Number from rust: ", num);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include <platform_session/connection.h>
|
#include <platform_session/connection.h>
|
||||||
#include <input/component.h>
|
#include <input/component.h>
|
||||||
#include <input/root.h>
|
#include <input/root.h>
|
||||||
#include <base/printf.h>
|
|
||||||
#include <os/server.h>
|
#include <os/server.h>
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
|
@ -55,7 +54,7 @@ struct Main
|
||||||
Input::Tablet_driver::factory(env, session.event_queue());
|
Input::Tablet_driver::factory(env, session.event_queue());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PWRN("No input driver available for this board");
|
warning("No input driver available for this board");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tell parent about the service */
|
/* tell parent about the service */
|
||||||
|
|
|
@ -50,7 +50,7 @@ class Vmm::Utcb_guard
|
||||||
Genode::memcpy(&_backup_utcb, utcb, len);
|
Genode::memcpy(&_backup_utcb, utcb, len);
|
||||||
|
|
||||||
if (utcb->msg_items())
|
if (utcb->msg_items())
|
||||||
PWRN("Error: msg items on UTCB are not saved and restored!");
|
Genode::warning("Error: msg items on UTCB are not saved and restored!");
|
||||||
}
|
}
|
||||||
|
|
||||||
~Utcb_guard()
|
~Utcb_guard()
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/printf.h>
|
#include <log_session/log_session.h>
|
||||||
|
#include <base/snprintf.h>
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
#include <base/heap.h>
|
#include <base/heap.h>
|
||||||
#include <base/sleep.h>
|
#include <base/sleep.h>
|
||||||
|
@ -27,32 +28,36 @@
|
||||||
|
|
||||||
enum { verbose_memory_leak = false };
|
enum { verbose_memory_leak = false };
|
||||||
|
|
||||||
|
static
|
||||||
Genode::Lock *printf_lock()
|
void vprintf(const char *format, va_list &args)
|
||||||
{
|
{
|
||||||
static Genode::Lock inst;
|
using namespace Genode;
|
||||||
return &inst;
|
typedef Vmm::Utcb_guard::Utcb_backup Utcb_backup;
|
||||||
|
|
||||||
|
static Lock lock;
|
||||||
|
static Utcb_backup utcb_backup;
|
||||||
|
static char buf[Log_session::MAX_STRING_LEN-4];
|
||||||
|
|
||||||
|
Lock::Guard guard(lock);
|
||||||
|
utcb_backup = *(Utcb_backup *)Thread::myself()->utcb();
|
||||||
|
|
||||||
|
String_console sc(buf, sizeof(buf));
|
||||||
|
sc.vprintf(format, args);
|
||||||
|
|
||||||
|
int n = sc.len();
|
||||||
|
if (0 < n && buf[n-1] == '\n') n--;
|
||||||
|
|
||||||
|
log("VMM: ", Cstring(buf, n));
|
||||||
|
|
||||||
|
*(Utcb_backup *)Thread::myself()->utcb() = utcb_backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef Vmm::Utcb_guard::Utcb_backup Utcb_backup;
|
|
||||||
|
|
||||||
static Utcb_backup utcb_backup;
|
|
||||||
|
|
||||||
|
|
||||||
void Logging::printf(const char *format, ...)
|
void Logging::printf(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
va_start(list, format);
|
va_start(list, format);
|
||||||
|
|
||||||
Genode::Lock::Guard guard(*printf_lock());
|
::vprintf(format, list);
|
||||||
|
|
||||||
utcb_backup = *(Utcb_backup *)Genode::Thread::myself()->utcb();
|
|
||||||
|
|
||||||
Genode::printf("VMM: ");
|
|
||||||
Genode::vprintf(format, list);
|
|
||||||
|
|
||||||
*(Utcb_backup *)Genode::Thread::myself()->utcb() = utcb_backup;
|
|
||||||
|
|
||||||
va_end(list);
|
va_end(list);
|
||||||
}
|
}
|
||||||
|
@ -60,15 +65,7 @@ void Logging::printf(const char *format, ...)
|
||||||
|
|
||||||
void Logging::vprintf(const char *format, va_list &ap)
|
void Logging::vprintf(const char *format, va_list &ap)
|
||||||
{
|
{
|
||||||
Genode::Lock::Guard guard(*printf_lock());
|
::vprintf(format, ap);
|
||||||
|
|
||||||
utcb_backup = *(Utcb_backup *)Genode::Thread::myself()->utcb();
|
|
||||||
|
|
||||||
Genode::printf("VMM: ");
|
|
||||||
Genode::printf(format);
|
|
||||||
Genode::error("Logging::vprintf not implemented");
|
|
||||||
|
|
||||||
*(Utcb_backup *)Genode::Thread::myself()->utcb() = utcb_backup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,9 +74,8 @@ void Logging::panic(const char *format, ...)
|
||||||
va_list list;
|
va_list list;
|
||||||
va_start(list, format);
|
va_start(list, format);
|
||||||
|
|
||||||
Genode::printf("\nVMM PANIC! ");
|
Genode::error("VMM PANIC!");
|
||||||
Genode::vprintf(format, list);
|
::vprintf(format, list);
|
||||||
Genode::printf("\n");
|
|
||||||
|
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
|
@ -159,9 +155,7 @@ void operator delete (void * ptr)
|
||||||
|
|
||||||
void do_exit(char const *msg)
|
void do_exit(char const *msg)
|
||||||
{
|
{
|
||||||
Genode::printf("*** ");
|
Genode::log("*** ", msg);
|
||||||
Genode::printf(msg);
|
|
||||||
Genode::printf("\n");
|
|
||||||
Genode::sleep_forever();
|
Genode::sleep_forever();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* interface to 'log_console' */
|
|
||||||
extern "C" int stdout_write(const char *);
|
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -121,7 +118,7 @@ namespace {
|
||||||
int curr_count= count > sizeof(tmp) - 1 ? sizeof(tmp) - 1 : count;
|
int curr_count= count > sizeof(tmp) - 1 ? sizeof(tmp) - 1 : count;
|
||||||
strncpy(tmp, src, curr_count);
|
strncpy(tmp, src, curr_count);
|
||||||
tmp[curr_count > 0 ? curr_count : 0] = 0;
|
tmp[curr_count > 0 ? curr_count : 0] = 0;
|
||||||
stdout_write(tmp);
|
Genode::log(Genode::Cstring(tmp));
|
||||||
count -= curr_count;
|
count -= curr_count;
|
||||||
src += curr_count;
|
src += curr_count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user