gems: remove the use of deprecated APIs

This patch also updates os/slave.h because the app/launcher cannot be
reasonably updated without it.

Issue #1987
Issue #3125
This commit is contained in:
Norman Feske 2019-01-21 15:46:48 +01:00
parent f23579532e
commit ba2b0b8360
63 changed files with 371 additions and 475 deletions

View File

@ -53,27 +53,12 @@ class Chunky_texture : Genode::Attached_ram_dataspace, public Genode::Texture<PT
public:
Chunky_texture(Genode::Ram_session &ram, Genode::Region_map &rm,
Chunky_texture(Genode::Ram_allocator &ram, Genode::Region_map &rm,
Genode::Surface_base::Area size)
:
Genode::Attached_ram_dataspace(ram, rm, _num_bytes(size)),
Genode::Texture<PT>(_pixel(), _alpha(size), size)
{ }
/**
* Constructor
*
* \deprecated
* \noapi
*
* This variant is solely meant to be used by deprecated functions.
* It will be removed if those functions are gone.
*/
Chunky_texture(Genode::Ram_session &ram, Genode::Surface_base::Area size) __attribute__((deprecated))
:
Genode::Attached_ram_dataspace(ram, *Genode::env_deprecated()->rm_session(), _num_bytes(size)),
Genode::Texture<PT>(_pixel(), _alpha(size), size)
{ }
};
#endif /* _INCLUDE__GEMS__CHUNKY_TEXTURE_H_ */

View File

@ -15,7 +15,7 @@
#define _INCLUDE__GEMS__NITPICKER_BUFFER_H_
/* Genode includes */
#include <ram_session/ram_session.h>
#include <base/ram_allocator.h>
#include <nitpicker_session/connection.h>
#include <base/attached_dataspace.h>
#include <base/attached_ram_dataspace.h>
@ -43,8 +43,8 @@ struct Nitpicker_buffer
typedef Genode::Attached_ram_dataspace Ram_ds;
Genode::Ram_session &ram;
Genode::Region_map &rm;
Genode::Ram_allocator &ram;
Genode::Region_map &rm;
Nitpicker::Connection &nitpicker;
@ -85,7 +85,7 @@ struct Nitpicker_buffer
* Constructor
*/
Nitpicker_buffer(Nitpicker::Connection &nitpicker, Area size,
Genode::Ram_session &ram, Genode::Region_map &rm)
Genode::Ram_allocator &ram, Genode::Region_map &rm)
:
ram(ram), rm(rm), nitpicker(nitpicker),
mode(Genode::max(1UL, size.w()), Genode::max(1UL, size.h()),
@ -94,20 +94,6 @@ struct Nitpicker_buffer
reset_surface();
}
/**
* Constructor
*
* \deprecated
* \noapi
*/
Nitpicker_buffer(Nitpicker::Connection &nitpicker, Area size,
Genode::Ram_session &ram) __attribute__((deprecated))
:
ram(ram), rm(*Genode::env_deprecated()->rm_session()), nitpicker(nitpicker),
mode(Genode::max(1UL, size.w()), Genode::max(1UL, size.h()),
nitpicker.mode().format())
{ }
/**
* Return size of virtual framebuffer
*/

View File

