mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
parent
5dc8e330b6
commit
f0f8d0e0ca
@ -14,6 +14,8 @@
|
||||
#ifndef _INCLUDE__BASE__AFFINITY_H_
|
||||
#define _INCLUDE__BASE__AFFINITY_H_
|
||||
|
||||
#include <util/xml_node.h>
|
||||
|
||||
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
|
||||
*/
|
||||
|
@ -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<Args>();
|
||||
|
||||
/* 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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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<PATH_MAX_LEN> 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user