Remove format strings from connection types

Issue #2064
This commit is contained in:
Norman Feske 2023-03-03 12:07:28 +01:00 committed by Christian Helmuth
parent fb66e733b5
commit 9debad4e91
58 changed files with 199 additions and 457 deletions

View File

@ -29,7 +29,7 @@ struct Sync::Connection : public Genode::Connection<Session>,
{
explicit Connection(Genode::Env &env)
:
Genode::Connection<Session>(env, session(env.parent(), "ram_quota=4K")),
Genode::Connection<Session>(env, Label(), Ram_quota { 4*1024 }, Args()),
Genode::Rpc_client<Session>(cap())
{ }

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2008-2017 Genode Labs GmbH
* Copyright (C) 2008-2023 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.
@ -22,23 +22,19 @@ namespace Genode { struct Cpu_connection; }
struct Genode::Cpu_connection : Connection<Cpu_session>, Cpu_session_client
{
enum { RAM_QUOTA = 36*1024 };
/**
* Constructor
*
* \param label initial session label
* \param priority designated priority of all threads created
* with this CPU session
*/
Cpu_connection(Env &env, const char *label = "", long priority = DEFAULT_PRIORITY,
Cpu_connection(Env &env,
Label const &label = Label(),
long priority = DEFAULT_PRIORITY,
Affinity const &affinity = Affinity())
:
Connection<Cpu_session>(env,
session(env.parent(), affinity,
"priority=0x%lx, ram_quota=%u, "
"cap_quota=%u, label=\"%s\"",
priority, RAM_QUOTA, CAP_QUOTA, label)),
Connection<Cpu_session>(env, label, Ram_quota { RAM_QUOTA }, affinity,
Args("priority=", Hex(priority))),
Cpu_session_client(cap())
{ }

View File

@ -43,7 +43,7 @@ struct Genode::Cpu_session : Session
* allocation, its session capability, the capability of the 'Native_cpu'
* RPC interface, and a capability for the trace-control dataspace.
*/
enum { CAP_QUOTA = 6 };
enum { CAP_QUOTA = 6, RAM_QUOTA = 36*1024 };
typedef Cpu_session_client Client;

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2008-2017 Genode Labs GmbH
* Copyright (C) 2008-2023 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.
@ -31,12 +31,10 @@ struct Genode::Io_mem_connection : Connection<Io_mem_session>, Io_mem_session_cl
*/
Io_mem_connection(Env &env, addr_t base, size_t size, bool write_combined = false)
:
Connection<Io_mem_session>(env,
session(env.parent(),
"cap_quota=%u, ram_quota=%u, "
"base=0x%p, size=0x%lx, wc=%s",
CAP_QUOTA, RAM_QUOTA, base, size,
write_combined ? "yes" : "no")),
Connection<Io_mem_session>(env, Label(), Ram_quota { RAM_QUOTA },
Args("base=", Hex(base), ", "
"size=", Hex(size), ", "
"wc=", write_combined ? "yes" : "no")),
Io_mem_session_client(cap())
{ }
};

View File

@ -41,7 +41,7 @@ struct Genode::Io_mem_session : Session
* session-object allocation, its session capability, and a dataspace
* capability for the handed-out memory-mapped I/O dataspace.
*/
enum { CAP_QUOTA = 3, RAM_QUOTA = 6 * 1024 };
enum { CAP_QUOTA = 3, RAM_QUOTA = 6*1024 };
virtual ~Io_mem_session() { }

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2008-2017 Genode Labs GmbH
* Copyright (C) 2008-2023 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.
@ -23,17 +23,6 @@ namespace Genode { struct Io_port_connection; }
struct Genode::Io_port_connection : Connection<Io_port_session>,
Io_port_session_client
{
/**
* Issue session request
*
* \noapi
*/
Capability<Io_port_session> _session(Parent &parent, unsigned base, unsigned size)
{
return session(parent, "ram_quota=%u, cap_quota=%u, io_port_base=%u, io_port_size=%u",
RAM_QUOTA, CAP_QUOTA, base, size);
}
/**
* Constructor
*
@ -42,11 +31,9 @@ struct Genode::Io_port_connection : Connection<Io_port_session>,
*/
Io_port_connection(Env &env, unsigned base, unsigned size)
:
Connection<Io_port_session>(env,
session(env.parent(),
"ram_quota=%u, cap_quota=%u, "
"io_port_base=%u, io_port_size=%u",
RAM_QUOTA, CAP_QUOTA, base, size)),
Connection<Io_port_session>(env, Label(), Ram_quota { RAM_QUOTA },
Args("io_port_base=", base, ", "
"io_port_size=", size)),
Io_port_session_client(cap())
{ }
};

View File

@ -38,10 +38,11 @@ struct Genode::Io_port_session : Session
*/
static const char *service_name() { return "IO_PORT"; }
enum { RAM_QUOTA = 6 * 1024, CAP_QUOTA = 2 };
enum { CAP_QUOTA = 2, RAM_QUOTA = 6*1024 };
virtual ~Io_port_session() { }
/******************************
** Read value from I/O port **
******************************/

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2008-2017 Genode Labs GmbH
* Copyright (C) 2008-2023 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.
@ -19,47 +19,27 @@
namespace Genode { struct Irq_connection; }
struct Genode::Irq_connection : Connection<Irq_session>, Irq_session_client
{
/**
* Constructor
*
* \param irq physical interrupt number
* \param label physical interrupt number
* \param trigger interrupt trigger (e.g., level/edge)
* \param polarity interrupt trigger polarity (e.g., low/high)
*/
Irq_connection(Env &env,
unsigned irq,
Irq_session::Trigger trigger = Irq_session::TRIGGER_UNCHANGED,
Irq_session::Polarity polarity = Irq_session::POLARITY_UNCHANGED,
Genode::addr_t device_config_phys = 0)
Irq_connection(Env &env,
Label const &label,
Trigger trigger = Irq_session::TRIGGER_UNCHANGED,
Polarity polarity = Irq_session::POLARITY_UNCHANGED,
addr_t device_config_phys = 0)
:
Connection<Irq_session>(env, session(env.parent(),
"ram_quota=%u, cap_quota=%u, "
"irq_number=%u, irq_trigger=%u, "
"irq_polarity=%u, device_config_phys=0x%lx",
RAM_QUOTA, CAP_QUOTA,
irq, trigger, polarity, device_config_phys)),
Irq_session_client(cap())
{ }
/**
* Constructor for label-based configuration (used by pin driver)
*
* \param label session label
*/
Irq_connection(Env &env,
char const *label)
:
Connection<Irq_session>(env, session(env.parent(),
"ram_quota=%u, cap_quota=%u, "
"irq_number=%u, irq_trigger=%u, "
"irq_polarity=%u, device_config_phys=0x%lx, "
"label=\"%s\"",
RAM_QUOTA, CAP_QUOTA, 0,
Irq_session::TRIGGER_UNCHANGED,
Irq_session::POLARITY_UNCHANGED,
0, label)),
Connection<Irq_session>(env, label, Ram_quota { RAM_QUOTA },
Args("irq_number=", label, ", "
"irq_trigger=", unsigned(trigger), ", "
"irq_polarity=", unsigned(polarity), ", "
"device_config_phys=", Hex(device_config_phys))),
Irq_session_client(cap())
{ }
};

View File

@ -78,7 +78,7 @@ struct Genode::Irq_session : Session
*/
static const char * service_name() { return "IRQ"; }
enum { CAP_QUOTA = 3, RAM_QUOTA = 6 * 1024 };
enum { CAP_QUOTA = 3, RAM_QUOTA = 6*1024 };
/*********************

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2008-2017 Genode Labs GmbH
* Copyright (C) 2008-2023 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.
@ -16,23 +16,15 @@
#include <log_session/client.h>
#include <base/connection.h>
#include <base/session_label.h>
namespace Genode { struct Log_connection; }
struct Genode::Log_connection : Connection<Log_session>, Log_session_client
{
enum { RAM_QUOTA = 8*1024UL };
/**
* Constructor
*/
Log_connection(Env &env, Session_label label = Session_label())
Log_connection(Env &env, Session_label const &label = Session_label())
:
Connection<Log_session>(env, session(env.parent(),
"ram_quota=%ld, cap_quota=%ld, label=\"%s\"",
RAM_QUOTA, CAP_QUOTA, label.string())),
Connection<Log_session>(env, label, Ram_quota { RAM_QUOTA }, Args()),
Log_session_client(cap())
{ }
};

View File

@ -37,7 +37,7 @@ struct Genode::Log_session : Session
* A LOG connection consumes a dataspace capability for the session-object
* allocation and its session capability.
*/
enum { CAP_QUOTA = 2 };
enum { CAP_QUOTA = 2, RAM_QUOTA = 8*1024 };
typedef Log_session_client Client;

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2008-2017 Genode Labs GmbH
* Copyright (C) 2008-2023 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.
@ -22,19 +22,12 @@ namespace Genode { struct Pd_connection; }
struct Genode::Pd_connection : Connection<Pd_session>, Pd_session_client
{
enum { RAM_QUOTA = 24*1024*sizeof(long)};
enum Virt_space { UNCONSTRAIN = 0, CONSTRAIN = 1 };
/**
* Constructor
*
* \param label session label
*/
Pd_connection(Env &env, char const *label = "", Virt_space space = CONSTRAIN)
Pd_connection(Env &env, Label const &label = Label(), Virt_space space = CONSTRAIN)
:
Connection<Pd_session>(env, session(env.parent(),
"ram_quota=%u, cap_quota=%u, label=\"%s\", virt_space=%u",
RAM_QUOTA, CAP_QUOTA, label, space)),
Connection<Pd_session>(env, label, Ram_quota { RAM_QUOTA },
Args("virt_space=", unsigned(space))),
Pd_session_client(cap())
{ }
@ -45,11 +38,9 @@ struct Genode::Pd_connection : Connection<Pd_session>, Pd_session_client
*/
Pd_connection(Env &env, Device_pd)
:
Connection<Pd_session>(env, session(env.parent(),
"ram_quota=%u, cap_quota=%u, "
"label=\"device PD\", virt_space=%u, "
"managing_system=yes",
RAM_QUOTA, CAP_QUOTA, UNCONSTRAIN)),
Connection<Pd_session>(env, "device PD", Ram_quota { RAM_QUOTA },
Args("virt_space=", unsigned(UNCONSTRAIN), ", "
"managing_system=yes")),
Pd_session_client(cap())
{ }
};

View File

@ -46,7 +46,7 @@ struct Genode::Pd_session : Session, Ram_allocator
* Furthermore, we account for the dataspace capabilities allocated during
* the component bootstrapping.
*/
enum { CAP_QUOTA = 6 + 7 };
enum { CAP_QUOTA = 6 + 7, RAM_QUOTA = 24*1024*sizeof(long) };
typedef Pd_session_client Client;

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2008-2018 Genode Labs GmbH
* Copyright (C) 2008-2023 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.
@ -23,21 +23,14 @@ namespace Genode { struct Rm_connection; }
struct Genode::Rm_connection : Connection<Rm_session>, Rm_session_client
{
enum { RAM_QUOTA = 64*1024 };
/**
* Constructor
*/
Rm_connection(Env &env)
:
Connection<Rm_session>(env, session(env.parent(), "ram_quota=%u, cap_quota=%u",
RAM_QUOTA, CAP_QUOTA)),
Connection<Rm_session>(env, Label(), Ram_quota { 64*1024 }, Args()),
Rm_session_client(cap())
{ }
/**
* Wrapper over 'create' that handles resource requests
* from the server.
* Wrapper over 'create' that handles resource requests from the server
*/
Capability<Region_map> create(size_t size) override
{

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2008-2017 Genode Labs GmbH
* Copyright (C) 2008-2023 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.
@ -16,35 +16,28 @@
#include <rom_session/client.h>
#include <base/connection.h>
#include <base/log.h>
namespace Genode { class Rom_connection; }
struct Genode::Rom_connection : Connection<Rom_session>,
Rom_session_client
struct Genode::Rom_connection : Connection<Rom_session>, Rom_session_client
{
class Rom_connection_failed : public Service_denied { };
enum { RAM_QUOTA = 6*1024UL };
struct Rom_connection_failed : Service_denied { };
/**
* Constructor
*
* \param label request label and name of ROM module
* \param label name of requested ROM module
*
* \throw Rom_connection_failed
*/
Rom_connection(Env &env, const char *label)
Rom_connection(Env &env, Session_label const &label)
try :
Connection<Rom_session>(env,
session(env.parent(),
"ram_quota=%ld, cap_quota=%ld, label=\"%s\"",
RAM_QUOTA, CAP_QUOTA, label)),
Connection<Rom_session>(env, label, Ram_quota { RAM_QUOTA }, Args()),
Rom_session_client(cap())
{ }
catch (...) {
error("Could not open ROM session for \"", label, "\"");
error("could not open ROM session for \"", label, "\"");
throw Rom_connection_failed();
}
};

View File

@ -46,7 +46,7 @@ struct Genode::Rom_session : Session
* allocation, a dataspace capability for the ROM dataspace, and its
* session capability.
*/
enum { CAP_QUOTA = 3 };
enum { CAP_QUOTA = 3, RAM_QUOTA = 6*1024 };
typedef Rom_session_client Client;

View File

@ -256,14 +256,15 @@ class Timer::Connection : public Genode::Connection<Session>,
* \param label optional label used in session routing
*/
Connection(Genode::Env &env,
Genode::Entrypoint & ep,
char const *label = "");
Genode::Entrypoint &ep,
Label const &label = Label());
/**
* Convenience constructor wrapper using the environment's entrypoint as
* timeout handler execution context
*/
Connection(Genode::Env &env, char const *label = "");
Connection(Genode::Env &env, Label const &label = Label())
: Connection(env, env.ep(), label) { }
~Connection() { _sig_rec.dissolve(&_default_sigh_ctx); }

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2013-2017 Genode Labs GmbH
* Copyright (C) 2013-2023 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.
@ -39,9 +39,9 @@ struct Genode::Trace::Connection : Genode::Connection<Genode::Trace::Session>,
*/
Connection(Env &env, size_t ram_quota, size_t arg_buffer_size, unsigned parent_levels)
:
Genode::Connection<Session>(env,
session(env.parent(), "ram_quota=%lu, arg_buffer_size=%lu, parent_levels=%u",
ram_quota + 10*1024, arg_buffer_size, parent_levels)),
Genode::Connection<Session>(env, Label(), Ram_quota { 10*1024 + ram_quota },
Args("arg_buffer_size=", arg_buffer_size, ", "
"parent_levels=", parent_levels)),
Session_client(env.rm(), cap())
{ }

View File

@ -9,7 +9,7 @@
*/
/*
* Copyright (C) 2012-2021 Genode Labs GmbH
* Copyright (C) 2012-2023 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.
@ -35,19 +35,6 @@ namespace Genode {
struct Genode::Vm_connection : Connection<Vm_session>, Rpc_client<Vm_session>
{
/**
* Issue session request
*
* \noapi
*/
Capability<Vm_session> _session(Parent &parent, char const *label, long priority,
unsigned long affinity)
{
return session(parent,
"priority=0x%lx, affinity=0x%lx, ram_quota=16K, cap_quota=10, label=\"%s\"",
priority, affinity, label);
}
/*
* VM-Exit state-transfer configuration
*
@ -82,15 +69,16 @@ struct Genode::Vm_connection : Connection<Vm_session>, Rpc_client<Vm_session>
/**
* Constructor
*
* \param label initial session label
* \param priority designated priority of the VM
* \param affinity which physical CPU the VM should run on top of
*/
Vm_connection(Env &env, const char *label = "",
Vm_connection(Env &env, Label const &label = Label(),
long priority = Cpu_session::DEFAULT_PRIORITY,
unsigned long affinity = 0)
:
Connection<Vm_session>(env, _session(env.parent(), label, priority, affinity)),
Connection<Vm_session>(env, label, Ram_quota { 16*1024 }, Affinity(),
Args("priority=", Hex(priority), ", "
"affinity=", Hex(affinity))),
Rpc_client<Vm_session>(cap())
{ }
@ -107,6 +95,7 @@ struct Genode::Vm_connection : Connection<Vm_session>, Rpc_client<Vm_session>
);
}
/**************************
** Vm_session interface **
**************************/

View File

@ -37,7 +37,7 @@ struct Genode::Vm_session : Session
bool writeable;
};
enum { CAP_QUOTA = 3 };
enum { CAP_QUOTA = 10 };
class Invalid_dataspace : Exception { };
class Region_conflict : Exception { };

