black_hole: provide Gpu service

Ref #4419
This commit is contained in:
Martin Stein 2022-03-14 17:30:33 +01:00 committed by Christian Helmuth
parent 046ebc3d34
commit 50fc2aa251
11 changed files with 192 additions and 3 deletions

View File

@ -8,6 +8,7 @@
<nic/>
<uplink/>
<rom/>
<gpu/>
</provides>
<config>
@ -18,6 +19,7 @@
<nic/>
<uplink/>
<rom/>
<gpu/>
</config>
<content>

View File

@ -1 +1 @@
2022-02-27 fe6aa1093a593ebb302573fcb11dab869c1acb0f
2022-03-14-a 6724cbbd02509f6ad5090732cbd0603996a364f6

View File

@ -30,6 +30,7 @@
<start name="black_hole" caps="100">
<resource name="RAM" quantum="1M"/>
<provides>
<service name="Gpu"/>
<service name="ROM"/>
<service name="Uplink"/>
<service name="Nic"/>
@ -39,6 +40,7 @@
<service name="Audio_out"/>
</provides>
<config>
<gpu/>
<rom/>
<uplink/>
<nic/>
@ -56,9 +58,10 @@
</route>
</start>
<start name="test-black_hole" caps="100">
<start name="test-black_hole" caps="200">
<resource name="RAM" quantum="10M"/>
<route>
<service name="Gpu"> <child name="black_hole"/> </service>
<service name="ROM" label="any_label"> <child name="black_hole"/> </service>
<service name="Uplink"> <child name="black_hole"/> </service>
<service name="Nic"> <child name="black_hole"/> </service>

View File

@ -1 +1 @@
2022-02-27 cc6e9715322ae66af7bb35c04f219ababd98c093
2022-03-14-a 3803170cb66f1d232ca2b73416503d11d691568b

View File

@ -5,4 +5,5 @@ capture_session
event_session
nic_session
uplink_session
gpu_session
os

View File

@ -7,3 +7,4 @@ event_session
capture_session
nic_session
uplink_session
gpu_session

View File

@ -11,6 +11,7 @@ in the configuration of the component:
* Nic
* Uplink
* ROM
* Gpu
<config>
<audio_in/>
@ -20,4 +21,5 @@ in the configuration of the component:
<nic/>
<uplink/>
<rom/>
<gpu/>
</config>

View File

@ -4,6 +4,7 @@
<xs:element name="config">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="gpu"/>
<xs:element name="rom"/>
<xs:element name="uplink"/>
<xs:element name="nic"/>

View File

@ -0,0 +1,171 @@
/*
* \brief Gpu session component and root
* \author Martin Stein
* \date 2022-02-12
*/
/*
* 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 _GPU_H_
#define _GPU_H_
/* Genode includes */
#include <base/attached_ram_dataspace.h>
#include <base/rpc_server.h>
#include <base/session_object.h>
#include <dataspace/client.h>
#include <gpu_session/gpu_session.h>
#include <root/component.h>
namespace Black_hole {
using namespace Genode;
using namespace Gpu;
class Gpu_session;
class Gpu_root;
using Gpu_root_component = Root_component<Gpu_session, Multiple_clients>;
}
class Black_hole::Gpu_session : public Session_object<Gpu::Session>
{
private:
Env &_env;
Attached_ram_dataspace _info_dataspace { _env.ram(), _env.rm(), 1 };
public:
Gpu_session(Env &env,
Resources resources,
Label const &label,
Diag diag)
:
Session_object { env.ep(), resources, label, diag },
_env { env }
{ }
/***************************
** Gpu session interface **
***************************/
Dataspace_capability info_dataspace() const override
{
return _info_dataspace.cap();
}
Sequence_number exec_buffer(Buffer_id /* id */,
size_t /* size */) override
{
throw Gpu::Session::Invalid_state();
}
bool complete(Sequence_number /* seqno */) override
{
return false;
}
void completion_sigh(Signal_context_capability /* sigh */) override
{ }
Dataspace_capability alloc_buffer(Buffer_id /* id */,
size_t /* size */) override
{
return Dataspace_capability { };
}
void free_buffer(Buffer_id /* id */) override { }
Buffer_capability export_buffer(Buffer_id /* id */) override
{
return Buffer_capability { };
}
void import_buffer(Buffer_capability /* cap */,
Buffer_id /* id */) override
{ }
Dataspace_capability
map_buffer(Buffer_id /* id */,
bool /* aperture */,
Mapping_attributes /* attrs */) override
{
return Dataspace_capability { };
}
void unmap_buffer(Buffer_id /* id */) override { }
bool map_buffer_ppgtt(Buffer_id /* id */,
Gpu::addr_t /* va */) override
{
return false;
}
void unmap_buffer_ppgtt(Buffer_id /* id */,
Gpu::addr_t /* va */) override
{ }
bool set_tiling(Buffer_id /* id */,
uint32_t const /* mode */) override
{
return false;
}
};
class Black_hole::Gpu_root : public Gpu_root_component
{
private:
Env &_env;
size_t _ram_quota(char const *args)
{
return Arg_string::find_arg(args, "ram_quota").ulong_value(0);
}
protected:
Gpu_session *_create_session(char const *args) override
{
/* at the moment we just need about ~160KiB for initial RCS bring-up */
size_t const required_quota { Gpu::Session::REQUIRED_QUOTA / 2 };
size_t const ram_quota { _ram_quota(args) };
if (ram_quota < required_quota) {
Session_label const label { label_from_args(args) };
warning("insufficient dontated ram_quota (", ram_quota,
" bytes), require ", required_quota, " bytes ",
" by '", label, "'");
throw Gpu::Session::Out_of_ram();
}
Genode::Session::Resources const resources {
session_resources_from_args(args) };
return new (md_alloc())
Gpu_session {
_env, resources, session_label_from_args(args),
session_diag_from_args(args) };
}
public:
Gpu_root(Env &env,
Allocator &alloc)
:
Root_component { env.ep(), alloc },
_env { env }
{ }
};
#endif /* _GPU_H_ */

View File

@ -28,6 +28,7 @@
#include "nic.h"
#include "uplink.h"
#include "rom.h"
#include "gpu.h"
/***************
@ -49,6 +50,7 @@ struct Black_hole::Main
Genode::Constructible<Nic_root> nic_root { };
Genode::Constructible<Uplink_root> uplink_root { };
Genode::Constructible<Rom_root> rom_root { };
Genode::Constructible<Gpu_root> gpu_root { };
Main(Genode::Env &env) : env(env)
{
@ -82,6 +84,10 @@ struct Black_hole::Main
rom_root.construct(env, heap);
env.parent().announce(env.ep().manage(*rom_root));
}
if (_config_rom.xml().has_sub_node("gpu")) {
gpu_root.construct(env, heap);
env.parent().announce(env.ep().manage(*gpu_root));
}
}
};

View File

@ -23,6 +23,7 @@
#include <base/attached_rom_dataspace.h>
/* os includes */
#include <gpu_session/connection.h>
#include <event_session/connection.h>
#include <capture_session/connection.h>
#include <audio_in_session/connection.h>
@ -336,6 +337,7 @@ class Black_hole_test::Main
Signal_handler<Main> _signal_handler { _env.ep(), *this, &Main::_handle_signal };
Audio_in::Connection _audio_in { _env, "left" };
Audio_out::Connection _audio_out { _env, "left" };
Gpu::Connection _gpu { _env };
Nic_test _nic_test { _env, _heap, _signal_handler };
Uplink_test _uplink_test { _env, _heap, _signal_handler };
Capture_test _capture_test { _env };