diff --git a/repos/base/include/base/affinity.h b/repos/base/include/base/affinity.h index 9d3420afb4..edaa01b999 100644 --- a/repos/base/include/base/affinity.h +++ b/repos/base/include/base/affinity.h @@ -14,6 +14,8 @@ #ifndef _INCLUDE__BASE__AFFINITY_H_ #define _INCLUDE__BASE__AFFINITY_H_ +#include + namespace Genode { class Affinity; } @@ -85,6 +87,12 @@ class Genode::Affinity * of the space. */ inline Location location_of_index(int index); + + static Space from_xml(Xml_node const &node) + { + return Affinity::Space(node.attribute_value("width", 0U), + node.attribute_value("height", 0U)); + } }; @@ -133,6 +141,15 @@ class Genode::Affinity { return Location(_xpos + dx, _ypos + dy, _width, _height); } + + static Location from_xml(Xml_node const &node) + { + return Location(node.attribute_value("xpos", 0U), + node.attribute_value("ypos", 0U), + node.attribute_value("width", 0U), + node.attribute_value("height", 0U)); + } + }; private: @@ -150,6 +167,21 @@ class Genode::Affinity Space space() const { return _space; } Location location() const { return _location; } + static Affinity from_xml(Xml_node const &node) + { + Affinity::Space space { }; + Affinity::Location location { }; + + node.with_sub_node("affinity", [&] (Xml_node const &node) { + node.with_sub_node("space", [&] (Xml_node const &node) { + space = Space::from_xml(node); }); + node.with_sub_node("location", [&] (Xml_node const &node) { + location = Location::from_xml(node); }); + }); + + return Affinity(space, location); + } + /** * Return location scaled to specified affinity space */ diff --git a/repos/base/src/lib/base/root_proxy.cc b/repos/base/src/lib/base/root_proxy.cc index 7ed09af27e..9d55b9e295 100644 --- a/repos/base/src/lib/base/root_proxy.cc +++ b/repos/base/src/lib/base/root_proxy.cc @@ -170,14 +170,16 @@ void Root_proxy::_handle_session_request(Xml_node request, char const *type) typedef Session_state::Args Args; Args const args = request.sub_node("args").decoded_content(); + /* construct session */ try { Service::Name const name = request.attribute_value("service", Service::Name()); _services.apply(name, [&] (Service &service) { - // XXX affinity Session_capability cap = - Root_client(service.root).session(args.string(), Affinity()); + Root_client(service.root).session(args.string(), + Affinity::from_xml(request)); + new (_session_slab) Session(_id_space, id, service, cap); _env.parent().deliver_session_cap(id, cap); diff --git a/repos/base/src/lib/base/session_state.cc b/repos/base/src/lib/base/session_state.cc index f1268a9f9d..279cb6bfcf 100644 --- a/repos/base/src/lib/base/session_state.cc +++ b/repos/base/src/lib/base/session_state.cc @@ -70,6 +70,18 @@ void Session_state::generate_session_request(Xml_generator &xml) const xml.node("args", [&] () { xml.append_sanitized(Server_args(*this).string()); }); + xml.node("affinity", [&] () { + xml.node("space", [&] () { + xml.attribute("width", _affinity.space().width()); + xml.attribute("height", _affinity.space().height()); + }); + xml.node("location", [&] () { + xml.attribute("xpos", _affinity.location().xpos()); + xml.attribute("ypos", _affinity.location().ypos()); + xml.attribute("width", _affinity.location().width()); + xml.attribute("height", _affinity.location().height()); + }); + }); }); break; diff --git a/repos/os/src/lib/sandbox/server.cc b/repos/os/src/lib/sandbox/server.cc index bdc607efa8..54c338c1a1 100644 --- a/repos/os/src/lib/sandbox/server.cc +++ b/repos/os/src/lib/sandbox/server.cc @@ -229,7 +229,7 @@ void Sandbox::Server::_handle_create_session_request(Xml_node request, Session_state &session = route.service.create_session(route.service.factory(), _client_id_space, id, route.label, - argbuf, Affinity()); + argbuf, Affinity::from_xml(request)); /* transfer session quota */ try { diff --git a/repos/os/src/server/chroot/component.cc b/repos/os/src/server/chroot/component.cc index b0ae2a28b7..b51a76dd53 100644 --- a/repos/os/src/server/chroot/component.cc +++ b/repos/os/src/server/chroot/component.cc @@ -104,7 +104,8 @@ struct Chroot::Main } Session_capability request_session(Parent::Client::Id const &id, - Session_state::Args const &args) + Session_state::Args const &args, + Affinity const affinity) { typedef String Prefix; @@ -180,7 +181,6 @@ struct Chroot::Main Arg_string::set_arg_string(new_args, ARGS_MAX_LEN, "root", new_root); - Affinity affinity; return env.session("File_system", id, new_args, affinity); } }; @@ -205,7 +205,9 @@ void Chroot::Main::handle_session_request(Xml_node request) try { session = new (heap) Session(env.id_space(), server_id_space, server_id); - Session_capability cap = request_session(session->client_id.id(), args); + Session_capability cap = request_session(session->client_id.id(), args, + Affinity::from_xml(request)); + env.parent().deliver_session_cap(server_id, cap); }