From b9b469c9a2160fc517721bb669a4b8c54a68ac97 Mon Sep 17 00:00:00 2001 From: Alexander Weidinger Date: Thu, 28 Feb 2019 18:06:30 +0100 Subject: [PATCH] Make minimal child example functional --- src/app/child/main.cc | 41 +++++++++++++++++++++++++---------------- src/app/hello/main.cc | 2 +- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/app/child/main.cc b/src/app/child/main.cc index b280adb..fcec587 100644 --- a/src/app/child/main.cc +++ b/src/app/child/main.cc @@ -70,24 +70,33 @@ public: } }; +namespace Example { + struct Main; +} + +struct Example::Main +{ + Genode::Env &_env; + + Genode::Heap _heap { _env.ram(), _env.rm() }; + + MyChild::Parent_services _parent_services { }; + + Main(Genode::Env &env) : _env(env) + { + const char *names[] = { "RM", "PD", "CPU", "IO_MEM", "IO_PORT", "IRQ", "ROM", "LOG", 0 }; + + for (unsigned i = 0; names[i]; i++) { + new (_heap) MyChild::Parent_service(_parent_services, env, names[i]); + } + + new (_heap) MyChild(_env, _parent_services); + } +}; + void Component::construct(Genode::Env &env) { Genode::log("Hello World from child!"); - Genode::Heap _heap {env.ram(), env.rm()}; - - static const char *names[] = { - /* core services */ - "RM", "PD", "CPU", "IO_MEM", "IO_PORT", "IRQ", "ROM", "LOG", - - 0 /* null-termination */ - }; - MyChild::Parent_services _parent_services { }; - for (unsigned i = 0; names[i]; i++) - new (_heap) MyChild::Parent_service(_parent_services, env, names[i]); - - MyChild mychild(env, _parent_services); - - while(1) { - } + static Example::Main main(env); } diff --git a/src/app/hello/main.cc b/src/app/hello/main.cc index 347b7cf..0c2004d 100644 --- a/src/app/hello/main.cc +++ b/src/app/hello/main.cc @@ -1,6 +1,6 @@ #include -void Component::construct(Genode::Env &env) +void Component::construct(Genode::Env &) { Genode::log("Hello World from hello!"); }