View File

@ -43,10 +43,8 @@ _Z16main_thread_utcbv T
_Z22__ldso_raise_exceptionv T
_ZN5Timer10Connection11set_timeoutEN6Genode12MicrosecondsERNS1_15Timeout_handlerE T
_ZN5Timer10Connection9curr_timeEv T
_ZN5Timer10ConnectionC1ERN6Genode3EnvEPKc T
_ZN5Timer10ConnectionC1ERN6Genode3EnvERNS1_10EntrypointEPKc T
_ZN5Timer10ConnectionC2ERN6Genode3EnvEPKc T
_ZN5Timer10ConnectionC2ERN6Genode3EnvERNS1_10EntrypointEPKc T
_ZN5Timer10ConnectionC1ERN6Genode3EnvERNS1_10EntrypointERKNS1_13Session_labelE T
_ZN5Timer10ConnectionC2ERN6Genode3EnvERNS1_10EntrypointERKNS1_13Session_labelE T
_ZN6Genode10Entrypoint16_dispatch_signalERNS_6SignalE T
_ZN6Genode10Entrypoint16schedule_suspendEPFvvES2_ T
_ZN6Genode10Entrypoint22Signal_proxy_component6signalEv T

View File

@ -304,7 +304,7 @@ int main()
/* CPU session representing core */
static Cpu_session_component
core_cpu(ep,
Session::Resources{{Cpu_connection::RAM_QUOTA},
Session::Resources{{Cpu_session::RAM_QUOTA},
{Cpu_session::CAP_QUOTA}},
"core", Session::Diag{false},
core_ram_alloc, local_rm, ep, pager_ep, Core::Trace::sources(), "",

View File

@ -120,12 +120,9 @@ void Timer::Connection::set_timeout(Microseconds duration,
}
Timer::Connection::Connection(Genode::Env &env, Genode::Entrypoint &ep,
char const *label)
Timer::Connection::Connection(Env &env, Entrypoint &ep, Label const &label)
:
Genode::Connection<Session>(env, session(env.parent(),
"ram_quota=10K, cap_quota=%u, label=\"%s\"",
CAP_QUOTA, label)),
Genode::Connection<Session>(env, label, Ram_quota { 10*1024 }, Args()),
Session_client(cap()),
_signal_handler(ep, *this, &Connection::_handle_timeout)
{
@ -134,10 +131,6 @@ Timer::Connection::Connection(Genode::Env &env, Genode::Entrypoint &ep,
}
Timer::Connection::Connection(Genode::Env &env, char const *label)
: Timer::Connection(env, env.ep(), label) {}
Timeout_scheduler &Timer::Connection::_switch_to_timeout_framework_mode()
{
if (_mode == TIMEOUT_FRAMEWORK) {
@ -148,7 +141,6 @@ Timeout_scheduler &Timer::Connection::_switch_to_timeout_framework_mode()
_timeout_scheduler._enable();
/* do initial calibration burst to make interpolation available earlier */
for (unsigned i = 0; i < NR_OF_INITIAL_CALIBRATIONS; i++) {
_update_real_time();

View File

@ -26,7 +26,7 @@ Timer::Time_source::Time_source(Env &env)
:
Attached_mmio(env, Imx6::EPIT_2_MMIO_BASE, Imx6::EPIT_2_MMIO_SIZE),
Signalled_time_source(env),
_timer_irq(env, Imx6::EPIT_2_IRQ)
_timer_irq(env, unsigned(Imx6::EPIT_2_IRQ))
{
_timer_irq.sigh(_signal_handler);
while (read<Cr::Swr>()) ;

View File

@ -26,4 +26,4 @@ enum {
Timer::Time_source::Time_source(Env &env)
: Attached_mmio(env, MMIO_BASE, MMIO_SIZE),
Signalled_time_source(env),
_timer_irq(env, IRQ) { _initialize(); }
_timer_irq(env, unsigned(IRQ)) { _initialize(); }

View File

@ -200,7 +200,7 @@ Timer::Time_source::Time_source(Env &env)
:
Signalled_time_source(env),
_io_port(env, PIT_DATA_PORT_0, PIT_CMD_PORT - PIT_DATA_PORT_0 + 1),
_timer_irq(env, IRQ_PIT)
_timer_irq(env, unsigned(IRQ_PIT))
{
/* operate PIT in one-shot mode */
_io_port.outb(PIT_CMD_PORT, PIT_CMD_SELECT_CHANNEL_0 |

View File

@ -76,7 +76,7 @@ C++ class in 'include/hello_session/hello_session.h'
!{
! static const char *service_name() { return "Hello"; }
!
! enum { CAP_QUOTA = 2 };
! enum { CAP_QUOTA = 4 };
!
! virtual void say_hello() = 0;
! virtual int add(int a, int b) = 0;
@ -93,12 +93,10 @@ across component boundaries.
Furthermore, we use the interface to specify the name of the service by
providing the 'service_name' method. This method will later be used by both
the server for announcing the service at its parent and the client for
requesting the creation of a "Hello" session. The 'CAP_QUOTA' definition
specifies the amount of capabilities required to establish the session.
The specified amount is transferred from the client to the server at session
creation time. For the "Hello" session, two capabilities are required, namely
a dataspace capability for the server-side memory occupied by the session
object and the actual session capability that refers to the RPC interface.
requesting the creation of a "Hello" session. The 'resources' definition
specifies the amount of capabilities and RAM required by the server to
establish the session. The specified amount is transferred from the client
to the server at session creation time.
The 'GENODE_RPC' macro is used to declare an RPC function. Its first argument
is a type name that is used to refer to the RPC function. The type name can
@ -351,10 +349,11 @@ of the session interface. For our case, the file
! Connection(Genode::Env &env)
! :
! /* create session */
! Genode::Connection<Hello::Session>(env, session(env.parent(),
! "ram_quota=4K, cap_quota=4")),
! Genode::Connection<Hello::Session>(env, Label(),
! Ram_quota { 8*1024 }, Args()),
! /* initialize RPC interface */
! Session_client(cap()) { }
! Session_client(cap())
! { }
!};

View File

@ -25,11 +25,11 @@ struct Hello::Connection : Genode::Connection<Session>, Session_client
Connection(Genode::Env &env)
:
/* create session */
Genode::Connection<Hello::Session>(env, session(env.parent(),
"ram_quota=6K, cap_quota=4")),
Genode::Connection<Hello::Session>(env, Label(),
Ram_quota { 8*1024 }, Args()),
/* initialize RPC interface */
Session_client(cap()) { }
Session_client(cap())
{ }
};
#endif /* _INCLUDE__HELLO_SESSION__CONNECTION_H_ */

View File

@ -24,7 +24,7 @@ struct Hello::Session : Genode::Session
{
static const char *service_name() { return "Hello"; }
enum { CAP_QUOTA = 2 };
enum { CAP_QUOTA = 4 };
virtual void say_hello() = 0;
virtual int add(int a, int b) = 0;

View File

@ -57,10 +57,7 @@ struct Libc::Clone_connection : Connection<Clone_session>,
Clone_connection(Genode::Env &env)
:
Connection<Clone_session>(env,
session(env.parent(),
"ram_quota=%ld, cap_quota=%ld",
RAM_QUOTA, CAP_QUOTA)),
Connection<Clone_session>(env, Label(), Ram_quota { RAM_QUOTA }, Args()),
Rpc_client<Clone_session>(cap()),
_buffer(env.rm(), call<Rpc_dataspace>())
{ }

View File

@ -23,17 +23,6 @@ namespace Audio_in { struct Connection; }
struct Audio_in::Connection : Genode::Connection<Session>, Audio_in::Session_client
{
/**
* Issue session request
*
* \noapi
*/
Genode::Capability<Audio_in::Session> _session(Genode::Parent &parent, char const *channel)
{
return session(parent, "ram_quota=%ld, cap_quota=%ld, channel=\"%s\"",
10*1024 + sizeof(Stream), CAP_QUOTA, channel);
}
/**
* Constructor
*
@ -43,7 +32,9 @@ struct Audio_in::Connection : Genode::Connection<Session>, Audio_in::Session_cli
*/
Connection(Genode::Env &env, char const *channel, bool progress_signal = false)
:
Genode::Connection<Session>(env, _session(env.parent(), channel)),
Genode::Connection<Session>(env, Label(),
Ram_quota { 10*1024 + sizeof(Stream) },
Args("channel=\"", channel, "\"")),
Session_client(env.rm(), cap(), progress_signal)
{ }
};

View File

@ -38,10 +38,9 @@ struct Audio_out::Connection : Genode::Connection<Session>, Audio_out::Session_c
bool alloc_signal = true,
bool progress_signal = false)
:
Genode::Connection<Session>(env,
session(env.parent(),
"ram_quota=%ld, cap_quota=%ld, channel=\"%s\"",
2*4096 + 2048 + sizeof(Stream), CAP_QUOTA, channel)),
Genode::Connection<Session>(env, Label(),
Ram_quota { 2*4096 + 2048 + sizeof(Stream) },
Args("channel=\"", channel, "\"")),
Session_client(env.rm(), cap(), alloc_signal, progress_signal)
{ }
};

View File

@ -19,7 +19,7 @@
*/
/*
* Copyright (C) 2019 Genode Labs GmbH
* Copyright (C) 2019-2023 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.
@ -233,12 +233,11 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
Connection(Genode::Env &env,
Genode::Range_allocator *tx_block_alloc,
Genode::size_t tx_buf_size = 128*1024,
const char *label = "")
Label const &label = Label())
:
Genode::Connection<Session>(env,
session(env.parent(),
"ram_quota=%ld, cap_quota=%ld, tx_buf_size=%ld, label=\"%s\"",
14*1024 + tx_buf_size, CAP_QUOTA, tx_buf_size, label)),
Genode::Connection<Session>(env, label,
Ram_quota { 14*1024 + tx_buf_size },
Args("tx_buf_size=", tx_buf_size)),
Session_client(cap(), *tx_block_alloc, env.rm()),
_max_block_count(_init_max_block_count(_tx.source()->bulk_buffer_size()))
{ }

View File

@ -26,10 +26,6 @@ namespace Capture { class Connection; }
class Capture::Connection : public Genode::Connection<Session>,
public Session_client
{
public:
enum { RAM_QUOTA = 36*1024UL };
private:
size_t _session_quota = 0;
@ -39,12 +35,10 @@ class Capture::Connection : public Genode::Connection<Session>,
/**
* Constructor
*/
Connection(Genode::Env &env, char const *label = "")
Connection(Genode::Env &env, Label const &label = Label())
:
Genode::Connection<Capture::Session>(
env, session(env.parent(),
"ram_quota=%u, cap_quota=%u, label=\"%s\"",
RAM_QUOTA, CAP_QUOTA, label)),
Genode::Connection<Capture::Session>(env, label,
Ram_quota { 36*1024 }, Args()),
Session_client(cap())
{ }

View File

@ -19,19 +19,12 @@
namespace Event { struct Connection; }
struct Event::Connection : Genode::Connection<Session>, Session_client
{
enum { RAM_QUOTA = 18*1024UL };
/**
* Constructor
*/
Connection(Genode::Env &env, char const *label = "")
Connection(Genode::Env &env, Label const &label = Label())
:
Genode::Connection<Event::Session>(env,
session(env.parent(),
"ram_quota=%u, cap_quota=%u, label=\"%s\"",
RAM_QUOTA, CAP_QUOTA, label)),
Genode::Connection<Event::Session>(env, label, Ram_quota { 18*1024 }, Args()),
Session_client(env.rm(), cap())
{ }
};

View File

@ -66,23 +66,16 @@ struct File_system::Connection : Genode::Connection<Session>, Session_client
*/
Connection(Genode::Env &env,
Genode::Range_allocator &tx_block_alloc,
char const *label = "",
char const *root = "/",
Label const &label = Label(),
char const *root = "/",
bool writeable = true,
size_t tx_buf_size = DEFAULT_TX_BUF_SIZE)
:
Genode::Connection<Session>(env,
session(env.parent(),
"ram_quota=%ld, "
"cap_quota=%ld, "
"tx_buf_size=%ld, "
"label=\"%s\", "
"root=\"%s\", "
"writeable=%d",
8*1024*sizeof(long) + tx_buf_size,
CAP_QUOTA,
tx_buf_size,
label, root, writeable)),
Genode::Connection<Session>(env, label,
Ram_quota { 8*1024*sizeof(long) + tx_buf_size },
Args("root=\"", root, "\", "
"writeable=", writeable, ", "
"tx_buf_size=", tx_buf_size)),
Session_client(cap(), tx_block_alloc, env.rm())
{ }

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2008-2017 Genode Labs GmbH
* Copyright (C) 2008-2023 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.
@ -15,62 +15,29 @@
#define _INCLUDE__FRAMEBUFFER_SESSION__CONNECTION_H_
#include <framebuffer_session/client.h>
#include <util/arg_string.h>
#include <base/connection.h>
namespace Framebuffer { class Connection; }
class Framebuffer::Connection : public Genode::Connection<Session>,
public Session_client
struct Framebuffer::Connection : Genode::Connection<Session>, Session_client
{
public:
enum { RAM_QUOTA = 8*1024UL };
private:
/**
* Create session and return typed session capability
*/
Session_capability _connect(Genode::Parent &parent, Area area)
{
using namespace Genode;
enum { ARGBUF_SIZE = 128 };
char argbuf[ARGBUF_SIZE];
argbuf[0] = 0;
/* donate ram and cap quota for storing server-side meta data */
Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota", RAM_QUOTA);
Arg_string::set_arg(argbuf, sizeof(argbuf), "cap_quota", CAP_QUOTA);
/* set optional session-constructor arguments */
if (area.w())
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_width", area.w());
if (area.h())
Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_height", area.h());
return session(parent, argbuf);
}
public:
/**
* Constructor
*
* \param mode desired size and pixel format
*
* The specified values are not enforced. After creating the
* session, you should validate the actual frame-buffer attributes
* by calling the 'info' method of the frame-buffer interface.
*/
Connection(Genode::Env &env, Framebuffer::Mode mode)
:
Genode::Connection<Session>(env, _connect(env.parent(),
mode.area)),
Session_client(cap())
{ }
/**
* Constructor
*
* \param mode desired size and pixel format
*
* The specified values are not enforced. After creating the
* session, you should validate the actual frame-buffer attributes
* by calling the 'info' method of the frame-buffer interface.
*/
Connection(Genode::Env &env, Framebuffer::Mode mode)
:
Genode::Connection<Session>(env, Label(), Ram_quota { 8*1024 },
Args("fb_width=", mode.area.w(), ", "
"fb_height=", mode.area.h())),
Session_client(cap())
{ }
};
#endif /* _INCLUDE__FRAMEBUFFER_SESSION__CONNECTION_H_ */

View File

@ -21,16 +21,13 @@
namespace Gpio { struct Connection; }
struct Gpio::Connection : Genode::Connection<Session>, Session_client
{
/**
* Constructor
*/
Connection(Genode::Env &env, unsigned long gpio_pin)
:
Genode::Connection<Session>(env, session(env.parent(),
"ram_quota=8K, cap_quota=%ld, gpio=%ld",
CAP_QUOTA, gpio_pin)),
Genode::Connection<Session>(env, Label(), Ram_quota { 8*1024 },
Args("gpio=", gpio_pin)),
Session_client(cap())
{ }
};

View File

@ -21,6 +21,7 @@
namespace Gpu { struct Connection; }
struct Gpu::Connection : Genode::Connection<Session>, Session_client
{
/**
@ -30,29 +31,16 @@ struct Gpu::Connection : Genode::Connection<Session>, Session_client
*/
Genode::Attached_dataspace _info_dataspace;
/**
* Issue session request
*
* \noapi
*/
Genode::Capability<Gpu::Session> _session(Genode::Parent &parent,
char const *label, Genode::size_t quota)
{
return session(parent, "ram_quota=%ld, cap_quota=%ld, label=\"%s\"",
quota, CAP_QUOTA, label);
}
/**
* Constructor
*
* \param quota initial amount of quota used for allocating Gpu
* memory
* \param quota initial amount of quota used for allocating GPU memory
*/
Connection(Genode::Env &env,
Genode::size_t quota = Session::REQUIRED_QUOTA,
const char *label = "")
Connection(Genode::Env &env,
Genode::size_t quota = Session::REQUIRED_QUOTA,
Label const &label = Label())
:
Genode::Connection<Session>(env, _session(env.parent(), label, quota)),
Genode::Connection<Session>(env, label, Ram_quota { quota }, Args()),
Session_client(cap()),
_info_dataspace(env.rm(), info_dataspace())
{ }

View File

@ -17,7 +17,6 @@
#include <gui_session/client.h>
#include <framebuffer_session/client.h>
#include <input_session/client.h>
#include <util/arg_string.h>
#include <base/connection.h>
namespace Gui { class Connection; }
@ -26,47 +25,21 @@ namespace Gui { class Connection; }
class Gui::Connection : public Genode::Connection<Session>,
public Session_client
{
public:
enum { RAM_QUOTA = 36*1024UL };
private:
Framebuffer::Session_client _framebuffer;
Input::Session_client _input;
Genode::size_t _session_quota = 0;
/**
* Create session and return typed session capability
*/
Session_capability _connect(Genode::Parent &parent, char const *label)
{
enum { ARGBUF_SIZE = 128 };
char argbuf[ARGBUF_SIZE];
argbuf[0] = 0;
if (Genode::strlen(label) > 0)
Genode::snprintf(argbuf, sizeof(argbuf), "label=\"%s\"", label);
/*
* Declare ram-quota donation
*/
using Genode::Arg_string;
Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota", RAM_QUOTA);
Arg_string::set_arg(argbuf, sizeof(argbuf), "cap_quota", CAP_QUOTA);
return session(parent, argbuf);
}
public:
/**
* Constructor
*/
Connection(Genode::Env &env, char const *label = "")
Connection(Genode::Env &env, Label const &label = Label())
:
/* establish nitpicker session */
Genode::Connection<Session>(env, _connect(env.parent(), label)),
Genode::Connection<Session>(env, label, Ram_quota { 36*1024 }, Args()),
Session_client(env.rm(), cap()),
/* request frame-buffer and input sub sessions */

View File

@ -23,9 +23,9 @@ namespace I2c { struct Connection; }
struct I2c::Connection : Genode::Connection<I2c::Session>, I2c::Session_client
{
Connection(Genode::Env &env, char const *label = "")
Connection(Genode::Env &env, Label const &label = Label())
:
Genode::Connection<Session>(env, session(env.parent(), "ram_quota=8K, label=%s", label)),
Genode::Connection<Session>(env, label, Ram_quota { 8*1024 }, Args()),
Session_client(cap())
{ }

View File

@ -34,11 +34,6 @@ struct I2c::Session : public Genode::Session
enum { CAP_QUOTA = 2 };
/***************
** Exception **
***************/
/**
* Exception thrown in case of a bus error
*

View File

@ -19,17 +19,12 @@
namespace Input { struct Connection; }
struct Input::Connection : Genode::Connection<Session>, Session_client
{
/**
* Constructor
*/
Connection(Genode::Env &env, char const *label = "")
Connection(Genode::Env &env, Label const &label = Label())
:
Genode::Connection<Input::Session>(env,
session(env.parent(),
"ram_quota=18K, cap_quota=%u, label=\"%s\"",
CAP_QUOTA, label)),
Genode::Connection<Input::Session>(env, label, Ram_quota { 18*1024 }, Args()),
Session_client(env.rm(), cap())
{ }
};

View File

@ -23,17 +23,13 @@ namespace Loader { struct Connection; }
struct Loader::Connection : Genode::Connection<Session>, Session_client
{
/**
* Constructor
*/
Connection(Genode::Env &env, Ram_quota ram_quota, Cap_quota cap_quota)
:
Genode::Connection<Session>(env, session(env.parent(),
"ram_quota=%ld, cap_quota=%ld",
ram_quota.value,
CAP_QUOTA + cap_quota.value)),
Genode::Connection<Session>(env, Label(), ram_quota, Args()),
Session_client(cap())
{ }
{
upgrade_caps(cap_quota.value);
}
};
#endif /* _INCLUDE__LOADER_SESSION__CONNECTION_H_ */

View File

@ -35,14 +35,13 @@ struct Nic::Connection : Genode::Connection<Session>, Session_client
Genode::Range_allocator *tx_block_alloc,
Genode::size_t tx_buf_size,
Genode::size_t rx_buf_size,
char const *label = "")
Label const &label = Label())
:
Genode::Connection<Session>(env,
session(env.parent(),
"ram_quota=%ld, cap_quota=%ld, "
"tx_buf_size=%ld, rx_buf_size=%ld, label=\"%s\"",
32*1024*sizeof(long) + tx_buf_size + rx_buf_size,
CAP_QUOTA, tx_buf_size, rx_buf_size, label)),
Genode::Connection<Session>(
env, label,
Ram_quota { 32*1024*sizeof(long) + tx_buf_size + rx_buf_size },
Args("tx_buf_size=", tx_buf_size, ", "
"rx_buf_size=", rx_buf_size)),
Session_client(cap(), *tx_block_alloc, env.rm())
{ }
};

View File

@ -20,17 +20,13 @@
namespace Pin_control { struct Connection; }
struct Pin_control::Connection : private Genode::Connection<Session>,
private Rpc_client<Session>
{
enum { RAM_QUOTA = 8*1024UL };
Connection(Env &env, char const *label = "")
Connection(Env &env, Label const &label = Label())
:
Genode::Connection<Session>(env,
session(env.parent(),
"ram_quota=%u, cap_quota=%u, label=\"%s\"",
RAM_QUOTA, CAP_QUOTA, label)),
Genode::Connection<Session>(env, label, Ram_quota { 8*1024 }, Args()),
Rpc_client<Session>(cap())
{ }

View File

@ -19,17 +19,13 @@
namespace Pin_state { struct Connection; }
struct Pin_state::Connection : private Genode::Connection<Session>,
private Rpc_client<Session>
{
enum { RAM_QUOTA = 8*1024UL };
Connection(Env &env, char const *label = "")
Connection(Env &env, Label const &label = Label())
:
Genode::Connection<Session>(env,
session(env.parent(),
"ram_quota=%u, cap_quota=%u, label=\"%s\"",
RAM_QUOTA, CAP_QUOTA, label)),
Genode::Connection<Session>(env, label, Ram_quota { 8*1024 }, Args()),
Rpc_client<Session>(cap())
{ }

View File

@ -72,9 +72,7 @@ class Platform::Connection : public Genode::Connection<Session>,
Connection(Env &env)
:
Genode::Connection<Session>(env, session(env.parent(),
"ram_quota=%u, cap_quota=%u",
RAM_QUOTA, CAP_QUOTA)),
Genode::Connection<Session>(env, Label(), Ram_quota { 32*1024 }, Args()),
Client(cap()),
_env(env)
{

View File

@ -57,7 +57,7 @@ struct Platform::Session : Genode::Session
*/
static const char *service_name() { return "Platform"; }
enum { RAM_QUOTA = 32 * 1024, CAP_QUOTA = 6 };
enum { CAP_QUOTA = 6 };
virtual ~Session() { }

View File

@ -22,16 +22,10 @@ namespace Report { struct Connection; }
struct Report::Connection : Genode::Connection<Session>, Session_client
{
enum { RAM_QUOTA = 10*1024 }; /* value used for 'Slave::Connection' */
Connection(Genode::Env &env, char const *label, size_t buffer_size = 4096)
Connection(Genode::Env &env, Label const &label, size_t buffer_size = 4096)
:
Genode::Connection<Session>(env,
session(env.parent(),
"label=\"%s\", ram_quota=%ld, "
"cap_quota=%ld, buffer_size=%zd",
label, RAM_QUOTA + buffer_size,
CAP_QUOTA, buffer_size)),
Genode::Connection<Session>(env, label, Ram_quota { 10*1024 + buffer_size },
Args("buffer_size=", buffer_size)),
Session_client(cap())
{ }
};

View File

@ -23,13 +23,9 @@ namespace Rtc { struct Connection; }
struct Rtc::Connection : Genode::Connection<Session>, Session_client
{
/**
* Constructor
*/
Connection(Genode::Env &env, char const *label = "")
Connection(Genode::Env &env, Label const &label = Label())
:
Genode::Connection<Rtc::Session>(
env, session(env.parent(), "ram_quota=8K, label=\"%s\"", label)),
Genode::Connection<Rtc::Session>(env, label, Ram_quota { 8*1024 }, Args()),
Session_client(cap())
{ }
};

View File

@ -57,6 +57,7 @@ struct Rtc::Session : Genode::Session
enum { CAP_QUOTA = 2 };
/***********************
** Session interface **
***********************/

View File

@ -44,14 +44,9 @@ struct Terminal::Connection : Genode::Connection<Session>, Session_client
sig_rec.dissolve(&sig_ctx);
}
/**
* Constructor
*/
Connection(Genode::Env &env, char const *label = "")
Connection(Genode::Env &env, Label const &label = Label())
:
Genode::Connection<Session>(env, session(env.parent(),
"ram_quota=%ld, cap_quota=%ld, label=\"%s\"",
10*1024, CAP_QUOTA, label)),
Genode::Connection<Session>(env, label, Ram_quota { 10*1024 }, Args()),
Session_client(env.rm(), cap())
{
wait_for_connection(cap());

View File

@ -22,12 +22,9 @@ namespace Uart { struct Connection; }
struct Uart::Connection : Genode::Connection<Session>, Session_client
{
/**
* Constructor
*/
Connection(Genode::Env &env)
:
Genode::Connection<Session>(env, session(env.parent(), "ram_quota=%ld", 2*4096)),
Genode::Connection<Session>(env, Label(), Ram_quota { 2*4096 }, Args()),
Session_client(env.rm(), cap())
{
Terminal::Connection::wait_for_connection(cap());

View File

@ -38,21 +38,14 @@ struct Uplink::Connection : Genode::Connection<Session>, Session_client
Genode::size_t tx_buf_size,
Genode::size_t rx_buf_size,
Net::Mac_address const &mac_address,
char const *label = "")
Label const &label = Label())
:
Genode::Connection<Session>(
env,
session(
env.parent(),
"ram_quota=%ld, cap_quota=%ld, mac_address=\"%s\", "
"tx_buf_size=%ld, rx_buf_size=%ld, label=\"%s\"",
32 * 1024 * sizeof(long) + tx_buf_size + rx_buf_size,
CAP_QUOTA,
Genode::String<18>(mac_address).string(),
tx_buf_size,
rx_buf_size,
label)),
env, label,
Ram_quota { 32*1024*sizeof(long) + tx_buf_size + rx_buf_size },
Args("mac_address=\"", mac_address, "\", "
"tx_buf_size=", tx_buf_size, ", "
"rx_buf_size=", rx_buf_size)),
Session_client(cap(), *tx_block_alloc, env.rm())
{ }
};

View File

@ -22,20 +22,15 @@ namespace Usb { struct Connection; }
struct Usb::Connection : Genode::Connection<Session>, Session_client
{
/**
* Constructor
*/
Connection(Genode::Env &env,
Genode::Range_allocator *tx_block_alloc,
char const *label = "",
Genode::size_t tx_buf_size = 512 * 1024,
Label const &label = Label(),
Genode::size_t tx_buf_size = 512*1024,
Genode::Signal_context_capability sigh_state_changed =
Genode::Signal_context_capability())
:
Genode::Connection<Session>(env,
session(env.parent(),
"ram_quota=%ld, cap_quota=%ld, tx_buf_size=%ld, label=\"%s\"",
5 * 4096 + tx_buf_size, CAP_QUOTA, tx_buf_size, label)),
Genode::Connection<Session>(env, label, Ram_quota { 5*4096 + tx_buf_size },
Args("tx_buf_size=", tx_buf_size)),
Session_client(cap(), *tx_block_alloc, env.rm(), sigh_state_changed)
{ }
};

View File

@ -68,7 +68,7 @@ class Gpio::Rpi_driver : public Driver
Rpi_driver(Genode::Env &env)
:
_reg(env, Rpi::GPIO_CONTROLLER_BASE, 0, Rpi::GPIO_CONTROLLER_SIZE),
_irq(env, IRQ),
_irq(env, unsigned(IRQ)),
_dispatcher(env.ep(), *this, &Rpi_driver::_handle),
_async(false)
{

View File

@ -23,25 +23,20 @@
namespace Local {
using namespace Genode;
struct Bad_args_nic;
struct Construct_destruct_test;
struct Main;
}
struct Bad_args_nic : Genode::Connection<Nic::Session>
struct Local::Bad_args_nic : Connection<Nic::Session>
{
Bad_args_nic(Genode::Env &env,
Genode::size_t ram_quota,
Genode::size_t cap_quota,
Genode::size_t tx_buf_size,
Genode::size_t rx_buf_size,
char const *label)
Bad_args_nic(Env &env, size_t ram_quota, size_t tx_buf_size, size_t rx_buf_size,
Session::Label const &label)
:
Genode::Connection<Nic::Session>(env,
session(env.parent(),
"ram_quota=%ld, cap_quota=%ld, "
"tx_buf_size=%ld, rx_buf_size=%ld, label=\"%s\"",
ram_quota, cap_quota, tx_buf_size, rx_buf_size, label))
Genode::Connection<Nic::Session>(env, label, Ram_quota { ram_quota },
Args("tx_buf_size=", tx_buf_size, ", "
"rx_buf_size=", rx_buf_size))
{ }
};
@ -81,7 +76,7 @@ struct Local::Construct_destruct_test
unsigned const round)
{
_bad_args_nic.construct(
_env, 0, 0, BUF_SIZE, BUF_SIZE, "bad_args");
_env, 0, BUF_SIZE, BUF_SIZE, "bad_args");
for (unsigned idx = 0; idx < _nr_of_sessions; idx++) {
try {
nic[idx].construct(_env, &_pkt_alloc, BUF_SIZE, BUF_SIZE);