black_hole: serve real USB sessions

* The server now answers session requests with a session instead of an
  exception#
* The test expects a session but doesn't access it so far

Ref #4419
This commit is contained in:
Martin Stein 2022-04-08 13:03:22 +02:00 committed by Christian Helmuth
parent 40a5eabf88
commit 6a61b60a5d
3 changed files with 29 additions and 27 deletions

View File

@ -25,7 +25,3 @@ in the configuration of the component:
<gpu/>
<usb/>
</config>
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.

View File

@ -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<Usb_session>
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<size_t>(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:

View File

@ -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