diff --git a/repos/base-hw/include/cpu_session/connection.h b/repos/base-hw/include/cpu_session/connection.h index 5598046068..ee5d5bf21f 100644 --- a/repos/base-hw/include/cpu_session/connection.h +++ b/repos/base-hw/include/cpu_session/connection.h @@ -18,27 +18,49 @@ #include #include -namespace Genode { +namespace Genode { struct Cpu_connection; } - struct Cpu_connection : Connection, Cpu_session_client + +struct Genode::Cpu_connection : Connection, Cpu_session_client +{ + enum { RAM_QUOTA = 128*1024 }; + + Capability _session(Parent &parent, + char const *label, long priority, + Affinity const &affinity) { - enum { RAM_QUOTA = 128*1024 }; + return session(parent, affinity, + "priority=0x%lx, ram_quota=128K, label=\"%s\"", + priority, label); + } - /** - * Constructor - * - * \param label initial session label - * \param priority designated priority of all threads created - * with this CPU session - */ - Cpu_connection(const char *label = "", long priority = DEFAULT_PRIORITY, - Affinity const &affinity = Affinity()) - : - Connection( - session(affinity, "priority=0x%lx, ram_quota=128K, label=\"%s\"", - priority, label)), - Cpu_session_client(cap()) { } - }; -} + /** + * 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, + Affinity const &affinity = Affinity()) + : + Connection(env, _session(env.parent(), label, priority, affinity)), + Cpu_session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ + Cpu_connection(const char *label = "", long priority = DEFAULT_PRIORITY, + Affinity const &affinity = Affinity()) + : + Connection(_session(*env()->parent(), label, priority, affinity)), + Cpu_session_client(cap()) + { } +}; #endif /* _INCLUDE__CPU_SESSION__CONNECTION_H_ */ diff --git a/repos/base-hw/include/vm_session/connection.h b/repos/base-hw/include/vm_session/connection.h index 5d392ead5e..f5ab0367ec 100644 --- a/repos/base-hw/include/vm_session/connection.h +++ b/repos/base-hw/include/vm_session/connection.h @@ -18,28 +18,48 @@ #include #include -namespace Genode +namespace Genode { struct Vm_connection; } + + +struct Genode::Vm_connection : Connection, Vm_session_client { - /** - * Connection to a VM service - */ - struct Vm_connection : Connection, Vm_session_client + Capability _session(Parent &parent, char const *label, long priority, + unsigned long affinity) { - /** - * 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(const char *label = "", - long priority = Cpu_session::DEFAULT_PRIORITY, - unsigned long affinity = 0) - : Connection( - session("priority=0x%lx, affinity=0x%lx, ram_quota=16K, label=\"%s\"", - priority, affinity, label)), - Vm_session_client(cap()) { } - }; -} + return session(parent, + "priority=0x%lx, affinity=0x%lx, ram_quota=16K, label=\"%s\"", + priority, affinity, label); + } + + /** + * 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 = "", + long priority = Cpu_session::DEFAULT_PRIORITY, + unsigned long affinity = 0) + : + Connection(env, _session(env.parent(), label, priority, affinity)), + Vm_session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ + Vm_connection(const char *label = "", + long priority = Cpu_session::DEFAULT_PRIORITY, + unsigned long affinity = 0) + : + Connection(_session(*env()->parent(), label, priority, affinity)), + Vm_session_client(cap()) + { } +}; #endif /* _INCLUDE__VM_SESSION__CONNECTION_H_ */ diff --git a/repos/base/include/base/connection.h b/repos/base/include/base/connection.h index c52717dd12..bf634aef6b 100644 --- a/repos/base/include/base/connection.h +++ b/repos/base/include/base/connection.h @@ -42,9 +42,12 @@ class Genode::Connection : public Noncopyable Capability _cap; + Parent &_parent; + On_destruction _on_destruction; - Capability _session(Affinity const &affinity, + Capability _session(Parent &parent, + Affinity const &affinity, const char *format_args, va_list list) { char buf[FORMAT_STRING_SIZE]; @@ -55,7 +58,7 @@ class Genode::Connection : public Noncopyable va_end(list); /* call parent interface with the resulting argument buffer */ - return env()->parent()->session(buf, affinity); + return parent.session(buf, affinity); } public: @@ -73,8 +76,18 @@ class Genode::Connection : public Noncopyable * session capability of the connection to another party but never * invokes any of the session's RPC functions. */ - Connection(Capability cap, On_destruction od = CLOSE): - _cap(cap), _on_destruction(od) { } + Connection(Env &env, Capability cap, On_destruction od = CLOSE) + : _cap(cap), _parent(env.parent()), _on_destruction(od) { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ + Connection(Capability cap, On_destruction od = CLOSE) + : _cap(cap), _parent(*env()->parent()), _on_destruction(od) { } /** * Destructor @@ -82,7 +95,7 @@ class Genode::Connection : public Noncopyable ~Connection() { if (_on_destruction == CLOSE) - env()->parent()->close(_cap); + _parent.close(_cap); } /** @@ -95,19 +108,49 @@ class Genode::Connection : public Noncopyable */ void on_destruction(On_destruction od) { _on_destruction = od; } + /** + * Issue session request to the parent + */ + Capability session(Parent &parent, const char *format_args, ...) + { + va_list list; + va_start(list, format_args); + + return _session(parent, Affinity(), format_args, list); + } + + /** + * Issue session request to the parent + */ + Capability session(Parent &parent, + Affinity const &affinity, + char const *format_args, ...) + { + va_list list; + va_start(list, format_args); + + return _session(parent, affinity, format_args, list); + } + /** * Shortcut for env()->parent()->session() + * + * \noapi + * \deprecated to be removed along with Genode::env() */ Capability session(const char *format_args, ...) { va_list list; va_start(list, format_args); - return _session(Affinity(), format_args, list); + return _session(*env()->parent(), Affinity(), format_args, list); } /** * Shortcut for env()->parent()->session() + * + * \noapi + * \deprecated to be removed along with Genode::env() */ Capability session(Affinity const &affinity, char const *format_args, ...) diff --git a/repos/base/include/cpu_session/connection.h b/repos/base/include/cpu_session/connection.h index 3fc8da6fd6..39d87bca28 100644 --- a/repos/base/include/cpu_session/connection.h +++ b/repos/base/include/cpu_session/connection.h @@ -24,6 +24,14 @@ struct Genode::Cpu_connection : Connection, Cpu_session_client { enum { RAM_QUOTA = 36*1024 }; + Capability _session(Parent &parent, char const *label, + long priority, Affinity const &affinity) + { + return session(parent, affinity, + "priority=0x%lx, ram_quota=128K, label=\"%s\"", + priority, label); + } + /** * Constructor * @@ -31,14 +39,26 @@ struct Genode::Cpu_connection : Connection, Cpu_session_client * \param priority designated priority of all threads created * with this CPU session */ - Cpu_connection(char const *label = "", - long priority = DEFAULT_PRIORITY, + Cpu_connection(Env &env, const char *label = "", long priority = DEFAULT_PRIORITY, Affinity const &affinity = Affinity()) : - Connection( - session(affinity, "priority=0x%lx, ram_quota=%u, label=\"%s\"", - priority, RAM_QUOTA, label)), - Cpu_session_client(cap()) { } + Connection(env, _session(env.parent(), label, priority, affinity)), + Cpu_session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ + Cpu_connection(const char *label = "", long priority = DEFAULT_PRIORITY, + Affinity const &affinity = Affinity()) + : + Connection(_session(*env()->parent(), label, priority, affinity)), + Cpu_session_client(cap()) + { } }; #endif /* _INCLUDE__CPU_SESSION__CONNECTION_H_ */ diff --git a/repos/base/include/io_mem_session/connection.h b/repos/base/include/io_mem_session/connection.h index 8fc8ebeb48..d92d9de24d 100644 --- a/repos/base/include/io_mem_session/connection.h +++ b/repos/base/include/io_mem_session/connection.h @@ -22,6 +22,13 @@ namespace Genode { struct Io_mem_connection; } struct Genode::Io_mem_connection : Connection, Io_mem_session_client { + Capability _session(Parent &parent, addr_t base, size_t size, + bool write_combined) + { + return session("ram_quota=4K, base=0x%p, size=0x%zx, wc=%s", + base, size, write_combined ? "yes" : "no"); + } + /** * Constructor * @@ -31,10 +38,7 @@ struct Genode::Io_mem_connection : Connection, Io_mem_session_cl */ Io_mem_connection(Env &env, addr_t base, size_t size, bool write_combined = false) : - Connection( - session("ram_quota=4K, base=0x%p, size=0x%zx, wc=%s", - base, size, write_combined ? "yes" : "no")), - + Connection(env, _session(env.parent(), base, size, write_combined)), Io_mem_session_client(cap()) { } @@ -47,10 +51,7 @@ struct Genode::Io_mem_connection : Connection, Io_mem_session_cl */ Io_mem_connection(addr_t base, size_t size, bool write_combined = false) : - Connection( - session("ram_quota=4K, base=0x%p, size=0x%zx, wc=%s", - base, size, write_combined ? "yes" : "no")), - + Connection(_session(*env()->parent(), base, size, write_combined)), Io_mem_session_client(cap()) { } }; diff --git a/repos/base/include/io_port_session/connection.h b/repos/base/include/io_port_session/connection.h index 052395fec9..268ebe31c4 100644 --- a/repos/base/include/io_port_session/connection.h +++ b/repos/base/include/io_port_session/connection.h @@ -23,18 +23,34 @@ namespace Genode { struct Io_port_connection; } struct Genode::Io_port_connection : Connection, Io_port_session_client { + Capability _session(Parent &parent, unsigned base, unsigned size) + { + return session(parent, "ram_quota=4K, io_port_base=%u, io_port_size=%u", + base, size); + } + /** * Constructor * * \param base base address of port range * \param size size of port range */ + Io_port_connection(Env &env, unsigned base, unsigned size) + : + Connection(env, _session(env.parent(), base, size)), + Io_port_session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Io_port_connection(unsigned base, unsigned size) : - Connection( - session("ram_quota=4K, io_port_base=%u, io_port_size=%u", - base, size)), - + Connection(_session(*env()->parent(), base, size)), Io_port_session_client(cap()) { } }; diff --git a/repos/base/include/irq_session/connection.h b/repos/base/include/irq_session/connection.h index 48fce7e4bf..d43f345365 100644 --- a/repos/base/include/irq_session/connection.h +++ b/repos/base/include/irq_session/connection.h @@ -21,26 +21,51 @@ namespace Genode { struct Irq_connection; } struct Genode::Irq_connection : Connection, Irq_session_client { - public: + Capability _session(Parent &parent, + unsigned irq, + Irq_session::Trigger trigger, + Irq_session::Polarity polarity, + Genode::addr_t device_config_phys) + { + return session("ram_quota=4K, irq_number=%u, irq_trigger=%u, " + " irq_polarity=%u, device_config_phys=0x%lx", + irq, trigger, polarity, device_config_phys); + } - /** - * Constructor - * - * \param irq physical interrupt number - * \param trigger interrupt trigger (e.g., level/edge) - * \param polarity interrupt trigger polarity (e.g., low/high) - */ - Irq_connection(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) - : - Connection( - session("ram_quota=4K, irq_number=%u, irq_trigger=%u, " - " irq_polarity=%u, device_config_phys=0x%lx", - irq, trigger, polarity, device_config_phys)), - Irq_session_client(cap()) - { } + /** + * Constructor + * + * \param irq 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) + : + Connection(env, _session(env.parent(), irq, trigger, + polarity, device_config_phys)), + Irq_session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ + Irq_connection(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) + : + Connection(_session(*Genode::env()->parent(), irq, + trigger, polarity, device_config_phys)), + Irq_session_client(cap()) + { } }; #endif /* _INCLUDE__IRQ_SESSION__CONNECTION_H_ */ diff --git a/repos/base/include/log_session/connection.h b/repos/base/include/log_session/connection.h index 5e923d58ed..7d34450070 100644 --- a/repos/base/include/log_session/connection.h +++ b/repos/base/include/log_session/connection.h @@ -22,6 +22,22 @@ namespace Genode { struct Log_connection; } struct Genode::Log_connection : Connection, Log_session_client { + /** + * Constructor + */ + Log_connection(Env &env) + : + Connection(env, session(env.parent(), "ram_quota=8K")), + Log_session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Log_connection() : Connection(session("ram_quota=8K")), diff --git a/repos/base/include/pd_session/connection.h b/repos/base/include/pd_session/connection.h index 6eee00fe2b..b94a88050a 100644 --- a/repos/base/include/pd_session/connection.h +++ b/repos/base/include/pd_session/connection.h @@ -29,9 +29,24 @@ struct Genode::Pd_connection : Connection, Pd_session_client * * \param label session label */ + Pd_connection(Env &env, char const *label = "") + : + Connection(env, session(env.parent(), + "ram_quota=%u, label=\"%s\"", + RAM_QUOTA, label)), + Pd_session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Pd_connection(char const *label = "") - : Connection(session("ram_quota=%u, label=\"%s\"", - RAM_QUOTA, label)), + : + Connection(session("ram_quota=%u, label=\"%s\"", RAM_QUOTA, label)), Pd_session_client(cap()) { } }; diff --git a/repos/base/include/ram_session/connection.h b/repos/base/include/ram_session/connection.h index bd79e8a273..434451bd6e 100644 --- a/repos/base/include/ram_session/connection.h +++ b/repos/base/include/ram_session/connection.h @@ -24,18 +24,37 @@ struct Genode::Ram_connection : Connection, Ram_session_client { enum { RAM_QUOTA = 4*1024*sizeof(long) }; + Capability _session(Parent &parent, char const *label, + addr_t phys_start, size_t phys_size) + { + return session(parent, + "ram_quota=%u, phys_start=0x%lx, phys_size=0x%zx, " + "label=\"%s\"", RAM_QUOTA, phys_start, phys_size, label); + } + /** * Constructor * * \param label session label */ + Ram_connection(Env &env, const char *label = "", unsigned long phys_start = 0UL, + unsigned long phys_size = 0UL) + : + Connection(env, _session(env.parent(), label, phys_start, phys_size)), + Ram_session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Ram_connection(const char *label = "", unsigned long phys_start = 0UL, unsigned long phys_size = 0UL) : - Connection( - session("ram_quota=%u, phys_start=0x%lx, phys_size=0x%lx, " - "label=\"%s\"", RAM_QUOTA, phys_start, phys_size, label)), - + Connection(_session(*env()->parent(), label, phys_start, phys_size)), Ram_session_client(cap()) { } }; diff --git a/repos/base/include/rm_session/connection.h b/repos/base/include/rm_session/connection.h index 9fc2f0b22a..9403eaa4f3 100644 --- a/repos/base/include/rm_session/connection.h +++ b/repos/base/include/rm_session/connection.h @@ -24,9 +24,27 @@ struct Genode::Rm_connection : Connection, Rm_session_client { enum { RAM_QUOTA = 64*1024 }; - Rm_connection() : + /** + * Constructor + */ + Rm_connection(Env &env) + : + Connection(env, session(env.parent(), "ram_quota=%u", RAM_QUOTA)), + Rm_session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ + Rm_connection() + : Connection(session("ram_quota=%u", RAM_QUOTA)), - Rm_session_client(cap()) { } + Rm_session_client(cap()) + { } }; #endif /* _INCLUDE__RM_SESSION__CONNECTION_H_ */ diff --git a/repos/base/include/rom_session/connection.h b/repos/base/include/rom_session/connection.h index 30fe4b3f14..1fdc82682f 100644 --- a/repos/base/include/rom_session/connection.h +++ b/repos/base/include/rom_session/connection.h @@ -30,10 +30,12 @@ class Genode::Rom_connection : public Connection, private: - Rom_session_capability _create_session(const char *module_name, const char *label) + Rom_session_capability _session(Parent &parent, + char const *module_name, + char const *label) { try { - return session("ram_quota=4K, filename=\"%s\", label=\"%s\"", + return session(parent, "ram_quota=4K, filename=\"%s\", label=\"%s\"", module_name, label ? label: module_name); } catch (...) { PERR("Could not open ROM session for module \"%s\"", module_name); @@ -53,7 +55,7 @@ class Genode::Rom_connection : public Connection, */ Rom_connection(Env &env, const char *module_name, const char *label = 0) : - Connection(_create_session(module_name, label)), + Connection(env, _session(env.parent(), module_name, label)), Rom_session_client(cap()) { } @@ -66,7 +68,7 @@ class Genode::Rom_connection : public Connection, */ Rom_connection(const char *module_name, const char *label = 0) : - Connection(_create_session(module_name, label)), + Connection(_session(*env()->parent(), module_name, label)), Rom_session_client(cap()) { } }; diff --git a/repos/base/include/trace_session/connection.h b/repos/base/include/trace_session/connection.h index b1a5a6a26e..a40fe05750 100644 --- a/repos/base/include/trace_session/connection.h +++ b/repos/base/include/trace_session/connection.h @@ -23,6 +23,16 @@ namespace Genode { namespace Trace { struct Connection; } } struct Genode::Trace::Connection : Genode::Connection, Genode::Trace::Session_client { + Capability _session(Parent &parent, + size_t ram_quota, + size_t arg_buffer_size, + unsigned parent_levels) + { + return session(parent, + "ram_quota=%zu, arg_buffer_size=%zu, parent_levels=%u", + ram_quota, arg_buffer_size, parent_levels); + } + /** * Constructor * @@ -30,11 +40,26 @@ struct Genode::Trace::Connection : Genode::Connection, * \param arg_buffer_size session argument-buffer size * \param parent_levels number of parent levels to trace */ - Connection(size_t ram_quota, size_t arg_buffer_size, unsigned parent_levels) : - Genode::Connection( - session("ram_quota=%zu, arg_buffer_size=%zu, parent_levels=%u", - ram_quota, arg_buffer_size, parent_levels)), - Session_client(cap()) { } + Connection(Env &env, size_t ram_quota, size_t arg_buffer_size, unsigned parent_levels) + : + Genode::Connection(env, _session(env.parent(), ram_quota, + arg_buffer_size, parent_levels)), + Session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ + Connection(size_t ram_quota, size_t arg_buffer_size, unsigned parent_levels) + : + Genode::Connection(_session(*env()->parent(), ram_quota, + arg_buffer_size, parent_levels)), + Session_client(cap()) + { } }; #endif /* _INCLUDE__TRACE_SESSION__CONNECTION_H_ */ diff --git a/repos/os/include/audio_in_session/connection.h b/repos/os/include/audio_in_session/connection.h index 852804ace3..8730ac5ec7 100644 --- a/repos/os/include/audio_in_session/connection.h +++ b/repos/os/include/audio_in_session/connection.h @@ -18,12 +18,17 @@ #include #include - namespace Audio_in { struct Connection; } struct Audio_in::Connection : Genode::Connection, Audio_in::Session_client { + Capability _session(Genode::Parent &parent, char const *channel) + { + return session(parent, "ram_quota=%zd, channel=\"%s\"", + 2*4096 + sizeof(Stream), channel); + } + /** * Constructor * @@ -31,11 +36,22 @@ struct Audio_in::Connection : Genode::Connection, Audio_in::Session_cli * call 'wait_for_progress', which is sent when the * server processed one or more packets */ + Connection(Genode::Env &env, char const *channel, bool progress_signal = false) + : + Genode::Connection(env, _session(env.parent(), channel)), + Session_client(cap(), progress_signal) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection(char const *channel, bool progress_signal = false) : - Genode::Connection( - session("ram_quota=%zd, channel=\"%s\"", - 2*4096 + sizeof(Stream), channel)), + Genode::Connection(_session(*Genode::env()->parent(), channel)), Session_client(cap(), progress_signal) { } }; diff --git a/repos/os/include/audio_out_session/connection.h b/repos/os/include/audio_out_session/connection.h index 2a9ad95d0a..8326b2fd5f 100644 --- a/repos/os/include/audio_out_session/connection.h +++ b/repos/os/include/audio_out_session/connection.h @@ -18,12 +18,17 @@ #include #include - namespace Audio_out { struct Connection; } struct Audio_out::Connection : Genode::Connection, Audio_out::Session_client { + Capability _session(Genode::Parent &parent, char const *channel) + { + return session(parent, "ram_quota=%zd, channel=\"%s\"", + 2*4096 + sizeof(Stream), channel); + } + /** * Constructor * @@ -34,13 +39,27 @@ struct Audio_out::Connection : Genode::Connection, Audio_out::Session_c * call 'wait_for_progress', which is sent when the * server processed one or more packets */ + Connection(Genode::Env &env, + char const *channel, + bool alloc_signal = true, + bool progress_signal = false) + : + Genode::Connection(env, _session(env.parent(), channel)), + Session_client(cap(), alloc_signal, progress_signal) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection(const char *channel, bool alloc_signal = true, bool progress_signal = false) : - Genode::Connection( - session("ram_quota=%zd, channel=\"%s\"", - 2*4096 + sizeof(Stream), channel)), + Genode::Connection(_session(*Genode::env()->parent(), channel)), Session_client(cap(), alloc_signal, progress_signal) { } }; diff --git a/repos/os/include/block_session/connection.h b/repos/os/include/block_session/connection.h index 941d362ea5..1a1e511679 100644 --- a/repos/os/include/block_session/connection.h +++ b/repos/os/include/block_session/connection.h @@ -22,6 +22,13 @@ namespace Block { struct Connection; } struct Block::Connection : Genode::Connection, Session_client { + Capability _session(Genode::Parent &parent, + char const *label, Genode::size_t tx_buf_size) + { + return session(parent, "ram_quota=%zd, tx_buf_size=%zd, label=\"%s\"", + 3*4096 + tx_buf_size, tx_buf_size, label); + } + /** * Constructor * @@ -29,14 +36,29 @@ struct Block::Connection : Genode::Connection, Session_client * transmission buffer * \param tx_buf_size size of transmission buffer in bytes */ + Connection(Genode::Env &env, + Genode::Range_allocator *tx_block_alloc, + Genode::size_t tx_buf_size = 128*1024, + const char *label = "") + : + Genode::Connection(env, _session(env.parent(), label, tx_buf_size)), + Session_client(cap(), tx_block_alloc) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection(Genode::Range_allocator *tx_block_alloc, Genode::size_t tx_buf_size = 128*1024, const char *label = "") : - Genode::Connection( - session("ram_quota=%zd, tx_buf_size=%zd, label=\"%s\"", - 3*4096 + tx_buf_size, tx_buf_size, label)), - Session_client(cap(), tx_block_alloc) { } + Genode::Connection(_session(*Genode::env()->parent(), label, tx_buf_size)), + Session_client(cap(), tx_block_alloc) + { } }; #endif /* _INCLUDE__BLOCK_SESSION__CONNECTION_H_ */ diff --git a/repos/os/include/file_system_session/connection.h b/repos/os/include/file_system_session/connection.h index cea72bd4f0..d571b1e68d 100644 --- a/repos/os/include/file_system_session/connection.h +++ b/repos/os/include/file_system_session/connection.h @@ -35,15 +35,51 @@ namespace File_system { */ struct File_system::Connection_base : Genode::Connection, Session_client { + Capability _session(Genode::Parent &parent, + char const *label, + char const *root, + bool writeable, + size_t tx_buf_size) + { + return session(parent, + "ram_quota=%zd, " + "tx_buf_size=%zd, " + "label=\"%s\", " + "root=\"%s\", " + "writeable=%d", + 8*1024*sizeof(long) + tx_buf_size, + tx_buf_size, + label, root, writeable); + } + /** * Constructor * * \param tx_buffer_alloc allocator used for managing the * transmission buffer - * \param tx_buf_size size of transmission buffer in bytes * \param label session label * \param root root directory of session * \param writeable session is writable + * \param tx_buf_size size of transmission buffer in bytes + */ + Connection_base(Genode::Env &env, + Genode::Range_allocator &tx_block_alloc, + char const *label = "", + char const *root = "/", + bool writeable = true, + size_t tx_buf_size = DEFAULT_TX_BUF_SIZE) + : + Genode::Connection(env, _session(env.parent(), label, root, + writeable, tx_buf_size)), + Session_client(cap(), tx_block_alloc) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead */ Connection_base(Genode::Range_allocator &tx_block_alloc, size_t tx_buf_size = DEFAULT_TX_BUF_SIZE, @@ -51,15 +87,8 @@ struct File_system::Connection_base : Genode::Connection, Session_clien char const *root = "/", bool writeable = true) : - Genode::Connection( - session("ram_quota=%zd, " - "tx_buf_size=%zd, " - "label=\"%s\", " - "root=\"%s\", " - "writeable=%d", - 8*1024*sizeof(long) + tx_buf_size, - tx_buf_size, - label, root, writeable)), + Genode::Connection(_session(*Genode::env()->parent(), label, + root, writeable, tx_buf_size)), Session_client(cap(), tx_block_alloc) { } }; diff --git a/repos/os/include/framebuffer_session/connection.h b/repos/os/include/framebuffer_session/connection.h index 4603675d17..92b25f0c78 100644 --- a/repos/os/include/framebuffer_session/connection.h +++ b/repos/os/include/framebuffer_session/connection.h @@ -29,7 +29,8 @@ class Framebuffer::Connection : public Genode::Connection, /** * Create session and return typed session capability */ - Session_capability _connect(unsigned width, unsigned height, + Session_capability _connect(Genode::Parent &parent, + unsigned width, unsigned height, Mode::Format format) { using namespace Genode; @@ -48,7 +49,7 @@ class Framebuffer::Connection : public Genode::Connection, if (format != Mode::INVALID) Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_format", format); - return session(argbuf); + return session(parent, argbuf); } public: @@ -56,19 +57,33 @@ class Framebuffer::Connection : public Genode::Connection, /** * Constructor * - * \param width desired frame-buffer width - * \param height desired frame-buffer height - * \param mode desired pixel format + * \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(env, _connect(env.parent(), + mode.width(), mode.height(), + mode.format())), + Session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection(unsigned width = 0, unsigned height = 0, Mode::Format format = Mode::INVALID) : - Genode::Connection(_connect(width, height, format)), + Genode::Connection(_connect(*Genode::env()->parent(), + width, height, format)), Session_client(cap()) { } }; diff --git a/repos/os/include/gpio_session/connection.h b/repos/os/include/gpio_session/connection.h index 5a44a0f5e2..ca75012be1 100644 --- a/repos/os/include/gpio_session/connection.h +++ b/repos/os/include/gpio_session/connection.h @@ -23,9 +23,28 @@ namespace Gpio { struct Connection; } struct Gpio::Connection : Genode::Connection, Session_client { + /** + * Constructor + */ + Connection(Genode::Env &env, unsigned long gpio_pin) + : + Genode::Connection(env, session(env.parent(), + "ram_quota=8K, gpio=%zd", gpio_pin)), + Session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection(unsigned long gpio_pin) - : Genode::Connection(session("ram_quota=8K, gpio=%zd", gpio_pin)), - Session_client(cap()) { } + : + Genode::Connection(session("ram_quota=8K, gpio=%zd", gpio_pin)), + Session_client(cap()) + { } }; #endif /* _INCLUDE__GPIO_SESSION__CONNECTION_H_ */ diff --git a/repos/os/include/input_session/connection.h b/repos/os/include/input_session/connection.h index 3eda71376a..584b5ecab3 100644 --- a/repos/os/include/input_session/connection.h +++ b/repos/os/include/input_session/connection.h @@ -21,6 +21,22 @@ namespace Input { struct Connection; } struct Input::Connection : Genode::Connection, Session_client { + /** + * Constructor + */ + Connection(Genode::Env &env) + : + Genode::Connection(env, session(env.parent(), "ram_quota=16K")), + Session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection() : Genode::Connection(session("ram_quota=16K")), diff --git a/repos/os/include/loader_session/connection.h b/repos/os/include/loader_session/connection.h index eeb656dc58..64b7d8e513 100644 --- a/repos/os/include/loader_session/connection.h +++ b/repos/os/include/loader_session/connection.h @@ -23,6 +23,23 @@ namespace Loader { struct Connection; } struct Loader::Connection : Genode::Connection, Session_client { + /** + * Constructor + */ + Connection(Genode::Env &env, size_t ram_quota) + : + Genode::Connection(env, session(env.parent(), + "ram_quota=%zd", ram_quota)), + Session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection(size_t ram_quota) : Genode::Connection(session("ram_quota=%zd", ram_quota)), diff --git a/repos/os/include/nic_session/connection.h b/repos/os/include/nic_session/connection.h index 22f1d56e5b..91f817d2a8 100644 --- a/repos/os/include/nic_session/connection.h +++ b/repos/os/include/nic_session/connection.h @@ -23,6 +23,16 @@ namespace Nic { struct Connection; } struct Nic::Connection : Genode::Connection, Session_client { + Capability _session(Genode::Parent &parent, + char const *label, + Genode::size_t tx_buf_size, + Genode::size_t rx_buf_size) + { + return session(parent, + "ram_quota=%zd, tx_buf_size=%zd, rx_buf_size=%zd, label=\"%s\"", + 6*4096 + tx_buf_size + rx_buf_size, tx_buf_size, rx_buf_size, label); + } + /** * Constructor * @@ -31,15 +41,31 @@ struct Nic::Connection : Genode::Connection, Session_client * \param tx_buf_size size of transmission buffer in bytes * \param rx_buf_size size of reception buffer in bytes */ + Connection(Genode::Env &env, + Genode::Range_allocator *tx_block_alloc, + Genode::size_t tx_buf_size, + Genode::size_t rx_buf_size, + char const *label = "") + : + Genode::Connection(env, _session(env.parent(), label, + tx_buf_size, rx_buf_size)), + Session_client(cap(), tx_block_alloc) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection(Genode::Range_allocator *tx_block_alloc, Genode::size_t tx_buf_size, Genode::size_t rx_buf_size, char const *label = "") : - Genode::Connection( - session("ram_quota=%zd, tx_buf_size=%zd, rx_buf_size=%zd, label=\"%s\"", - 6*4096 + tx_buf_size + rx_buf_size, - tx_buf_size, rx_buf_size, label)), + Genode::Connection(_session(*Genode::env()->parent(), label, + tx_buf_size, rx_buf_size)), Session_client(cap(), tx_block_alloc) { } }; diff --git a/repos/os/include/nitpicker_session/connection.h b/repos/os/include/nitpicker_session/connection.h index 086e0d02e0..9d7a7e19c6 100644 --- a/repos/os/include/nitpicker_session/connection.h +++ b/repos/os/include/nitpicker_session/connection.h @@ -35,7 +35,7 @@ class Nitpicker::Connection : public Genode::Connection, /** * Create session and return typed session capability */ - Session_capability _connect(char const *label) + Session_capability _connect(Genode::Parent &parent, char const *label) { enum { ARGBUF_SIZE = 128 }; char argbuf[ARGBUF_SIZE]; @@ -51,7 +51,7 @@ class Nitpicker::Connection : public Genode::Connection, enum { SESSION_METADATA = 36*1024 }; Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota", SESSION_METADATA); - return session(argbuf); + return session(parent, argbuf); } public: @@ -59,10 +59,28 @@ class Nitpicker::Connection : public Genode::Connection, /** * Constructor */ + Connection(Genode::Env &env, char const *label = "") + : + /* establish nitpicker session */ + Genode::Connection(env, _connect(env.parent(), label)), + Session_client(cap()), + + /* request frame-buffer and input sub sessions */ + _framebuffer(framebuffer_session()), + _input(input_session()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection(char const *label = "") : /* establish nitpicker session */ - Genode::Connection(_connect(label)), + Genode::Connection(_connect(*Genode::env()->parent(), label)), Session_client(cap()), /* request frame-buffer and input sub sessions */ diff --git a/repos/os/include/platform_session/connection.h b/repos/os/include/platform_session/connection.h index ba6b0f48b9..17aab4826e 100644 --- a/repos/os/include/platform_session/connection.h +++ b/repos/os/include/platform_session/connection.h @@ -23,6 +23,20 @@ namespace Platform { class Connection; } struct Platform::Connection : Genode::Connection, Client { + /** + * Constructor + */ + Connection(Genode::Env &env) + : Genode::Connection(env, session(env.parent(), "ram_quota=4K")), + Client(cap()) { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection() : Genode::Connection(session("ram_quota=4K")), Client(cap()) { } diff --git a/repos/os/include/regulator_session/connection.h b/repos/os/include/regulator_session/connection.h index 9323722c08..18323f7790 100644 --- a/repos/os/include/regulator_session/connection.h +++ b/repos/os/include/regulator_session/connection.h @@ -23,6 +23,26 @@ namespace Regulator { struct Connection; } struct Regulator::Connection : Genode::Connection, Session_client { + Capability _session(Genode::Parent &parent, + char const *label, + Regulator_id regulator) + { + return session("ram_quota=8K, regulator=\"%s\", label=\"%s\"", + regulator_name_by_id(regulator), label); + } + + /** + * Constructor + * + * \param regulator identifier for the specific regulator + * \param label string identifier of the client + */ + Connection(Genode::Env &env, Regulator_id regulator, const char * label = "") + : + Genode::Connection(env, _session(env.parent(), label, regulator)), + Session_client(cap()) + { } + /** * Constructor * @@ -30,10 +50,10 @@ struct Regulator::Connection : Genode::Connection, Session_client * \param label string identifier of the client */ Connection(Regulator_id regulator, const char * label = "") - : Genode::Connection( - session("ram_quota=8K, regulator=\"%s\", label=\"%s\"", - regulator_name_by_id(regulator), label)), - Session_client(cap()) { } + : + Genode::Connection(_session(*Genode::env()->parent(), label, regulator)), + Session_client(cap()) + { } }; #endif /* _INCLUDE__REGULATOR_SESSION__CONNECTION_H_ */ diff --git a/repos/os/include/report_session/connection.h b/repos/os/include/report_session/connection.h index f1a382e93b..e8a0c8130b 100644 --- a/repos/os/include/report_session/connection.h +++ b/repos/os/include/report_session/connection.h @@ -22,11 +22,32 @@ namespace Report { struct Connection; } struct Report::Connection : Genode::Connection, Session_client { + Capability _session(Genode::Parent &parent, + char const *label, size_t buffer_size) + { + return session(parent, "label=\"%s\", ram_quota=%zd, buffer_size=%zd", + label, 2*4096 + buffer_size, buffer_size); + } + + /** + * Constructor + */ + Connection(Genode::Env &env, char const *label, size_t buffer_size = 4096) + : + Genode::Connection(env, _session(env.parent(), label, buffer_size)), + Session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection(char const *label, size_t buffer_size = 4096) : - Genode::Connection( - session("label=\"%s\", ram_quota=%zd, buffer_size=%zd", - label, 2*4096 + buffer_size, buffer_size)), + Genode::Connection(_session(*Genode::env()->parent(), label, buffer_size)), Session_client(cap()) { } }; diff --git a/repos/os/include/rtc_session/connection.h b/repos/os/include/rtc_session/connection.h index 8e78af87d6..d394d998ea 100644 --- a/repos/os/include/rtc_session/connection.h +++ b/repos/os/include/rtc_session/connection.h @@ -23,9 +23,27 @@ namespace Rtc { struct Connection; } struct Rtc::Connection : Genode::Connection, Session_client { - Connection() : - Genode::Connection(session("foo, ram_quota=4K")), - Session_client(cap()) { } + /** + * Constructor + */ + Connection(Genode::Env &env) + : + Genode::Connection(env, session(env.parent(), "ram_quota=4K")), + Session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ + Connection() + : + Genode::Connection(session("ram_quota=4K")), + Session_client(cap()) + { } }; #endif /* _INCLUDE__RTC_SESSION__CONNECTION_H_ */ diff --git a/repos/os/include/spec/imx53/imx_framebuffer_session/connection.h b/repos/os/include/spec/imx53/imx_framebuffer_session/connection.h index aff75887d8..1fcf3022d2 100644 --- a/repos/os/include/spec/imx53/imx_framebuffer_session/connection.h +++ b/repos/os/include/spec/imx53/imx_framebuffer_session/connection.h @@ -29,7 +29,8 @@ class Framebuffer::Imx_connection : public Genode::Connection, /** * Create session and return typed session capability */ - Capability _connect(unsigned width, unsigned height, + Capability _connect(Genode::Parent &parent, + unsigned width, unsigned height, Mode::Format format) { using namespace Genode; @@ -48,7 +49,7 @@ class Framebuffer::Imx_connection : public Genode::Connection, if (format != Mode::INVALID) Arg_string::set_arg(argbuf, sizeof(argbuf), "fb_format", format); - return session(argbuf); + return session(parent, argbuf); } public: @@ -56,18 +57,32 @@ class Framebuffer::Imx_connection : public Genode::Connection, /** * Constructor * - * \param width desired frame-buffer width - * \param height desired frame-buffer height - * \param mode desired pixel format + * \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. */ + Imx_connection(Genode::Env &env, Framebuffer::Mode mode) + : + Genode::Connection(env, _connect(env.parent(), + mode.width(), mode.height(), + mode.format())), + Imx_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Imx_connection(unsigned width = 0, unsigned height = 0, Mode::Format format = Mode::INVALID) - : Genode::Connection(_connect(width, height, format)), + : Genode::Connection(_connect(*Genode::env()->parent(), + width, height, format)), Imx_client(cap()) { } }; diff --git a/repos/os/include/spec/x86/platform_session/connection.h b/repos/os/include/spec/x86/platform_session/connection.h index 1c3e68a892..00800e0346 100644 --- a/repos/os/include/spec/x86/platform_session/connection.h +++ b/repos/os/include/spec/x86/platform_session/connection.h @@ -21,6 +21,22 @@ namespace Platform { struct Connection; } struct Platform::Connection : Genode::Connection, Client { + /** + * Constructor + */ + Connection(Genode::Env &env) + : + Genode::Connection(env, session("ram_quota=20K")), + Client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection() : Genode::Connection(session("ram_quota=20K")), diff --git a/repos/os/include/terminal_session/connection.h b/repos/os/include/terminal_session/connection.h index 037236240f..66344ec82e 100644 --- a/repos/os/include/terminal_session/connection.h +++ b/repos/os/include/terminal_session/connection.h @@ -42,6 +42,26 @@ struct Terminal::Connection : Genode::Connection, Session_client sig_rec.dissolve(&sig_ctx); } + /** + * Constructor + */ + Connection(Genode::Env &env, char const *label = "") + : + Genode::Connection(env, session(env.parent(), + "ram_quota=%zd, label=\"%s\"", + 2*4096, label)), + Session_client(cap()) + { + wait_for_connection(cap()); + } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection(char const *label = "") : Genode::Connection(session("ram_quota=%zd, label=\"%s\"", diff --git a/repos/os/include/timer_session/connection.h b/repos/os/include/timer_session/connection.h index ba48b7c99d..a8bc810ac0 100644 --- a/repos/os/include/timer_session/connection.h +++ b/repos/os/include/timer_session/connection.h @@ -24,19 +24,40 @@ class Timer::Connection : public Genode::Connection, public Session_cli { private: - Genode::Lock _lock; - Genode::Signal_receiver _sig_rec; - Genode::Signal_context _default_sigh_ctx; - Genode::Signal_context_capability _default_sigh_cap; + Genode::Lock _lock; + Genode::Signal_receiver _sig_rec; + Genode::Signal_context _default_sigh_ctx; + + Genode::Signal_context_capability + _default_sigh_cap = _sig_rec.manage(&_default_sigh_ctx); + Genode::Signal_context_capability _custom_sigh_cap; public: + /** + * Constructor + */ + Connection(Genode::Env &env) + : + Genode::Connection(env, session(env.parent(), "ram_quota=8K")), + Session_client(cap()) + { + /* register default signal handler */ + Session_client::sigh(_default_sigh_cap); + } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection() : Genode::Connection(session("ram_quota=8K")), - Session_client(cap()), - _default_sigh_cap(_sig_rec.manage(&_default_sigh_ctx)) + Session_client(cap()) { /* register default signal handler */ Session_client::sigh(_default_sigh_cap); diff --git a/repos/os/include/uart_session/connection.h b/repos/os/include/uart_session/connection.h index 5ddb8207a3..e738b6a679 100644 --- a/repos/os/include/uart_session/connection.h +++ b/repos/os/include/uart_session/connection.h @@ -22,6 +22,24 @@ namespace Uart { struct Connection; } struct Uart::Connection : Genode::Connection, Session_client { + /** + * Constructor + */ + Connection(Genode::Env &env) + : + Genode::Connection(env, session(env.parent(), "ram_quota=%zd", 2*4096)), + Session_client(cap()) + { + Terminal::Connection::wait_for_connection(cap()); + } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ Connection() : Genode::Connection(session("ram_quota=%zd", 2*4096)), diff --git a/repos/os/include/usb_session/connection.h b/repos/os/include/usb_session/connection.h index 1e1e7fcfed..2966d13b19 100644 --- a/repos/os/include/usb_session/connection.h +++ b/repos/os/include/usb_session/connection.h @@ -22,17 +22,42 @@ namespace Usb { struct Connection; } struct Usb::Connection : Genode::Connection, Session_client { + Capability _session(Genode::Parent &parent, + char const *label, + Genode::size_t tx_buf_size) + { + return session(parent, "ram_quota=%zd, tx_buf_size=%zd, label=\"%s\"", + 3 * 4096 + tx_buf_size, tx_buf_size, label); + } + /** - * Connect to a USB device. + * Constructor + */ + Connection(Genode::Env &env, + Genode::Range_allocator *tx_block_alloc, + char const *label = "", + Genode::size_t tx_buf_size = 512 * 1024, + Genode::Signal_context_capability sigh_state_changed = + Genode::Signal_context_capability()) + : + Genode::Connection(env, _session(env.parent(), label, tx_buf_size)), + Session_client(cap(), tx_block_alloc, sigh_state_changed) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead */ Connection(Genode::Range_allocator *tx_block_alloc, char const *label = "", Genode::size_t tx_buf_size = 512 * 1024, Genode::Signal_context_capability sigh_state_changed = - Genode::Signal_context_capability()) + Genode::Signal_context_capability()) : - Genode::Connection(session("ram_quota=%zd, tx_buf_size=%zd, label=\"%s\"", - 3 * 4096 + tx_buf_size, tx_buf_size, label)), + Genode::Connection(_session(*Genode::env()->parent(), label, tx_buf_size)), Session_client(cap(), tx_block_alloc, sigh_state_changed) { } }; diff --git a/repos/ports/include/noux_session/connection.h b/repos/ports/include/noux_session/connection.h index 6890fd6dc1..27ab62338a 100644 --- a/repos/ports/include/noux_session/connection.h +++ b/repos/ports/include/noux_session/connection.h @@ -17,15 +17,29 @@ #include #include -namespace Noux { +namespace Noux { struct Connection; } - struct Connection : Genode::Connection, Session_client - { - Connection() : - Genode::Connection(session("")), - Session_client(cap()) - { } - }; -} + +struct Noux::Connection : Genode::Connection, Session_client +{ + /** + * Constructor + */ + Connection(Genode::Env &env) + : + Genode::Connection(env, session(env.parent(), "")), + Session_client(cap()) + { } + + /** + * Constructor + * + * \noapi + * \deprecated Use the constructor with 'Env &' as first + * argument instead + */ + Connection() + : Genode::Connection(session("")), Session_client(cap()) { } +}; #endif /* _INCLUDE__NOUX_SESSION__CONNECTION_H_ */