diff --git a/repos/os/recipes/pkg/black_hole/runtime b/repos/os/recipes/pkg/black_hole/runtime
index 2c41dfc4cc..1a4c938ea0 100644
--- a/repos/os/recipes/pkg/black_hole/runtime
+++ b/repos/os/recipes/pkg/black_hole/runtime
@@ -7,6 +7,7 @@
+
@@ -16,6 +17,7 @@
+
diff --git a/repos/os/recipes/pkg/test-black_hole/runtime b/repos/os/recipes/pkg/test-black_hole/runtime
index 3711cd5408..af214040be 100644
--- a/repos/os/recipes/pkg/test-black_hole/runtime
+++ b/repos/os/recipes/pkg/test-black_hole/runtime
@@ -30,6 +30,7 @@
+
@@ -38,6 +39,7 @@
+
@@ -57,16 +59,17 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/repos/os/src/server/black_hole/README b/repos/os/src/server/black_hole/README
index d08e5a6737..2581c0e316 100644
--- a/repos/os/src/server/black_hole/README
+++ b/repos/os/src/server/black_hole/README
@@ -10,6 +10,7 @@ in the configuration of the component:
* Event
* Nic
* Uplink
+* ROM
@@ -18,4 +19,5 @@ in the configuration of the component:
+
diff --git a/repos/os/src/server/black_hole/config.xsd b/repos/os/src/server/black_hole/config.xsd
index df2da3f308..c1205eed3c 100644
--- a/repos/os/src/server/black_hole/config.xsd
+++ b/repos/os/src/server/black_hole/config.xsd
@@ -4,6 +4,7 @@
+
diff --git a/repos/os/src/server/black_hole/main.cc b/repos/os/src/server/black_hole/main.cc
index b732e95e72..6642292f21 100644
--- a/repos/os/src/server/black_hole/main.cc
+++ b/repos/os/src/server/black_hole/main.cc
@@ -27,6 +27,7 @@
#include "event.h"
#include "nic.h"
#include "uplink.h"
+#include "rom.h"
/***************
@@ -47,6 +48,7 @@ struct Black_hole::Main
Genode::Constructible event_root { };
Genode::Constructible nic_root { };
Genode::Constructible uplink_root { };
+ Genode::Constructible rom_root { };
Main(Genode::Env &env) : env(env)
{
@@ -56,12 +58,10 @@ struct Black_hole::Main
audio_in_root.construct(env, heap);
env.parent().announce(env.ep().manage(*audio_in_root));
}
-
if (_config_rom.xml().has_sub_node("audio_out")) {
audio_out_root.construct(env, heap);
env.parent().announce(env.ep().manage(*audio_out_root));
}
-
if (_config_rom.xml().has_sub_node("capture")) {
capture_root.construct(env, heap);
env.parent().announce(env.ep().manage(*capture_root));
@@ -70,16 +70,18 @@ struct Black_hole::Main
event_root.construct(env, heap);
env.parent().announce(env.ep().manage(*event_root));
}
-
if (_config_rom.xml().has_sub_node("nic")) {
nic_root.construct(env, heap);
env.parent().announce(env.ep().manage(*nic_root));
}
-
if (_config_rom.xml().has_sub_node("uplink")) {
uplink_root.construct(env, heap);
env.parent().announce(env.ep().manage(*uplink_root));
}
+ if (_config_rom.xml().has_sub_node("rom")) {
+ rom_root.construct(env, heap);
+ env.parent().announce(env.ep().manage(*rom_root));
+ }
}
};
diff --git a/repos/os/src/server/black_hole/rom.h b/repos/os/src/server/black_hole/rom.h
new file mode 100644
index 0000000000..25e3f72f36
--- /dev/null
+++ b/repos/os/src/server/black_hole/rom.h
@@ -0,0 +1,91 @@
+/*
+ * \brief ROM session component and root
+ * \author Martin Stein
+ * \date 2022-03-11
+ */
+
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#ifndef _ROM_H_
+#define _ROM_H_
+
+/* base includes */
+#include
+#include
+#include
+
+namespace Black_hole {
+
+ using namespace Genode;
+
+ class Rom_session;
+ class Rom_root;
+}
+
+
+class Black_hole::Rom_session : public Session_object
+{
+ private:
+
+ enum { RAM_DS_SIZE = 16 };
+
+ Env &_env;
+ Attached_ram_dataspace _ram_ds { _env.ram(), _env.rm(), RAM_DS_SIZE };
+
+ public:
+
+ Rom_session(Env &env,
+ Resources const &resources,
+ Label const &label,
+ Diag const &diag)
+ :
+ Session_object(env.ep(), resources, label, diag),
+ _env { env }
+ {
+ copy_cstring(_ram_ds.local_addr(), "", RAM_DS_SIZE);
+ }
+
+ Rom_dataspace_capability dataspace() override
+ {
+ return
+ static_cap_cast(
+ static_cap_cast(_ram_ds.cap()));
+ }
+
+ void sigh(Signal_context_capability /* sigh */) override { }
+};
+
+
+class Black_hole::Rom_root : public Root_component
+{
+ private:
+
+ Env &_env;
+
+ protected:
+
+ Rom_session *_create_session(const char *args) override
+ {
+ return new (md_alloc())
+ Rom_session {
+ _env, session_resources_from_args(args),
+ session_label_from_args(args),
+ session_diag_from_args(args) };
+ }
+
+ public:
+
+ Rom_root(Env &env,
+ Allocator &alloc)
+ :
+ Root_component { &env.ep().rpc_ep(), &alloc },
+ _env { env }
+ { }
+};
+
+#endif /* _ROM_H_ */
diff --git a/repos/os/src/test/black_hole/main.cc b/repos/os/src/test/black_hole/main.cc
index 5f2ac15bff..494cbbc635 100644
--- a/repos/os/src/test/black_hole/main.cc
+++ b/repos/os/src/test/black_hole/main.cc
@@ -19,6 +19,8 @@
#include
#include
#include
+#include
+#include
/* os includes */
#include
@@ -38,6 +40,7 @@ namespace Black_hole_test {
class Uplink_test;
class Capture_test;
class Event_test;
+ class Rom_test;
class Main;
}
@@ -295,6 +298,35 @@ class Black_hole_test::Event_test
};
+class Black_hole_test::Rom_test
+{
+ private:
+
+ Env &_env;
+ Attached_rom_dataspace _rom_ds { _env, "any_label" };
+ bool _finished { false };
+
+ public:
+
+ Rom_test(Env &env)
+ :
+ _env { env }
+ {
+ String<16> const str { Cstring { _rom_ds.local_addr() } };
+ if (str != "") {
+ class Unexpected_rom_content { };
+ throw Unexpected_rom_content { };
+ }
+ _finished = true;
+ }
+
+ bool finished() const
+ {
+ return _finished;
+ }
+};
+
+
class Black_hole_test::Main
{
private:
@@ -308,6 +340,7 @@ class Black_hole_test::Main
Uplink_test _uplink_test { _env, _heap, _signal_handler };
Capture_test _capture_test { _env };
Event_test _event_test { _env };
+ Rom_test _rom_test { _env };
void _handle_signal()
{
@@ -321,7 +354,8 @@ class Black_hole_test::Main
if (_nic_test.finished() &&
_uplink_test.finished() &&
_capture_test.finished() &&
- _event_test.finished()) {
+ _event_test.finished() &&
+ _rom_test.finished()) {
log("Finished");
}