diff --git a/repos/os/src/server/rom_filter/README b/repos/os/src/server/rom_filter/README index 07386bdb3..d737326b8 100644 --- a/repos/os/src/server/rom_filter/README +++ b/repos/os/src/server/rom_filter/README @@ -30,6 +30,10 @@ The '' node can contain the following sub nodes: sub node is evaluated. Each of those sub nodes can contain the same nodes as the '' node. +:'': + Copies all sub nodes named by the 'sub_node' attribute of the input ROM + specified by the 'name' attribute to the output node. + Conditions ---------- diff --git a/repos/os/src/server/rom_filter/input_rom_registry.h b/repos/os/src/server/rom_filter/input_rom_registry.h index ab829f0d2..612f87c16 100644 --- a/repos/os/src/server/rom_filter/input_rom_registry.h +++ b/repos/os/src/server/rom_filter/input_rom_registry.h @@ -54,6 +54,7 @@ class Rom_filter::Input_rom_registry * Exception type */ class Nonexistent_input_value { }; + class Nonexistent_input_node { }; private: @@ -191,6 +192,15 @@ class Rom_filter::Input_rom_registry throw Nonexistent_input_value(); } + + Xml_node node() const + { + try { + return Xml_node(_top_level); + } catch (...) { } + + throw Nonexistent_input_node(); + } }; Genode::Allocator &_alloc; @@ -372,6 +382,21 @@ class Rom_filter::Input_rom_registry return input_value; } + + /** + * Lookup content of input with specified name + * + * \throw Nonexistent_input_value + */ + Xml_node xml(Input_name const &input_name) const + { + Entry const *e = _lookup_entry_by_name(input_name); + + if (!e) + throw Nonexistent_input_node(); + + return e->node(); + } }; #endif /* _INPUT_ROM_REGISTRY_H_ */ diff --git a/repos/os/src/server/rom_filter/main.cc b/repos/os/src/server/rom_filter/main.cc index fb1c95338..bd96bdde0 100644 --- a/repos/os/src/server/rom_filter/main.cc +++ b/repos/os/src/server/rom_filter/main.cc @@ -310,6 +310,26 @@ void Rom_filter::Main::_evaluate_node(Xml_node node, Xml_generator &xml) for (; src_len > 0 && Genode::is_whitespace(src[src_len - 1]); src_len--); xml.append(src, src_len); + } else + + if (node.has_type("input")) { + typedef Genode::String<128> String; + + Input_name const input_name = + node.attribute_value("name", Input_name()); + + String const sub_node = + node.attribute_value("sub_node", String()); + + if (!sub_node.valid()) + return; + + try { + Xml_node input_node = _input_rom_registry.xml(input_name); + + input_node.for_each_sub_node(sub_node.string(), + [&] (Xml_node node) { xml.append(node.addr(), node.size()); }); + } catch (...) { } } };