From e204b9532b974a8655018ae89709b26bfc9c1d64 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Sun, 19 Nov 2017 23:24:18 +0100 Subject: [PATCH] rom_filter: allow use of input as attribute value --- repos/os/src/server/rom_filter/README | 5 +++++ repos/os/src/server/rom_filter/main.cc | 27 +++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/repos/os/src/server/rom_filter/README b/repos/os/src/server/rom_filter/README index d737326b8..07fbe10aa 100644 --- a/repos/os/src/server/rom_filter/README +++ b/repos/os/src/server/rom_filter/README @@ -34,6 +34,11 @@ The '' node can contain the following sub nodes: Copies all sub nodes named by the 'sub_node' attribute of the input ROM specified by the 'name' attribute to the output node. +:'': + Adds an attribute with the specified 'name' and 'value'. If the node + has an 'input' attribute, the content of the specified input is taken + as attribute value. + Conditions ---------- diff --git a/repos/os/src/server/rom_filter/main.cc b/repos/os/src/server/rom_filter/main.cc index bd96bdde0..b57879bd2 100644 --- a/repos/os/src/server/rom_filter/main.cc +++ b/repos/os/src/server/rom_filter/main.cc @@ -283,10 +283,31 @@ void Rom_filter::Main::_evaluate_node(Xml_node node, Xml_generator &xml) } else if (node.has_type("attribute")) { + typedef Genode::String<128> String; - xml.attribute( - node.attribute_value("name", String()).string(), - node.attribute_value("value", String()).string()); + + /* assign input value to attribute value */ + if (node.has_attribute("input")) { + + Input_name const input_name = + node.attribute_value("input", Input_name()); + try { + Input_value const input_value = + _input_rom_registry.query_value(_config.xml(), input_name); + + xml.attribute(node.attribute_value("name", String()).string(), + input_value); + } + catch (Input_rom_registry::Nonexistent_input_value) { + Genode::warning("could not obtain input value for input ", input_name); + } + } + + /* assign fixed attribute value */ + else { + xml.attribute(node.attribute_value("name", String()).string(), + node.attribute_value("value", String()).string()); + } } else if (node.has_type("inline")) {