From 9e42a9ac7e5b2baaa985374556d22f5749246046 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 13 Aug 2020 12:06:55 +0200 Subject: [PATCH] Replace server/acpi_input with app/acpi_event Fixes #3827 --- repos/libports/run/acpica.run | 37 ++++----- .../acpi_input => app/acpi_event}/main.cc | 77 +++++++++---------- repos/libports/src/app/acpi_event/target.mk | 3 + .../libports/src/server/acpi_input/target.mk | 5 -- 4 files changed, 53 insertions(+), 69 deletions(-) rename repos/libports/src/{server/acpi_input => app/acpi_event}/main.cc (86%) create mode 100644 repos/libports/src/app/acpi_event/target.mk delete mode 100644 repos/libports/src/server/acpi_input/target.mk diff --git a/repos/libports/run/acpica.run b/repos/libports/run/acpica.run index 4b36c090da..8e1a4a8a11 100644 --- a/repos/libports/run/acpica.run +++ b/repos/libports/run/acpica.run @@ -12,12 +12,12 @@ if { set build_components { core init timer drivers/input - server/acpi_input server/dynamic_rom server/event_filter server/report_rom server/event_dump app/acpica + app/acpi_event app/input_event_client } @@ -96,11 +96,11 @@ append config { - - - - - + + + + + @@ -183,20 +183,8 @@ append config { } append config { - + - - - - - - - - - - - - @@ -211,11 +199,12 @@ append config { - + - - - + + + + } @@ -237,7 +226,7 @@ set boot_modules { report_rom dynamic_rom acpica - acpi_input + acpi_event event_dump input_event_client } diff --git a/repos/libports/src/server/acpi_input/main.cc b/repos/libports/src/app/acpi_event/main.cc similarity index 86% rename from repos/libports/src/server/acpi_input/main.cc rename to repos/libports/src/app/acpi_event/main.cc index a03a49e886..7f386cf474 100644 --- a/repos/libports/src/server/acpi_input/main.cc +++ b/repos/libports/src/app/acpi_event/main.cc @@ -16,23 +16,21 @@ #include #include #include +#include #include /* os includes */ -#include -#include -#include +#include namespace Transform { - using Genode::Xml_node; - using Genode::String; + using namespace Genode; struct Main; class Keys; }; -class Transform::Keys : public Genode::Avl_node { +class Transform::Keys : public Avl_node { public: @@ -46,8 +44,8 @@ class Transform::Keys : public Genode::Avl_node { bool _first = true; Type _type; - static Genode::Avl_tree _map_ec; - static Genode::Avl_tree _map_special; + static Avl_tree _map_ec; + static Avl_tree _map_special; Keys *_find_by_acpi_value(long acpi_value) { @@ -65,7 +63,7 @@ class Transform::Keys : public Genode::Avl_node { bool higher(Keys *k) const { return k->_acpi_value > _acpi_value; } - Type const type() { return _type; } + Type type() const { return _type; } unsigned long update_count(unsigned long acpi_count) { @@ -120,25 +118,24 @@ struct Transform::Main { ACPI_AC_ONLINE, ACPI_AC_OFFLINE, ACPI_BATTERY }; - Genode::Heap _heap; + Heap _heap; - Genode::Attached_rom_dataspace _config; - Genode::Attached_rom_dataspace _acpi_ac; - Genode::Attached_rom_dataspace _acpi_battery; - Genode::Attached_rom_dataspace _acpi_ec; - Genode::Attached_rom_dataspace _acpi_fixed; - Genode::Attached_rom_dataspace _acpi_lid; + Attached_rom_dataspace _config; + Attached_rom_dataspace _acpi_ac; + Attached_rom_dataspace _acpi_battery; + Attached_rom_dataspace _acpi_ec; + Attached_rom_dataspace _acpi_fixed; + Attached_rom_dataspace _acpi_lid; - Genode::Signal_handler
_dispatch_acpi_ac; - Genode::Signal_handler
_dispatch_acpi_battery; - Genode::Signal_handler
_dispatch_acpi_ec; - Genode::Signal_handler
_dispatch_acpi_fixed; - Genode::Signal_handler
_dispatch_acpi_lid; + Signal_handler
_dispatch_acpi_ac; + Signal_handler
_dispatch_acpi_battery; + Signal_handler
_dispatch_acpi_ec; + Signal_handler
_dispatch_acpi_fixed; + Signal_handler
_dispatch_acpi_lid; - Input::Session_component _session; - Input::Root_component _root; + Event::Connection _event; - Main(Genode::Env &env) + Main(Env &env) : _heap(env.ram(), env.rm()), _config(env, "config"), @@ -152,18 +149,17 @@ struct Transform::Main { _dispatch_acpi_ec(env.ep(), *this, &Main::check_acpi_ec), _dispatch_acpi_fixed(env.ep(), *this, &Main::check_acpi_fixed), _dispatch_acpi_lid(env.ep(), *this, &Main::check_acpi_lid), - _session(env, env.ram()), - _root(env.ep().rpc_ep(), _session) + _event(env) { Xml_node config(_config.local_addr(), _config.size()); config.for_each_sub_node("map", [&] (Xml_node map_node) { try { long acpi_value = 0; - Genode::String<8> acpi_type; - Genode::String<8> acpi_value_string; - Genode::String<32> to_key; + String<8> acpi_type; + String<8> acpi_value_string; + String<32> to_key; - Genode::String<16> key_type("PRESS_RELEASE"); + String<16> key_type("PRESS_RELEASE"); Keys::Type press_release = Keys::Type::PRESS_RELEASE; map_node.attribute("acpi").value(acpi_type); @@ -257,8 +253,6 @@ struct Transform::Main { _acpi_fixed.sigh(_dispatch_acpi_fixed); _acpi_lid.sigh(_dispatch_acpi_lid); - env.parent().announce(env.ep().manage(_root)); - /* check for initial valid ACPI data */ check_acpi_ac(); check_acpi_battery(); @@ -299,16 +293,19 @@ struct Transform::Main { void submit_input(Keys * key) { - if (!key) - return; + _event.with_batch([&] (Event::Session_client::Batch &batch) { - if (key->type() == Keys::Type::PRESS_RELEASE || - key->type() == Keys::Type::PRESS) - _session.submit(Input::Press{key->key_code()}); + if (!key) + return; - if (key->type() == Keys::Type::PRESS_RELEASE || - key->type() == Keys::Type::RELEASE) - _session.submit(Input::Release{key->key_code()}); + if (key->type() == Keys::Type::PRESS_RELEASE || + key->type() == Keys::Type::PRESS) + batch.submit(Input::Press{key->key_code()}); + + if (key->type() == Keys::Type::PRESS_RELEASE || + key->type() == Keys::Type::RELEASE) + batch.submit(Input::Release{key->key_code()}); + }); } void check_acpi_fixed() diff --git a/repos/libports/src/app/acpi_event/target.mk b/repos/libports/src/app/acpi_event/target.mk new file mode 100644 index 0000000000..05d22cd72f --- /dev/null +++ b/repos/libports/src/app/acpi_event/target.mk @@ -0,0 +1,3 @@ +TARGET = acpi_event +SRC_CC = main.cc +LIBS = base diff --git a/repos/libports/src/server/acpi_input/target.mk b/repos/libports/src/server/acpi_input/target.mk deleted file mode 100644 index 5fb566bb80..0000000000 --- a/repos/libports/src/server/acpi_input/target.mk +++ /dev/null @@ -1,5 +0,0 @@ -TARGET = acpi_input -SRC_CC = main.cc -LIBS = base - -CC_CXX_WARN_STRICT =