mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-10 03:11:45 +00:00
parent
b7474bceff
commit
3ae19a9eb7
@ -24,7 +24,6 @@
|
|||||||
#include <pd_session/connection.h>
|
#include <pd_session/connection.h>
|
||||||
#include <region_map/client.h>
|
#include <region_map/client.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
@ -32,11 +31,16 @@ namespace Loader {
|
|||||||
typedef Registered<Parent_service> Parent_service;
|
typedef Registered<Parent_service> Parent_service;
|
||||||
typedef Registry<Parent_service> Parent_services;
|
typedef Registry<Parent_service> Parent_services;
|
||||||
|
|
||||||
class Child : public Child_policy
|
class Child;
|
||||||
{
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Loader::Child : public Child_policy
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Env &_env;
|
Env &_env;
|
||||||
|
Allocator &_alloc;
|
||||||
|
|
||||||
Session_label const _label;
|
Session_label const _label;
|
||||||
Name const _binary_name;
|
Name const _binary_name;
|
||||||
@ -55,6 +59,7 @@ namespace Loader {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Child(Env &env,
|
Child(Env &env,
|
||||||
|
Allocator &alloc,
|
||||||
Name const &binary_name,
|
Name const &binary_name,
|
||||||
Session_label const &label,
|
Session_label const &label,
|
||||||
size_t ram_quota,
|
size_t ram_quota,
|
||||||
@ -66,6 +71,7 @@ namespace Loader {
|
|||||||
Signal_context_capability fault_sigh)
|
Signal_context_capability fault_sigh)
|
||||||
:
|
:
|
||||||
_env(env),
|
_env(env),
|
||||||
|
_alloc(alloc),
|
||||||
_label(label),
|
_label(label),
|
||||||
_binary_name(binary_name),
|
_binary_name(binary_name),
|
||||||
_ram_quota(Genode::Child::effective_ram_quota(ram_quota)),
|
_ram_quota(Genode::Child::effective_ram_quota(ram_quota)),
|
||||||
@ -114,9 +120,8 @@ namespace Loader {
|
|||||||
if (service)
|
if (service)
|
||||||
return *service;
|
return *service;
|
||||||
|
|
||||||
return *new (env()->heap()) Parent_service(_parent_services, name);
|
return *new (_alloc) Parent_service(_parent_services, name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _CHILD_H_ */
|
#endif /* _CHILD_H_ */
|
||||||
|
@ -41,6 +41,7 @@ class Input::Session_component : public Rpc_object<Session>
|
|||||||
|
|
||||||
Session_client _real_input;
|
Session_client _real_input;
|
||||||
Motion_delta &_motion_delta;
|
Motion_delta &_motion_delta;
|
||||||
|
Attached_dataspace _ev_ds;
|
||||||
Event * const _ev_buf;
|
Event * const _ev_buf;
|
||||||
|
|
||||||
Genode::Signal_context_capability _sigh;
|
Genode::Signal_context_capability _sigh;
|
||||||
@ -50,18 +51,15 @@ class Input::Session_component : public Rpc_object<Session>
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Session_component(Session_capability real_input,
|
Session_component(Region_map &rm,
|
||||||
|
Session_capability real_input,
|
||||||
Motion_delta &motion_delta)
|
Motion_delta &motion_delta)
|
||||||
:
|
:
|
||||||
_real_input(real_input), _motion_delta(motion_delta),
|
_real_input(real_input), _motion_delta(motion_delta),
|
||||||
_ev_buf(env()->rm_session()->attach(_real_input.dataspace()))
|
_ev_ds(rm, _real_input.dataspace()),
|
||||||
|
_ev_buf(_ev_ds.local_addr<Event>())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
~Session_component() { env()->rm_session()->detach(_ev_buf); }
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
** Input session interface **
|
** Input session interface **
|
||||||
|
@ -160,6 +160,7 @@ class Loader::Session_component : public Rpc_object<Session>
|
|||||||
struct Local_nitpicker_factory : Local_service<Nitpicker::Session_component>::Factory
|
struct Local_nitpicker_factory : Local_service<Nitpicker::Session_component>::Factory
|
||||||
{
|
{
|
||||||
Entrypoint &_ep;
|
Entrypoint &_ep;
|
||||||
|
Region_map &_rm;
|
||||||
Ram_session &_ram;
|
Ram_session &_ram;
|
||||||
|
|
||||||
Area _max_size;
|
Area _max_size;
|
||||||
@ -169,8 +170,8 @@ class Loader::Session_component : public Rpc_object<Session>
|
|||||||
|
|
||||||
Constructible<Nitpicker::Session_component> session;
|
Constructible<Nitpicker::Session_component> session;
|
||||||
|
|
||||||
Local_nitpicker_factory(Entrypoint &ep, Ram_session &ram)
|
Local_nitpicker_factory(Entrypoint &ep, Region_map &rm, Ram_session &ram)
|
||||||
: _ep(ep), _ram(ram) { }
|
: _ep(ep), _rm(rm), _ram(ram) { }
|
||||||
|
|
||||||
void constrain_geometry(Area size) { _max_size = size; }
|
void constrain_geometry(Area size) { _max_size = size; }
|
||||||
|
|
||||||
@ -186,7 +187,7 @@ class Loader::Session_component : public Rpc_object<Session>
|
|||||||
throw Parent::Service_denied();
|
throw Parent::Service_denied();
|
||||||
}
|
}
|
||||||
|
|
||||||
session.construct(_ep, _ram, _max_size,
|
session.construct(_ep, _rm, _ram, _max_size,
|
||||||
_parent_view, view_ready_sigh, args.string());
|
_parent_view, view_ready_sigh, args.string());
|
||||||
return *session;
|
return *session;
|
||||||
}
|
}
|
||||||
@ -212,7 +213,7 @@ class Loader::Session_component : public Rpc_object<Session>
|
|||||||
Local_rom_service _rom_service { _rom_factory };
|
Local_rom_service _rom_service { _rom_factory };
|
||||||
Local_cpu_service _cpu_service { _env };
|
Local_cpu_service _cpu_service { _env };
|
||||||
Local_pd_service _pd_service { _env };
|
Local_pd_service _pd_service { _env };
|
||||||
Local_nitpicker_factory _nitpicker_factory { _env.ep(), _local_ram };
|
Local_nitpicker_factory _nitpicker_factory { _env.ep(), _env.rm(), _local_ram };
|
||||||
Local_nitpicker_service _nitpicker_service { _nitpicker_factory };
|
Local_nitpicker_service _nitpicker_service { _nitpicker_factory };
|
||||||
Signal_context_capability _fault_sigh;
|
Signal_context_capability _fault_sigh;
|
||||||
Constructible<Child> _child;
|
Constructible<Child> _child;
|
||||||
@ -264,7 +265,7 @@ class Loader::Session_component : public Rpc_object<Session>
|
|||||||
* on demand. Revert those allocations.
|
* on demand. Revert those allocations.
|
||||||
*/
|
*/
|
||||||
_parent_services.for_each([&] (Parent_service &service) {
|
_parent_services.for_each([&] (Parent_service &service) {
|
||||||
destroy(env()->heap(), &service); });
|
destroy(_md_alloc, &service); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -337,7 +338,7 @@ class Loader::Session_component : public Rpc_object<Session>
|
|||||||
: _ram_quota;
|
: _ram_quota;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_child.construct(_env, binary_name.string(),
|
_child.construct(_env, _md_alloc, binary_name.string(),
|
||||||
prefixed_label(_label, Session_label(label.string())),
|
prefixed_label(_label, Session_label(label.string())),
|
||||||
ram_quota, _parent_services, _rom_service,
|
ram_quota, _parent_services, _rom_service,
|
||||||
_cpu_service, _pd_service, _nitpicker_service,
|
_cpu_service, _pd_service, _nitpicker_service,
|
||||||
@ -397,17 +398,17 @@ namespace Loader { struct Main; }
|
|||||||
|
|
||||||
struct Loader::Main
|
struct Loader::Main
|
||||||
{
|
{
|
||||||
Env &env;
|
Env &_env;
|
||||||
|
|
||||||
Heap heap { env.ram(), env.rm() };
|
Heap _heap { _env.ram(), _env.rm() };
|
||||||
|
|
||||||
Attached_rom_dataspace config { env, "config" };
|
Attached_rom_dataspace _config { _env, "config" };
|
||||||
|
|
||||||
Root root { env, config.xml(), heap };
|
Root _root { _env, _config.xml(), _heap };
|
||||||
|
|
||||||
Main(Env &env) : env(env)
|
Main(Env &env) : _env(env)
|
||||||
{
|
{
|
||||||
env.parent().announce(env.ep().manage(root));
|
_env.parent().announce(_env.ep().manage(_root));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,18 +18,20 @@
|
|||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <util/arg_string.h>
|
#include <util/arg_string.h>
|
||||||
#include <util/misc_math.h>
|
#include <util/misc_math.h>
|
||||||
#include <base/signal.h>
|
#include <base/component.h>
|
||||||
#include <os/attached_ram_dataspace.h>
|
#include <base/attached_ram_dataspace.h>
|
||||||
#include <nitpicker_session/connection.h>
|
#include <nitpicker_session/connection.h>
|
||||||
#include <nitpicker_session/nitpicker_session.h>
|
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include <input.h>
|
#include <input.h>
|
||||||
|
|
||||||
namespace Nitpicker { class Session_component; }
|
namespace Nitpicker {
|
||||||
|
using namespace Genode;
|
||||||
|
class Session_component;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
class Nitpicker::Session_component : public Rpc_object<Session>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -37,9 +39,9 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
|||||||
* Signal handler to be notified once the geometry of the view is
|
* Signal handler to be notified once the geometry of the view is
|
||||||
* known.
|
* known.
|
||||||
*/
|
*/
|
||||||
Genode::Signal_context_capability _view_ready_sigh;
|
Signal_context_capability _view_ready_sigh;
|
||||||
|
|
||||||
Genode::Entrypoint &_ep;
|
Entrypoint &_ep;
|
||||||
|
|
||||||
Area _max_size;
|
Area _max_size;
|
||||||
|
|
||||||
@ -64,16 +66,15 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
|||||||
Input::Motion_delta _motion_delta;
|
Input::Motion_delta _motion_delta;
|
||||||
|
|
||||||
Input::Session_component _proxy_input;
|
Input::Session_component _proxy_input;
|
||||||
Input::Session_capability _proxy_input_cap;
|
|
||||||
|
|
||||||
static long _session_arg(const char *arg, const char *key) {
|
static long _session_arg(const char *arg, const char *key) {
|
||||||
return Genode::Arg_string::find_arg(arg, key).long_value(0); }
|
return Arg_string::find_arg(arg, key).long_value(0); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Command buffer
|
* Command buffer
|
||||||
*/
|
*/
|
||||||
typedef Nitpicker::Session::Command_buffer Command_buffer;
|
typedef Nitpicker::Session::Command_buffer Command_buffer;
|
||||||
Genode::Attached_ram_dataspace _command_ds;
|
Attached_ram_dataspace _command_ds;
|
||||||
Command_buffer &_command_buffer = *_command_ds.local_addr<Command_buffer>();
|
Command_buffer &_command_buffer = *_command_ds.local_addr<Command_buffer>();
|
||||||
|
|
||||||
void _propagate_view_offset()
|
void _propagate_view_offset()
|
||||||
@ -96,7 +97,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
|||||||
_virt_view_geometry = command.geometry.rect;
|
_virt_view_geometry = command.geometry.rect;
|
||||||
|
|
||||||
if (!_virt_view_geometry_defined)
|
if (!_virt_view_geometry_defined)
|
||||||
Genode::Signal_transmitter(_view_ready_sigh).submit();
|
Signal_transmitter(_view_ready_sigh).submit();
|
||||||
|
|
||||||
_virt_view_geometry_defined = true;
|
_virt_view_geometry_defined = true;
|
||||||
|
|
||||||
@ -121,13 +122,13 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
|||||||
|
|
||||||
case Command::OP_TO_BACK:
|
case Command::OP_TO_BACK:
|
||||||
{
|
{
|
||||||
Genode::warning("OP_TO_BACK not implemented");
|
warning("OP_TO_BACK not implemented");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Command::OP_BACKGROUND:
|
case Command::OP_BACKGROUND:
|
||||||
{
|
{
|
||||||
Genode::warning("OP_BACKGROUND not implemented");
|
warning("OP_BACKGROUND not implemented");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,12 +149,13 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Session_component(Genode::Entrypoint &ep,
|
Session_component(Entrypoint &ep,
|
||||||
Genode::Ram_session &ram,
|
Region_map &rm,
|
||||||
|
Ram_session &ram,
|
||||||
Area max_size,
|
Area max_size,
|
||||||
Nitpicker::View_capability parent_view,
|
Nitpicker::View_capability parent_view,
|
||||||
Genode::Signal_context_capability view_ready_sigh,
|
Signal_context_capability view_ready_sigh,
|
||||||
const char *args)
|
char const *args)
|
||||||
:
|
:
|
||||||
_view_ready_sigh(view_ready_sigh),
|
_view_ready_sigh(view_ready_sigh),
|
||||||
_ep(ep),
|
_ep(ep),
|
||||||
@ -165,11 +167,11 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
|||||||
/* create nitpicker view */
|
/* create nitpicker view */
|
||||||
_view_handle(_nitpicker.create_view(_parent_view_handle)),
|
_view_handle(_nitpicker.create_view(_parent_view_handle)),
|
||||||
|
|
||||||
_proxy_input(_nitpicker.input_session(), _motion_delta),
|
_proxy_input(rm, _nitpicker.input_session(), _motion_delta),
|
||||||
_proxy_input_cap(_ep.manage(_proxy_input)),
|
|
||||||
|
|
||||||
_command_ds(&ram, sizeof(Command_buffer))
|
_command_ds(&ram, sizeof(Command_buffer))
|
||||||
{
|
{
|
||||||
|
_ep.manage(_proxy_input);
|
||||||
_ep.manage(*this);
|
_ep.manage(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +193,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
|||||||
|
|
||||||
Input::Session_capability input_session() override
|
Input::Session_capability input_session() override
|
||||||
{
|
{
|
||||||
return _proxy_input_cap;
|
return _proxy_input.cap();
|
||||||
}
|
}
|
||||||
|
|
||||||
View_handle create_view(View_handle) override
|
View_handle create_view(View_handle) override
|
||||||
@ -213,7 +215,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
|||||||
|
|
||||||
void release_view_handle(View_handle) override { }
|
void release_view_handle(View_handle) override { }
|
||||||
|
|
||||||
Genode::Dataspace_capability command_dataspace() override
|
Dataspace_capability command_dataspace() override
|
||||||
{
|
{
|
||||||
return _command_ds.cap();
|
return _command_ds.cap();
|
||||||
}
|
}
|
||||||
@ -238,14 +240,14 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
|||||||
_nitpicker.mode().format());
|
_nitpicker.mode().format());
|
||||||
}
|
}
|
||||||
|
|
||||||
void mode_sigh(Genode::Signal_context_capability) override { }
|
void mode_sigh(Signal_context_capability) override { }
|
||||||
|
|
||||||
void buffer(Framebuffer::Mode mode, bool use_alpha) override
|
void buffer(Framebuffer::Mode mode, bool use_alpha) override
|
||||||
{
|
{
|
||||||
_nitpicker.buffer(mode, use_alpha);
|
_nitpicker.buffer(mode, use_alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
void focus(Genode::Capability<Session>) override { }
|
void focus(Capability<Session>) override { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return geometry of loader view
|
* Return geometry of loader view
|
||||||
@ -253,11 +255,11 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
|||||||
Area loader_view_size() const
|
Area loader_view_size() const
|
||||||
{
|
{
|
||||||
int const width = _max_size.valid()
|
int const width = _max_size.valid()
|
||||||
? Genode::min(_virt_view_geometry.w(), _max_size.w())
|
? min(_virt_view_geometry.w(), _max_size.w())
|
||||||
: _virt_view_geometry.w();
|
: _virt_view_geometry.w();
|
||||||
|
|
||||||
int const height = _max_size.valid()
|
int const height = _max_size.valid()
|
||||||
? Genode::min(_virt_view_geometry.h(), _max_size.h())
|
? min(_virt_view_geometry.h(), _max_size.h())
|
||||||
: _virt_view_geometry.h();
|
: _virt_view_geometry.h();
|
||||||
|
|
||||||
return Area(width, height);
|
return Area(width, height);
|
||||||
|
@ -11,42 +11,52 @@
|
|||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <base/printf.h>
|
#include <base/component.h>
|
||||||
#include <base/sleep.h>
|
|
||||||
#include <loader_session/connection.h>
|
#include <loader_session/connection.h>
|
||||||
#include <timer_session/connection.h>
|
#include <timer_session/connection.h>
|
||||||
|
|
||||||
|
namespace Test {
|
||||||
int main(int argc, char **argv)
|
using namespace Genode;
|
||||||
{
|
struct Main;
|
||||||
Loader::Connection loader(8*1024*1024);
|
|
||||||
|
|
||||||
static Genode::Signal_receiver sig_rec;
|
|
||||||
|
|
||||||
Genode::Signal_context sig_ctx;
|
|
||||||
|
|
||||||
loader.view_ready_sigh(sig_rec.manage(&sig_ctx));
|
|
||||||
|
|
||||||
loader.start("testnit", "test-label");
|
|
||||||
|
|
||||||
sig_rec.wait_for_signal();
|
|
||||||
|
|
||||||
Loader::Area size = loader.view_size();
|
|
||||||
|
|
||||||
Timer::Connection timer;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < 10; i++) {
|
|
||||||
|
|
||||||
loader.view_geometry(Loader::Rect(Loader::Point(50*i, 50*i), size),
|
|
||||||
Loader::Point(0, 0));
|
|
||||||
|
|
||||||
timer.msleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Genode::sleep_forever();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct Test::Main
|
||||||
|
{
|
||||||
|
Env &_env;
|
||||||
|
|
||||||
|
Loader::Connection _loader { _env, 8*1024*1024 };
|
||||||
|
Timer::Connection _timer { _env };
|
||||||
|
|
||||||
|
Loader::Area _size;
|
||||||
|
Loader::Point _pos;
|
||||||
|
|
||||||
|
void _handle_view_ready()
|
||||||
|
{
|
||||||
|
_size = _loader.view_size();
|
||||||
|
_timer.trigger_periodic(250*1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
Signal_handler<Main> _view_ready_handler {
|
||||||
|
_env.ep(), *this, &Main::_handle_view_ready };
|
||||||
|
|
||||||
|
void _handle_timer()
|
||||||
|
{
|
||||||
|
_loader.view_geometry(Loader::Rect(_pos, _size), Loader::Point(0, 0));
|
||||||
|
_pos = Loader::Point((_pos.x() + 50) % 500, (_pos.y() + 30) % 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
Signal_handler<Main> _timer_handler {
|
||||||
|
_env.ep(), *this, &Main::_handle_timer };
|
||||||
|
|
||||||
|
Main(Env &env) : _env(env)
|
||||||
|
{
|
||||||
|
_loader.view_ready_sigh(_view_ready_handler);
|
||||||
|
_timer.sigh(_timer_handler);
|
||||||
|
|
||||||
|
_loader.start("testnit", "test-label");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void Component::construct(Genode::Env &env) { static Test::Main main(env); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user