@ -45,9 +45,9 @@ class Png_image
return arg;
};
Genode::Ram_session &_ram;
Genode::Region_map &_rm;
Genode::Allocator &_alloc;
Genode::Ram_allocator &_ram;
Genode::Region_map &_rm;
Genode::Allocator &_alloc;
class Read_struct
{
@ -173,26 +173,12 @@ class Png_image
* \throw Read_struct_failed
* \throw Info_failed
*/
Png_image(Genode::Ram_session &ram, Genode::Region_map &rm,
Png_image(Genode::Ram_allocator &ram, Genode::Region_map &rm,
Genode::Allocator &alloc, void *data)
:
_ram(ram), _rm(rm), _alloc(alloc), _read_struct(data)
{ }
/**
* Constructor
*
* \deprecated
* \noapi
*/
Png_image(void *data) __attribute__((deprecated))
:
_ram(*Genode::env_deprecated()->ram_session()),
_rm(*Genode::env_deprecated()->rm_session()),
_alloc(*Genode::env_deprecated()->heap()),
_read_struct(data)
{ }
/**
* Return size of PNG image
*/

View File

@ -26,14 +26,18 @@ class Report_rom_slave : public Genode::Noncopyable
{
private:
class Policy
:
private Genode::Static_parent_services<Genode::Rom_session,
Genode::Cpu_session,
Genode::Pd_session,
Genode::Ram_session,
Genode::Log_session>,
public Genode::Slave::Policy
struct Policy_base
{
Genode::Static_parent_services<Genode::Rom_session,
Genode::Cpu_session,
Genode::Pd_session,
Genode::Log_session>
_parent_services;
Policy_base(Genode::Env &env) : _parent_services(env) { }
};
class Policy : Policy_base, public Genode::Slave::Policy
{
private:
@ -41,24 +45,20 @@ class Report_rom_slave : public Genode::Noncopyable
Genode::Root_capability _rom_root_cap;
bool _announced;
protected:
static Name _name() { return "report_rom"; }
static Genode::Ram_quota _quota() { return { 1024*1024 }; }
static Genode::Cap_quota _caps() { return { 75 }; }
public:
Policy(Genode::Rpc_entrypoint &ep,
Genode::Region_map &rm,
Genode::Pd_session &ref_pd,
Genode::Pd_session_capability ref_pd_cap,
Genode::Ram_session &ref_ram,
Genode::Ram_session_capability ref_ram_cap,
Policy(Genode::Env &env,
Genode::Rpc_entrypoint &ep,
const char *config)
:
Genode::Slave::Policy(_name(), _name(), *this, ep, rm,
ref_pd, ref_pd_cap, _caps(), _quota())
Policy_base(env),
Genode::Slave::Policy(env, _name(), _name(),
Policy_base::_parent_services,
ep, _caps(), _quota())
{
if (config)
configure(config);
@ -76,19 +76,12 @@ class Report_rom_slave : public Genode::Noncopyable
* Constructor
*
* \param ep entrypoint used for child thread
* \param ram RAM session used to allocate the configuration
* dataspace
*/
Report_rom_slave(Genode::Region_map &rm,
Genode::Pd_session &pd,
Genode::Pd_session_capability pd_cap,
Genode::Ram_session &ram,
Genode::Ram_session_capability ram_cap,
char const *config)
Report_rom_slave(Genode::Env &env, char const *config)
:
_ep(&pd, _ep_stack_size, "report_rom"),
_policy(_ep, rm, pd, pd_cap, ram, ram_cap, config),
_child(rm, _ep, _policy)
_ep(&env.pd(), _ep_stack_size, "report_rom"),
_policy(env, _ep, config),
_child(env.rm(), _ep, _policy)
{ }
Genode::Slave::Policy &policy() { return _policy; }

View File

@ -58,18 +58,6 @@ static void scale(Genode::Texture<PT> const &src, Genode::Texture<PT> &dst,
}
/*
* \deprecated
*/
template <typename PT>
static void scale(Genode::Texture<PT> const &src, Genode::Texture<PT> &dst) __attribute__ ((deprecated));
template <typename PT>
static void scale(Genode::Texture<PT> const &src, Genode::Texture<PT> &dst)
{
scale(src, dst, *Genode::env_deprecated()->heap());
}
template <typename SRC_PT, typename DST_PT>
static void convert_pixel_format(Genode::Texture<SRC_PT> const &src,
Genode::Texture<DST_PT> &dst,
@ -108,20 +96,4 @@ static void convert_pixel_format(Genode::Texture<SRC_PT> const &src,
alloc.free(row, row_num_bytes);
}
/*
* deprecated
*/
template <typename SRC_PT, typename DST_PT>
static void convert_pixel_format(Genode::Texture<SRC_PT> const &src,
Genode::Texture<DST_PT> &dst,
unsigned alpha) __attribute__((deprecated));
template <typename SRC_PT, typename DST_PT>
static void convert_pixel_format(Genode::Texture<SRC_PT> const &src,
Genode::Texture<DST_PT> &dst,
unsigned alpha)
{
convert_pixel_format(src, dst, alpha, *Genode::env_deprecated()->heap());
}
#endif /* _INCLUDE__GEMS__TEXTURE_UTILS_H_ */

View File

@ -1 +1 @@
2019-01-02 e565ac94881a3f40c03e13e2db9965360f6277bb
2019-01-20 c5ebfed2e8d91d7a1462e65cb832b5daa24db8cd

View File

@ -1 +1 @@
2019-01-13 6c5be1b6c948d0923456df9b31119e87b2e10d22
2019-01-20 929541cb5097e084d18f5f5dd24e0cf49599923d

View File

@ -1 +1 @@
2019-01-13 42c526209e1eb46f33ae9dc497ee6b6d91e30b8e
2019-01-20 da5fd0f48c66e68e850dc77b2e94b89a10a86d05

View File

@ -1 +1 @@
2019-01-13 19e0883b69673ecf033775cd127d40bfc1c13997
2019-01-19-b 546d94be3e5127a925e59a82ebc1043f250ab0aa

View File

@ -1 +1 @@
2019-01-13 49a6661cefac6aaa0087b8d2969b62aacd7a6f5f
2019-01-20 170001467dbeca318f758ed7274a6247f9d01866

View File

@ -1 +1 @@
2019-01-13 d23d2ab4ad486f72fe8e78786bfa9695bfbdda8d
2019-01-20 f30c43e1f1b349150711a1357dbcd2fd3233e3c1

View File

@ -1 +1 @@
2019-01-13 d866fa9f3545e8fd674b259854baffd31e074208
2019-01-20-a 6eed5cb491f02c2308f0a084363dcb9b6bf01625

View File

@ -1 +1 @@
2019-01-13 51bce6f7f3580912d2f31bafaa7671ad209734e8
2019-01-19-b 930fa22ed77135f767389d548667e13198b37743

View File

@ -1 +1 @@
2019-01-13 4aee51adcf3f2c9d4623714189302a8493967fbe
2019-01-19-b 996e2bfa79e3b40788b525f6784a3e31385613b4

View File

@ -1 +1 @@
2019-01-13 60231dc7f56f07135c0fd00d32974fa5a5282c93
2019-01-20 2da6488a81ffeae411a73cb4d9267837ce198286

View File

@ -1 +1 @@
2019-01-13 778c0fdd683db79df583c53b62e635f774e3d413
2019-01-20 f857608bdf30f30df0f6b5260d587d0ae31886f6

View File

@ -242,11 +242,10 @@ void Backdrop::Main::_apply_image(Xml_node operation)
return;
}
char png_file_name[256];
png_file_name[0] = 0;
operation.attribute("png").value(png_file_name, sizeof(png_file_name));
typedef String<256> File_name;
File_name const png_file_name = operation.attribute_value("png", File_name());
File file(png_file_name, _heap);
File file(png_file_name.string(), _heap);
Anchor anchor(operation);
@ -277,7 +276,7 @@ void Backdrop::Main::_apply_image(Xml_node operation)
bool const tiled = operation.attribute_value("tiled", false);
unsigned alpha = Decorator::attribute(operation, "alpha", 256U);
unsigned alpha = operation.attribute_value("alpha", 256U);
/* obtain texture containing the pixels of the PNG image */
Texture<Pixel_rgb888> *png_texture = png_image.texture<Pixel_rgb888>();
@ -313,7 +312,7 @@ void Backdrop::Main::_apply_fill(Xml_node operation)
/* create texture with down-sampled scaled image */
typedef Pixel_rgb565 PT;
Color const color = Decorator::attribute(operation, "color", Color(0, 0, 0));
Color const color = operation.attribute_value("color", Color(0, 0, 0));
_buffer->apply_to_surface<PT>([&] (Surface<PT> &surface) {
Box_painter::paint(surface, Surface_base::Rect(Surface_base::Point(0, 0),

View File

@ -131,8 +131,8 @@ class Cpu_load_display::Cpu : public Genode::List<Cpu>::Element
{
unsigned long const subject_id = subject.attribute_value("id", 0UL);
char label[sizeof(Timeline::Label)];
subject.attribute("label").value(label, sizeof(label));
Timeline::Label const label =
subject.attribute_value("label", Timeline::Label());
for (Timeline *t = _timelines.first(); t; t = t->next()) {
if (t->has_subject_id(subject_id))
@ -140,7 +140,7 @@ class Cpu_load_display::Cpu : public Genode::List<Cpu>::Element
}
/* add new timeline */
Timeline *t = new (_heap) Timeline(subject_id, Genode::Cstring(label));
Timeline *t = new (_heap) Timeline(subject_id, label);
_timelines.insert(t);
return t;
}

View File

@ -35,7 +35,7 @@ namespace Decorator {
};
Genode::Texture_base const &texture_by_id(Texture_id,
Genode::Ram_session &,
Genode::Ram_allocator &,
Genode::Region_map &);
class Canvas_base;
@ -62,13 +62,13 @@ class Decorator::Canvas : public Decorator::Canvas_base
{
private:
Genode::Ram_session &_ram;
Genode::Region_map &_rm;
Genode::Surface<PT> _surface;
Genode::Ram_allocator &_ram;
Genode::Region_map &_rm;
Genode::Surface<PT> _surface;
public:
Canvas(PT *base, Area size, Genode::Ram_session &ram, Genode::Region_map &rm)
Canvas(PT *base, Area size, Genode::Ram_allocator &ram, Genode::Region_map &rm)
: _ram(ram), _rm(rm), _surface(base, size) { }
Rect clip() const override { return _surface.clip(); }

View File

@ -186,8 +186,8 @@ struct Decorator::Main : Window_factory_base
for (unsigned retry = 0 ; retry < 2; retry ++) {
try {
return new (_heap)
Window(attribute(window_node, "id", 0UL), _nitpicker,
_animator, _decorator_config);
Window(window_node.attribute_value("id", 0UL),
_nitpicker, _animator, _decorator_config);
}
catch (Genode::Out_of_ram) {
Genode::log("Handle Out_of_ram of nitpicker session - upgrade by 8K");

View File

@ -33,7 +33,7 @@ class Icon_texture : public Chunky_texture<PT>
*/
enum { WIDTH = 14, HEIGHT = 14 };
Icon_texture(Ram_session &ram, Region_map &rm,
Icon_texture(Ram_allocator &ram, Region_map &rm,
unsigned char rgba_data[])
:
Chunky_texture<PT>(ram, rm, Surface_base::Area(WIDTH, HEIGHT))
@ -60,7 +60,7 @@ extern unsigned char _binary_windowed_rgba_start[];
* Return texture for the specified texture ID
*/
Texture_base const &
Decorator::texture_by_id(Texture_id id, Ram_session &ram, Region_map &rm)
Decorator::texture_by_id(Texture_id id, Ram_allocator &ram, Region_map &rm)
{
static Icon_texture<Pixel_rgb565> const icons[4] {
{ ram, rm, _binary_closer_rgba_start },

View File

@ -216,8 +216,8 @@ bool Decorator::Window::update(Genode::Xml_node window_node)
_focused = window_node.attribute_value( "focused", false);
_has_alpha = window_node.attribute_value("has_alpha", false);
Window_title title = Decorator::string_attribute(window_node, "title",
Window_title("<untitled>"));
Window_title const title =
window_node.attribute_value("title", Window_title("<untitled>"));
updated |= !(title == _title);
_title = title;

View File

@ -196,7 +196,8 @@ void Child::_gen_routes(Xml_generator &xml,
*/
if (_start_xml->xml().has_sub_node("route")) {
Xml_node const route = _start_xml->xml().sub_node("route");
xml.append(route.content_base(), route.content_size());
route.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
}
/*
@ -204,7 +205,8 @@ void Child::_gen_routes(Xml_generator &xml,
*/
if (_launcher_xml.constructed() && _launcher_xml->xml().has_sub_node("route")) {
Xml_node const route = _launcher_xml->xml().sub_node("route");
xml.append(route.content_base(), route.content_size());
route.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
}
/**
@ -255,7 +257,8 @@ void Child::_gen_routes(Xml_generator &xml,
/*
* Add common routes as defined in our config.
*/
xml.append(common.content_base(), common.content_size());
common.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
/*
* Add ROM routing rule with the label rewritten to the path within the
@ -357,7 +360,8 @@ void Child::_gen_copy_of_sub_node(Xml_generator &xml,
return;
Xml_node const sub_node = from_node.sub_node(sub_node_type.string());
xml.append(sub_node.addr(), sub_node.size());
sub_node.with_raw_node([&] (char const *start, size_t length) {
xml.append(start, length); });
}
@ -592,19 +596,10 @@ void Child::log_session_write(Log_event::Line const &log_line)
void Child::apply_config(Xml_node start_node)
{
if (_skip) {
return; }
if (_skip)
return;
/*
* String-compare new with current start node to quicky skip
* the start nodes that have not changed.
*/
bool const start_node_changed =
(start_node.size() != _start_xml->xml().size()) ||
(strcmp(start_node.addr(), _start_xml->xml().addr(),
start_node.size()) != 0);
if (!start_node_changed)
if (!start_node.differs_from(_start_xml->xml()))
return;
Archive::Path const old_pkg_path = _config_pkg_path();
@ -657,8 +652,8 @@ void Child::apply_blueprint(Xml_node pkg)
void Child::apply_launcher(Launcher_name const &name,
Xml_node launcher)
{
if (_skip) {
return; }
if (_skip)
return;
if (!_defined_by_launcher())
return;
@ -666,15 +661,8 @@ void Child::apply_launcher(Launcher_name const &name,
if (_launcher_name() != name)
return;
if (_launcher_xml.constructed()) {
bool const launcher_changed =
(launcher.size() != _launcher_xml->xml().size()) ||
(strcmp(launcher.addr(), _launcher_xml->xml().addr(),
launcher.size()) != 0);
if (!launcher_changed)
return;
}
if (_launcher_xml.constructed() && !launcher.differs_from(_launcher_xml->xml()))
return;
_launcher_xml.construct(_alloc, launcher);
@ -887,14 +875,30 @@ void Timeout_event::_handle_timeout(Duration)
** Log_event **
***************/
static char const *xml_content_base(Xml_node node)
{
char const *result = nullptr;
node.with_raw_content([&] (char const *start, size_t) { result = start; });
return result;
}
static size_t xml_content_size(Xml_node node)
{
size_t result = 0;
node.with_raw_content([&] (char const *, size_t length) { result = length; });
return result;
}
Log_event::Log_event(Xml_node const &xml)
:
Event { xml, Type::LOG },
_base { xml.content_base() },
_size { xml.content_size() },
_remaining_base { xml.content_base() },
_remaining_end { _remaining_base + xml.content_size() },
_reset_to { xml.content_base() }
_base { xml_content_base(xml) },
_size { xml_content_size(xml) },
_remaining_base { xml_content_base(xml) },
_remaining_end { _remaining_base + xml_content_size(xml) },
_reset_to { xml_content_base(xml) }
{ }

View File

@ -147,7 +147,8 @@ struct Depot_deploy::Main
bool finished;
_init_config_reporter.generate([&] (Xml_generator &xml) {
Xml_node static_config = config.sub_node("static");
xml.append(static_config.content_base(), static_config.content_size());
static_config.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
Child::Depot_rom_server const parent { };
finished = _children.gen_start_nodes(xml, config.sub_node("common_routes"),
parent, parent);
@ -189,9 +190,9 @@ struct Depot_deploy::Main
log("\n--- Finished after ", time_sec + previous_time_sec, ".", time_ms < 10 ? "00" : time_ms < 100 ? "0" : "", time_ms, " sec ---\n");
if (config.has_sub_node("previous-results")) {
Xml_node const previous_results = config.sub_node("previous-results");
if (previous_results.content_size()) {
log(Cstring(previous_results.content_base(), previous_results.content_size()));
}
previous_results.with_raw_content([&] (char const *start, size_t length) {
if (length)
log(Cstring(start, length)); });
}
_children.print_conclusion();
log("");

View File

@ -132,7 +132,8 @@ class Depot_deploy::Child : public List_model<Child>::Element
return;
Xml_node const sub_node = from_node.sub_node(sub_node_type.string());
xml.append(sub_node.addr(), sub_node.size());
sub_node.with_raw_node([&] (char const *start, size_t length) {
xml.append(start, length); });
}
public:
@ -148,16 +149,7 @@ class Depot_deploy::Child : public List_model<Child>::Element
void apply_config(Xml_node start_node)
{
/*
* String-compare new with current start node to quicky skip
* the start nodes that have not changed.
*/
bool const start_node_changed =
(start_node.size() != _start_xml->xml().size()) ||
(strcmp(start_node.addr(), _start_xml->xml().addr(),
start_node.size()) != 0);
if (!start_node_changed)
if (!start_node.differs_from(_start_xml->xml()))
return;
Archive::Path const old_pkg_path = _config_pkg_path();
@ -205,15 +197,8 @@ class Depot_deploy::Child : public List_model<Child>::Element
if (_launcher_name() != name)
return;
if (_launcher_xml.constructed()) {
bool const launcher_changed =
(launcher.size() != _launcher_xml->xml().size()) ||
(strcmp(launcher.addr(), _launcher_xml->xml().addr(),
launcher.size()) != 0);
if (!launcher_changed)
return;
}
if (_launcher_xml.constructed() && !launcher.differs_from(_launcher_xml->xml()))
return;
_launcher_xml.construct(_alloc, launcher);
@ -426,7 +411,8 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common,
*/
if (_start_xml->xml().has_sub_node("route")) {
Xml_node const route = _start_xml->xml().sub_node("route");
xml.append(route.content_base(), route.content_size());
route.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
}
/*
@ -434,7 +420,8 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common,
*/
if (_launcher_xml.constructed() && _launcher_xml->xml().has_sub_node("route")) {
Xml_node const route = _launcher_xml->xml().sub_node("route");
xml.append(route.content_base(), route.content_size());
route.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
}
/**
@ -485,7 +472,8 @@ void Depot_deploy::Child::_gen_routes(Xml_generator &xml, Xml_node common,
/*
* Add common routes as defined in our config.
*/
xml.append(common.content_base(), common.content_size());
common.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
/*
* Add ROM routing rule with the label rewritten to the path within the

View File

@ -62,7 +62,8 @@ struct Depot_deploy::Main
/* generate init config containing all configured start nodes */
_init_config_reporter.generate([&] (Xml_generator &xml) {
Xml_node static_config = config.sub_node("static");
xml.append(static_config.content_base(), static_config.content_size());
static_config.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
Child::Depot_rom_server const parent { };
_children.gen_start_nodes(xml, config.sub_node("common_routes"),
parent, parent);

View File

@ -472,7 +472,8 @@ void Depot_query::Main::_query_blueprint(Directory::Path const &pkg_path, Xml_ge
String<160> comment("\n\n<!-- content of '", pkg_path, "/runtime' -->\n");
xml.append(comment.string());
xml.append(node.addr(), node.size());
node.with_raw_node([&] (char const *start, size_t length) {
xml.append(start, length); });
xml.append("\n");
});
});

View File

@ -669,7 +669,8 @@ void Driver_manager::Main::_generate_usb_drv_config(Reporter &usb_drv_config,
xml.node("report", [&] () { xml.attribute("devices", true); });
/* incorporate user-managed policy */
xml.append(policy.content_base(), policy.content_size());
policy.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
devices.for_each_sub_node("device", [&] (Xml_node device) {

View File

@ -48,7 +48,8 @@ struct Fs_query::Watched_file
if (!node.has_type("empty")) {
xml.attribute("xml", "yes");
xml.append("\n");
xml.append(node.addr(), node.size());
node.with_raw_node([&] (char const *start, size_t length) {
xml.append(start, length); });
content_is_xml = true;
}
});

View File

@ -150,8 +150,7 @@ class Launcher::Context_dialog : Input_event_handler, Dialog_generator,
for (Element *e = _elements.first(); e; e = e->next()) {
Label const label =
Decorator::string_attribute(button, "name", Label(""));
Label const label = button.attribute_value("name", Label(""));
if (e->label == label)
e->hovered = true;

View File

@ -187,7 +187,7 @@ class Launcher::Fading_dialog : private Input_event_handler
_hover_rom(report_rom_slave.policy(), Slave::Args("label=", hover_name)),
_hover_report(report_rom_slave.policy(),
Slave::Args("label=", hover_name, ", buffer_size=4096")),
_dialog_reporter(env.rm(), "dialog", _dialog_report),
_dialog_reporter(env.rm(), "dialog", _dialog_report.rpc_cap()),
_dialog_input_event_handler(input_event_handler),
_hover_handler(hover_handler),
_dialog_generator(dialog_generator),
@ -196,12 +196,11 @@ class Launcher::Fading_dialog : private Input_event_handler
_fader_slave_ep(&env.pd(), _fader_slave_ep_stack_size, "nit_fader"),
_nitpicker_connection(env, "menu"),
_nitpicker_session(env, _nitpicker_connection, env.ep(), _fader_slave_ep, *this),
_nit_fader_slave(_fader_slave_ep, env.rm(), env.pd(), env.pd_session_cap(),
_nitpicker_service),
_nit_fader_slave(env, _fader_slave_ep, _nitpicker_service),
_nit_fader_connection(env.rm(), _nit_fader_slave.policy(), Slave::Args("label=menu")),
_menu_view_slave(env.rm(), env.pd(), env.pd_session_cap(),
_nit_fader_connection,
_dialog_rom, _hover_report, initial_position)
_menu_view_slave(env, _nit_fader_connection.rpc_cap(),
_dialog_rom.rpc_cap(), _hover_report.rpc_cap(),
initial_position)
{
Rom_session_client(_hover_rom).sigh(_hover_update_handler);
}

View File

@ -42,9 +42,7 @@ struct Launcher::Main
" <policy label=\"context_hover\" report=\"context_hover\"/>"
"</config>";
Report_rom_slave _report_rom_slave {
_env.rm(), _env.pd(), _env.pd_session_cap(), _env.ram(), _env.ram_session_cap(),
_report_rom_config };
Report_rom_slave _report_rom_slave { _env, _report_rom_config };
/**
* Nitpicker session used to perform session-control operations on the

View File

@ -56,8 +56,8 @@ class Launcher::Menu_dialog : Input_event_handler, Dialog_generator,
Element(Xml_node node)
:
label(Decorator::string_attribute(node, "name", Label(""))),
title(Decorator::string_attribute(node, "title", Title(label.string())))
label(node.attribute_value("name", Label(""))),
title(node.attribute_value("title", Title(label.string())))
{ }
};
@ -163,8 +163,7 @@ class Launcher::Menu_dialog : Input_event_handler, Dialog_generator,
for (Element *e = _elements.first(); e; e = e->next()) {
Label const label =
Decorator::string_attribute(button, "name", Label(""));
Label const label = button.attribute_value("name", Label(""));
if (e->label == label) {
e->hovered = true;

View File

@ -37,16 +37,20 @@ class Launcher::Menu_view_slave
private:
class Policy
:
private Genode::Static_parent_services<Genode::Cpu_session,
Genode::Pd_session,
Genode::Ram_session,
Genode::Rom_session,
Genode::Log_session,
File_system::Session,
Timer::Session>,
public Genode::Slave::Policy
struct Policy_base
{
Genode::Static_parent_services<Genode::Cpu_session,
Genode::Pd_session,
Genode::Rom_session,
Genode::Log_session,
File_system::Session,
Timer::Session>
_parent_services;
Policy_base(Env &env) : _parent_services(env) { }
};
class Policy : Policy_base, public Genode::Slave::Policy
{
private:
@ -80,20 +84,35 @@ class Launcher::Menu_view_slave
static Genode::Ram_quota _quota() { return { 6*1024*1024 }; }
static Genode::Cap_quota _caps() { return { 100 }; }
Service &_matching_service(Genode::Service::Name const &service,
Genode::Session_label const &label)
{
if (service == "Nitpicker")
return _nitpicker.service();
if ((service == "ROM") && (label == "menu_view -> dialog"))
return _dialog_rom.service();
if ((service == "Report") && (label == "menu_view -> hover"))
return _hover_report.service();
throw Genode::Service_denied();
}
public:
Policy(Genode::Rpc_entrypoint &ep,
Genode::Region_map &rm,
Genode::Pd_session &ref_pd,
Genode::Pd_session_capability ref_pd_cap,
Policy(Genode::Env &env,
Genode::Rpc_entrypoint &ep,
Capability<Nitpicker::Session> nitpicker_session,
Capability<Rom_session> dialog_rom_session,
Capability<Report::Session> hover_report_session,
Position position)
:
Genode::Slave::Policy(_name(), _name(), *this, ep, rm,
ref_pd, ref_pd_cap, _caps(), _quota()),
_nitpicker(rm, nitpicker_session),
Policy_base(env),
Genode::Slave::Policy(env, _name(), _name(),
Policy_base::_parent_services,
ep, _caps(), _quota()),
_nitpicker(env.rm(), nitpicker_session),
_dialog_rom(dialog_rom_session),
_hover_report(hover_report_session),
_position(position)
@ -103,21 +122,17 @@ class Launcher::Menu_view_slave
void position(Position pos) { _configure(pos); }
Genode::Service &resolve_session_request(Genode::Service::Name const &service,
Genode::Session_state::Args const &args) override
Route resolve_session_request(Genode::Service::Name const &name,
Genode::Session_label const &label) override
{
if (service == "Nitpicker")
return _nitpicker.service();
try {
return Route { .service = _matching_service(name, label),
.label = label,
.diag = Genode::Session::Diag() };
}
catch (Genode::Service_denied) { }
Genode::Session_label const label(label_from_args(args.string()));
if ((service == "ROM") && (label == "menu_view -> dialog"))
return _dialog_rom.service();
if ((service == "Report") && (label == "menu_view -> hover"))
return _hover_report.service();
return Genode::Slave::Policy::resolve_session_request(service, args);
return Genode::Slave::Policy::resolve_session_request(name, label);
}
};
@ -131,19 +146,17 @@ class Launcher::Menu_view_slave
/**
* Constructor
*/
Menu_view_slave(Genode::Region_map &rm,
Genode::Pd_session &ref_pd,
Genode::Pd_session_capability ref_pd_cap,
Menu_view_slave(Genode::Env &env,
Capability<Nitpicker::Session> nitpicker_session,
Capability<Rom_session> dialog_rom_session,
Capability<Report::Session> hover_report_session,
Position initial_position)
:
_ep(&ref_pd, _ep_stack_size, "nit_fader"),
_policy(_ep, rm, ref_pd, ref_pd_cap,
_ep(&env.pd(), _ep_stack_size, "nit_fader"),
_policy(env, _ep,
nitpicker_session, dialog_rom_session,
hover_report_session, initial_position),
_child(rm, _ep, _policy)
_child(env.rm(), _ep, _policy)
{ }
void position(Position position) { _policy.position(position); }

View File

@ -29,15 +29,19 @@ class Launcher::Nit_fader_slave
{
private:
class Policy
:
private Genode::Static_parent_services<Genode::Ram_session,
Genode::Cpu_session,
Genode::Pd_session,
Genode::Rom_session,
Genode::Log_session,
Timer::Session>,
public Slave::Policy
struct Policy_base
{
Genode::Static_parent_services<Genode::Cpu_session,
Genode::Pd_session,
Genode::Rom_session,
Genode::Log_session,
Timer::Session>
_parent_services;
Policy_base(Env &env) : _parent_services(env) { }
};
class Policy : Policy_base, public Slave::Policy
{
private:
@ -51,14 +55,14 @@ class Launcher::Nit_fader_slave
public:
Policy(Rpc_entrypoint &ep,
Region_map &rm,
Pd_session &ref_pd,
Pd_session_capability ref_pd_cap,
Genode::Service &nitpicker_service)
Policy(Env &env,
Rpc_entrypoint &ep,
Genode::Service &nitpicker_service)
:
Genode::Slave::Policy(_name(), _name(), *this, ep, rm,
ref_pd, ref_pd_cap, _caps(), _quota()),
Policy_base(env),
Genode::Slave::Policy(env, _name(), _name(),
Policy_base::_parent_services,
ep, _caps(), _quota()),
_nitpicker_service(nitpicker_service)
{
visible(false);
@ -72,13 +76,15 @@ class Launcher::Nit_fader_slave
configure(config, strlen(config) + 1);
}
Genode::Service &resolve_session_request(Genode::Service::Name const &service,
Genode::Session_state::Args const &args) override
Route resolve_session_request(Genode::Service::Name const &service,
Genode::Session_label const &label) override
{
if (service == Nitpicker::Session::service_name())
return _nitpicker_service;
return Route { .service = _nitpicker_service,
.label = label,
.diag = Session::Diag() };
return Genode::Slave::Policy::resolve_session_request(service, args);
return Genode::Slave::Policy::resolve_session_request(service, label);
}
};
@ -90,18 +96,14 @@ class Launcher::Nit_fader_slave
/**
* Constructor
*
* \param ep entrypoint used for nitpicker child thread
* \param ref_ram RAM session used to allocate the configuration
* dataspace and child memory
* \param ep entrypoint used for nitpicker child thread
*/
Nit_fader_slave(Rpc_entrypoint &ep,
Genode::Region_map &rm,
Pd_session &ref_pd,
Pd_session_capability ref_pd_cap,
Genode::Service &nitpicker_service)
Nit_fader_slave(Env &env,
Rpc_entrypoint &ep,
Genode::Service &nitpicker_service)
:
_policy(ep, rm, ref_pd, ref_pd_cap, nitpicker_service),
_child(rm, ep, _policy)
_policy(env, ep, nitpicker_service),
_child(env.rm(), ep, _policy)
{
visible(false);
}

View File

@ -323,8 +323,7 @@ class Launcher::Panel_dialog : Input_event_handler, Dialog_generator,
for (Element *e = _elements.first(); e; e = e->next()) {
Label const label =
Decorator::string_attribute(button, "name", Label(""));
Label const label = button.attribute_value("name", Label(""));
if (e->label == label) {
e->hovered = true;

View File

@ -24,7 +24,6 @@
namespace Launcher {
class Subsystem_manager;
using Decorator::string_attribute;
using Cli_monitor::Ram;
using namespace Genode;
}
@ -107,8 +106,8 @@ class Launcher::Subsystem_manager
Genode::Signal_context_capability _exited_child_sig_cap;
Ram _ram { _env.ram(),
_env.ram_session_cap(),
Ram _ram { _env.pd(),
_env.pd_session_cap(),
_ram_preservation,
_yield_broadcast_handler,
_resource_avail_handler };
@ -116,8 +115,8 @@ class Launcher::Subsystem_manager
static Child::Binary_name _binary_name(Xml_node subsystem)
{
try {
return string_attribute(subsystem.sub_node("binary"),
"name", Child::Binary_name(""));
return subsystem.sub_node("binary")
.attribute_value("name", Child::Binary_name());
} catch (Xml_node::Nonexistent_sub_node) {
Genode::error("missing <binary> definition");
throw Invalid_config();
@ -133,10 +132,10 @@ class Launcher::Subsystem_manager
subsystem.for_each_sub_node("resource", [&] (Xml_node rsc) {
if (rsc.attribute("name").has_value("RAM")) {
rsc.attribute("quantum").value(&quantum);
rsc.attribute("quantum").value(quantum);
if (rsc.has_attribute("limit"))
rsc.attribute("limit").value(&limit);
rsc.attribute("limit").value(limit);
}
});
} catch (...) {
@ -178,7 +177,7 @@ class Launcher::Subsystem_manager
{
Child::Binary_name const binary_name = _binary_name(subsystem);
Label const label = string_attribute(subsystem, "name", Label(""));
Label const label = subsystem.attribute_value("name", Label(""));
Ram_config const ram_config = _ram_config(subsystem);
@ -186,33 +185,38 @@ class Launcher::Subsystem_manager
try {
Child *child = new (_heap)
Child(_ram, _heap, label, binary_name.string(),
Child(_env, _ram, _heap, label, binary_name.string(),
_env.pd(),
_env.pd_session_cap(),
_env.ram(),
_env.ram_session_cap(),
_env.rm(),
_caps_config(subsystem),
ram_config.quantum, ram_config.limit,
_yield_broadcast_handler,
_exited_child_sig_cap);
auto configure_with_xml = [&] (Xml_node config)
{
config.with_raw_node([&] (char const *start, size_t length) {
child->configure(start, length); });
};
/* configure child */
try {
if (subsystem.has_sub_node("configfile")) {
Genode::String<96> name;
Xml_node node = subsystem.sub_node("configfile");
Xml_attribute attr = node.attribute("name");
attr.value(&name);
Xml_node const node = subsystem.sub_node("configfile");
typedef Genode::String<96> Name;
Name const name = node.attribute_value("name", Name());
Attached_rom_dataspace rom(_env, name.string());
Xml_node config_node = rom.xml();
child->configure(config_node.addr(), config_node.size());
configure_with_xml(rom.xml());
} else if (subsystem.has_sub_node("config")) {
configure_with_xml(subsystem.sub_node("config"));
} else {
Xml_node config_node = subsystem.sub_node("config");
child->configure(config_node.addr(), config_node.size());
configure_with_xml(Xml_node("<config/>"));
}
} catch (...) { }
} catch (...) { warning("failed to configure child ", label); }
_children.insert(child);

View File

@ -36,7 +36,7 @@ struct Menu_view::Label_widget : Widget
void update(Xml_node node)
{
font = _factory.styles.font(node);
text = Decorator::string_attribute(node, "text", Text(""));
text = node.attribute_value("text", Text(""));
}
Area min_size() const override

View File

@ -48,7 +48,7 @@ class Menu_view::Style_database
*
* \throw Reading_failed
*/
Texture_entry(Ram_session &ram, Region_map &rm,
Texture_entry(Ram_allocator &ram, Region_map &rm,
Allocator &alloc, Path const &path)
:
path(path),
@ -82,7 +82,7 @@ class Menu_view::Style_database
catch (...) { throw Reading_failed(); }
};
Ram_session &_ram;
Ram_allocator &_ram;
Region_map &_rm;
Allocator &_alloc;
Directory const &_fonts_dir;
@ -118,7 +118,7 @@ class Menu_view::Style_database
public:
Style_database(Ram_session &ram, Region_map &rm, Allocator &alloc,
Style_database(Ram_allocator &ram, Region_map &rm, Allocator &alloc,
Directory const &fonts_dir)
:
_ram(ram), _rm(rm), _alloc(alloc), _fonts_dir(fonts_dir)

View File

@ -83,17 +83,9 @@ class Menu_view::Widget : List_model<Widget>::Element
bool valid() const { return value != 0; }
};
static Type_name node_type_name(Xml_node node)
{
char type[NAME_MAX_LEN];
node.type_name(type, sizeof(type));
return Type_name(Cstring(type));
}
static Name node_name(Xml_node node)
{
return Decorator::string_attribute(node, "name", node_type_name(node));
return node.attribute_value("name", Name(node.type()));
}
private:
@ -204,7 +196,7 @@ class Menu_view::Widget : List_model<Widget>::Element
Widget(Widget_factory &factory, Xml_node node, Unique_id unique_id)
:
_type_name(node_type_name(node)),
_type_name(node.type()),
_name(node_name(node)),
_unique_id(unique_id),
_factory(factory)

View File

@ -177,7 +177,8 @@ void Sculpt::Deploy::gen_runtime_start_nodes(Xml_generator &xml) const
/* insert content of '<static>' node as is */
if (managed_deploy.has_sub_node("static")) {
Xml_node static_config = managed_deploy.sub_node("static");
xml.append(static_config.content_base(), static_config.content_size());
static_config.with_raw_content([&] (char const *start, size_t length) {
xml.append(start, length); });
}
/* generate start nodes for deployed packages */

View File

@ -81,7 +81,8 @@ struct Sculpt::Deploy
auto append_xml_node = [&] (Xml_node node) {
xml.append("\t");
xml.append(node.addr(), node.size());
node.with_raw_node([&] (char const *start, size_t length) {
xml.append(start, length); });
xml.append("\n");
};

View File

@ -166,8 +166,8 @@ struct Decorator::Main : Window_factory_base
Window_base *create(Xml_node window_node) override
{
return new (_heap)
Window(_env, attribute(window_node, "id", 0UL), _nitpicker, _animator,
_theme, _decorator_config);
Window(_env, window_node.attribute_value("id", 0UL),
_nitpicker, _animator, _theme, _decorator_config);
}
/**

View File

@ -39,7 +39,7 @@ struct Texture_from_png_file
Png_image png_image;
Texture &texture { *png_image.texture<Genode::Pixel_rgb888>() };
Texture_from_png_file(Genode::Ram_session &ram, Genode::Region_map &rm,
Texture_from_png_file(Genode::Ram_allocator &ram, Genode::Region_map &rm,
Genode::Allocator &alloc, char const *path)
:
png_file(path, alloc), png_image(ram, rm, alloc, png_file.data<void>())
@ -48,7 +48,7 @@ struct Texture_from_png_file
static Genode::Texture<Genode::Pixel_rgb888> const &
texture_by_id(Genode::Ram_session &ram, Genode::Region_map &rm,
texture_by_id(Genode::Ram_allocator &ram, Genode::Region_map &rm,
Genode::Allocator &alloc, Texture_id texture_id)
{
if (texture_id == TEXTURE_ID_DEFAULT) {
@ -72,7 +72,7 @@ texture_by_id(Genode::Ram_session &ram, Genode::Region_map &rm,
static Genode::Texture<Genode::Pixel_rgb888> const &
texture_by_element_type(Genode::Ram_session &ram, Genode::Region_map &rm,
texture_by_element_type(Genode::Ram_allocator &ram, Genode::Region_map &rm,
Genode::Allocator &alloc, Decorator::Theme::Element_type type)
{
switch (type) {
@ -157,7 +157,7 @@ Decorator::Rect Decorator::Theme::title_geometry() const
static Decorator::Rect
element_geometry(Genode::Ram_session &ram, Genode::Region_map &rm,
element_geometry(Genode::Ram_allocator &ram, Genode::Region_map &rm,
Genode::Allocator &alloc, char const *sub_node_type,
Texture_id texture_id)
{

View File

@ -41,9 +41,9 @@ class Decorator::Theme
{
private:
Genode::Ram_session &_ram;
Genode::Region_map &_rm;
Genode::Allocator &_alloc;
Genode::Ram_allocator &_ram;
Genode::Region_map &_rm;
Genode::Allocator &_alloc;
public:
@ -56,7 +56,7 @@ class Decorator::Theme
enum Element_type { ELEMENT_TYPE_CLOSER, ELEMENT_TYPE_MAXIMIZER };
Theme(Genode::Ram_session &ram, Genode::Region_map &rm, Genode::Allocator &alloc)
Theme(Genode::Ram_allocator &ram, Genode::Region_map &rm, Genode::Allocator &alloc)
: _ram(ram), _rm(rm), _alloc(alloc) { }
Area background_size() const;

View File

@ -15,7 +15,7 @@
#define _WINDOW_H_
/* Genode includes */
#include <ram_session/ram_session.h>
#include <base/ram_allocator.h>
#include <decorator/window.h>
#include <nitpicker_session/connection.h>
#include <base/attached_dataspace.h>

View File

@ -554,7 +554,7 @@ void Window_layouter::Main::_handle_hover()
try {
Xml_node const hover_window_xml = _hover.xml().sub_node("window");
_user_state.hover(attribute(hover_window_xml, "id", 0UL),
_user_state.hover(hover_window_xml.attribute_value("id", 0UL),
_element_from_hover_model(hover_window_xml));
}

View File

@ -226,7 +226,8 @@ class Window_layouter::Target_list
return;
_rules->xml().for_each_sub_node("screen", [&] (Xml_node screen) {
xml.append(screen.addr(), screen.size());
screen.with_raw_node([&] (char const *start, size_t length) {
xml.append(start, length); });
xml.append("\n");
});
}

View File

@ -26,8 +26,6 @@ namespace Window_layouter {
typedef Decorator::Area Area;
typedef Decorator::Rect Rect;
using Decorator::attribute;
using Decorator::string_attribute;
using Decorator::area_attribute;
using Decorator::point_attribute;

View File

@ -87,10 +87,10 @@ class Window_layouter::Window_list
void update_element(Window &win, Xml_node node)
{
win.client_size(area_attribute(node));
win.title(string_attribute(node, "title", Window::Title("")));
win.has_alpha( node.attribute_value("has_alpha", false));
win.hidden( node.attribute_value("hidden", false));
win.resizeable(node.attribute_value("resizeable", false));
win.title (node.attribute_value("title", Window::Title("")));
win.has_alpha (node.attribute_value("has_alpha", false));
win.hidden (node.attribute_value("hidden", false));
win.resizeable (node.attribute_value("resizeable", false));
}
static bool element_matches_xml_node(Window const &elem, Xml_node node)

View File

@ -68,7 +68,7 @@ class Cpu_sampler::Cpu_thread_component : public Rpc_object<Cpu_thread>
Cpu_session_component const *cpu_session_component() const
{ return &_cpu_session_component; }
Thread_capability parent_thread() { return _parent_cpu_thread; }
Thread_capability parent_thread() { return _parent_cpu_thread.rpc_cap(); }
Session_label &label() { return _label; }
void take_sample();

View File

@ -237,29 +237,25 @@ namespace Terminal {
Session_component *_create_session(const char *args)
{
Genode::size_t io_buffer_size = 4096;
using namespace Genode;
try {
Genode::Session_label label = Genode::label_from_args(args);
Genode::Session_policy policy(label, _config);
Session_label const label = label_from_args(args);
Session_policy const policy(label, _config);
char filename[256];
policy.attribute("filename").value(filename, sizeof(filename));
if (policy.has_attribute("io_buffer_size"))
policy.attribute("io_buffer_size").value(&io_buffer_size);
return new (md_alloc())
Session_component(_env, io_buffer_size, filename);
}
catch (Genode::Xml_node::Nonexistent_attribute) {
Genode::error("missing \"filename\" attribute in policy definition");
throw Genode::Service_denied();
}
catch (Genode::Session_policy::No_policy_defined) {
Genode::error("invalid session request, no matching policy");
throw Genode::Service_denied();
if (!policy.has_attribute("filename")) {
error("missing \"filename\" attribute in policy definition");
throw Service_denied();
}
typedef String<256> File_name;
File_name const file_name =
policy.attribute_value("filename", File_name());
size_t const io_buffer_size =
policy.attribute_value("io_buffer_size", 4096UL);
return new (md_alloc())
Session_component(_env, io_buffer_size, file_name.string());
}
public:

View File

@ -177,7 +177,7 @@ void Http::do_read(void * buf, size_t size)
}
Http::Http(Genode::Heap &heap, ::String &uri)
Http::Http(Genode::Heap &heap, ::String const &uri)
: _heap(heap), _port((char *)"80")
{
_heap.alloc(HTTP_BUF, (void**)&_http_buf);
@ -205,7 +205,7 @@ Http::~Http()
}
void Http::parse_uri(::String & u)
void Http::parse_uri(::String const &u)
{
/* strip possible http prefix */
const char *http = "http://";

View File

@ -56,7 +56,7 @@ class Http
/*
* Set URI of remote file
*/
void parse_uri(::String &uri);
void parse_uri(::String const &uri);
/*
* Resolve host
@ -83,7 +83,7 @@ class Http
/*
* Constructor (default host port is 80
*/
Http(Genode::Heap &heap, ::String &uri);
Http(Genode::Heap &heap, ::String const &uri);
/*
* Destructor

View File

@ -32,8 +32,8 @@ class Driver : public Block::Driver
public:
Driver(Heap &heap, Ram_session &ram,
size_t block_size, ::String &uri)
Driver(Heap &heap, Ram_allocator &ram,
size_t block_size, ::String const &uri)
: Block::Driver(ram),
_block_size(block_size), _http(heap, uri) {}
@ -71,20 +71,17 @@ class Factory : public Block::Driver_factory
Env &_env;
Heap &_heap;
Attached_rom_dataspace _config { _env, "config" };
::String _uri;
size_t _blk_sz;
::String const _uri;
size_t const _blk_sz;
public:
Factory(Env &env, Heap &heap)
: _env(env), _heap(heap), _blk_sz(512)
:
_env(env), _heap(heap),
_uri (_config.xml().attribute_value("uri", ::String())),
_blk_sz(_config.xml().attribute_value("block_size", 512U))
{
try {
_config.xml().attribute("uri").value(&_uri);
_config.xml().attribute("block_size").value(&_blk_sz);
}
catch (...) { }
log("Using file=", _uri, " as device with block size ",
Hex(_blk_sz, Hex::OMIT_PREFIX), ".");
}

View File

@ -42,7 +42,6 @@ namespace Nit_fader {
typedef Genode::Surface_base::Rect Rect;
using Genode::size_t;
using Genode::env;
using Genode::Xml_node;
using Genode::Dataspace_capability;
using Genode::Attached_ram_dataspace;
@ -498,7 +497,7 @@ void Nit_fader::Main::handle_config_update()
unsigned long new_alpha = alpha;
if (config_xml.has_attribute("alpha"))
config_xml.attribute("alpha").value(&new_alpha);
config_xml.attribute("alpha").value(new_alpha);
/* respond to state change */
if (new_alpha != alpha) {

View File

@ -525,27 +525,22 @@ class Terminal::Root_component : public Genode::Root_component<Session_component
*/
Genode::size_t io_buffer_size = 4096;
try {
Session_label const label = label_from_args(args);
Session_policy policy(label, _config);
Session_label const label = label_from_args(args);
Session_policy const policy(label, _config);
unsigned tcp_port = 0;
policy.attribute("port").value(&tcp_port);
Session_component *session = nullptr;
Libc::with_libc([&] () {
session = new (md_alloc())
Session_component(_env, io_buffer_size, tcp_port);
});
return session;
}
catch (Xml_node::Nonexistent_attribute) {
if (!policy.has_attribute("port")) {
error("Missing \"port\" attribute in policy definition");
throw Service_denied();
}
catch (Session_policy::No_policy_defined) {
error("Invalid session request, no matching policy");
throw Service_denied();
}
unsigned const tcp_port = policy.attribute_value("port", 0U);
Session_component *session = nullptr;
Libc::with_libc([&] () {
session = new (md_alloc())
Session_component(_env, io_buffer_size, tcp_port); });
return session;
}
public:

View File

@ -162,7 +162,7 @@ struct Wm::Decorator_nitpicker_session : Genode::Rpc_object<Nitpicker::Session>,
Genode::Heap _heap { _env.ram(), _env.rm() };
Genode::Ram_session &_ram;
Genode::Ram_allocator &_ram;
Nitpicker::Connection _nitpicker_session { _env, "decorator" };
@ -205,7 +205,7 @@ struct Wm::Decorator_nitpicker_session : Genode::Rpc_object<Nitpicker::Session>,
* \param ep entrypoint used for dispatching signals
*/
Decorator_nitpicker_session(Genode::Env &env,
Genode::Ram_session &ram,
Genode::Ram_allocator &ram,
Allocator &md_alloc,
Reporter &pointer_reporter,
Last_motion &last_motion,

View File

@ -28,7 +28,6 @@ namespace Wm {
class Main;
using Genode::size_t;
using Genode::env;
using Genode::Rom_session_client;
using Genode::Rom_connection;
using Genode::Xml_node;
@ -76,7 +75,7 @@ struct Wm::Main
unsigned long win_id = 0;
Xml_node(focus_rom.local_addr<char>()).sub_node("window")
.attribute("id").value(&win_id);
.attribute("id").value(win_id);
if (win_id) {
Nitpicker::Session_capability session_cap =
@ -95,32 +94,17 @@ struct Wm::Main
void handle_resize_request_update()
{
try {
resize_request_rom.update();
if (!resize_request_rom.valid())
return;
resize_request_rom.update();
char const * const node_type = "window";
resize_request_rom.xml().for_each_sub_node("window", [&] (Xml_node window) {
Xml_node window =
Xml_node(resize_request_rom.local_addr<char>()).sub_node(node_type);
unsigned long const
win_id = window.attribute_value("id", 0UL),
width = window.attribute_value("width", 0UL),
height = window.attribute_value("height", 0UL);
for (;;) {
unsigned long win_id = 0, width = 0, height = 0;
window.attribute("id") .value(&win_id);
window.attribute("width") .value(&width);
window.attribute("height").value(&height);
nitpicker_root.request_resize(win_id, Area(width, height));
if (window.last(node_type))
break;
window = window.next(node_type);
}
} catch (...) { /* no resize-request model available */ }
nitpicker_root.request_resize(win_id, Area(width, height));
});
}
Genode::Signal_handler<Main> resize_request_handler =

View File

@ -42,7 +42,6 @@ namespace Wm {
using Genode::Affinity;
using Genode::static_cap_cast;
using Genode::Signal_handler;
using Genode::Ram_session_capability;
using Genode::Weak_ptr;
using Genode::Locked_ptr;
using Genode::Tslab;
@ -454,7 +453,7 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
Genode::Env &_env;
Session_label _session_label;
Genode::Ram_session &_ram;
Genode::Ram_allocator &_ram;
Nitpicker::Connection _session { _env, _session_label.string() };
Window_registry &_window_registry;
@ -730,7 +729,7 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
* \param ep entrypoint used for managing the views
*/
Session_component(Genode::Env &env,
Genode::Ram_session &ram,
Genode::Ram_allocator &ram,
Window_registry &window_registry,
Allocator &session_alloc,
Session_label const &session_label,
@ -848,7 +847,7 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
/**
* Return session capability to real nitpicker session
*/
Capability<Session> session() { return _session; }
Capability<Session> session() { return _session.rpc_cap(); }
/*********************************
@ -1019,7 +1018,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
Allocator &_md_alloc;
Genode::Ram_session &_ram;
Genode::Ram_allocator &_ram;
enum { STACK_SIZE = 1024*sizeof(long) };
@ -1109,7 +1108,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
*/
Root(Genode::Env &env,
Window_registry &window_registry, Allocator &md_alloc,
Genode::Ram_session &ram,
Genode::Ram_allocator &ram,
Reporter &pointer_reporter, Reporter &focus_request_reporter,
Nitpicker::Session &focus_nitpicker_session)
:

View File

@ -64,6 +64,34 @@ class Genode::Slave::Policy : public Child_policy
Child_policy_dynamic_rom_file _config_policy;
Session_requester _session_requester;
Service &_matching_service(Service::Name const &service_name,
Session_label const &label)
{
/* check for config file request */
if (Service *s = _config_policy.resolve_session_request(service_name, label))
return *s;
if (service_name == "ROM") {
Session_label const rom_name(label.last_element());
if (rom_name == _binary_name) return _binary_service;
if (rom_name == "session_requests") return _session_requester.service();
}
/* fill parent service registry on demand */
Parent_service *service = nullptr;
_parent_services.for_each([&] (Parent_service &s) {
if (!service && s.name() == service_name)
service = &s; });
if (!service) {
error(name(), ": illegal session request of "
"service \"", service_name, "\" (", label, ")");
throw Service_denied();
}
return *service;
}
public:
class Connection;
@ -73,29 +101,25 @@ class Genode::Slave::Policy : public Child_policy
*
* \param ep entrypoint used to provide local services
* such as the config ROM service
* \param local_rm local address space, needed to populate dataspaces
* provided to the child (config, session_requests)
*
* \throw Out_of_ram by 'Child_policy_dynamic_rom_file'
* \throw Out_of_caps by 'Child_policy_dynamic_rom_file'
*/
Policy(Label const &label,
Name const &binary_name,
Parent_services &parent_services,
Rpc_entrypoint &ep,
Region_map &rm,
Pd_session &ref_pd,
Pd_session_capability ref_pd_cap,
Cap_quota cap_quota,
Ram_quota ram_quota)
Policy(Env &env,
Label const &label,
Name const &binary_name,
Parent_services &parent_services,
Rpc_entrypoint &ep,
Cap_quota cap_quota,
Ram_quota ram_quota)
:
_label(label), _binary_name(binary_name),
_ref_pd(ref_pd), _ref_pd_cap(ref_pd_cap),
_binary_service(Rom_session::service_name()),
_ref_pd(env.pd()), _ref_pd_cap(env.pd_session_cap()),
_binary_service(env, Rom_session::service_name()),
_cap_quota(cap_quota), _ram_quota(ram_quota),
_parent_services(parent_services), _ep(ep),
_config_policy(rm, "config", _ep, &_ref_pd),
_session_requester(ep, _ref_pd, rm)
_config_policy(env.rm(), "config", _ep, &env.pd()),
_session_requester(ep, env.pd(), env.rm())
{
configure("<config/>");
}
@ -139,32 +163,12 @@ class Genode::Slave::Policy : public Child_policy
_ref_pd.transfer_quota(cap, _ram_quota);
}
Service &resolve_session_request(Service::Name const &service_name,
Session_state::Args const &args)
Route resolve_session_request(Service::Name const &name,
Session_label const &label) override
{
/* check for config file request */
if (Service *s = _config_policy.resolve_session_request(service_name.string(), args.string()))
return *s;
if (service_name == "ROM") {
Session_label const rom_name(label_from_args(args.string()).last_element());
if (rom_name == _binary_name) return _binary_service;
if (rom_name == "session_requests") return _session_requester.service();
}
/* fill parent service registry on demand */
Parent_service *service = nullptr;
_parent_services.for_each([&] (Parent_service &s) {
if (!service && s.name() == service_name)
service = &s; });
if (!service) {
error(name(), ": illegal session request of "
"service \"", service_name, "\" (", args, ")");
throw Service_denied();
}
return *service;
return Route { .service = _matching_service(name, label),
.label = label,
.diag = Session::Diag() };
}
Id_space<Parent::Server> &server_id_space() override {
@ -247,7 +251,7 @@ class Genode::Slave::Connection_base
/**
* Service ('Ram_transfer::Account') interface
*/
void transfer(Ram_session_capability to, Ram_quota amount) override
void transfer(Pd_session_capability to, Ram_quota amount) override
{
if (to.valid()) _policy.ref_pd().transfer_quota(to, amount);
}

View File

@ -36,8 +36,7 @@ struct Test::Policy
Policy(Env &env, Name const &name)
:
Static_parent_services(env),
Slave::Policy(name, name, *this, env.ep().rpc_ep(), env.rm(),
env.pd(), env.pd_session_cap(),
Slave::Policy(env, name, name, *this, env.ep().rpc_ep(),
Cap_quota{100}, Ram_quota{1024*1024})
{ }
};

View File

@ -294,9 +294,8 @@ class Test::Parent
Policy(Parent &parent, Env &env)
:
Static_parent_services(env),
Slave::Policy(Label("child"), "test-resource_yield",
*this, env.ep().rpc_ep(), env.rm(),
env.pd(), env.pd_session_cap(),
Slave::Policy(env, Label("child"), "test-resource_yield",
*this, env.ep().rpc_ep(),
Cap_quota{SLAVE_CAPS}, Ram_quota{SLAVE_RAM}),
_parent(parent)
{