From a8667a55bd5bf9fe88f0ec2e2c5002c97b3148bf Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 27 Jan 2022 15:47:44 +0100 Subject: [PATCH] test/framebuffer/intel: use VFS, not of fs session This patch updates the intel_fb_controller test component to use the VFS API instead of interacting with an file-system session directly. Issue #4390 --- repos/dde_linux/run/intel_fb.run | 4 +- .../src/test/framebuffer/intel/main.cc | 87 ++++++++++--------- .../src/test/framebuffer/intel/target.mk | 2 +- 3 files changed, 48 insertions(+), 45 deletions(-) diff --git a/repos/dde_linux/run/intel_fb.run b/repos/dde_linux/run/intel_fb.run index 47662238b8..71c675c88c 100644 --- a/repos/dde_linux/run/intel_fb.run +++ b/repos/dde_linux/run/intel_fb.run @@ -138,7 +138,9 @@ append config { - + + + diff --git a/repos/dde_linux/src/test/framebuffer/intel/main.cc b/repos/dde_linux/src/test/framebuffer/intel/main.cc index e786b73f4d..e50fe5cb14 100644 --- a/repos/dde_linux/src/test/framebuffer/intel/main.cc +++ b/repos/dde_linux/src/test/framebuffer/intel/main.cc @@ -15,8 +15,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -27,43 +26,45 @@ using namespace Genode; struct Framebuffer_controller { - Attached_rom_dataspace rom; - Signal_handler rom_sigh; - Heap heap; - Allocator_avl fs_alloc; - File_system::Connection fs; - Timer::Connection timer; - Signal_handler timer_handler; + Env &_env; + Heap _heap { _env.ram(), _env.rm() }; - void update_connector_config(Xml_generator & xml, Xml_node & node); - void update_fb_config(Xml_node const &report); - void report_changed(); - void handle_timer(); + Attached_rom_dataspace _connectors { _env, "connectors" }; - Framebuffer_controller(Env &env) - : rom(env, "connectors"), - rom_sigh(env.ep(), *this, &Framebuffer_controller::report_changed), - heap(env.ram(), env.rm()), - fs_alloc(&heap), - fs(env, fs_alloc, "", "/", true, 128*1024), - timer(env), - timer_handler(env.ep(), *this, &Framebuffer_controller::handle_timer) + Signal_handler _connectors_handler { + _env.ep(), *this, &Framebuffer_controller::_handle_connectors }; + + Attached_rom_dataspace _config { _env, "config" }; + + uint64_t const _period_ms = + _config.xml().attribute_value("artifical_update_ms", (uint64_t)0); + + Root_directory _root_dir { _env, _heap, _config.xml().sub_node("vfs") }; + + Timer::Connection _timer { _env }; + Signal_handler _timer_handler { + _env.ep(), *this, &Framebuffer_controller::_handle_timer }; + + void _update_connector_config(Xml_generator & xml, Xml_node & node); + void _update_fb_config(Xml_node const &report); + void _handle_connectors(); + void _handle_timer(); + + Framebuffer_controller(Env &env) : _env(env) { - Attached_rom_dataspace config(env, "config"); - Genode::uint64_t const period_ms = config.xml().attribute_value("artifical_update_ms", (Genode::uint64_t)0); + _connectors.sigh(_connectors_handler); + _handle_connectors(); - rom.sigh(rom_sigh); - - if (period_ms) { - timer.sigh(timer_handler); - timer.trigger_periodic(period_ms * 1000 /* in us */); + if (_period_ms) { + _timer.sigh(_timer_handler); + _timer.trigger_periodic(_period_ms * 1000 /* in us */); } } }; -void Framebuffer_controller::update_connector_config(Xml_generator & xml, - Xml_node & node) +void Framebuffer_controller::_update_connector_config(Xml_generator & xml, + Xml_node & node) { xml.node("connector", [&] { @@ -96,7 +97,7 @@ void Framebuffer_controller::update_connector_config(Xml_generator & xml, } -void Framebuffer_controller::update_fb_config(Xml_node const &report) +void Framebuffer_controller::_update_fb_config(Xml_node const &report) { try { static char buf[4096]; @@ -108,34 +109,34 @@ void Framebuffer_controller::update_fb_config(Xml_node const &report) }); report.for_each_sub_node("connector", [&] (Xml_node &node) { - update_connector_config(xml, node); }); + _update_connector_config(xml, node); }); }); buf[xml.used()] = 0; - File_system::Dir_handle root_dir = fs.dir("/", false); - File_system::File_handle file = - fs.file(root_dir, "fb_drv.config", File_system::READ_WRITE, false); - if (File_system::write(fs, file, buf, xml.used()) == 0) - error("Could not write config"); - fs.close(file); + { + New_file file { _root_dir, "fb_drv.config" }; + + file.append(buf, xml.used()); + } + } catch (...) { error("Cannot update config"); } } -void Framebuffer_controller::report_changed() +void Framebuffer_controller::_handle_connectors() { - rom.update(); + _connectors.update(); - update_fb_config(rom.xml()); + _update_fb_config(_connectors.xml()); } -void Framebuffer_controller::handle_timer() +void Framebuffer_controller::_handle_timer() { /* artificial update */ - update_fb_config(rom.xml()); + _update_fb_config(_connectors.xml()); } diff --git a/repos/dde_linux/src/test/framebuffer/intel/target.mk b/repos/dde_linux/src/test/framebuffer/intel/target.mk index d7387a7068..e0217ada53 100644 --- a/repos/dde_linux/src/test/framebuffer/intel/target.mk +++ b/repos/dde_linux/src/test/framebuffer/intel/target.mk @@ -1,5 +1,5 @@ TARGET = intel_fb_controller -LIBS = base +LIBS = base vfs SRC_CC = main.cc CC_CXX_WARN_STRICT =