mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
parent
1aed881313
commit
3f97269988
@ -363,6 +363,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
Attached_rom_dataspace _editor_saved_rom { _env, "report -> runtime/editor/saved" };
|
||||
|
||||
Affinity::Space _affinity_space { 1, 1 };
|
||||
|
||||
/**
|
||||
* Panel_dialog::State interface
|
||||
@ -886,7 +887,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
Start_name new_construction(Component::Path const &pkg,
|
||||
Component::Info const &info) override
|
||||
{
|
||||
return _runtime_state.new_construction(pkg, info);
|
||||
return _runtime_state.new_construction(pkg, info, _affinity_space);
|
||||
}
|
||||
|
||||
void _apply_to_construction(Popup_dialog::Action::Apply_to &fn) override
|
||||
@ -1091,6 +1092,14 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_handle_pci_devices();
|
||||
_handle_runtime_config();
|
||||
|
||||
/*
|
||||
* Read static platform information
|
||||
*/
|
||||
_platform.xml().with_sub_node("affinity-space", [&] (Xml_node const &node) {
|
||||
_affinity_space = Affinity::Space(node.attribute_value("width", 1U),
|
||||
node.attribute_value("height", 1U));
|
||||
});
|
||||
|
||||
/*
|
||||
* Generate initial config/managed/deploy configuration
|
||||
*/
|
||||
@ -1686,11 +1695,9 @@ void Sculpt::Main::_generate_runtime_config(Xml_generator &xml) const
|
||||
gen_parent_service<Irq_session>(xml);
|
||||
});
|
||||
|
||||
_platform.xml().with_sub_node("affinity-space", [&] (Xml_node const &node) {
|
||||
xml.node("affinity-space", [&] () {
|
||||
xml.attribute("width", node.attribute_value("width", 1U));
|
||||
xml.attribute("height", node.attribute_value("height", 1U));
|
||||
});
|
||||
xml.node("affinity-space", [&] () {
|
||||
xml.attribute("width", _affinity_space.width());
|
||||
xml.attribute("height", _affinity_space.height());
|
||||
});
|
||||
|
||||
xml.node("start", [&] () {
|
||||
|
@ -37,12 +37,18 @@ struct Sculpt::Component : Noncopyable
|
||||
uint64_t ram { };
|
||||
size_t caps { };
|
||||
|
||||
Affinity::Space const affinity_space;
|
||||
Affinity::Location affinity_location { 0, 0,
|
||||
affinity_space.width(),
|
||||
affinity_space.height() };
|
||||
|
||||
bool blueprint_known = false;
|
||||
|
||||
List_model<Route> routes { };
|
||||
|
||||
Component(Allocator &alloc, Path const &path, Info const &info)
|
||||
: _route_update_policy(alloc), path(path), info(info) { }
|
||||
Component(Allocator &alloc, Path const &path, Info const &info,
|
||||
Affinity::Space const space)
|
||||
: _route_update_policy(alloc), path(path), info(info), affinity_space (space) { }
|
||||
|
||||
~Component()
|
||||
{
|
||||
|
@ -107,11 +107,12 @@ class Sculpt::Runtime_state : public Runtime_info
|
||||
*/
|
||||
Launched_child(Allocator &alloc, Start_name const &name,
|
||||
Component::Path const &pkg_path,
|
||||
Component::Info const &info)
|
||||
Component::Info const &info,
|
||||
Affinity::Space const space)
|
||||
:
|
||||
name(name), launcher(), launched(false)
|
||||
{
|
||||
construction.construct(alloc, pkg_path, info);
|
||||
construction.construct(alloc, pkg_path, info, space);
|
||||
}
|
||||
|
||||
void gen_deploy_start_node(Xml_generator &xml) const
|
||||
@ -125,6 +126,11 @@ class Sculpt::Runtime_state : public Runtime_info
|
||||
if (construction.constructed()) {
|
||||
xml.attribute("pkg", construction->path);
|
||||
|
||||
xml.attribute("xpos", construction->affinity_location.xpos());
|
||||
xml.attribute("ypos", construction->affinity_location.ypos());
|
||||
xml.attribute("width", construction->affinity_location.width());
|
||||
xml.attribute("height", construction->affinity_location.height());
|
||||
|
||||
xml.node("route", [&] () {
|
||||
construction->routes.for_each([&] (Route const &route) {
|
||||
route.gen_xml(xml); }); });
|
||||
@ -363,7 +369,8 @@ class Sculpt::Runtime_state : public Runtime_info
|
||||
}
|
||||
|
||||
Start_name new_construction(Component::Path const pkg,
|
||||
Component::Info const &info)
|
||||
Component::Info const &info,
|
||||
Affinity::Space const space)
|
||||
{
|
||||
/* allow only one construction at a time */
|
||||
discard_construction();
|
||||
@ -377,7 +384,7 @@ class Sculpt::Runtime_state : public Runtime_info
|
||||
|
||||
_currently_constructed = new (_alloc)
|
||||
Registered<Launched_child>(_launched_children, _alloc,
|
||||
unique_name, pkg, info);
|
||||
unique_name, pkg, info, space);
|
||||
return unique_name;
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,25 @@ void Popup_dialog::_gen_pkg_elements(Xml_generator &xml,
|
||||
});
|
||||
});
|
||||
|
||||
if (_resources.constructed() && component.affinity_space.total() > 1) {
|
||||
xml.node("frame", [&] {
|
||||
xml.node("vbox", [&] () {
|
||||
bool const selected = _route_selected(_resources->start_name());
|
||||
|
||||
if (!selected)
|
||||
_gen_route_entry(xml, _resources->start_name(),
|
||||
"Resource assignment", false, "enter");
|
||||
|
||||
if (selected) {
|
||||
_gen_route_entry(xml, "back", "Resource assignment",
|
||||
true, "back");
|
||||
|
||||
_resources->generate(xml);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Display "Add component" button once all routes are defined
|
||||
*/
|
||||
@ -457,6 +476,12 @@ void Popup_dialog::click(Action &action)
|
||||
_state = ROUTE_SELECTED;
|
||||
_selected_route.construct(clicked_route);
|
||||
}
|
||||
|
||||
if (_resources.constructed()) {
|
||||
action.apply_to_construction([&] (Component &component) {
|
||||
_resources->click(component);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <view/activatable_item.h>
|
||||
#include <depot_query.h>
|
||||
|
||||
#include <view/resource_dialog.h>
|
||||
|
||||
namespace Sculpt { struct Popup_dialog; }
|
||||
|
||||
|
||||
@ -113,6 +115,8 @@ struct Sculpt::Popup_dialog : Dialog
|
||||
Activatable_item _install_item { };
|
||||
Hoverable_item _route_item { };
|
||||
|
||||
Constructible<Resource_dialog> _resources { };
|
||||
|
||||
enum State { TOP_LEVEL, DEPOT_REQUESTED, DEPOT_SHOWN, DEPOT_SELECTION,
|
||||
INDEX_REQUESTED, INDEX_SHOWN,
|
||||
PKG_REQUESTED, PKG_SHOWN, ROUTE_SELECTED };
|
||||
@ -194,6 +198,10 @@ struct Sculpt::Popup_dialog : Dialog
|
||||
_install_item.match(hover, "frame", "vbox", "float", "vbox", "float", "button", "name"),
|
||||
_route_item .match(hover, "frame", "vbox", "frame", "vbox", "hbox", "name"));
|
||||
|
||||
if (_resources.constructed() &&
|
||||
hover_result == Dialog::Hover_result::UNMODIFIED)
|
||||
return _resources->hover(hover, "frame", "vbox", "frame", "vbox");
|
||||
|
||||
return hover_result;
|
||||
}
|
||||
|
||||
@ -448,6 +456,10 @@ struct Sculpt::Popup_dialog : Dialog
|
||||
if (_state < PKG_REQUESTED)
|
||||
return;
|
||||
|
||||
if (!_resources.constructed())
|
||||
_resources.construct(construction.affinity_space,
|
||||
construction.affinity_location);
|
||||
|
||||
_pkg_rom_missing = blueprint_rom_missing(blueprint, construction.path);
|
||||
_pkg_missing = blueprint_missing (blueprint, construction.path);
|
||||
|
||||
|
147
repos/gems/src/app/sculpt_manager/view/resource_dialog.cc
Normal file
147
repos/gems/src/app/sculpt_manager/view/resource_dialog.cc
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* \brief Resource assignment dialog
|
||||
* \author Alexander Boettcher
|
||||
* \date 2020-07-22
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#include <view/resource_dialog.h>
|
||||
|
||||
using namespace Sculpt;
|
||||
|
||||
void Resource_dialog::_gen_affinity_entry(Xml_generator &xml,
|
||||
Start_name const &name) const
|
||||
{
|
||||
gen_named_node(xml, "hbox", name, [&] () {
|
||||
gen_named_node(xml, "float", "center", [&] () {
|
||||
xml.attribute("north", "yes");
|
||||
xml.attribute("south", "yes");
|
||||
|
||||
xml.node("vbox", [&] () {
|
||||
if (_space.height() > 1) {
|
||||
xml.node("label", [&] () {
|
||||
xml.attribute("text", String<12>("Cores 0-", _space.width() - 1));
|
||||
});
|
||||
} else {
|
||||
xml.node("label", [&] () {
|
||||
xml.attribute("text", String<12>("CPUs 0-", _space.width() - 1));
|
||||
});
|
||||
}
|
||||
for (unsigned y = 0; y < _space.height(); y++) {
|
||||
bool const row = unsigned(_location.ypos()) <= y && y < _location.ypos() + _location.height();
|
||||
String<12> const row_id("row", y);
|
||||
|
||||
gen_named_node(xml, "hbox", row_id, [&] () {
|
||||
if (_space.height() > 1) {
|
||||
xml.node("label", [&] () {
|
||||
xml.attribute("text", String<12>("Thread ", y));
|
||||
});
|
||||
}
|
||||
for (unsigned x = 0; x < _space.width(); x++) {
|
||||
String<12> const name_cpu("cpu", x, "x", y);
|
||||
bool const column = unsigned(_location.xpos()) <= x && x < _location.xpos() + _location.width();
|
||||
gen_named_node(xml, "button", name_cpu, [&] () {
|
||||
if (row && column)
|
||||
xml.attribute("selected", "yes");
|
||||
|
||||
xml.attribute("style", "radio");
|
||||
_space_item.gen_hovered_attr(xml, name_cpu);
|
||||
xml.node("hbox", [&] () { });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void Resource_dialog::click(Component &component)
|
||||
{
|
||||
if (component.affinity_space.total() <= 1)
|
||||
return;
|
||||
|
||||
Route::Id const clicked_space = _space_item._hovered;
|
||||
if (!clicked_space.valid())
|
||||
return;
|
||||
|
||||
for (unsigned y = 0; y < component.affinity_space.height(); y++) {
|
||||
for (unsigned x = 0; x < component.affinity_space.width(); x++) {
|
||||
String<12> const name_cpu("cpu", x, "x", y);
|
||||
if (name_cpu != clicked_space)
|
||||
continue;
|
||||
|
||||
unsigned loc_x = _location.xpos();
|
||||
unsigned loc_y = _location.ypos();
|
||||
unsigned loc_w = _location.width();
|
||||
unsigned loc_h = _location.height();
|
||||
|
||||
bool handled_x = false;
|
||||
bool handled_y = false;
|
||||
|
||||
if (x < loc_x) {
|
||||
loc_w += loc_x - x;
|
||||
loc_x = x;
|
||||
handled_x = true;
|
||||
} else if (x >= loc_x + loc_w) {
|
||||
loc_w = x - loc_x + 1;
|
||||
handled_x = true;
|
||||
}
|
||||
|
||||
if (y < loc_y) {
|
||||
loc_h += loc_y - y;
|
||||
loc_y = y;
|
||||
handled_y = true;
|
||||
} else if (y >= loc_y + loc_h) {
|
||||
loc_h = y - loc_y + 1;
|
||||
handled_y = true;
|
||||
}
|
||||
|
||||
if (handled_x && !handled_y) {
|
||||
handled_y = true;
|
||||
} else
|
||||
if (handled_y && !handled_x) {
|
||||
handled_x = true;
|
||||
}
|
||||
|
||||
if (!handled_x) {
|
||||
if ((x - loc_x) < (loc_x + loc_w - x)) {
|
||||
if (x - loc_x + 1 < loc_w) {
|
||||
loc_w -= x - loc_x + 1;
|
||||
loc_x = x + 1;
|
||||
} else {
|
||||
loc_w = loc_x + loc_w - x;
|
||||
loc_x = x;
|
||||
}
|
||||
} else {
|
||||
loc_w = x - loc_x;
|
||||
}
|
||||
}
|
||||
|
||||
if (!handled_y) {
|
||||
if ((y - loc_y) < (loc_y + loc_h - y)) {
|
||||
if (y - loc_y + 1 < loc_h) {
|
||||
loc_h -= y - loc_y + 1;
|
||||
loc_y = y + 1;
|
||||
} else {
|
||||
loc_h = loc_y + loc_h - y;
|
||||
loc_y = y;
|
||||
}
|
||||
} else {
|
||||
loc_h = y - loc_y;
|
||||
}
|
||||
}
|
||||
|
||||
_location = Affinity::Location(loc_x, loc_y,
|
||||
loc_w, loc_h);
|
||||
|
||||
component.affinity_location = _location;
|
||||
}
|
||||
}
|
||||
}
|
74
repos/gems/src/app/sculpt_manager/view/resource_dialog.h
Normal file
74
repos/gems/src/app/sculpt_manager/view/resource_dialog.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* \brief Resource assignment dialog
|
||||
* \author Alexander Boettcher
|
||||
* \date 2020-07-22
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _VIEW__RESOURCE_DIALOG_H_
|
||||
#define _VIEW__RESOURCE_DIALOG_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <os/reporter.h>
|
||||
#include <depot/archive.h>
|
||||
|
||||
/* local includes */
|
||||
#include <xml.h>
|
||||
#include <model/component.h>
|
||||
#include <view/dialog.h>
|
||||
|
||||
namespace Sculpt { struct Resource_dialog; }
|
||||
|
||||
|
||||
struct Sculpt::Resource_dialog : Noncopyable, Dialog
|
||||
{
|
||||
Affinity::Space const _space;
|
||||
Affinity::Location _location;
|
||||
Hoverable_item _space_item { };
|
||||
|
||||
|
||||
Resource_dialog(Affinity::Space space,
|
||||
Affinity::Location loc)
|
||||
: _space(space), _location(loc)
|
||||
{ }
|
||||
|
||||
void _gen_affinity_entry(Xml_generator &, Start_name const &) const;
|
||||
|
||||
Hover_result hover(Xml_node hover_node) override
|
||||
{
|
||||
Dialog::Hover_result const hover_result = hover(hover_node);
|
||||
return hover_result;
|
||||
}
|
||||
|
||||
template <typename... ARGS>
|
||||
Hover_result hover(Xml_node hover, ARGS &&... args)
|
||||
{
|
||||
Dialog::Hover_result const hover_result = Dialog::any_hover_changed(
|
||||
_space_item.match(hover, args..., "hbox", "float", "vbox", "hbox", "button", "name"));
|
||||
|
||||
return hover_result;
|
||||
}
|
||||
|
||||
Start_name start_name() const { return "cpus"; }
|
||||
|
||||
void click(Component &);
|
||||
|
||||
void generate(Xml_generator &xml) const override
|
||||
{
|
||||
_gen_affinity_entry(xml, start_name());
|
||||
}
|
||||
|
||||
void reset() override
|
||||
{
|
||||
_space_item._hovered = Hoverable_item::Id();
|
||||
_location = Affinity::Location();
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _VIEW__RESOURCE_DIALOG_H_ */
|
Loading…
Reference in New Issue
Block a user