diff --git a/repos/os/src/server/black_hole/README b/repos/os/src/server/black_hole/README
index d1d31197a0..94593d1aa8 100644
--- a/repos/os/src/server/black_hole/README
+++ b/repos/os/src/server/black_hole/README
@@ -25,7 +25,3 @@ in the configuration of the component:
-
-Be aware, that the USB service is merely announced but always throws a
-Service_denied exception when trying to request a session. This is considered
-a temporary solution.
diff --git a/repos/os/src/server/black_hole/usb.h b/repos/os/src/server/black_hole/usb.h
index 689cb65177..a61f688727 100644
--- a/repos/os/src/server/black_hole/usb.h
+++ b/repos/os/src/server/black_hole/usb.h
@@ -34,6 +34,13 @@ class Black_hole::Usb_session : public Usb::Session_rpc_object
{
public:
+ Usb_session(Ram_dataspace_capability tx_ds,
+ Entrypoint &ep,
+ Region_map &rm)
+ :
+ Session_rpc_object { tx_ds, ep.rpc_ep(), rm }
+ { }
+
void sigh_state_change(Signal_context_capability /* sigh */) override { }
bool plugged() override { return false; }
@@ -70,17 +77,23 @@ class Black_hole::Usb_root : public Root_component
protected:
- Usb_session *_create_session(char const * /* args */) override
+ Usb_session *_create_session(char const *args) override
{
- /*
- * FIXME
- *
- * Currently, we're fine with a service that is routable but
- * not usable. In the long term, this exception should be removed
- * and a session object should be returned that can be used as if
- * it was a real USB session.
- */
- throw Service_denied { };
+ size_t const ram_quota {
+ Arg_string::find_arg(args, "ram_quota" ).ulong_value(0) };
+
+ size_t const tx_buf_size {
+ Arg_string::find_arg(args, "tx_buf_size").ulong_value(0) };
+
+ size_t const session_size {
+ max(4096, sizeof(Usb_session)) };
+
+ if (ram_quota < session_size + tx_buf_size) {
+ throw Insufficient_ram_quota { };
+ }
+ Ram_dataspace_capability tx_ds { _env.ram().alloc(tx_buf_size) };
+ return new (md_alloc())
+ Usb_session { tx_ds, _env.ep(), _env.rm() };
}
public:
diff --git a/repos/os/src/test/black_hole/main.cc b/repos/os/src/test/black_hole/main.cc
index 29824c2625..a50553c203 100644
--- a/repos/os/src/test/black_hole/main.cc
+++ b/repos/os/src/test/black_hole/main.cc
@@ -5,7 +5,7 @@
*
* FIXME
*
- * Accessing the Audio_in and Audio_out connections is yet missing.
+ * Accessing the Audio_in, Audio_out and Usb connections is yet missing.
*/
/*
@@ -334,9 +334,10 @@ class Black_hole_test::Usb_test
{
private:
- Env &_env;
- Allocator_avl _alloc;
- bool _finished { false };
+ Env &_env;
+ Allocator_avl _alloc;
+ Usb::Connection _connection { _env, &_alloc };
+ bool _finished { false };
public:
@@ -346,15 +347,7 @@ class Black_hole_test::Usb_test
_env { env },
_alloc { &heap }
{
- try {
- Usb::Connection connection { _env, &_alloc };
- class Session_request_succeeded { };
- throw Session_request_succeeded { };
-
- } catch (Service_denied) {
-
- _finished = true;
- }
+ _finished = true;
}
bool finished() const